验证redis的主从复制
生活随笔
收集整理的這篇文章主要介紹了
验证redis的主从复制
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?? ?1.1 修改配置文件
?? ??? ?[root@ractdg3 redis-2.8.4]# cp redis.conf redis_master.conf
?? ??? ?[root@ractdg3 redis-2.8.4]# cp redis.conf redis_slave.conf
?? ??? ?[root@ractdg3 redis-2.8.4]# vi redis_slave.conf
?? ??? ?從屬服務器設置端口及主服務器端口:
?? ??? ? port 6380
?? ??? ? slaveof localhost 6379
?? ?1.2 啟動主從服務器:
?? ??? ?[root@ractdg3 redis-2.8.4]# src/redis-server redis_master.conf &
?? ??? ?[root@ractdg3 redis-2.8.4]# src/redis-server redis_slave.conf &
?? ??? ?[2] 32729
?? ??? ?[root@ractdg3 redis-2.8.4]# [32729] 23 Jan 10:05:33.496 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now.
?? ??? ??? ??? ??? ??? ??? ??? ??? ??? ?_._???????????????????????????????????????????????? ?
?? ??? ??? ??? ??? ??? ??? ? _.-``__ ''-._??????????????????????????????????????????? ?
?? ??? ??? ??? ??? ?_.-``??? `.? `_.? ''-._?????????? Redis 2.8.4 (00000000/0) 32 bit
?? ??? ??? ?.-`` .-```.? ```\/??? _.,_ ''-._????????????????????????????????? ?
?? ??? ? (??? '????? ,?????? .-`? | `,??? )???? Running in stand alone mode
?? ??? ? |`-._`-...-` __...-.``-._|'` _.-'|???? Port: 6380
?? ??? ? |??? `-._?? `._??? /???? _.-'??? |???? PID: 32729
?? ??? ??? ?`-._??? `-._? `-./? _.-'??? _.-'????????????????????????????????? ?
?? ??? ? |`-._`-._??? `-.__.-'??? _.-'_.-'|???????????????????????????????? ?
?? ??? ? |??? `-._`-._??????? _.-'_.-'??? |?????????? http://redis.io?????? ?
?? ??? ??? ?`-._??? `-._`-.__.-'_.-'??? _.-'????????????????????????????????? ?
?? ??? ? |`-._`-._??? `-.__.-'??? _.-'_.-'|???????????????????????????????? ?
?? ??? ? |??? `-._`-._??????? _.-'_.-'??? |???????????????????????????????? ?
?? ??? ??? ?`-._??? `-._`-.__.-'_.-'??? _.-'????????????????????????????????? ?
?? ??? ??? ??? ??? ?`-._??? `-.__.-'??? _.-'????????????????????????????????????? ?
?? ??? ??? ??? ??? ??? ??? ?`-._??????? _.-'????????????????????????????????????????? ?
?? ??? ??? ??? ??? ??? ??? ??? ??? ?`-.__.-'????????????????????????????????????????????? ?
?? ??? ?[32729] 23 Jan 10:05:33.498 # Server started, Redis version 2.8.4
?? ??? ?[32729] 23 Jan 10:05:33.499 # 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.
?? ??? ?[32729] 23 Jan 10:05:33.500 * DB loaded from disk: 0.001 seconds
?? ??? ?[32729] 23 Jan 10:05:33.500 * The server is now ready to accept connections on port 6380
?? ??? ?[32729] 23 Jan 10:05:34.495 * Connecting to MASTER localhost:6379
?? ??? ?[32729] 23 Jan 10:05:34.498 * MASTER <-> SLAVE sync started
?? ??? ?[32729] 23 Jan 10:05:34.498 * Non blocking connect for SYNC fired the event.
?? ??? ?[32729] 23 Jan 10:05:34.498 * Master replied to PING, replication can continue...
?? ??? ?[32729] 23 Jan 10:05:34.499 * Partial resynchronization not possible (no cached master)
?? ??? ?[32726] 23 Jan 10:05:34.500 * Slave asks for synchronization
?? ??? ?[32726] 23 Jan 10:05:34.500 * Full resync requested by slave.
?? ??? ?[32726] 23 Jan 10:05:34.500 * Starting BGSAVE for SYNC
?? ??? ?[32729] 23 Jan 10:05:34.500 * Full resync from master: 9a6eceefa217f57f5a9c99e6af494a997b871d47:1
?? ??? ?[32726] 23 Jan 10:05:34.503 * Background saving started by pid 32735
?? ??? ?[32735] 23 Jan 10:05:34.511 * DB saved on disk
?? ??? ?[32735] 23 Jan 10:05:34.512 * RDB: 0 MB of memory used by copy-on-write
?? ??? ?[32726] 23 Jan 10:05:34.585 * Background saving terminated with success
?? ??? ?[32726] 23 Jan 10:05:34.586 * Synchronization with slave succeeded
?? ??? ?[32729] 23 Jan 10:05:34.586 * MASTER <-> SLAVE sync: receiving 675 bytes from master
?? ??? ?[32729] 23 Jan 10:05:34.587 * MASTER <-> SLAVE sync: Flushing old data
?? ??? ?[32729] 23 Jan 10:05:34.587 * MASTER <-> SLAVE sync: Loading DB in memory
?? ??? ?[32729] 23 Jan 10:05:34.588 * MASTER <-> SLAVE sync: Finished with success
?? ??? ?[root@ractdg3 redis-2.8.4]# ps aux|grep redis
?? ??? ?root???? 32726? 0.0? 0.0? 33820? 1948 pts/3??? Sl?? 10:05?? 0:00 src/redis-server *:6379????????? ?
?? ??? ?root???? 32729? 0.1? 0.0? 33868? 2004 pts/3??? Sl?? 10:05?? 0:00 src/redis-server *:6380???????? ?
?? ??? ?root???? 32740? 0.0? 0.0?? 4264?? 696 pts/3??? S+?? 10:05?? 0:00 grep redis
?? ??? ?[root@ractdg3 redis-2.8.4]#
?? ?1.3 在主服務器賦值
?? ?[oracle@ractdg3 src]$ telnet localhost 6379
?? ?Trying 127.0.0.1...
?? ?Connected to localhost.localdomain (127.0.0.1).
?? ?Escape character is '^]'.
?? ?rpush data 1
?? ?:1
?? ?lrange data 0 -1
?? ?*1
?? ?$1
?? ?1
?? ?set name tang
?? ?+OK
?? ?get name
?? ?$4
?? ?tang
?? ?1.4 在從服務器測試數據
?? ??? ?[root@ractdg3 redis-2.8.4]# telnet localhost 6380
?? ?Trying 127.0.0.1...
?? ?Connected to localhost.localdomain (127.0.0.1).
?? ?Escape character is '^]'.
?? ?[32726] 23 Jan 10:49:56.273 * 1 changes in 900 seconds. Saving...
?? ?[32729] 23 Jan 10:49:56.273 * 1 changes in 900 seconds. Saving...
?? ?[32729] 23 Jan 10:49:56.327 * Background saving started by pid 1185
?? ?[32726] 23 Jan 10:49:56.333 * Background saving started by pid 1184
?? ?[1184] 23 Jan 10:49:56.344 * DB saved on disk
?? ?[1185] 23 Jan 10:49:56.344 * DB saved on disk
?? ?[1184] 23 Jan 10:49:56.346 * RDB: 0 MB of memory used by copy-on-write
?? ?[1185] 23 Jan 10:49:56.347 * RDB: 0 MB of memory used by copy-on-write
?? ?[32729] 23 Jan 10:49:56.429 * Background saving terminated with success
?? ?[32726] 23 Jan 10:49:56.433 * Background saving terminated with success
?? ?lrange data 0 -1
?? ?*1
?? ?$1
?? ?1
?? ?get name
?? ?$4
?? ?tang
?? ?可以看到,數據已在從服務器中訪問成功。
總結
以上是生活随笔為你收集整理的验证redis的主从复制的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Redis中7种集合类型应用场景
- 下一篇: mogodb 的自定义函数定义及引用