一、增加redis使用者
groupadd redis
useradd redis -g redis -s /sbin/nologin -M
###關閉防火牆###
systemctl stop firewalld # 關閉服務
systemctl disable firewalld # 禁止開機啟動
systemctl disable NetworkManager.service
二、下載原始碼包
yum install tcl -y
cd /usr/local/src
wget http://download.redis.io/releases/redis-4.0.10.tar.gz
tar -zxvf redis-4.0.10.tar.gz
cd redis-4.0.10
make test
make MALLOC=libc
make install
#make PREFIX=/usr/local/redis MALLOC=libc install #安裝到指定目錄
三、將redis服務設定成啟動項
#啟動指令碼
cp /usr/local/src/redis-4.0.10/utils/redis_init_script /etc/init.d/redis
注意增加了chkconfig和description兩行 不然會提示 服務 redisd 不支援 chkconfig
或者
新增開機啟動服務
vim /etc/systemd/system/redis-server.service
[Unit]
Description=The redis-server Process Manager
After=syslog.target network.target
[Service]
Type=simple
PIDFile=/var/run/redis_6379.pid
ExecStart=/usr/local/redis/redis-server /usr/local/redis/redis.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
[Install]
WantedBy=multi-user.target
設定開機啟動
systemctl daemon-reload
systemctl start redis-server.service
systemctl enable redis-server.service