Redis Master/Slave Configuration

Source: Internet
Author: User

Redis Master/Slave Configuration

MASTER: 192.168.209.18

SLAVE: 192.168.209.19

MASTER:

Tar xzvf redis-2.8.12.tar.gz

Music redis-2.8.12/usr/local/redis

CD/usr/local/redis

Make

CP redis. conf redis. conf. Bak

Mkdir/data1/redis_6379

VI redis. conf

 

Grep-V "#" redis. conf | tr-s '\ N'

The configuration file is shown as follows:

Daemonize Yes

# Whether to run in the background

Pidfile/var/run/redis. PID

# Service port

Port 6379

TCP-Back log 511

Timeout 0

TCP-keepalive 0

Loglevel notice

Logfile ""

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Stop-writes-on-bgsave-error Yes

Rdbcompression Yes

Rdbchecksum Yes

Dbfilename dump. RDB

DIR/data1/redis_6379/

# Data file path

Slave-serve-stale-data Yes

Slave-read-only yes

Repl-Disable-TCP-nodelay No

Slave-priority 100

Appendonly No

Appendfilename "appendonly. aof"

Appendfsync everysec

No-appendfsync-on-Rewrite No

Auto-Aof-rewrite-percentage 100

Auto-Aof-rewrite-Min-size 64 MB

Lua-time-limit 5000

Slowlog-log-slower-than 10000

Slowlog-max-len 128

Policy-keyspace-events ""

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-entries 512

List-max-ziplist-value 64

Set-max-intset-entries 512

Zset-max-ziplist-entries 128

Zset-max-ziplist-value 64

Hll-Sparse-max-bytes 3000

Activerehashing Yes

Client-output-buffer-limit normal 0 0 0

Client-output-buffer-limit slave 256 MB 64 MB 60

Client-output-buffer-limit pubsub 32 MB 8 Mb 60

Hz 10

Aof-rewrite-incremental-fsync Yes

 

 

 

 

Start redis

/Usr/local/redis/src/redis-server/usr/local/redis. conf

Disable redis

/Usr/local/redis/src/redis-cli-N 6379 Shutdown

 

Redis command Test

Log on to the shell client first.

/Usr/local/redis/src/redis-cli-P 6379

 

Set Test

Redis 127.0.0.1: 6379> Set Name ABC

OK <--- succeeded

 

Get Test

Redis 127.0.0.1: 6379> get name

"ABC"

 

/Usr/local/redis/src/redis-cli-P 6379

/Usr/local/redis/src/Redi-cli-P 6379

 

 

Slave

Tar xzvf redis-2.8.12.tar.gz

Music redis-2.8.12/usr/local/redis

CD/usr/local/redis

Make

CP redis. conf redis. conf. Bak

Mkdir/data1/redis_6379

VI redis. conf

 

Grep-V "#" redis. conf | tr-s '\ N'

The configuration file is shown as follows:

Daemonize Yes

Pidfile/var/run/redis. PID

Port 6379

TCP-Back log 511

Timeout 0

TCP-keepalive 0

Loglevel notice

Logfile ""

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Stop-writes-on-bgsave-error Yes

Rdbcompression Yes

Rdbchecksum Yes

Dbfilename dump. RDB

DIR/data1/redis_6379/

Slaveof 192.168.209.18 6379

# Slaveof master's Ip Master Port

Slave-serve-stale-data Yes

Slave-read-only yes

Repl-Disable-TCP-nodelay No

Slave-priority 100

Appendonly No

Appendfilename "appendonly. aof"

Appendfsync everysec

No-appendfsync-on-Rewrite No

Auto-Aof-rewrite-percentage 100

Auto-Aof-rewrite-Min-size 64 MB

Lua-time-limit 5000

Slowlog-log-slower-than 10000

Slowlog-max-len 128

Policy-keyspace-events ""

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-entries 512

List-max-ziplist-value 64

Set-max-intset-entries 512

Zset-max-ziplist-entries 128

Zset-max-ziplist-value 64

Hll-Sparse-max-bytes 3000

Activerehashing Yes

Client-output-buffer-limit normal 0 0 0

Client-output-buffer-limit slave 256 MB 64 MB 60

Client-output-buffer-limit pubsub 32 MB 8 Mb 60

Hz 10

Aof-rewrite-incremental-fsync Yes

 

6.2 Master/Slave Test

In the master set

Redis 192.168.209.18: 12002> set testms gogogogo

OK

 

In slave get

Redis 192.168.209.19: 12002> Get testms

"Gogogo" <---- value obtained

 

 

 

 

==========================================

One master, multiple slaves

Directly on the master and slave, copy the master redis directory and modify the configuration file. You only need to modify the configuration file port, Dir, and slaveof.

CP-RP redis redis_6380

Mkdir/data1/redis_6380

CD redis_6380/

VI redis. conf

Shape:

Daemonize Yes

Pidfile/var/run/redis. PID

Port 6380

TCP-Back log 511

Timeout 0

TCP-keepalive 0

Loglevel notice

Logfile ""

Databases 16

Save 900 1

Save 300 10

Save 60 10000

Stop-writes-on-bgsave-error Yes

Rdbcompression Yes

Rdbchecksum Yes

Dbfilename dump. RDB

DIR/data1/redis_6380/

Slaveof 192.168.209.18 6379

Slave-serve-stale-data Yes

Slave-read-only yes

Repl-Disable-TCP-nodelay No

Slave-priority 100

Appendonly No

Appendfilename "appendonly. aof"

Appendfsync everysec

No-appendfsync-on-Rewrite No

Auto-Aof-rewrite-percentage 100

Auto-Aof-rewrite-Min-size 64 MB

Lua-time-limit 5000

Slowlog-log-slower-than 10000

Slowlog-max-len 128

Policy-keyspace-events ""

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-entries 512

List-max-ziplist-value 64

Set-max-intset-entries 512

Zset-max-ziplist-entries 128

Zset-max-ziplist-value 64

Hll-Sparse-max-bytes 3000

Activerehashing Yes

Client-output-buffer-limit normal 0 0 0

Client-output-buffer-limit slave 256 MB 64 MB 60

Client-output-buffer-limit pubsub 32 MB 8 Mb 60

Hz 10

Aof-rewrite-incremental-fsync Yes

========================================

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.