欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

redis5.0以上基于密碼認(rèn)證的集群cluster方式

 更新時間:2023年11月04日 09:59:18   作者:葒脃坧頭  
這篇文章主要介紹了redis5.0以上基于密碼認(rèn)證的集群cluster方式,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教

本篇基于redis密碼認(rèn)證的集群cluster搭建。

以三主三從進(jìn)行測試,redis選用5.0以上的版本。

1、環(huán)境描述

服務(wù)器:centos7.9
redis:5.0.3
服務(wù)端口:6379,6378,6377,6376,6375,6374

2、下載安裝包

wget http://download.redis.io/releases/redis-5.0.3.tar.gz

3、安裝redis

yum install gcc -y
tar xvf redis-5.0.3.tar.gz
cd redis-5.0.3
make && make install

4、修改配置文件

拷貝6份同樣的配置文件
mv redis.conf redis6379.conf
echo 'redis6378.conf redis6377.conf redis6376.conf redis6375.conf redis6374.conf' | xargs -n 1 cp redis6379.conf

redis6379.conf修改:

69 #bind 127.0.0.1                       #注釋掉此行
88 protected-mode no                     #關(guān)閉保護(hù)模式
136 daemonize yes                        #后臺啟動
158 pidfile /var/run/redis_6379.pid      #啟動進(jìn)程文件
171 logfile "6379.log"                   #方便查看日志
253 dbfilename dump6379.rdb              #數(shù)據(jù)文件
507 requirepass foobared                 #密碼認(rèn)證
293 masterauth foobared                  #主從切換時需要認(rèn)證的主庫密碼
以下是集群配置:
699 appendonly yes                       #開啟AOF模式
838 cluster-enabled yes                  #開啟 Redis Cluster
846 cluster-config-file nodes-6379.conf  #集群配置文件,每個容器配置改唯一就行
852 cluster-node-timeout 5000            #集群中的節(jié)點能夠失聯(lián)的最大時間,超過這個時間,該節(jié)點就會被認(rèn)為故障

redis6378.conf修改:

69 #bind 127.0.0.1                       #注釋掉此行
88 protected-mode no                     #關(guān)閉保護(hù)模式
136 daemonize yes                        #后臺啟動
158 pidfile /var/run/redis_6378.pid      #啟動進(jìn)程文件
171 logfile "6378.log"                   #方便查看日志
253 dbfilename dump6378.rdb              #數(shù)據(jù)文件
507 requirepass foobared                 #密碼認(rèn)證
293 masterauth foobared                  #主從切換時需要認(rèn)證的主庫密碼
以下是集群配置:
699 appendonly yes                       #開啟AOF模式
838 cluster-enabled yes                  #開啟 Redis Cluster
846 cluster-config-file nodes-6378.conf  #集群配置文件,每個容器配置改唯一就行
852 cluster-node-timeout 5000            #集群中的節(jié)點能夠失聯(lián)的最大時間,超過這個時間,該節(jié)點就會被認(rèn)為故障

redis6377.conf修改:

69 #bind 127.0.0.1                       #注釋掉此行
88 protected-mode no                     #關(guān)閉保護(hù)模式
136 daemonize yes                        #后臺啟動
158 pidfile /var/run/redis_6377.pid      #啟動進(jìn)程文件
171 logfile "6377.log"                   #方便查看日志
253 dbfilename dump6377.rdb              #數(shù)據(jù)文件
507 requirepass foobared                 #密碼認(rèn)證
293 masterauth foobared                  #主從切換時需要認(rèn)證的主庫密碼
以下是集群配置:
699 appendonly yes                       #開啟AOF模式
838 cluster-enabled yes                  #開啟 Redis Cluster
846 cluster-config-file nodes-6377.conf  #集群配置文件,每個容器配置改唯一就行
852 cluster-node-timeout 5000            #集群中的節(jié)點能夠失聯(lián)的最大時間,超過這個時間,該節(jié)點就會被認(rèn)為故障

redis6376.conf修改:

