Centos7安裝redis5.0.7


1. 安裝依賴包(Redis是C語言開發,需要安裝gcc依賴環境)

yum install -y gcc gcc-c++

 

2. 下載最新版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
mkdir -p /usr/local/redis/{etc,data}
cd redis-5.0.7/

#指定redis使用哪種內存分配器,目前有jemalloc,tcmalloc,libc
#jemalloc是facebook推出的,https://github.com/jemalloc/jemalloc
#tcmalloc是Google推出的,https://github.com/gperftools/gperftools
#libc是標准的內存分配庫malloc和free
#具體使用哪種自己可以調整下面參數對比下
make MALLOC=libc
make install PREFIX=/usr/local/redis

ln -s /usr/local/src/redis-5.0.7/redis.conf /usr/local/redis/redis.conf

#創建日志文件
touch /var/log/redis/6379.log
復制代碼

 

3.  打開 redis.conf 並更改配置文件

復制代碼
更改密碼
# requirepass foobared
requirepass xxx

允許后台靜默運行
#daemonize no
daemonize yes

更改日志文件
#logfile ""
logfile "/var/log/redis/6379.log"
復制代碼

 

4. 增加啟動服務腳本

復制代碼
新增配置文件
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/redis/bin/redis-server /usr/local/redis/redis.conf
ExecStop=/usr/local/redis/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

啟動redis
systemctl start redis
停止redis
systemctl stop redis
重啟redis
systemctl restart redis
加入開機啟動
systemctl enable redis
禁止開機啟動
systemctl disable redis
查看狀態
systemctl status redis
復制代碼
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM