Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ To compile and install Redis Linux and master-slave replication configuration     - Multipath configuration under Linux (Linux)

- Ubuntu mysql stop fail to solve the problem (Database)

- Sort search algorithm Java - application examples with recursive dichotomy (Programming)

- Linux script commands - terminal recorder (Linux)

- Archlinux installation tutorial (Linux)

- Configure the Linux kernel and use iptables to do port mapping (Linux)

- Linux directory configuration (Linux)

- Redis configuration file interpretation (Database)

- CentOS build JDK environment (Linux)

- Android Studio Installation and Configuration Guide tutorial (Linux)

- How to configure AWStats in Ubuntu Server (Server)

- Unetbootin make use U disk loading Linux system (Linux)

- Detailed Linux su command to switch users Mistakes (Linux)

- How to use jgit to manage Git submodule (Linux)

- Build RubyMine + Ruby On Rails + MySQL development environment under Windows (Server)

- Lazarus IDE Start Basics Tutorial (Linux)

- Java memory mechanism Description (Programming)

- Programmers Do not neglect debugging techniques (Programming)

- Through Oracle to help restore MySQL data problems (Database)

- Using the Android interface in Parcelable (Programming)

 
         
  To compile and install Redis Linux and master-slave replication configuration
     
  Add Date : 2017-08-31      
         
       
         
  Redis installation configuration is very simple, and long before the installed Redis, these days can be installed again forgotten some details, it seems better to write a bad memory, or in the blog record is better, at least not always Hold your mother thigh.

Today, the compiler installed several times and found that the list did not actually specified in the document generated prefix? ?? Read a half-day results found PREFIX I used lowercase letters. . .

It seems to have recorded a correct operation steps, so again such distress.

First, select the version

Go to the official website: http: //www.redis.io/download

Choose a suitable stable version, such as the latest stable version of redis-3.0 (stable), access to download address:

Http://download.redis.io/releases/redis-3.0.0.tar.gz

Second, compile and install

Cd / usr / local / src
Wget http://download.redis.io/releases/redis-3.0.0.tar.gz
Tar zxvf redis-3.0.0.tar.gz
Cd redis-3.0.0
Make
# Run the make test command

# Remember here PREFIX is capitalized, lowercase does not take effect!
Make PREFIX = / usr / local / redis-3.0.0 install

# Create a soft link
Ln -s /usr/local/redis-3.0.0 / usr / local / redis

# Create a directory and copy the default configuration file in the past
Mkdir -p / usr / local / redis / {etc, var}
Cp redis.conf / usr / local / etc /

# If it is to provide services to other machines, it is recommended to set the monitor IP in redis.conf 0.0.0.0, start can open a process, the default is 2, there is a 127.0.0.1
Bind 0.0.0.0

Cd / usr / local / src

Wget http://download.redis.io/releases/redis-3.0.0.tar.gz

Tar zxvf redis-3.0.0.tar.gz

Cd redis-3.0.0

Make

# Run the make test command

 

# Remember here PREFIX is capitalized, lowercase does not take effect!

Make PREFIX = / usr / local / redis-3.0.0 install

 

# Create a soft link

Ln -s /usr/local/redis-3.0.0 / usr / local / redis

# Create a directory and copy the default configuration file in the past

Mkdir -p / usr / local / redis / {etc, var}

Cp redis.conf / usr / local / etc /
 

# If it is to provide services to other machines, it is recommended to set the monitor IP in redis.conf 0.0.0.0, start can open a process, the default is 2, there is a 127.0.0.1

Bind 0.0.0.0


After the installation is complete, redis directory structure is as follows:

[Root @ cache-ns-4 ~] # tree / usr / local / redis
/ Usr / local / redis
 Bin # bin stored below the implementation of various documents
 Redis-benchmark
 Redis-check-aof
 Redis-check-dump
 Redis-cli #redis The client executes the file
 Redis-sentinel -> /usr/local/redis-3.0.0/bin/redis-server
 Redis-server #redis The server executable file
 Dump.rdb # After the default data file generated, you can set the redis.conf path parameters specified in the dir to another directory
 Etc
 Redis.conf
 Var

[Root @ cache-ns-4 ~] # tree / usr / local / redis

/ Usr / local / redis

  Bin # bin stored below the implementation of various documents

  Redis-benchmark

  Redis-check-aof

  Redis-check-dump

  Redis-cli #redis The client executes the file

  Redis-sentinel -> /usr/local/redis-3.0.0/bin/redis-server

  Redis-server #redis The server executable file

Dump.rdb # After the default data file generated, you can set the redis.conf path parameters specified in the dir to another directory

Etc

Redis.conf

  Var

 

Third, registration services

1, the preparation of service control script

Vi /etc/init.d/redis

#! / Bin / bash
#
# Redis - this script starts and stops the redis-server daemon
#
# Chkconfig: - 80 12
# Description: Redis is a persistent key-value database
# Processname: redis-server
# Config: /usr/local/redis/etc/redis.conf
# Pidfile: /usr/local/redis/var/redis.pid
 
