CentOS7 下 yum 安裝 Redis

1. 安裝 Redis 服務

1> 檢查是否有redis yum 源

shell> yum install redis

2> 下載fedora的epel倉庫

shell> yum install epel-release

3> 安裝redis數據庫

shell> yum install redis

2.啓動/關閉/重啓 Redis 服務

1> 啓動 Redis 服務

shell> systemctl start redis.service

2> 關閉 Redis 服務

shell> systemctl stop redis.service

3> 重啓 Redis 服務

shell> systemctl restart redis.service

3.設置redis開機啓動

shell> systemctl enable redis.service

4.設置redis密碼

1> 打開配置文件

shell> vi /etc/redis.conf

2> 找到 “# requirepass foobared”,去掉前面的 “#”,並把 “foobared” 改成你的密碼。

3> 保存文件,重啓服務

shell> systemctl restart redis.service

5.使用 redis desktop manager 遠程連接

1> 下載地址:https://github.com/MicrosoftArchive/redis/releases

2> 如果長時間連接不上,可能有兩種可能性

a> bind了127.0.01:只允許在本機連接redis
b> protected-mode設置了yes(使用redis desktop manager工具需要配置,其餘不用)

解決方案:

i> 打開redis配置文件
shell> vi /etc/redis.conf
ii> 修改如下內容:

找到 bind 127.0.0.1 將其註釋
找到 protected-mode yes 將其改爲 protected-mode no

iii > 保存文件,重啓服
shell> systemctl restart redis.service

3> 開放 6379 端口 :沒有開放該端口無法進行遠程鏈接

shell> firewall-cmd --zone=public --add-port=6379/tcp --permanent
shell> firewall-cmd --reload

參考鏈接:

https://www.cnblogs.com/rslai/p/8249812.html

https://www.jianshu.com/p/ebda253a8daa

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章