日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

Linux系统:Centos7搭建Redis单台和集群环境

發(fā)布時(shí)間:2025/3/17 linux 38 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Linux系统:Centos7搭建Redis单台和集群环境 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

一、環(huán)境和版本

Linux:centos7 三臺

三臺Linux服務(wù) 192.168.72.129 192.168.72.130 192.168.72.131 Redis:redis-4.0.14

二、上傳Redis軟件

1、創(chuàng)建軟件目錄

[root@localhost local]# cd /usr/local/ [root@localhost local]# mkdir mysoft

2、Xftp上傳軟件,解壓

[root@localhost mysoft]# cd /usr/local/mysoft/ [root@localhost mysoft]# ll total 1704 -rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz [root@localhost mysoft]# tar -zxvf redis-4.0.14.tar.gz

3、編譯項(xiàng)目

[root@localhost mysoft]# ll total 1708 drwxrwxr-x. 6 root root 4096 Mar 19 00:23 redis-4.0.14 -rw-r--r--. 1 root root 1740967 Apr 30 11:29 redis-4.0.14.tar.gz [root@localhost mysoft]# cd redis-4.0.14/ [root@localhost redis-4.0.14]# make MALLOC=libc

4、安裝Redis

[root@localhost redis-4.0.14]# cd src && make install

5、啟動(dòng)服務(wù)

[root@localhost redis-4.0.14]# cd src [root@localhost src]# ./redis-server

6、配置進(jìn)程啟動(dòng)

修改redis.conf

daemonize yes

7、進(jìn)程查看關(guān)閉

[root@localhost redis-4.0.14]# ./src/redis-server redis.conf 11320:C 05 May 14:26:31.053 # Redis is starting 11320:C 05 May 14:26:31.053 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=11320, just started 11320:C 05 May 14:26:31.053 # Configuration loaded [root@localhost redis-4.0.14]# ps -aux |grep redis root 11321 0.1 0.1 141840 2028 ? Ssl 14:26 0:00 ./src/redis-server *:6379 root 11338 0.0 0.0 112708 980 pts/1 S+ 14:27 0:00 grep --color=auto redis [root@localhost redis-4.0.14]# kill -9 11321

三、配置開機(jī)啟動(dòng)

1、相關(guān)配置

[root@localhost init.d]# cd /etc [root@localhost etc]# mkdir redis [root@localhost etc]# cp /usr/local/mysoft/redis-4.0.14/redis.conf /etc/redis/6379.conf [root@localhost etc]# cd redis/ [root@localhost redis]# ll total 60 -rw-r--r--. 1 root root 58767 May 5 14:36 redis-6379.conf [root@localhost redis]# cp /usr/local/mysoft/redis-4.0.14/utils/redis_init_script /etc/init.d/redisd [root@localhost redis]# chkconfig redisd on # 開機(jī)啟動(dòng)命令

2、服務(wù)啟動(dòng)關(guān)閉

[root@localhost redis]# service redisd start Starting Redis server... 3163:C 05 May 14:59:13.872 # Redis is starting 3163:C 05 May 14:59:13.872 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=3163, just started 3163:C 05 May 14:59:13.872 # Configuration loaded [root@localhost redis]# service redisd stop Stopping ... Waiting for Redis to shutdown ... Redis stopped

3、重啟虛擬機(jī)查看Redis狀態(tài)

[root@localhost ~]# ps -aux |grep redis root 987 0.1 0.1 141836 2012 ? Ssl 15:02 0:00 /usr/local/bin/redis-server *:6379 root 2966 0.0 0.0 112712 980 pts/1 S+ 15:04 0:00 grep --color=auto redis

四、解決客戶端連接問題

關(guān)閉防火墻,或者開放6379端口

firewalld的基本使用 啟動(dòng): systemctl start firewalld 關(guān)閉: systemctl stop firewalld 查看狀態(tài): systemctl status firewalld 開機(jī)禁用 : systemctl disable firewalld 開機(jī)啟用 : systemctl enable firewalld

修改redis.conf 配置

注釋掉:# bind 127.0.0.1 修改保護(hù)模式:protected-mode no

五、sentinel哨兵模式

1、基礎(chǔ)配置

192.168.72.129 主服務(wù) 192.168.72.130 從服務(wù) 192.168.72.131 從服務(wù)

2、配置主服務(wù) redis.conf

requirepass 123456 masterauth 123456

3、配置從服務(wù) redis.conf

requirepass 123456 slaveof 192.168.72.129 6379 masterauth 123456

4、配置sentinel.conf

protected-mode no # sentinel monitor代表監(jiān)控 # mymaster代表服務(wù)器的名稱,可以自定義, # 192.168.72.129代表監(jiān)控的主服務(wù)器,6379代表端口, # 2 標(biāo)識 >=2 哨兵認(rèn)為主服務(wù)器不可用,執(zhí)行failover操作。 sentinel monitor mymaster 192.168.72.129 6379 2 sentinel auth-pass mymaster 123456

5、啟動(dòng)服務(wù)

先主服務(wù),后從服務(wù)

[root@localhost src]# ./redis-server ../redis.conf [root@localhost src]# ./redis-sentinel ../sentinel.conf

沒錯(cuò),就是這樣搭建完畢了!

新人創(chuàng)作打卡挑戰(zhàn)賽發(fā)博客就能抽獎(jiǎng)!定制產(chǎn)品紅包拿不停!

總結(jié)

以上是生活随笔為你收集整理的Linux系统:Centos7搭建Redis单台和集群环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。