Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis master-slave service configuration

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I. the purpose of the compilation

This article provides a master-slave configuration guide for redis, which can be used by redis operators.

II. Operation steps

The 1.redis main service does not need to be modified

2.Redis modify from service

(1) Open the redis.conf file of the slave library

(path / usr/local/software/redis-2.6.15), find the ip address and port of the main database of the following data configuration

# slaveof

Slaveof 192.168.3.185 6379

As shown in the figure:

(2) restart the slave redis service

Ps-ef | grep redis

Kill-9 redis process number

Nohup. / redis-server.. / redis.conf &

Nphup. / redis-sentinel.. / sentinel.conf-- sentinel &

(3) verify whether the configuration is successful

# View the information of the main redis

Redis-cli-h 192.168.3.185 info Replication

# Replication

Role:master

Connected_slaves:1

Slave0:192.168.3.186,6379,online

# View the information from redis

Redis-cli-h 192.168.3.186 info Replication

# Replication

Role:slave

Master_host:192.168.3.185

Master_port:6379

Master_link_status:up

Master_last_io_seconds_ago:4

Master_sync_in_progress:0

Slave_priority:100

Slave_read_only:1

Connected_slaves:0

(4) Test insert data

Operations on the primary server:

From the server:

The obtained data is consistent with the test data, that is, the configuration is successful.

3. Configure Sentinel Service

Modify master / slave server / usr/local/software/redis-2.6.15/

Sentinel.conf file (the new content is the same on both servers), add the following:

# master1

Sentinel monitor master1 192.168.3.185 6379 1 this is the IP and port of the main service

Sentinel down-after-milliseconds master1 5000

Sentinel failover-timeout master1 900000

Sentinel can-failover master1 yes

Sentinel parallel-syncs master1 1

4. Modify the contents of the file runtime_config_root\ redis\ jedis.xml

Similar to the following figure, you can add two new lines from the service ip and port.

5. Restart all EYT services

6. Verify that the master-slave redis takes over the service

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report