Source /etc/init.d/functions
 
BIN = "/ usr / local / redis / bin"
CONFIG = "/ usr / local / redis / etc / redis.conf"
PIDFILE = "/ var / run / redis.pid"
 
 
### Read configuration
[-r "$ SYSCONFIG"] && source "$ SYSCONFIG"
 
RETVAL = 0
Prog = "redis-server"
Desc = "Redis Server"
 
Start () {
 
     If [-e $ PIDFILE]; then
       Echo "$ desc already running ...."
       Exit 1
     Fi
 
     Echo -n $ "Starting $ desc:"

     # Occasionally found in the use of server startup actually do not turn into the background, so in the final addition of a "&"
     Daemon $ BIN / $ prog $ CONFIG &
 
     RETVAL = $?
     Echo
     [$ RETVAL -eq 0] && touch / var / lock / subsys / $ prog
     Return $ RETVAL
}}

Stop () {
     Echo -n $ "Stop $ desc:"
     Killproc $ prog
     RETVAL = $?
     Echo
     [$ RETVAL -eq 0] && rm -f / var / lock / subsys / $ prog $ PIDFILE
     Return $ RETVAL
}}
 
Restart () {
   Stop
   Start
}}
 
Case "$ 1" in
  Start)
     Start
     ;
  Stop)
     Stop
     ;
  Restart)
     Restart
     ;
  Condrestart)
     [-e / var / lock / subsys / $ prog] && restart
     RETVAL = $?
     ;
  Status)
     Status $ prog
     RETVAL = $?
     ;
   *)
     Echo $ "Usage: $ 0 {start | stop | restart | condrestart | status}"
     RETVAL = 1
Esac
 
Exit $ RETVAL


#! / Bin / bash

#

# Redis - this script starts and stops the redis-server daemon

#

# Chkconfig: - 80 12

# Description: Redis is a persistent key-value database

# Processname: redis-server

# Config: /usr/local/redis/etc/redis.conf

# Pidfile: /usr/local/redis/var/redis.pid

Source /etc/init.d/functions

 
BIN = "/ usr / local / redis / bin"

CONFIG = "/ usr / local / redis / etc / redis.conf"

PIDFILE = "/ var / run / redis.pid"

### Read configuration

[-r "$ SYSCONFIG"] && source "$ SYSCONFIG"



RETVAL = 0

Prog = "redis-server"

Desc = "Redis Server"

 
Start () {

    If [-e $ PIDFILE]; then

      Echo "$ desc already running ...."

      Exit 1

    Fi


    Echo -n $ "Starting $ desc:"

    # Occasionally found in the use of server startup actually do not turn into the background, so in the final addition of a "&"

    Daemon $ BIN / $ prog $ CONFIG &

    RETVAL = $?

    Echo

    [$ RETVAL -eq 0] && touch / var / lock / subsys / $ prog

    Return $ RETVAL

}}

 
Stop () {

    Echo -n $ "Stop $ desc:"

    Killproc $ prog

    RETVAL = $?

    Echo

    [$ RETVAL -eq 0] && rm -f / var / lock / subsys / $ prog $ PIDFILE

    Return $ RETVAL

}}

 
Restart () {

  Stop

  Start

}}

 

Case "$ 1" in

Start)

    Start

    ;

Stop)

    Stop

    ;

Restart)

    Restart

    ;

Condrestart)

    [-e / var / lock / subsys / $ prog] && restart

    RETVAL = $?

    ;

Status)

    Status $ prog

    RETVAL = $?

    ;

  *)

    Echo $ "Usage: $ 0 {start | stop | restart | condrestart | status}"

    RETVAL = 1

Esac

Exit $ RETVAL

2, registration services and start

# Give Execute permission
Chmod + x /etc/init.d/redis

#boot
Chkconfig redis on

# Start the service
Service redis start

# The following is the startup record
[Root @ localhost ~] # service redis start
Starting Redis Server:
[Root @ localhost ~] # _._
          _.- `` __ '' -._
      _.- ``. `_. '' -._ Redis 3.0.0 (00000000/0) 64 bit
  . -``. `` `.` `` \ / _., _ '' -._
 ( ',.-`|`,) Running in stand alone mode
 | `-._` -...- `__...-.` `-._ | '_.-' | Port: 6379
 | `-._` ._ / _.- '| PID: 28584
  `-._` -._ `-. / _.- '_.-'
 | `-._` -._ `-.__.- '_.-'_.-' |
 | `-._` -._ _.-'_.- '| http://redis.io
  `-._` -._ `-.__.-'_.- '_.-'
 | `-._` -._ `-.__.- '_.-'_.-' |
 | `-._` -._ _.-'_.- '|
  `-._` -._ `-.__.-'_.- '_.-'
      `-._` -.__.- '_.-'
          `-._ _.- '
              `-.__.- '

[28584] 16 Apr 23: 48: 55.614 # Server started, Redis version 3.0.0
[28584] 16 Apr 23: 48: 55.614 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or Run the command 'sysctl vm.overcommit_memory = 1' for this to take effect.
[28584] 16 Apr 23:48:55.614 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never> / sys / Kernel / mm / transparent_hugepage / enabled 'as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
[28584] 16 Apr 23: 48: 55.614 # WARNING: The TCP backlog setting of 511 can not be enforced because / proc / sys / net / core / somaxconn is set to the lower value of 128.
[28584] 16 Apr 23: 48: 55.615 * DB loaded from disk: 0.000 seconds
[28584] 16 Apr 23: 48: 55.615 * The server is now ready to accept connections on port 6379


# Give Execute permission

Chmod + x /etc/init.d/redis

#boot

Chkconfig redis on

# Start the service

Service redis start


# The following is the startup record

[Root @ localhost ~] # service redis start

Starting Redis Server:

[Root @ localhost ~] # _._

          _.- `` __ '' -._

      _.- ``. `_. '' -._ Redis 3.0.0 (00000000/0) 64 bit

  . -``. `` `.` `` \ / _., _ '' -._

