亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

NoSQL之Redis群集配置(實踐篇)

發布時間:2020-08-09 12:25:24 來源:網絡 閱讀:175 作者:SiceLc 欄目:系統運維

實驗環境

用兩臺服務器模擬6臺服務器(添加網卡)

  • IP節點
    • 主服務器
    • 192.168.144.144
    • 192.168.144.159
    • 192.168.144.154
    • 從服務器
    • 192.168.144.141
    • 192.168.144.155
    • 192.168.144.160

在主服務器與從服務器上分別添加兩張網卡

NoSQL之Redis群集配置(實踐篇)

[root@master ruby-2.4.1]# service network restart        //重啟網卡
[root@master ruby-2.4.1]# systemctl stop firewalld.service      //關閉防火墻
[root@master ruby-2.4.1]# setenforce 0
[root@slave utils]# service network restart         //重啟網卡
[root@slave utils]# systemctl stop firewalld.service   //關閉防火墻
[root@slave utils]# setenforce 0

在兩臺服務器上都安裝Redis

[root@localhost utils]# vim /etc/redis/6379.conf 
#bind 127.0.0.1                 //注釋第70行的監聽127地址,已監聽所有地址
protected-mode no               //開啟關閉安全保護
port 6379                       //開啟端口6379
daemonize yes                   //開啟以獨立進程啟動
cluster-enabled yes             //開啟群集功能
cluster-config-file nodes-6379.conf  //群集名稱文件設置
cluster-node-timeout 15000           //群集超時時間設置
appendonly yes                       //開啟aof持久化
[root@localhost utils]# /etc/init.d/redis_6379 restart   //重啟服務
Stopping ...
Redis stopped
Starting Redis server...
[root@localhost utils]# cd /var/lib/redis/6379/
[root@localhost 6379]# ls
appendonly.aof  dump.rdb  nodes-6379.conf        //生成aof、rdb和節點文件

在主服務器上安裝rvm、Ruby控制群集軟件

[root@master 6379]# gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3        //導入key文件
[root@master 6379]# curl -sSL https://get.rvm.io | bash -s stable      //安裝rvm
[root@localhost utils]# source /etc/profile.d/rvm.sh       //執行環境變量
[root@localhost utils]# rvm list known          //列出ruby可以安裝的版本
[root@localhost utils]# rvm install 2.4.1        //安裝2.4.1 版本
[root@localhost utils]# rvm use 2.4.1             //使用rubyruby2.4.1版本
Using /usr/local/rvm/gems/ruby-2.4.1
[root@localhost utils]# ruby -v                   //查看當前版本
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[root@localhost utils]# gem install redis               //再次安裝Redis

在master服務器上創建集群

[root@master ruby-2.4.1]# redis-cli --cluster create 192.168.144.144:6379 192.168.144.159:6379 192.168.144.154:6379 192.168.144.141:6379 192.168.144.155:6379 192.168.144.160:6379 --cluster-replicas 1     //創建群集,每組一主一從
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 192.168.144.155:6379 to 192.168.144.144:6379
Adding replica 192.168.144.160:6379 to 192.168.144.159:6379
Adding replica 192.168.144.141:6379 to 192.168.144.154:6379
M: d2aef8bb466d29891e051edd1c9c35d760c452e8 192.168.144.144:6379
   slots:[0-5460] (5461 slots) master
M: d2aef8bb466d29891e051edd1c9c35d760c452e8 192.168.144.159:6379
   slots:[5461-10922] (5462 slots) master
M: d2aef8bb466d29891e051edd1c9c35d760c452e8 192.168.144.154:6379
   slots:[10923-16383] (5461 slots) master
S: 984482d225d614b2b2b084f5c54bf197202065a0 192.168.144.141:6379
   replicates d2aef8bb466d29891e051edd1c9c35d760c452e8
S: 984482d225d614b2b2b084f5c54bf197202065a0 192.168.144.155:6379
   replicates d2aef8bb466d29891e051edd1c9c35d760c452e8
S: 984482d225d614b2b2b084f5c54bf197202065a0 192.168.144.160:6379
   replicates d2aef8bb466d29891e051edd1c9c35d760c452e8
Can I set the above configuration? (type 'yes' to accept): yes    //輸入yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join

>>> Performing Cluster Check (using node 192.168.144.144:6379)
M: d2aef8bb466d29891e051edd1c9c35d760c452e8 192.168.144.144:6379
   slots:[0-16383] (16384 slots) master
   1 additional replica(s)
S: 984482d225d614b2b2b084f5c54bf197202065a0 192.168.144.155:6379
   slots: (0 slots) slave
   replicates d2aef8bb466d29891e051edd1c9c35d760c452e8
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

驗證群集讀寫原理

root@master opt]# redis-cli -h 192.168.144.144 -p 6379      //主服務器
1192.168.144.144:6379> set name zhangsan        //創建鍵值對
OK 
192.168.144.144:6379> keys *
1) "name"
192.168.144.144:6379> get name
"zhangsan"
192.168.144.144:6379> exit
[root@master opt]# redis-cli -h 192.168.144.155 -p 6379       //從服務器
192.168.144.155:6379> keys *           //查看從上也有
1) "name"
192.168.144.155:6379> get name
"zhangsan"
[root@master opt]# redis-cli -h 192.168.144.144 -p 6379 
192.168.144.144:6379> hset person age 20       //用hash方式建立鍵值對
(integer) 1
192.168.144.144:6379> hset person name lisi
(integer) 1
192.168.144.144:6379> keys *
1) "person"
192.168.144.144:6379> hget person age        //獲取鍵的值
"20"
192.168.144.144:6379> expire person 5       //設置鍵的刪除時間5s
(integer) 1
192.168.144.144:6379> keys *
1) "person"
192.168.144.144:6379> keys *
(empty list or set)
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

侯马市| 万山特区| 尼木县| 深泽县| 双柏县| 铜鼓县| 准格尔旗| 延长县| 开阳县| 阿拉善左旗| 太白县| 佳木斯市| 阿克陶县| 阿荣旗| 成都市| 彩票| 张家口市| 舒城县| 东台市| 尤溪县| 济阳县| 平和县| 汪清县| 博客| 桓仁| 湘潭县| 宝清县| 噶尔县| 濮阳县| 依安县| 太白县| 桓台县| 武安市| 县级市| 新宁县| 龙江县| 井冈山市| 凤翔县| 阜城县| 霞浦县| 武鸣县|