1. 程式人生 > >Redis--(linux安裝redis3.2.9--教程)

Redis--(linux安裝redis3.2.9--教程)

如果中間遇見問題可以加扣扣群300458205
這裡寫圖片描述
下載安裝包
1、第一步上傳並且解壓編譯原始碼

tar xzf redis-3.2.9.tar.gz -C ../server/
cd redis-3.2.9/
make

這裡寫圖片描述
這裡寫圖片描述
這裡寫圖片描述
2、啟動服務
這裡寫圖片描述
3、啟動客戶端驗證
這裡寫圖片描述

遠端訪問伺服器失敗,知道下面有四種解決方案:
DENIED Redis is running in protected mode 
because protected mode is enabled, 
no bind address was specified, 
no authentication password is requested to
clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to
Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to
'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.

但是改了配置檔案不管用,看到了如圖提示資訊:
這裡寫圖片描述
這裡寫圖片描述

因為沒有指定配置檔案所以使用的是預設的,指定了路徑然後說我剛才改的有問題,是因為我註釋了bind並且設定了'--protected-mode no又設定了密碼所以有問題。
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.
警告:過量使用記憶體設定為0!在低記憶體環境下,後臺儲存可能失敗。為了修正這個問題,請在/etc/sysctl.conf 新增一項 'vm.overcommit_memory = 1' ,然後重啟(或者執行命令'sysctl vm.overcommit_memory=1' )使其生效。

4-可以適當進行優化引數
vim /etc/sysctl.conf
net.core.somaxconn = 20480 #最大佇列長度,應付突發的大併發連線請求,預設為128
net.ipv4.tcp_max_syn_backlog = 20480 #半連線佇列長度,此值受限於記憶體大小,預設為1024
vm.overcommit_memory = 1
0 表示檢查是否有足夠的記憶體可用,如果是,允許分配;如果記憶體不夠,拒絕該請求,並返回一個錯誤給應用程式。
1 允許分配超出實體記憶體加上交換記憶體的請求
2 核心總是返回true
sysctl -p #使引數生效