Redis-主从复制
2022/2/22 19:23:44
本文主要是介绍Redis-主从复制,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1,什么是主从复制
主机数据更新后根据配置和策略,自动同步到备机的 master/slaver 机制,Master 以写为主,Slave 以读为主
2,能干嘛
1)读写分离性能扩展,
2)容灾快速恢复
3,搭建一个1主2从主从复制
1),创建一个文件夹/myredis
2)复制redis.conf文件到myredis文件夹中
3)配置1主2从,创建三个配置文件(指定不同的端口号)
*redis6379.conf
*redis6380.conf
*redis6381.conf
4)在三个配置文件中写入你的内容
在redis6379.conf 写入如下内容:
include /myredis/redis.conf
pidfile /var/run/redis_6379.pid
port 6379
dbfilename dump6379.rdb
在redis6380.conf文件中写入如下内容:
include /myredis/redis.conf
pidfile /var/run/redis_6380.pid
port 6380
dbfilename dump6380.rdb
在redis6381.conf文件中写入如下内容:
include /myredis/redis.conf
pidfile /var/run/redis_6381.pid
port 6381
dbfilename dump6381.rdb
5)appendonly 关闭
6)启动三个redis服务
7)查看三台服务器运行情况 info replication ( redis-cli 中查看) 打印出主从复制相关信息
8)配从库不配主库
slaveof <ip> <port>
成为某个实例的从服务器
1,在6380和6381上执行:slaveof 127.0.0.1 6379
这篇关于Redis-主从复制的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-31Tiny RDM:你的下一代Redis桌面GUI神器-icode9专业技术文章分享
- 2024-03-21redisinsight-v2
- 2024-02-26Typed property App\Api\Mapper\GamePropsConfigMapper::$apiRedis must not be accessed before initia-icode9专业技术文章分享
- 2024-02-21redisson getlock
- 2024-02-20redis config
- 2024-02-20redis leaderboard
- 2024-01-23缓存选型:Redis or MemCache
- 2024-01-22面试官:Redis持久化能关吗?怎么关?
- 2024-01-21Redis压测工具redis-benchmark-icode9专业技术文章分享
- 2024-01-19这才是你应该了解的Redis数据结构!