1.安裝
centos7中安裝redis
1.由于CentOS官方y(tǒng)um源里面沒有Redis,這里我們需要安裝一個第三方的yum源,這里用了Fedora的epel倉庫 yum install epel-release
安裝過程中一直輸入y按回車就可以了
2.安裝redis yum install redis
同樣也是一直輸入y按回車就可以了
3.啟動redis
service redis start
如果輸入提示 Redirecting to /bin/systemctl start redis.service這個語句崭参,則直接輸入/bin/systemctl start redis.service去啟動redis
- 查看redis的狀態(tài)
service redis status
或者
/bin/systemctl status redis.service
5.重啟redis ``` service redis restart 或者 /bin/systemctl restart redis.service
6\. 關(guān)閉redis
service redis stop
或者
/bin/systemctl stop redis.service
##### [](https://github.com/coco369/knowledge/blob/master/sql/redis.md#b-%E6%B5%8B%E8%AF%95)b) 測試
PING:使用客戶端向 Redis 服務(wù)器發(fā)送一個 PING 寡润,如果服務(wù)器運作正常的話提澎,會返回一個 PONG 。通常用于測試與服務(wù)器的連接是否仍然生效,或者用于測量延遲值呐舔。
返回值:如果連接正常就返回一個 PONG 淑趾,否則返回一個連接錯誤烹棉。
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379>
#### [](https://github.com/coco369/knowledge/blob/master/sql/redis.md#2%E4%BF%AE%E6%94%B9redisconf%E6%96%87%E4%BB%B6)2.修改 redis.conf文件
##### [](https://github.com/coco369/knowledge/blob/master/sql/redis.md#a-%E9%85%8D%E7%BD%AE%E6%96%87%E4%BB%B6)a) 配置文件
配置文件位置:redisd 配置信息在 /etc/redis.conf中
##### [](https://github.com/coco369/knowledge/blob/master/sql/redis.md#b-%E4%BF%AE%E6%94%B9%E7%99%BB%E5%BD%95%E5%AF%86%E7%A0%81)b) 修改登錄密碼
在vim中通過搜索:/requirepass 可以找到如下配置
requirepass foobared
如果取消該注釋攒霹,修改foobared的值新的密碼值,并保存文件浆洗,則說明redis重啟以后需要輸入新設(shè)置的密碼newfoobared登錄
requirepass newfoobared
然后重啟
##### [](https://github.com/coco369/knowledge/blob/master/sql/redis.md#c-%E8%BF%9B%E5%85%A5redis)c) 進入redis
直接使用redis-cli命令進入催束,使用auth 加密碼進行驗證 如果auth密碼驗證失敗的話提示 (error) NOAUTH Authentication required. 錯誤
##### [](https://github.com/coco369/knowledge/blob/master/sql/redis.md#d-%E9%80%80%E5%87%BA)d) 退出
quit: 關(guān)閉連接(connection)