WEB开发网
开发学院服务器云计算 Redis安装及主从配置 阅读

Redis安装及主从配置

 2012-07-18 19:36:33 来源:WEB开发网   
核心提示:主从结构的配置在进行主从结构配置之前,请确保已经在上述三台机器上已经安装了Redis服务,Redis安装及主从配置(2),对于Redis的主从结构的配置相对比较简单,只需修改redis.conf文件,其中包括IP及端口号,当主结点在启动时 当只有一台主结点在启动时,配置上主结点对应的IP及端口,具体如下所示:
主从结构的配置
在进行主从结构配置之前,请确保已经在上述三台机器上已经安装了Redis服务。对于Redis的主从结构的配置相对比较简单,只需修改redis.conf文件,配置上主结点对应的IP及端口。具体如下所示:
Port 6380
bind 10.20.150.205
slaveof 10.20.150.205 6379
l  port 6380表示当前该Redis服务对应的端口号;
l  bind 10.20.150.205 表示当前Redis绑定的主结点的IP地址;
l  slaveof 10.20.150.205 6379 表示当前Redis是哪个主结点的从结点,其中包括IP及端口号。
当主结点在启动时            
当只有一台主结点在启动时,会显示如下的信息:
[29028] 26 Sep 18:39:12 * Server started, Redis version 2.2.12
[29028] 26 Sep 18:39:12 # 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.
[29028] 26 Sep 18:39:12 * DB loaded from disk: 0 seconds
[29028] 26 Sep 18:39:12 * The server is now ready to accept connections on port 6379
[29028] 26 Sep 18:39:12 - 0 clients connected (0 slaves), 790584 bytes in use
当有一台从结点10.20.150.208启动时
其中主结点会自动检测到有新的从结点启动并加入进来,其显示的信息如下:
[29028] 26 Sep 18:40:31 - Accepted 10.20.150.208:44779
[29028] 26 Sep 18:40:31 * Slave ask for synchronization
[29028] 26 Sep 18:40:31 * Starting BGSAVE for SYNC
[29028] 26 Sep 18:40:31 * Background saving started by pid 29091
[29091] 26 Sep 18:40:31 * DB saved on disk
[29028] 26 Sep 18:40:31 * Background saving terminated with success
[29028] 26 Sep 18:40:31 * Synchronization with slave succeeded
[29028] 26 Sep 18:40:32 - 0 clients connected (1 slaves), 798752 bytes in use
[29028] 26 Sep 18:40:37 - 0 clients connected (1 slaves), 798752 bytes in use
[29028] 26 Sep 18:40:42 - 0 clients connected (1 slaves), 798752 bytes in use
[29028] 26 Sep 18:40:47 - 0 clients connected (1 slaves), 798752 bytes in use

上一页  1 2 3 4 5 6  下一页

Tags:Redis 主从 配置

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接