Centos 安裝Redis紀錄

安裝Redis紀錄
1.安裝編譯套件
2.下載redis
3.編譯安裝redis
4.啟動redis服務
5.設定開機啟動服務

1.安裝編譯套件

#yum install -y gcc gcc-c++ make cmake

2.下載redis
這邊使用 redis 6.2.7

#cd /opt/
#wget https://download.redis.io/releases/redis-6.2.7.tar.gz
#tar -zxvf redis-6.2.7.tar.gz
#rm -rf redis-6.2.7.tar.gz

3.編譯安裝redis

#cd redis-6.2.7
#make install PREFIX=/usr/local/redis
#ln -s /usr/local/redis/bin/redis-server /usr/bin/redis-server
#ln -s /usr/local/redis/bin/redis-cli /usr/bin/redis-cli
#mkdir -p /etc/redis
#cp /opt/redis-6.2.7/redis.conf /etc/redis/redis.conf
#vim /etc/redis/redis.conf
daemonize yes
logfile /var/log/redis/redis.log 
bind 0.0.0.0 -::1
requirepass test5478

4.啟動redis服務

#redis-server /etc/redis/redis.conf

5.設定開機啟動

#vim /usr/lib/systemd/system/redis.service
[Unit]
Description=Redis 6379
After=syslog.target network.target
[Service]
Type=forking
PrivateTmp=yes
Restart=always
ExecStart=/usr/local/redis/bin/redis-server /etc/redis/redis.conf
ExecStop=/usr/local/redis/bin/redis-server/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
#systemctl daemon-reload
#systemctl enable redis
#systemctl start redis
Facebook Comments