Home | 简体中文 | 繁体中文 | 杂文 | 打赏(Donations) | Github | OSChina 博客 | 云社区 | 云栖社区 | Facebook | Linkedin | 知乎专栏 | 视频教程 | About

32.2. CentOS 6

安装fedora的YUM源,

				rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm
			

安装redis

				# yum install redis

				# chkconfig redis on

				# service redis start
			

备份配置文件,

				# cp /etc/redis.conf /etc/redis.conf.original
			

32.2.1. 主从同步

主从同步配置非常简单,只需在从服务器 /etc/redis.conf 文件中开启 slaveof 即可

					slaveof 192.168.2.1 6379
				

查看 /var/log/redis/redis.log 日志,可以看到同步情况

				
[20274] 09 Jul 13:13:53 * Server started, Redis version 2.4.10
[20274] 09 Jul 13:13:53 * DB loaded from disk: 0 seconds
[20274] 09 Jul 13:13:53 * The server is now ready to accept connections on port 6379
[20274] 09 Jul 13:13:54 * Connecting to MASTER...
[20274] 09 Jul 13:13:54 * MASTER <-> SLAVE sync started
[20274] 09 Jul 13:13:54 * Non blocking connect for SYNC fired the event.
[20274] 09 Jul 13:13:54 * MASTER <-> SLAVE sync: receiving 672 bytes from master
[20274] 09 Jul 13:13:54 * MASTER <-> SLAVE sync: Loading DB in memory
[20274] 09 Jul 13:13:54 * MASTER <-> SLAVE sync: Finished with success
				
				

32.2.2. Sentinel