centos 安裝redis5.0.9
阿新 • • 發佈:2020-09-20
下載包
wget http://download.redis.io/releases/redis-5.0.9.tar.gz
解壓並移動
tar -zvxf redis-5.0.9.tar.gz
mv /root/redis-5.0.9 /usr/local/redis
編譯
cd /usr/local/redis
make
安裝
make PREFIX=/usr/local/redis install
修改配置檔案
#遠端訪問
#bind 127.0.0.1
protected-mode no
port 6360 #隨意
requirepass yourpassword
daemonize yes #可以後臺程序執行
啟動
./bin/redis-server ./redis.conf
開發埠
firewall-cmd --zone=public --add-port=6360/tcp --permanent
firewall-cmd --reload
設定開機啟動
建立服務
vim /lib/systemd/system/redis.service
[Unit] Description=Redis After=network.target [Service] Type=forking PIDFile=/var/run/redis_6379.pid ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.conf ExecReload=/bin/kill -s HUP $MAINPID ExecStop=/bin/kill -s QUIT $MAINPID PrivateTmp=true [Install] WantedBy=multi-user.target
重新整理配置
systemctl daemon-reload
啟動、重啟、停止
systemctl start redis
systemctl restart redis
systemctl stop redis
開機自啟動
redis服務加入開機啟動
systemctl enable redis
禁止開機啟動
systemctl disable redis