Master-slave replication configuration experiment of Redis

Source: Internet
Author: User

Environment Introduction:
OS: Oracle linux 5.6
Redis: redis-2.6.8
Master rac1 192.168.2.101
Slave rac2 192.168.2.102

:
Http://redis.googlecode.com/files/redis-2.6.8.tar.gz

Install and configure redis master-slave Replication
1. master node configuration
[Root @ rac1 opt] tar zxvf redis-2.6.8.tar.gz
[Root @ rac1 opt] redis-2.6.8 cd
[Root @ rac1 redis-2.6.8] # make
[Root @ rac1 redis-2.6.8] # cp src/redis-server/usr/local/bin/
[Root @ maid redis-2.6.8] # cp redis. conf/etc/redis_master.conf
[Root @ maid redis-2.6.8] # cat/etc/redis_master.conf
# If port 0 is specified Redis will not listen on a TCP socket.
Port 6379 # This port is default for redis and can be left unchanged

-- Copy software to slave Node
[Root @ rac1 opt] # scp-r redis-2.6.8 rac2:/opt

2. Slave node configuration
[Root @ rac2 redis-2.6.8] # cp src/redis-server/usr/local/bin/
[Root @ rac2 redis-2.6.8] # cp redis. conf/etc/redis_slave.conf
# If port 0 is specified Redis will not listen on a TCP socket.
Port 6389 # modify the port to the custom port of the slave Node
# Slaveof <masterip> <masterport>
Slaveof 192.168.2.101 6379 # this step is the most critical step. Add the IP address or host and port number of the master.

3. Start the redis Service
-- Start the master node
[Root @ rac1 ~] # Redis-server/etc/redis_master.conf> redis_master.log 2> & 1 & # & enables command execution in the background without affecting screen usage.
_._
_.-''__''-._
_.-'''. '_. ''-. _ Redis 2.6.8 (00000000/0) 64 bit
.-''.-'''.'''\/_.,_''-._
(',.-' | ',) Running in stand alone mode
| '-. _'-...-'_...-.'-. _ | ''_.-'| Port: 6379
| '-. _'. _/_.-'| PID: 477
'-._'-._'-./_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' | Http://redis.io
'-._'-._'-.__.-'_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' |
'-._'-._'-.__.-'_.-'_.-'
'-._'-.__.-'_.-'
'-.__.-'
'-.__.-'
[477] 12 Mar 16:43:30. 319 # Server started, Redis version 2.6.8
[477] 12 Mar 16:43:30. 319 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl vm. overcommit_memory = 1' for this to take effect.
[477] 12 Mar 16:43:30. 319 * The server is now ready to accept connections on port 6379
[Root @ rac1 ~] # Ps-ef | grep redis
Root 5930 14334 0 00:00:02 pts/1 redis-server/etc/redis_master.conf
Root 7250 14334 0 00:00:00 pts/1 grep redis

-- Start the slave Node
[Root @ rac2 ~] # Redis-server/etc/redis_slave.conf> redis_slave.log 2> & 1 &
[1] 32507
[32507] 12 Mar 17:51:55. 346 * Max number of open files set to 10032
_._
_.-''__''-._
_.-'''. '_. ''-. _ Redis 2.6.8 (00000000/0) 64 bit
.-''.-'''.'''\/_.,_''-._
(',.-' | ',) Running in stand alone mode
| '-. _'-...-'_...-.'-. _ | ''_.-'| Port: 6389
| '-. _'. _/_.-'| PID: 32507
'-._'-._'-./_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' | Http://redis.io
'-._'-._'-.__.-'_.-'_.-'
| '-. _.-' |
| '-. _'-. _.-'_.-' |
'-._'-._'-.__.-'_.-'_.-'
'-._'-.__.-'_.-'
'-.__.-'
'-.__.-'
[32507] 12 Mar 17:51:55. 350 # Server started, Redis version 2.6.8
[32507] 12 Mar 17:51:55. 350 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. to fix this issue add'vm. overcommit_memory = 1' to/etc/sysctl. conf and then reboot or run the command 'sysctl vm. overcommit_memory = 1' for this to take effect.
[32507] 12 Mar 17:51:55. 350 * The server is now ready to accept connections on port 6389
[32507] 12 Mar 17:51:56. 348 * Connecting to MASTER...
[32507] 12 Mar 17:51:56. 349 * MASTER <-> SLAVE sync started
[32507] 12 Mar 17:51:56. 495 * Non blocking connect for SYNC fired the event.
[32507] 12 Mar 17:51:57. 014 * Master replied to PING, replication can continue...
[32507] 12 Mar 17:51:57. 028 * MASTER <-> SLAVE sync: flushing 18 bytes from master
[32507] 12 Mar 17:51:57. 029 * MASTER <-> SLAVE sync: Loading DB in memory
[32507] 12 Mar 17:51:57. 037 * MASTER <-> SLAVE sync: Finished with success

[Root @ rac2 ~] # Ps-ef | grep redis
Root 321 29770 0 00:00:00 pts/1 grep redis
Root 32507 29770 0 00:00:00 pts/1 redis-server/etc/redis_slave.conf

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.