Redist的主从配置
Redis的主从复制一般用来在线备份和读写分离,提高服务器的负载能力。主数据库主要进行写操作,而从数据库负责读操作。
主从的配置:
主节点:
[root@master ~]# grep -v -E "^#|^$" /etc/redis/6379.conf
bind 0.0.0.0 //绑定的主机地址。说明只能通过这个ip地址连接本机的redis。最好绑定0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes //这个修改为yes,守护进程
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis_6379.log
databases 16
always-show-logo yes
save 900 1 #启用RDB快照功能,默认就是启用的
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/6379 #redis数据目录
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes #启用AOF持久化方式
appendfilename "appendonly.aof" #AOF文件的名称,默认为appendonly.aof
appendfsync everysec #每秒钟强制写入磁盘一次,在性能和持久化方面做了很好的折中,是受推荐的方式。
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
从节点的配置,只需加一行replicaof 192.168.0.10 6379
[root@node2 redis]# grep -v -E "^#|^$" /etc/redis/6379.conf
bind 0.0.0.0
protected-mode yes
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile /var/log/redis_6379.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir /var/lib/redis/6379
replicaof 192.168.0.10 6379 #主节点redis的IP和端口
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
replica-priority 100
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
启动主,从节点数据就开始同步了
=============================================配置密码======================================
主节点;
requirepass pass1234 # 注意,这个是连接master节点,同步数据用的密码. slave节点需要设置这两个密码
从节点:
requirepass pass1234 这个是slave节点上登录自己的redis用的密码
masterauth pass1234 # 注意,这个是连接master节点,同步数据用的密码. slave节点需要设置这两个密码
使用role和info 查看主从信息
127.0.0.1:6379> role
1) "master" #主节点
2) (integer) 4740 #偏移量
3) 1) 1) "192.168.0.12" #从节点
2) "6379"
3) "4740" 127.0.0.1:6379> INFO replication
# Replication
role:master
connected_slaves:1
slave0:ip=192.168.0.12,port=6379,state=online,offset=5300,lag=1
master_replid:3f8d3c3ab80297ef3916615f8c3b2c22733814cf
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:5300
second_repl_offset:-1
repl_backlog_active:1
repl_backlog_size:1048576
repl_backlog_first_byte_offset:1
repl_backlog_histlen:530
参考:
https://redis.io/topics/replication
Redist的主从配置的更多相关文章
- mysql主从配置
引言: 双11,阿里云服务器打折,于是我忍不住又买了一台服务器,于是咱也是有两台服务器的爷们了,既然有了两台服务器,那么肯定要好好利用一下吧,那么就来玩玩mysql的主从配置吧. 准备 两台数据库服务 ...
- postgresql pgsql最新版安装指南及数据存储路径更改及主从配置
postgresql pgsql最新版安装指南及数据存储路径更改及主从配置 安装指南 首先在apt的list添加你当前系统版本对应的apt列表 目前官网有16.04,14.04,12.04 分别对应下 ...
- Redis——学习之路四(初识主从配置)
首先我们配置一台master服务器,两台slave服务器.master服务器配置就是默认配置 端口为6379,添加就一个密码CeshiPassword,然后启动master服务器. 两台slave服务 ...
- redis主从配置及主从切换
环境描述: 主redis:192.168.10.1 6379从redis:192.168.10.2 6380 一.主从配置 1.将主从redis配置文件redis.conf中的aemonize no ...
- Redis集群(三):主从配置一
一.本文目的 Redis的主从配置分为两篇文章,第一篇主要介绍了Redis主从配置的搭建过程及使用,第二篇主要说明各种情况下Redis主从状态,如Master挂掉,Slaver挂掉, ...
- Mysql主从配置,实现读写分离
大型网站为了软解大量的并发访问,除了在网站实现分布式负载均衡,远远不够.到了数据业务层.数据访问层,如果还是传统的数据结构,或者只是单单靠一台服务器扛,如此多的数据库连接操作,数据库必然会崩溃,数据丢 ...
- BIND的进程一:DNS简单配置与的主从配置
DNS的简单配置和DNS的主从配置 摘要:DNS(Domain-Name Server) ,DNS的服务起到的作用就是名称解析,在网络通讯来说计算机与计算机是通过IP地址相互通信的, 当是IP地址 ...
- redis主从配置
首先安装redis 我的redis安装在/app/redis/文件夹下 第二步,写两个redis实例的配置文件,一主一从.我的设计如下,6379端口为主,6380端口为从. 6379:redis_ma ...
- CentOS 7下的 Mysql 主从配置
最近在玩mysql主从配置,在此记录一下 一.前言 1.安装两个虚拟机(CentOS 7).iP分别是192.168.47.131 和192.168.47.133.其中192.168.47.133作为 ...
随机推荐
- Elasticsearch 日期类型的自动监测,官方文档
资料 网址 Elasticsearch Reference [7.3] » Mapping » Field datatypes » Date datatype https://www.elastic. ...
- linux定时任务(转)
转自:https://www.cnblogs.com/intval/p/5763929.html linux 系统则是由 cron (crond) 这个系统服务来控制的.Linux 系统上面原本就有非 ...
- spark调优——Shuffle调优
在Spark任务运行过程中,如果shuffle的map端处理的数据量比较大,但是map端缓冲的大小是固定的,可能会出现map端缓冲数据频繁spill溢写到磁盘文件中的情况,使得性能非常低下,通过调节m ...
- Spark SQL中的Catalyst 的工作机制
Spark SQL中的Catalyst 的工作机制 答:不管是SQL.Hive SQL还是DataFrame.Dataset触发Action Job的时候,都会经过解析变成unresolved的逻 ...
- bind的模拟实现
bind 一句话介绍 bind: bind() 方法会创建一个新函数.当这个新函数被调用时,bind() 的第一个参数将作为它运行时的 this,之后的一序列参数将会在传递的实参前传入作为它的参数.( ...
- AlwaysInstallElevated提权
前言:自己在学习3gstudent的AlwaysInstallElevated提权的文章中,他说过由于Metasploit的某些原因会导致权限不够,所以自己就尝试去复现其他的两种方法了,详细的文章参考 ...
- [React] Write a generic React Suspense Resource factory
Using Suspense within our component isn't exactly ergonomic. Let's put all that logic into a reusabl ...
- itertools 高效的循环
在打印内容字节数较小时,全部载入内存后,再打印,没有问题.可是,如果现在有成千上百万条车辆行驶轨迹,叫你分析出其中每个客户的出行规律,堵车情况等,假如是在单机上处理这件事. 你可能首先要面临,也可能被 ...
- vcenter监控
在vcenter上配置好用户名密码和url即可使用自动发现自动发现vmware
- py3 与 Django 连接数据库: No module named 'MySQLdb'
问题 在使用 Django 连接 MySQL 数据库的时候,出现了错误 django.core.exceptions.ImproperlyConfigured: Error loading MySQL ...