( ',.-`|`,) Running in stand alone mode

| `-._` -...- `__...-.` `-._ | '_.-' | Port: 6379

| `-._` ._ / _.- '| PID: 28584

  `-._` -._ `-. / _.- '_.-'

| `-._` -._ `-.__.- '_.-'_.-' |

| `-._` -._ _.-'_.- '| http://redis.io

  `-._` -._ `-.__. -'_.- '_.-'

| `-._` -._ `-.__.- '_.-'_.-' |

| `-._` -._ _.-'_.- '|

  `-._` -._ `-.__.-'_.- '_.-'

      `-._` -.__.- '_.-'

          `-._ _.- '

              `-.__.- '

 

[28584] 16 Apr 23: 48: 55.614 # Server started, Redis version 3.0.0

[28584] 16 Apr 23: 48: 55.614 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or Run the command 'sysctl vm.overcommit_memory = 1' for this to take effect.

[28584] 16 Apr 23:48:55.614 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never> / sys / Kernel / mm / transparent_hugepage / enabled 'as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

[28584] 16 Apr 23: 48: 55.614 # WARNING: The TCP backlog setting of 511 can not be enforced because / proc / sys / net / core / somaxconn is set to the lower value of 128.

[28584] 16 Apr 23: 48: 55.615 * DB loaded from disk: 0.000 seconds

[28584] 16 Apr 23: 48: 55.615 * The server is now ready to accept connections on port 6379

Fourth, the master-slave configuration

1, configuration

In accordance with the above steps from the machine to install redis, and then from the machine redis.conf which add the following configuration items:


# Specify the IP address and port number of the redis host (password authentication is disabled by default)
Slaveof 192.168.10.124 6379


# Specify the IP address and port number of the redis host (password authentication is disabled by default)

Slaveof 192.168.10.124 6379


Save the redis to complete a simple master-slave configuration.

2, the test

Test is very simple, first in the host through the client redis-cli implementation of the new key-value command:


[Root @ localhost ~] # / usr / local / redis / bin / redis-cli
127.0.0.1:6379> set newkey slavetest
OK

 

[Root @ localhost ~] # / usr / local / redis / bin / redis-cli

127.0.0.1:6379> set newkey slavetest

OK


Then, the same machine from the implementation of redis-cli implementation of the inquiry:


[Root @ localhost ~] # / usr / local / redis / bin / redis-cli
127.0.0.1:6379> get newkey
"Slavetest"

[Root @ localhost ~] # / usr / local / redis / bin / redis-cli

127.0.0.1:6379> get newkey

"Slavetest"


Obviously the new host keys have been automatically synchronized to the slave, master-slave synchronization success!

This article only records the basic compilation and installation and master-slave configuration, of course, redis also can continue to customize the settings or optimization of the project, the follow-up have the opportunity to continue to organize to add.
     
         
       
         
  More:      
 
- CentOS 7 install Hadoop-cdh-2.5 on Mesos (Server)
- Installation of Theano + CUDA under Ubuntu (Linux)
- Mounting kit under Fedora Linux (Linux)
- Linux and hardware (Linux)
- How to Install Puppet in the Ubuntu 15.04 (Server)
- Java reflection technology explain (Programming)
- Python substring format (Programming)
- ORA-01157 & ORA-01110 Troubleshooting (Database)
- Nginx server load balancing dual-system availability (Server)
- Linux System Getting Started Learning: Statistical process a number of threads in Linux (Linux)
- Zabbix configuration external network mail alarm (Server)
- How to use the on-screen keyboard in Linux (Linux)
- Linux file permissions to modify the command: chmod (Linux)
- Storm how to assign tasks and load balancing (Programming)
- Ubuntu: To install chat client Chatty 0.6.1 (Linux)
- DB2 table space is redirected to restore the database combat (Database)
- Linux RPM default installation path (Linux)
- RPM package management tools under Linux (Linux)
- Linux Demo dd IO test (Linux)
- Docker installation under CentOS7 (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.