69 #bind 127.0.0.1                       #注釋掉此行
88 protected-mode no                     #關(guān)閉保護(hù)模式
136 daemonize yes                        #后臺啟動
158 pidfile /var/run/redis_6376.pid      #啟動進(jìn)程文件
171 logfile "6376.log"                   #方便查看日志
253 dbfilename dump6376.rdb              #數(shù)據(jù)文件
507 requirepass foobared                 #密碼認(rèn)證
293 masterauth foobared                  #主從切換時需要認(rèn)證的主庫密碼
以下是集群配置:
699 appendonly yes                       #開啟AOF模式
838 cluster-enabled yes                  #開啟 Redis Cluster
846 cluster-config-file nodes-6376.conf  #集群配置文件,每個容器配置改唯一就行
852 cluster-node-timeout 5000            #集群中的節(jié)點能夠失聯(lián)的最大時間,超過這個時間,該節(jié)點就會被認(rèn)為故障

redis6375.conf修改:

69 #bind 127.0.0.1                       #注釋掉此行
88 protected-mode no                     #關(guān)閉保護(hù)模式
136 daemonize yes                        #后臺啟動
158 pidfile /var/run/redis_6375.pid      #啟動進(jìn)程文件
171 logfile "6375.log"                   #方便查看日志
253 dbfilename dump6375.rdb              #數(shù)據(jù)文件
507 requirepass foobared                 #密碼認(rèn)證
293 masterauth foobared                  #主從切換時需要認(rèn)證的主庫密碼
以下是集群配置:
699 appendonly yes                       #開啟AOF模式
838 cluster-enabled yes                  #開啟 Redis Cluster
846 cluster-config-file nodes-6375.conf  #集群配置文件,每個容器配置改唯一就行
852 cluster-node-timeout 5000            #集群中的節(jié)點能夠失聯(lián)的最大時間,超過這個時間,該節(jié)點就會被認(rèn)為故障

redis6374.conf修改:

69 #bind 127.0.0.1                       #注釋掉此行
88 protected-mode no                     #關(guān)閉保護(hù)模式
136 daemonize yes                        #后臺啟動
158 pidfile /var/run/redis_6374.pid      #啟動進(jìn)程文件
171 logfile "6374.log"                   #方便查看日志
253 dbfilename dump6374.rdb              #數(shù)據(jù)文件
507 requirepass foobared                 #密碼認(rèn)證
293 masterauth foobared                  #主從切換時需要認(rèn)證的主庫密碼
以下是集群配置:
699 appendonly yes                       #開啟AOF模式
838 cluster-enabled yes                  #開啟 Redis Cluster
846 cluster-config-file nodes-6374.conf  #集群配置文件,每個容器配置改唯一就行
852 cluster-node-timeout 5000            #集群中的節(jié)點能夠失聯(lián)的最大時間,超過這個時間,該節(jié)點就會被認(rèn)為故障

說明:每個配置文件pidfile,logfile,dbfilename,cluster-config-file不同,其余配置均相同。

5、啟動服務(wù)

在redis解壓目錄下依次啟動
redis-server redis6379.conf
redis-server redis6378.conf
redis-server redis6377.conf
redis-server redis6376.conf
redis-server redis6375.conf
redis-server redis6374.conf
[root@iZuf612i9bshiuw3zzlfe9Z redis-5.0.3]# ps -aux |grep redis
root     16956  0.0  0.1 153980  2840 ?        Ssl  09:36   0:00 redis-server *:6379 [cluster]
root     16965  0.0  0.1 153980  2844 ?        Ssl  09:36   0:00 redis-server *:6378 [cluster]
root     16972  0.0  0.1 153980  2848 ?        Ssl  09:36   0:00 redis-server *:6377 [cluster]
root     16980  0.0  0.1 153980  2848 ?        Ssl  09:36   0:00 redis-server *:6376 [cluster]
root     16994  0.0  0.1 153980  2848 ?        Ssl  09:36   0:00 redis-server *:6375 [cluster]
root     17003  0.0  0.1 153980  2852 ?        Ssl  09:36   0:00 redis-server *:6374 [cluster]
root     17015  0.0  0.0 112808   964 pts/0    S+   09:36   0:00 grep --color=auto redis

6、創(chuàng)建集群

redis-cli --cluster create  127.0.0.1:6379 127.0.0.1:6378 127.0.0.1:6377 127.0.0.1:6376 127.0.0.1:6375 127.0.0.1:6374 --cluster-replicas 1 -a foobared

集群創(chuàng)建

集群創(chuàng)建

7、數(shù)據(jù)驗證

#登錄
redis-cli -p 端口-a foobared -c

說明:-c的目的是為解決“(error) MOVED 5798”報錯 

