Redis二進制安裝
(0) cd /usr/src 進入下載目錄
(1) yum install -y wget gcc make tcl 安裝依賴
(2) wget http://download.redis.io/releases/redis-3.2.2.tar.gz 下載源碼包 redis官網http://www.redis.io
(3) tar -zxvf redis-3.2.2.tar.gz 解壓
(4) cd redis-3.2.2 進入redis目錄
(5) make 編譯
(6) make test 測試
測試結果如下,正常
\o/ All tests passed without errors!
Cleanup: may take some time... OK
make[1]: Leaving directory `/app/redis-3.2.11/src'
測試過程報錯
[exception]: Executing test client: NOREPLICAS Not enough good slaves to write..
NOREPLICAS Not enough good slaves to write.
while executing
這種情況下,可以修改當前目錄文件tests/integration/replication-2.tcl,將after 1000改爲after 10000以延長等待時間 重新測試
(7) make install PREFIX未指定目錄,默認安裝到/usr/local/bin裏面了
該目錄下生成幾個可執行文件
redis-benchmark 性能測試程序
redis-check-aof
redis-check-rdb
redis-cli 客戶端可執行程序
redis-server 服務端可執行程序
(8)啓動redis服務 redis-server 不加配置文件爲默認,一般需加redis.conf
啓動後出現的錯誤及解決辦法
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.
解決方法:往/etc/sysctl.conf 中添加vm.overcommit_memory = 1
WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128
解決方法:echo 511 > /proc/sys/net/core/somaxconn 寫到/etc/rc.local裏面 rc.local 是開機啓動程序 是一個軟連接 (確定兩者都有執行權限)lrwxrwxrwx. 1 root root 13 Aug 2 07:50 /etc/rc.local -> rc.d/rc.local
WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
解決方法:echo never > /sys/kernel/mm/transparent_hugepage/enabled 寫到/etc/rc.local裏面
還有想在後臺運行的話修改配置redis.conf daemonize yes 就可以了
Redis的啓動,查看,關閉,登錄,退出,幫助
啓動命令(全路徑/usr/local/redis/bin/redis-server)
redis-server(命令) /usr/local/redis/etc/redis.conf (配置文件) & (爲redis-server指定配置文件並後臺啓動)
查看命令
Ps -ef |grep redis 或 netstat -anptu|grep 6379 或 lsof -i :6379
關閉命令
redis-cli shutdown 參數(-h -p -u -a) 對應 (ip地址,端口號,用戶名,密碼) 注意,參數放在前面
登錄命令
redis-cli 參數(-h -p -u -a) 對應 (ip地址,端口號,用戶名,密碼)
退出命令
127.0.0.1:6379> quit
命令幫助
Redis-server --help 或 redis-cli --help