3.redis single node and standby mode

1. The single-node mode
Single-node configuration mode, to use redis common configuration.
(1) Start command:
  1 /path/to/redis-server /path/to/redis-6379.conf
Note: The name of the profile is only an example, typically more than one machine start a redis example, using the port area points profile is a better way of
 
(2) Close the command:
  1 /path/to/redis-cli -h <host> -p <port> -a '<password>' shutdown save
Note: It is recommended not to directly kill the process, cause data loss
 
2.redis standby mode
Note: This mode does not support high availability, application availability can only be used for less demanding. If the master node goes down, slave node does not automatically switch the master node. In-memory data is more important, but time is not high availability can be used. General use small, production is generally sentinel pattern described later and cluster model
(1) master configuration
. Step1 according to the general configuration modify the configuration files, such as: redis-6379.conf
. step2 increase a setting: masterauth "XXXXX" . The content in this "##### REPLICATION #####" section
 
(2) slave configuration
. Step1 according to the general configuration modify the configuration files, such as: redis-6379.conf
step2.比master的配置多配置一个slaveof.这一项仍然在"##### REPLICATION #####"这个section下。
示例如下:
 
# 配置主服务器地址
slaveof 192.168.235.121 6379
# 主节点密码
masterauth "xxxxx"
 
注:
(1)如果备份节点和主节点在同一台注意,可以通过端口进行区分,这样一般没有多大意义。一般都是两台主机,这样主备最好使用一致的端口
(2)slaveof是redis-5.0之前版本的,redis-5.0之后,使用replicaof设置
 
(3)主从节点的启动
和单节点启动一样,只要分别启动主从节点即可。启动后查看日志,如果主节点日志出现如下信息,则证明启动成功。
* Synchronization with slave 192.168.235.121:6379 succeeded
 
(4)主从节点的关闭
建议先关闭主节点再关闭从节点,以免数据不一致。关闭方法和单节点关闭一致

Guess you like

Origin www.cnblogs.com/anand-sun/p/12099461.html