Redis master-slave architecture structures (D)

A master-slave, the master node to write to, read from the node, you can read, master-slave architecture to build success

1, enable replication, deployment slave node

wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
tar -xzvf tcl8.6.1-src.tar.gz
cd  /usr/local/tcl8.6.1/unix/
./configure  
make && make install

  Use redis-3.2.8.tar.gz

tar -zxvf redis-3.2.8.tar.gz
cd redis-3.2.8
make && make test && make install

  

(1) Under redis utils directory, there is a redis_init_script script
(2) a copy of the script to the /etc/init.d directory redis_init_script of linux, the redis_init_script rename redis_6379,6379 is our hope that this redis instance is listening port number
( 3) REDISPORT line 6 changes redis_6379 script, set to the same port number (default is 6379)
(4) create two directories: / etc / redis (redis storage configuration file), / var / redis / 6379 ( persistent files stored the redis)
(5) redis modify the configuration file (by default in the root directory, redis.conf), copied to the / etc / redis directory, change the name of 6379.conf
(. 6) of modified redis.conf part of the configuration for the production environment

daemonize yes redis to make daemon processes running 
pidfile /var/run/redis_6379.pid redis set the pid file location 
port 6379 is set redis listening port number 
dir / var / redis / 6379 set the storage location of persistent files

  

(7) so that the system starts automatically start to follow redis

In redis_6379 script, top, adding two line comment

# chkconfig: 2345 90 10

# description: Redis is a persistent key-value database

chkconfig redis_6379 on

On the slave node configuration: slaveof 192.168.1.1 6379

You can also use the command slaveof

2, forcibly separate read and write

Based on the replication master architecture to achieve separate read and write

redis slave node read-only, enabled by default, slave-read-only

Opened the read-only redis slave node, denies all write operations, such as read and write can be forced to build a separate infrastructure

3, clusters safety certification

Enabling secure authentication on the Master, requirepass
Master connection password, masterauth

4, the split architecture read and write tests

First start the master node, the instance redis eshop-cache01
restart redis instance from the node, eshop-cache02 of

When building a cluster production environment, do not forget to change a configuration, bind

bind 127.0.0.1 -> Local development and debugging mode, you can only have access to 127.0.0.1 local port of 6379

bind 127.0.0.1 in each redis.conf -> bind their ip address

Release port 6379:
in each node: iptables -A INPUT -ptcp --dport 6379 -j ACCEPT

Connected to the address:

redis-cli -h ipaddr

Open the configuration file:
info Replication

Guess you like

Origin www.cnblogs.com/sunliyuan/p/11298991.html