日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

redis安装,主从集群

發布時間:2024/9/30 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 redis安装,主从集群 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1:服務端下載 $ 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 ......出現一大堆信息 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]$ ? 運行 $ 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?? 設置鍵值? redis> set foo bar? OK? 讀取鍵值? redis> get foo? "bar" 2:集群配置 用一致性哈希,做多個主從,可以做主從集群。 主從配置 配置Master-Slave,只需要在Slave上配置Master節點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
啟動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安装,主从集群的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。