Stories

Detail Return Return

redis數據庫筆記第8篇:配置機器2,數據驗證 - Stories Detail


🚀🚀🚀本篇主要內容

配置機器2

  • 在演示中,172.16.179.131為當前ubuntu機器的ip
  • 在172.16.179.131上進⼊Desktop⽬錄,創建conf⽬錄
  • 在conf⽬錄下創建⽂件7003.conf,編輯內容如下
port 7003
bind 172.16.179.131
daemonize yes
pidfile 7003.pid
cluster-enabled yes
cluster-config-file 7003_node.conf
cluster-node-timeout 15000
appendonly yes
  • 在conf⽬錄下創建⽂件7004.conf,編輯內容如下
port 7004
bind 172.16.179.131
daemonize yes
pidfile 7004.pid

# 創建集羣
  
  


[文檔連接](http://doc.redisfans.com/topic/cluster-tutorial.html)

* redis的安裝包中包含了redis-trib.rb,⽤於創建集羣
* 接下來的操作在172.16.179.130機器上進⾏
* 將命令複製,這樣可以在任何⽬錄下調⽤此命令

sudo cp /usr/share/doc/redis-tools/examples/redis-trib.rb /usr/local/bin/




* 安裝ruby環境,因為redis-trib.rb是⽤ruby開發的
> 
sudo apt-get install ruby

* 在提示信息處輸⼊y,然後回⻋繼續安裝<br></br>![](/img/bVdmsbv)

* 運⾏如下命令創建集羣

數據驗證

  • 根據上圖可以看出,當前搭建的主服務器為7000、7001、7003,對應的從服務器是7004、7005、7002
  • 在172.16.179.131機器上連接7002,加參數-c表示連接到集羣

    redis-cli -h 172.16.179.131 -c -p 7002
  • 寫⼊數據

    set name itheima
  • ⾃動跳到了7003服務器,並寫⼊數據成功

  • 在7003可以獲取數據,如果寫入數據又重定向到7000(負載均衡)

user avatar y_luoe_hai_61a734cbf3c94 Avatar databend Avatar woniuseo Avatar lab4ai Avatar chaoshenjinghyperai Avatar esunr Avatar gracetangyi Avatar qinwanzi Avatar daguaisou Avatar laughingzhu Avatar duokeli Avatar fanwenjie Avatar
Favorites 24 users favorite the story!
Favorites

Add a new Comments

Some HTML is okay.