1. 安裝依賴包c++
yum install -y gcc gcc-c++
2. 下載最新版redis安裝包並解壓安裝redis
cd /usr/local/src
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar -zxvf redis-5.0.7.tar.gz
make
make install
3. 打開 redis.conf 並更改配置文件ui
更改密碼 # requirepass foobared requirepass xxx 容許後臺靜默運行 #daemonize no daemonize yes 更改日誌文件 #logfile "" logfile "/var/log/redis/6379.log"
4. 建立配置文件軟鏈spa
ln -s /usr/local/src/redis-5.0.7/redis.conf /etc/redis/6379.conf
5. 增長啓動服務腳本rest
touch /usr/lib/systemd/system/redis.service redis.service內容以下: [Unit] Description=Redis 6379 After=syslog.target network.target [Service] Type=forking PrivateTmp=yes Restart=always ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf ExecStop=/usr/local/bin/redis-cli -h 127.0.0.1 -p 6379 -a jcon shutdown User=root Group=root LimitCORE=infinity LimitNOFILE=100000 LimitNPROC=100000 [Install] WantedBy=multi-user.target
從新加載redis服務配置文件
systemctl daemon-reload
啓動redissystemctl start redis中止redissystemctl stop redis重啓redissystemctl restart redis加入開機啓動systemctl enable redis禁止開機啓動systemctl disable redis查看狀態systemctl status redis