Centos7.4 安裝配置 redis
阿新 • • 發佈:2020-09-11
一、安裝redis
1、設定redis的倉庫地址,執行命令:
yum install epel-release
出現下圖即設定成功
2、安裝redis
執行命令如下:
yum install redis
3、啟動redis
service redis start
4、設定開機自動啟動
執行命令:chkconfig redis on
5、如果要遠端訪問資料庫,那麼需要開啟防火牆埠,命令如下:
firewall-cmd --zone=public --add-port=6379/tcp --permanent
6、設定開啟防火牆埠生效,命令如下:
firewall-cmd --reload
7、檢視防火牆開放所有埠,命令如下:
firewall-cmd --list
8、設定遠端訪問,需修改配置檔案,首先查詢redis.conf配置檔案所在位置:
whereis redis.config
9、修改 redis.conf 配置檔案,執行命令:
vi /etc/redis.conf
進入檔案後,找到 bing 127.0.0.1 欄位,註釋掉所在行,如圖:
如果需要修改資料庫密碼,在 redis.conf 配置檔案中,找到 requirepass foobared 欄位,將foobared 改為所要設定的密碼,然後儲存並退出。
10、儲存退出,(按ESC,再按:號,輸入wq)
wq
11、設定完成後,重新redis資料庫,執行命令:
service redis restart
二、測試redis
1、進入redis 互動命令列,執行命令:
redis-cli
2、資料庫新增資料,執行命令:
set 'a' 'b'
查詢資料,執行命令:get 'a'
3、當出現上圖結果,則安裝完成。
摘抄自:https://blog.csdn.net/a575553272/article/details/79743802 很好的一篇指導文件,怕丟失,抄下來