安裝步驟
若系統(tǒng)沒有安裝wget
,需要先安裝wget
yum -y install wget
從官網下載redis
wget https://download.redis.io/releases/redis-6.2.3.tar.gz
將下載的文件解壓至/usr/local
tar -zxvf redis-6.2.3.tar.gz -C /usr/local
redis編譯需要依賴gcc
,安裝gcc
yum -y install gcc
檢查gcc
版本,若gcc
版本過低5.3以下,則無法編譯redis6
gcc -v
升級到gcc 9
yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
scl enable devtoolset-9 bash
若沒有安裝tcl
,還需安裝tcl
,或者下載壓縮包編譯安裝
yum install tcl #tcl主要用于下一步執(zhí)行make test所需
切換到解壓后的redis目錄,開始嘗試編譯安裝
make && make test && make install
安裝后進行配置
mkdir /etc/redis
cp redis.conf /etc/redis/6379.conf
cd utils
cp redis_init_script /etc/init.d/redis_6379
chmod 777 /etc/init.d/redis_6379
修改redis配置文件
vim /etc/redis/6379.conf
bind 127.0.0.1 # 將這行代碼注釋,監(jiān)聽所有的ip地址,外網可以訪問
requirepass xxxxxxx # 添加訪問時的密碼
daemonize yes # 把no改成yes,后臺運行
appendonly yes # 開啟aof備份(是否開啟視情況而定)
設置開機自啟動
將redis服務添加到開機自啟
chkconfig --add redis_6379
設置redis開機自啟文章來源:http://www.zghlxwxcb.cn/news/detail-693975.html
chkconfig redis_6379 on
查看redis有沒有設置為開機啟動文章來源地址http://www.zghlxwxcb.cn/news/detail-693975.html
chkconfig --list | grep redis
部分查看redis服務的命令
systemctl start redis_6379.service #啟動redis服務
systemctl enable redis_6379.service #設置開機自啟動
systemctl disable redis_6379.service #停止開機自啟動
systemctl status redis_6379.service #查看服務當前狀態(tài)
systemctl restart redis_6379.service #重新啟動服務
systemctl list-units --type=service #查看所有已啟動的服務
到了這里,關于CentOS 7安裝Redis6的文章就介紹完了。如果您還想了解更多內容,請在右上角搜索TOY模板網以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網!