Redis master Copy Simple Configuration tutorial detailed

Source: Internet
Author: User
Tags mkdir redis

Master-slave replication

192.168.1.106 Master Machine
Mkdir-p/data/redis
Cp/etc/redis/redis.conf/etc/redis/redis-6379.conf
Vim/etc/redis/redis-6379.conf


Daemonize Yes
Pidfile/var/run/redis-6379.pid
Port 6379
LogFile "6379.log"
Dbfilename "Dump-6379.rdb"
Dir "/data/redis"
AppendOnly Yes
Appendfilename "Appendonly-6379.aof"

192.168.1.107 slave Machine
Mkdir-p/data/redis
Cp/etc/redis/redis.conf/etc/redis/redis-6381.conf
Vim/etc/redis/redis-6381.conf


Daemonize Yes
Pidfile/var/run/redis-6381.pid
Port 6381
LogFile "6381.log"
Dbfilename "Dump-6381.rdb"
Dir "/data/redis"
AppendOnly Yes
Appendfilename "Appendonly-6381.aof"

Connect from server


[Root@slave redis]# redis-cli-p 6381
127.0.0.1:6381>
127.0.0.1:6381> dbsize
(integer) 0
127.0.0.1:6381> slaveof 192.168.1.106 6379
127.0.0.1:6381> Get Hello
"World"
127.0.0.1:6381> Info Replication
# Replication
Role:slave
master_host:192.168.1.106
master_port:6379
Master_link_status:up
Master_last_io_seconds_ago:9
master_sync_in_progress:0
slave_repl_offset:773
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

[Root@slave redis]# redis-cli-p 6381
127.0.0.1:6381> slaveof 192.168.1.106 6379
127.0.0.1:6381> Config rewrite

Then configure one from the server


[Root@slave redis]# cd/etc/redis/
[root@slave redis]# ls
redis-6379.conf  redis-6381.conf
[ Root@slave redis]# sed ' s/6381/6382/g ' redis-6381.conf > redis-6382.conf
[root@slave, redis]# redis-server/etc/ redis/redis-6382.conf
[root@slave redis]# redis-cli-p 6382
127.0.0.1:6382> get Hello
' world '
127.0.0.1:6382> info Replication
# replication
Role:slave
master_host:192.168.1.106
Master_port : 6379
Master_link_status:up
master_last_io_seconds_ago:6
master_sync_in_progress:0
Slave_repl_ offset:3026
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
127.0.0.1:6382>
 

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.