Home | 簡體中文 | 繁體中文 | 雜文 | 打賞(Donations) | Github | OSChina 博客 | 雲社區 | 雲棲社區 | Facebook | Linkedin | 知乎專欄 | 視頻教程 | About

1.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
			

1.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
				
				

1.2.2. Sentinel