标签:
redis主从复制配置:
环境:Linux一台(192.168.6.205)、redis端口分别为6379、6370
安装好redis之后我的测试目录是这样的:
1
2
3
4
|
[root@web01 redis] # pwd /usr/local/redis [root@web01 redis] # ls master master-redis-2.8.1 slave slave-redis-2.8.1 |
1
2
3
4
|
[root@web01 bin] # pwd /usr/local/redis/master/bin [root@web01 bin] # ls dump.rdb mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server |
1
2
3
4
|
[root@web01 etc] # pwd /usr/local/redis/master/etc [root@web01 etc] # ls master-redis.conf |
1
2
3
4
|
[root@web01 bin] # pwd /usr/local/redis/slave/bin [root@web01 bin] # ls dump.rdb mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-sentinel redis-server |
1
2
3
4
|
[root@web01 etc] # pwd /usr/local/redis/slave/etc [root@web01 etc] # ls slave-redis.conf |
1
2
3
4
|
[root@web01 redis] # pwd /usr/local/bin/redis [root@web01 redis] # ls master slave |
1
2
3
4
|
[root@web01 master] # cd /usr/local/redis/slave/etc/ [root@web01 etc] # vi slave-redis.conf # slaveof <masterip> <masterport> slaveof 192.168.6.205 6379 |
启动master:
1
2
3
4
|
[root@web01 etc] # ps -ef |grep redis root 6830 5985 0 13:54 pts /2 00:00:00 grep redis [root@web01 bin] # cd /usr/local/redis/master/bin/ [root@web01 bin] # ./redis-server /usr/local/redis/master/etc/master-redis.conf |
1
2
3
4
5
6
|
[root@web01 bin] # ./redis-cli 127.0.0.1:6379> keys * 1) "aaaaaaaaaaa" 2) "security" 3) "mm" 4) "a" |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
127.0.0.1:6379> info ... config_file: /usr/local/redis/master/etc/master-redis .conf # Clients connected_clients:1 client_longest_output_list:0 client_biggest_input_buf:0 blocked_clients:0 # Replication role:master connected_slaves:0 master_repl_offset:0 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0 |
启动slave:
1
2
|
[root@web01 bin] # cd /usr/local/redis/slave/bin/ [root@web01 bin] # ./redis-server /usr/local/redis/slave/etc/slave-redis.conf |
1
2
3
4
5
6
|
[root@web01 bin] # ./redis-cli -p 6370 127.0.0.1:6370> keys * 1) "mm" 2) "a" 3) "security" 4) "aaaaaaaaaaa" |
查看进程可以看到已经有两个redis服务在运行
1
2
3
4
|
[root@web01 bin] # ps -ef |grep redis root 6835 1 0 13:56 ? 00:00:00 . /redis-server *:6379 root 6866 1 0 14:01 ? 00:00:00 . /redis-server *:6370 root 6895 4071 0 14:05 pts /1 00:00:00 grep redis |
查看slave连接信息:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
127.0.0.1:6370> info ... config_file: /usr/local/redis/slave/etc/slave-redis .conf ... # Replication role:slave master_host:192.168.6.205 master_port:6379 master_link_status:up master_last_io_seconds_ago:3 master_sync_in_progress:0 slave_repl_offset:463 slave_priority:100 slave_read_only:1 connected_slaves:0 master_repl_offset:0 repl_backlog_active:0 repl_backlog_size:1048576 repl_backlog_first_byte_offset:0 repl_backlog_histlen:0 |
标签:
原文地址:http://www.cnblogs.com/lsx1993/p/4633026.html