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

What is the master/slave replication of Redis?

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

Many novices are not very clear about what the master/slave replication of Redis is like. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can get something.

Master/slave replication of Redis:

The master/slave data replication mode of Redis can be one master, one slave or one master and multiple slaves. Redis is non-blocking mode in master, that is to say, when slave performs data synchronization, master can accept the client.

The request does not affect the consistency of the synchronized data, but it is blocking mode on the slave side, and slave cannot respond to the client's query when synchronizing master data.

Under Redis's master/slave mode, master provides data reading and writing services, while slave only provides read services.

The master/slave of Redis is configured by adding to the redis.conf configuration file under the Redis directory of the slave host:

Slaveof master_ip master_port

For example:

We configure our slave to: redis-slave.conf daemonize yes

Pidfile redis-slave.pid port 6380 timeout 300 loglevel verbose logfile stdout databases 16 save 900 1 save 300 10 save 60 10000

Rdbcompression yes

Dbfilename dump-slave.rdb dir / home/falcon/redis-2.0.0/ slaveof 127.0.0.1 6379 appendonly no

Appendfsync everysec vm-enabled no

Vm-swap-file logs/redis-slave.swap vm-max-memory 0

Vm-page-size 32 IT Operation and maintenance expert Network http://www.LinuxTone.Org vm-pages 134217728 vm-max-threads 4 glueoutputbuf yes

Hash-max-zipmap-entries 64 hash-max-zipmap-value 512 activerehashing yes

Start slave:

[falcon@www.fwphp.cn ~ / redis-2.0.0] $. / redis-server redis-slave.conf

View status information:

[falcon@www.fwphp.cn ~ / redis-2.0.0] $. / redis-cli-p 6380 info redis_version:1.3.17 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:32

Multiplexing_api:epoll process_id:10772

Uptime_in_seconds:249 uptime_in_days:0 connected_clients:2 connected_slaves:0 blocked_clients:0

Used_memory:1756868

Used_memory_human:1.68M changes_since_last_save:0 bgsave_in_progress:0

Last_save_time:1281654285 bgrewriteaof_in_progress:0 total_connections_received:13 total_commands_processed:9 expired_keys:0

Hash_max_zipmap_entries:64 hash_max_zipmap_value:512 pubsub_channels:0 pubsub_patterns:0 vm_enabled:0 role:slave

Master_host:127.0.0.1 master_port:6379 master_link_status:up

Master_last_io_seconds_ago:248 db0:keys=23,expires=0

[falcon@www.fwphp.cn ~ / redis-2.0.0] $. / redis-cli-p 6379 info IT Operation and maintenance expert Network http://www.LinuxTone.Org redis_version:1.3.17 redis_git_sha1:00000000 redis_git_dirty:0 arch_bits:32

Multiplexing_api:epoll process_id:7663

Uptime_in_seconds:16787 uptime_in_days:0 connected_clients:1 connected_slaves:1 blocked_clients:0

Used_memory:1757232

Used_memory_human:1.68M changes_since_last_save:0 bgsave_in_progress:0

Last_save_time:1281654286 bgrewriteaof_in_progress:0 total_connections_received:835 total_commands_processed:55953 expired_keys:1

Hash_max_zipmap_entries:64 hash_max_zipmap_value:512

Pubsub_channels:0 pubsub_patterns:0 vm_enabled:0 role:master

Db0:keys=23,expires=0

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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

Servers

Wechat

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

12
Report