Redis安裝教程(超詳細)

哈哈哈hh發表於2022-05-05

映象下載、域名解析、時間同步請點選  阿里雲開源映象站

Redis

一、Redis安裝

1、windows下安裝

預設埠:6379

下載連線

解壓

雙擊redis-server.exe啟動服務端

雙擊redis-cli.exe啟動客戶端連線服務端

在客戶端輸入 “ping”,出現“PONG”,即證明連線成功

file

2、Linux下安裝

2.1、下載linux壓縮包 【redis-5.0.5.tar.gz】

2.2、通過FlashFXP把壓縮包傳送到伺服器

2.3、解壓縮

tar -zxvf redis-5.0.5.tar.gz

file

2.4、進入redis-5.0.5可以看到redis的配置檔案redis.conf

file

2.5、基本的環境安裝

使用gcc -v 命令檢視gcc版本已經是4.8.5了,於是就沒有再次安裝,直接執行make,安裝完之後再次make,出現圖片內容即可。

yum install gcc-c++
make
make
make install   //確認安裝的東西

file

2.6、redis預設安裝路徑是 /usr/local/bin

在該目錄下可以看到redis的客戶端和服務端

cd /usr/local/bin/

file

2.7、將redis的配置檔案拷貝到新建的目錄myredis-config下

我們以後就使用myredis-config下的配置檔案,錯了還可以回到原來那裡取

[root@Lzdwtl bin]# mkdir myredis-config
[root@Lzdwtl bin]# cp /home/caoyinyuan/redis-5.0.5/redis.conf myredis-config/

2.8、redis預設不是後臺啟動,需要修改配置檔案

按圖修改檔案,將daemonize的值修改為yes

[root@Lzdwtl myredis-config]# vim redis.conf

file

2.9、啟動redis

1、回到bin目錄下

2、啟動redis服務端,通過指定的配置檔案啟動服務

[root@Lzdwtl bin]# redis-server myredis-config/redis.conf

3、啟動redis客戶端

[root@Lzdwtl bin]# redis-cli -p 6379
# 如果redis設定有密碼,則需要現認證才能傳送資訊,"123456"是redis的密碼
127.0.0.1:6379> auth "123456"

file

2.10、檢視redis的程式是否開啟

複製一個新的會話,然後執行下面命令檢視程式狀態

[root@Lzdwtl /]# ps -ef|grep redis

file

2.11、關閉redis服務

執行shutdown和exit即可推出redis服務,再次檢視也發現redis的服務端和客戶端程式都消失了

127.0.0.1:6379> shutdown
not connected> exit

file

3、RedisDesktop連線遠端資料庫

3.1、修改配置檔案redis.conf

1.將bind 127.0.0.1 改為 bind 0.0.0.0

2.將 protected-mode yes 改為 protected-mode no

3.2、執行Redis管理工具

(這個步驟的前提是redis已經開啟)新建連線,地址填伺服器的地址,然後點選測試連線,成功後點選右下角的確定即可。

file

二、錯誤與總結

1、redis管理工具連線不上伺服器

解決辦法:

1、bind 127.0.0.1 改為bind 0.0.0.0

2、將 protected-mode yes 改為 protected-mode no

3、設定redis祕密,requirepass 123456

注意如果不行,可以嘗試重啟伺服器試試

file

設定密碼後登陸需要如下圖操作

[root@Lzdwtl bin]# redis-server myredis-config/redis.conf 
[root@Lzdwtl bin]# redis-cli 
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK

file

本文轉自:https://blog.csdn.net/X_lsod/article/details/123263429


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/70003733/viewspace-2890728/,如需轉載,請註明出處,否則將追究法律責任。

相關文章