久久精品人人爽,华人av在线,亚洲性视频网站,欧美专区一二三

CentOS 7.4如何安裝redis 4.0

196次閱讀
沒有評論

共計 3315 個字符,預計需要花費 9 分鐘才能閱讀完成。

這篇文章主要為大家展示了“CentOS 7.4 如何安裝 redis 4.0”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓丸趣 TV 小編帶領大家一起研究并學習一下“CentOS 7.4 如何安裝 redis 4.0”這篇文章吧。

一、redis 單實例安裝

1、安裝依賴包

[root@VM_2_13_centos redis]# yum install gcc*

2、獲取安裝文件

[root@VM_2_13_centos redis]# wget http://download.redis.io/releases/redis-4.0.9.tar.gz

3、解壓文件

[root@VM_2_13_centos redis]# tar zxvf redis-4.0.9.tar.gz

[root@VM_2_13_centos redis]# ll

total 1708

drwxrwxr-x 6 root root  4096 Mar 27 00:04 redis-4.0.9

-rw-r–r– 1 root root 1737022 Mar 27 00:04 redis-4.0.9.tar.gz

4、編譯安裝

[root@VM_2_13_centos redis-4.0.9]# make

[root@VM_2_13_centos redis-4.0.9]# make PREFIX=/usr/local/redis install

cd src make install

make[1]: Entering directory `/usr/local/redis/redis-4.0.9/src

 CC Makefile.dep

make[1]: Leaving directory `/usr/local/redis/redis-4.0.9/src

make[1]: Entering directory `/usr/local/redis/redis-4.0.9/src

Hint: It s a good idea to run make test )

 INSTALL install

 INSTALL install

 INSTALL install

 INSTALL install

 INSTALL install

5、查看 redis 的版本

[root@VM_2_13_centos ~]# redis-server –version

Redis server v=4.0.9 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=c97ec2b5e9b86914

6、啟動 redis

[root@VM_2_13_centos redis]# /usr/local/redis/bin/redis-server /etc/redis/redis.conf

[root@VM_2_13_centos redis]# netstat -tuplan | grep 6379

tcp  0  0 127.0.0.1:6379  0.0.0.0:*  LISTEN  5305/redis-server 1

[root@VM_2_13_centos redis]# ps -ef | grep redis

root  5305  1  0 21:38 ?  00:00:00 /usr/local/redis/bin/redis-server 127.0.0.1:6379

root  5356 30807  0 21:39 pts/1  00:00:00 grep –color=auto redis

7、通過客戶端登錄

[root@VM_2_13_centos ~]# redis-cli

127.0.0.1:6379

備注:如果要卸載 redis,把 /usr/local/redis/bin/ 目錄下的 redis 刪除即可。為了卸載干凈,你還可以把解壓和編譯的 redis 包及配置的 redis.conf 也刪除。

二、安全配置

1、設置密碼

redis 的默認安裝是不設置密碼的,可以在 redis.conf 中進行配置

[root@VM_2_13_centos ~]# vim /etc/redis/redis.conf

requirepass qcloud@2018

或者通過命令配置

127.0.0.1:6379 CONFIG set requirepass qcloud@2018

由于 Redis 的性能極高,并且輸入錯誤密碼后 Redis 并不會進行主動延遲(考慮到 Redis 的單線程模型),所以攻擊者可以通過窮舉法破解 Redis 的密碼(1 秒內能夠嘗試十幾萬個密碼),因此在設置時一定要選擇復雜的密碼,可以用隨機密碼生成器生成。

注意:配置 Redis 復制的時候如果主數據庫設置了密碼,需要在從數據庫的配置文件中通過 masterauth 參數設置主數據庫的密碼,以使從數據庫連接主數據庫時自動使用 AUTH 命令認證。

驗證密碼是否有效,是否需要認證

[root@VM_2_13_centos ~]# redis-cli

127.0.0.1:6379

127.0.0.1:6379 keys *

(error) NOAUTH Authentication required.

127.0.0.1:6379

127.0.0.1:6379  auth qcloud@2018

OK

127.0.0.1:6379

127.0.0.1:6379 keys *

(empty list or set)

2、禁用高危命令

目前該命令可以正常使用

127.0.0.1:6379 flushall

OK

關閉 redis,但是由于上面設置了密碼,必須要認證成功后才能關閉

[root@VM_2_13_centos ~]# redis-cli shutdown

(error) NOAUTH Authentication required.

[root@VM_2_13_centos ~]# redis-cli -a qcloud@2018 shutdown

[root@VM_2_13_centos ~]#

[root@VM_2_13_centos ~]# ps -ef | grep redis

root  6144  5406  0 21:54 pts/0  00:00:00 grep –color=auto redis

修改配置文件 redis.conf,增加如下行:

[root@VM_2_13_centos ~]# vim /etc/redis/redis.conf

rename-command FLUSHALL

rename-command CONFIG  

rename-command EVAL  

重新啟動 redis

[root@VM_2_13_centos ~]# redis-server /etc/redis/redis.conf

[root@VM_2_13_centos ~]#

[root@VM_2_13_centos ~]# redis-cli

127.0.0.1:6379

127.0.0.1:6379 keys *

(error) NOAUTH Authentication required.

127.0.0.1:6379

127.0.0.1:6379 auth qcloud@2018

OK

127.0.0.1:6379

127.0.0.1:6379 flushall

(error) ERR unknown command flushall

127.0.0.1:6379

127.0.0.1:6379 config

(error) ERR unknown command config

127.0.0.1:6379

127.0.0.1:6379 eval

(error) ERR unknown command eval

通過上面的報錯可以發現,在配置文件禁用的三個命令無法使用

3、綁定只能本機訪問

[root@VM_2_13_centos ~]# vim /etc/redis/redis.conf

bind 127.0.0.1

4、設置 redis 開啟自啟動

[root@VM_2_13_centos ~]# vim /etc/rc.d/rc.local

/usr/local/redis/bin/redis-server /etc/redis/redis.conf

以上是“CentOS 7.4 如何安裝 redis 4.0”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注丸趣 TV 行業資訊頻道!

正文完
 
丸趣
版權聲明:本站原創文章,由 丸趣 2023-07-24發表,共計3315字。
轉載說明:除特殊說明外本站除技術相關以外文章皆由網絡搜集發布,轉載請注明出處。
評論(沒有評論)
主站蜘蛛池模板: 辽阳县| 吴川市| 清水县| 报价| 营山县| 盐城市| 石台县| 崇礼县| 图们市| 连云港市| 巨鹿县| 凤翔县| 扶沟县| 隆尧县| 靖边县| 民权县| 巴彦淖尔市| 临桂县| 五寨县| 泰兴市| 南川市| 贡嘎县| 宁陵县| 宁夏| 渑池县| 罗平县| 乌兰浩特市| 乌苏市| 尼木县| 木里| 富民县| 绿春县| 钦州市| 常宁市| 遂昌县| 万全县| 永平县| 望江县| 庆阳市| 陆河县| 霍林郭勒市|