Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ To compile and install Redis Linux and master-slave replication configuration     - Oracle GoldenGate tutorial Second, configure and use (Database)

- Oracle 12c users create (Database)

- OpenNMS separate database (Server)

- C / C ++ various data types Conversion Summary (Programming)

- GDB remote connections RX Probe online debug program (Programming)

- Install Firefox 32 official version of the Linux system (Linux)

- The difference Docker save and export commands (Linux)

- The security administrator network analysis tools SATAN Introduction under Linux (Linux)

- Python Flask environment to build (Linux)

- The source code compiler installation Nginx 1.8.0 under Ubuntu 14.10 (Server)

- Linux uses the SMTP proxy to send mail (Linux)

- Ftp user to create multiple virtual machines to support different access rights Examples (Server)

- apt-get and apt-cache show command examples (Linux)

- Struts2 form of non-use component tags (Programming)

- Ubuntu file security removal tool (Linux)

- Spring Data JPA call a stored procedure examples (Programming)

- Wine 1.7 is installed on a system based on RedHat or Debian (Linux)

- Oracle view object space usage show_space (Database)

- Linux security settings Basics (Linux)

- Linux resource restriction level summary (Linux)

 
         
  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:      
 
- MySQL performance view and configure finishing Daquan (Database)
- CentOS 6.6 shortcut command execution (Linux)
- VNC configuration detailed analysis under Linux (Linux)
- Installation JDK 1.8 under CentOS7 (Linux)
- PULL operation mechanism parsing XML Comments (Programming)
- RedHat Linux 6 desktop installation (Linux)
- ActiveMQ5.10.2 version configuration JMX (Linux)
- Java static internal class (Programming)
- Logging information through the web GUI (LogAnalyzer) (Server)
- To teach you a trick to find the real IP address (Linux)
- Quagga use authentication on strengthening BGP session security (Linux)
- Ubuntu 12.04 installation DHCP Server (Server)
- Linux hard drive failure Case Studies (Linux)
- MongoDB simple replication configuration (Database)
- Ant command-line compiler Android project (Programming)
- C ++ Supplements - locates the new expression (Programming)
- 12 novice Linux command must learn (Linux)
- Spring Boot + Nginx + Tomcat + SSL configuration notes (Server)
- Linux command to view the system status (Linux)
- Fedora10 use Git version Configuration Management (Linux)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.