准备环境
三台centos,ip:10.211.55.14;    10.211.55.16;   10.211.55.17
各装有redis,端口号6379

修改配置redis.conf文件
<master>10.211.55.14 
设置密码为
requirepass 1234
其他的根据各自需求配置
 <slave>
10.211.55.16
replicaof 10.211.55.14 6379
masterauth 1234

其余的根据各自需求配置
scp redis.conf parallels@10.211.55.17:/home/parallels/program/redis-6.0.8/redis.conf
将配置文件传给另外一台机器

分别启动着三台机器
10.211.55.14查看info
# Replication
role:master
connected_slaves:2
slave0:ip=10.211.55.17,port=6379,state=online,offset=1384,lag=1
slave1:ip=10.211.55.16,port=6379,state=online,offset=1384,lag=1
master_replid:f1301114e024f3a58c7c5f443cd5838ef732772f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1384
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:1384
角色是master,连接两个salves

10.211.55.16查看info
# Replication
role:slave
master_host:10.211.55.14
master_port:6379
master_link_status:up
master_last_io_seconds_ago:2
master_sync_in_progress:0
slave_repl_offset:1440
slave_priority:100
slave_read_only:1
connected_slaves:0
master_replid:f1301114e024f3a58c7c5f443cd5838ef732772f
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:1440
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:867
repl_backlog_histlen:574
角色是slave,master地址是14的ip
在master上插入一个key发现副本上同步创建了,
在副本上新增一个key报错
(error) READONLY You can't write against a read only replica.

这是主从模式下的一个特点。副本只能读,不能写,

Replication的优点在于配置简单,一个master可以同步多个slaves,
master和salve之间的同步是非阻塞的
缺点在于,不具备高空可用行,master宕机后,写入操作停止
主从复制是全量复制,master会fork一个进程对内存做个快照,将这个快照发给salve,如果数据量太大,这个需要有足够的内存才能实现,并且影响服务器性能,
最主要的是网络不稳定,闪断也会做一个全量备份。

126 对 “redis主从同步”的想法;

  1. Pingback: sildenafil online
  2. Pingback: buy viagra
  3. Pingback: annkimfashion
  4. Pingback: buy sildenafil online
  5. Pingback: cialis prescription
  6. Pingback: how to get cialis
  7. Pingback: cialis for sale
  8. Pingback: buy cialis 20mg
  9. Pingback: generic viagra india
  10. Pingback: sildenafil citrate
  11. Pingback: purchase viagra
  12. Pingback: eli lilly cialis 5mg
  13. Pingback: viagra pill
  14. Pingback: viagra vs. cialis
  15. Pingback: viagra buy online
  16. Pingback: generic cialis canada
  17. Pingback: sildenafil viagra
  18. Pingback: cialis soft tabs
  19. Pingback: viagra pill stories
  20. Pingback: cialis coupons
  21. Pingback: otc viagra

发表评论