[root@iZuf612i9bshiuw3zzlfe9Z redis-5.0.3]# redis-cli -p 6379 -a foobared
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set name mike
(error) MOVED 5798 127.0.0.1:6378
127.0.0.1:6379> exit
[root@iZuf612i9bshiuw3zzlfe9Z redis-5.0.3]# redis-cli -p 6379 -a foobared -c
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
127.0.0.1:6379> set name mike
-> Redirected to slot [5798] located at 127.0.0.1:6378

OK

《數(shù)據(jù)驗證》驗證如下:

集群數(shù)據(jù)驗證

《主從切換驗證》驗證如下:

6374為6378的從,現(xiàn)在停掉6378進(jìn)行測試 

切換之前:

切換之后:

集群主從切換

到此,redis集群基于5.0以上版本密碼認(rèn)證搭建?;赿ocker的redis集群的搭建可參考:基于docker的redis集群搭建

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • redis分布式鎖解決緩存雙寫一致性

    redis分布式鎖解決緩存雙寫一致性

    這篇文章主要為大家介紹了redis分布式鎖解決緩存雙寫一致性示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-05-05
  • Redis性能大幅提升之Batch批量讀寫詳解

    Redis性能大幅提升之Batch批量讀寫詳解

    這篇文章主要給大家介紹了關(guān)于Redis性能大幅提升之Batch批量讀寫的相關(guān)資料,文中介紹的非常詳細(xì),對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來跟著小編一起來學(xué)習(xí)學(xué)習(xí)吧。
    2017-06-06
  • Redis中什么是Big?Key(大key)問題?如何解決Big?Key問題?

    Redis中什么是Big?Key(大key)問題?如何解決Big?Key問題?

    大key并不是指key的值很大,而是key對應(yīng)的value很大,下面這篇文章主要給大家介紹了Redis中什么是Big?Key(大key)問題?如何解決Big?Key問題的相關(guān)資料,需要的朋友可以參考下
    2023-03-03
  • 如何通過redis減庫存的秒殺場景實現(xiàn)

    如何通過redis減庫存的秒殺場景實現(xiàn)

    本文通過解決秒殺系統(tǒng)中的一個場景即數(shù)據(jù)預(yù)加載,即把庫存數(shù)據(jù)事先加載到緩存,然后通過緩存來更新庫存,簡單介紹了如何通過redis減庫存的秒殺場景實現(xiàn),感興趣的可以了解一下
    2022-06-06
  • 解決redis啟動的警告日志問題

    解決redis啟動的警告日志問題

    這篇文章主要介紹了解決redis啟動的警告日志問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-01-01
  • 淺談一下Redis的數(shù)據(jù)結(jié)構(gòu)

    淺談一下Redis的數(shù)據(jù)結(jié)構(gòu)

    這篇文章主要介紹了淺談一下Redis的數(shù)據(jù)結(jié)構(gòu),簡單字符串結(jié)構(gòu)被用于存儲redis的key對象和String類型的value對象,其中的free和len字段可以輕松的使得在該字符串被修改時判斷是否需要擴(kuò)容,需要的朋友可以參考下
    2023-08-08
  • 淺談Redis 緩存的三大問題及其解決方案

    淺談Redis 緩存的三大問題及其解決方案

    Redis 經(jīng)常用于系統(tǒng)中的緩存,這樣可以解決目前 IO 設(shè)備無法滿足互聯(lián)網(wǎng)應(yīng)用海量的讀寫請求的問題。本文主要介紹了淺談Redis 緩存的三大問題及其解決方案,感興趣的可以了解一下
    2021-07-07
  • 通過redis的腳本lua如何實現(xiàn)搶紅包功能

    通過redis的腳本lua如何實現(xiàn)搶紅包功能

    這篇文章主要給大家介紹了關(guān)于通過redis的腳本lua如何實現(xiàn)搶紅包功能的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-05-05
  • Redis事務(wù)機制與Springboot項目中的使用方式

    Redis事務(wù)機制與Springboot項目中的使用方式

    Redis事務(wù)機制允許將多個命令打包在一起,作為一個原子操作來執(zhí)行,開啟事務(wù)使用MULTI命令,執(zhí)行事務(wù)使用EXEC命令,取消事務(wù)使用DISCARD命令,監(jiān)視一個或多個鍵使用WATCH命令,Redis事務(wù)的核心思想是將多個命令放入一個隊列中
    2025-03-03
  • 如何用redis?setNX命令來加鎖

    如何用redis?setNX命令來加鎖

    這篇文章主要介紹了如何用redis?setNX命令來加鎖,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-01-01

最新評論