1.備份redis配置文件
cp /etc/redis.conf /etc/redis.conf.bak
2.將redis中不要的注釋和空行刪除
sed -i '/^#/d; /^$/d' /etc/redis.conf????????
3.redis配置文件
bing 0.0.0.0 :綁定本機所有網卡
daemonize yes:設置后臺運行
requirepass redispwd :設置redis密碼
4.redis啟動
redis-server /etc/etc/redis.conf
5.查看redis啟動日志,根據日志提示信息調整內核參數。
tail -f /data/redis/redis.log
(1)根據啟動日志中提示的參數進行修改
vim /etc/security/limits.conf
* - nofile 65535
設置完該參數后,終端退出重新登錄下會生效。
ulimit -n
(2)內核參數修改
vim /etc/sysctl.conf
net.core.somaxconn=10240? ? ? ? ? ? ? ? #調大somaxconn數
vm.overcommit_memory=1? ? ? ? ? ? ? ? #如果這個參數沒有修改,可能會引起redis參數丟失,參數很重要。
sysctl -p? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #內核參數生效
調整參數后kill掉redis進程,重啟redis就不會報以上警告了。
6.將redis加入系統管理
vim /etc/lib/systemd/system/redis.service
systemctl daemon-reload? ? ? ? #重載服務
systemctl status redis? ? ? ? #查看服務
7.redis登錄測試
redis-cli -a redispwd