验证redis的主从复制
2014-01-29 15:36
387 查看
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
可以看到,数据已在从服务器中访问成功。
[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中7种集合类型应用场景
- linux Ubuntu 安装 redis2.8.4
- Redis安装和使用示例
- 给phpstrom 加上 yii的redis提示
- php+redis应用
- 关于Spring Data redis几种对象序列化的比较
- tomcat 使用redis 管理session
- redis使用实例
- redis备忘
- redis 分片(zz)
- redis事务
- Redis学习
- redis 学习篇(基础)
- NodeJS+Redis实现Web实时通讯聊天模块
- 转:Redis源码分析网站
- redis源码分析-1 字符串处理
- Redis need tcl 8.5 or newer
- instagram redis优化
- Redis 的Lua Script脚本功能
- 使用kendynet构建异步redis访问服务