redis安装,主从集群
生活随笔
收集整理的這篇文章主要介紹了
redis安装,主从集群
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1:服務(wù)端下載 $ wget http://download.redis.io/releases/redis-2.8.13.tar.gz
? 解壓 $ tar xzf redis-2.8.13.tar.gz$ cd redis-2.8.13編譯 $ make
[jifeng@jifeng04 ~]$ tar xzf redis-2.8.13.tar.gz
[jifeng@jifeng04 ~]$ cd redis-2.8.13
[jifeng@jifeng04 redis-2.8.13]$ make
cd src && make all
......出現(xiàn)一大堆信息
Hint: To run 'make test' is a good idea ;)make[1]: Leaving directory `/home/jifeng/redis-2.8.13/src'[jifeng@jifeng04 redis-2.8.13]$ ? 運(yùn)行 $ src/redis-server[jifeng@jifeng04 redis-2.8.13]$ src/redis-server
[6675] 10 Aug 17:19:48.837 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
[6675] 10 Aug 17:19:48.838 # You requested maxclients of 10000 requiring at least 10032 max file descriptors.
[6675] 10 Aug 17:19:48.838 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted.
[6675] 10 Aug 17:19:48.838 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'._._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.13 (00000000/0) 64 bit.-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379| `-._ `._ / _.-' | PID: 6675`-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6675] 10 Aug 17:19:48.839 # Server started, Redis version 2.8.13
[6675] 10 Aug 17:19:48.839 # 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.
[6675] 10 Aug 17:19:48.839 * The server is now ready to accept connections on port 6379
測試一下
? 連接redis? $ src/redis-cli?? 設(shè)置鍵值? redis> set foo bar? OK? 讀取鍵值? redis> get foo? "bar" 2:集群配置 用一致性哈希,做多個(gè)主從,可以做主從集群。 主從配置 配置Master-Slave,只需要在Slave上配置Master節(jié)點(diǎn)IP Port: [jifeng@jifeng04 redis-2.8.13]$ vi redis.conf ################################# REPLICATION ################################## Master-Slave replication. Use slaveof to make a Redis instance a copy of # another Redis server. Note that the configuration is local to the slave # so for example it is possible to configure the slave to save the DB with a # different interval, or to listen to another port, and so on. # # slaveof <masterip> <masterport>修改上面最后一行 slaveof 10.3.7.212 6379
啟動(dòng)slave [jifeng@jifeng04 redis-2.8.13]$ src/redis-server ./redis.conf [6762] 10 Aug 17:46:46.907 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. [6762] 10 Aug 17:46:46.907 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted. [6762] 10 Aug 17:46:46.907 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'._._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.13 (00000000/0) 64 bit.-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379| `-._ `._ / _.-' | PID: 6762`-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6762] 10 Aug 17:46:46.915 # Server started, Redis version 2.8.13 [6762] 10 Aug 17:46:46.916 # 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. [6762] 10 Aug 17:46:46.916 * DB loaded from disk: 0.000 seconds [6762] 10 Aug 17:46:46.916 * The server is now ready to accept connections on port 6379 [6762] 10 Aug 17:46:47.916 * Connecting to MASTER 10.3.7.212:6379 [6762] 10 Aug 17:46:47.916 * MASTER <-> SLAVE sync started [6762] 10 Aug 17:46:47.916 * Non blocking connect for SYNC fired the event. [6762] 10 Aug 17:46:47.917 * Master replied to PING, replication can continue... [6762] 10 Aug 17:46:47.917 * Partial resynchronization not possible (no cached master) [6762] 10 Aug 17:46:47.917 * Full resync from master: 925b249e41d001e66c4e683983439c346b96571f:1 [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: receiving 29 bytes from master [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Flushing old data [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Loading DB in memory [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Finished with success
測試 Master寫,Slave讀: OK!!
? 連接redis? $ src/redis-cli?? 設(shè)置鍵值? redis> set foo bar? OK? 讀取鍵值? redis> get foo? "bar" 2:集群配置 用一致性哈希,做多個(gè)主從,可以做主從集群。 主從配置 配置Master-Slave,只需要在Slave上配置Master節(jié)點(diǎn)IP Port: [jifeng@jifeng04 redis-2.8.13]$ vi redis.conf ################################# REPLICATION ################################## Master-Slave replication. Use slaveof to make a Redis instance a copy of # another Redis server. Note that the configuration is local to the slave # so for example it is possible to configure the slave to save the DB with a # different interval, or to listen to another port, and so on. # # slaveof <masterip> <masterport>修改上面最后一行 slaveof 10.3.7.212 6379
啟動(dòng)slave [jifeng@jifeng04 redis-2.8.13]$ src/redis-server ./redis.conf [6762] 10 Aug 17:46:46.907 # You requested maxclients of 10000 requiring at least 10032 max file descriptors. [6762] 10 Aug 17:46:46.907 # Redis can't set maximum open files to 10032 because of OS error: Operation not permitted. [6762] 10 Aug 17:46:46.907 # Current maximum open files is 1024. maxclients has been reduced to 4064 to compensate for low ulimit. If you need higher maxclients increase 'ulimit -n'._._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 2.8.13 (00000000/0) 64 bit.-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in stand alone mode|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379| `-._ `._ / _.-' | PID: 6762`-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' [6762] 10 Aug 17:46:46.915 # Server started, Redis version 2.8.13 [6762] 10 Aug 17:46:46.916 # 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. [6762] 10 Aug 17:46:46.916 * DB loaded from disk: 0.000 seconds [6762] 10 Aug 17:46:46.916 * The server is now ready to accept connections on port 6379 [6762] 10 Aug 17:46:47.916 * Connecting to MASTER 10.3.7.212:6379 [6762] 10 Aug 17:46:47.916 * MASTER <-> SLAVE sync started [6762] 10 Aug 17:46:47.916 * Non blocking connect for SYNC fired the event. [6762] 10 Aug 17:46:47.917 * Master replied to PING, replication can continue... [6762] 10 Aug 17:46:47.917 * Partial resynchronization not possible (no cached master) [6762] 10 Aug 17:46:47.917 * Full resync from master: 925b249e41d001e66c4e683983439c346b96571f:1 [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: receiving 29 bytes from master [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Flushing old data [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Loading DB in memory [6762] 10 Aug 17:46:47.952 * MASTER <-> SLAVE sync: Finished with success
測試 Master寫,Slave讀: OK!!
總結(jié)
以上是生活随笔為你收集整理的redis安装,主从集群的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Hadoop中Namenode单点故障的
- 下一篇: ActiveMQ的集群与高可用