redis叢集安裝

來源:互聯網
上載者:User
redis-trib.rb是採用ruby實現的redis叢集管理工具。內部通過cluster相關命令幫我們簡化叢集建立,檢查,槽遷移和均衡等常見的營運操作

1.ruby安裝
下載地址: wget https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.1.tar.gz
./configure -prefix=/usr/local/ruby
make  make install
cd /usr/local/ruby cp /usr/local/ruby/bin/ruby  /usr/local/bin cp /usr/local/ruby/bin/gem  /usr/local/bin

下載: https://rubygems.org/downloads/redis-4.0.1.gem

[root@localhost tools]# gem install -l redis-4.0.1.gem ERROR: Loading command: install (LoadError)  cannot load such file -- zlib ERROR: While executing gem ... (NoMethodError)     undefined method `invoke_with_build_args' for nil:NilClass

解決辦法是:
yum -y install zlib-devel

進入ruby源碼檔案夾 安裝ruby自身提供的zlib包 cd  ruby-2.5.1/ext/zlib ruby  ./extconf.rb 
[root@localhost zlib]# make make: *** No rule to make target `/include/ruby.h', needed by `zlib.o'. Stop.
這個時候開啟ext/zlib/Makefile檔案,找到下面一行把路徑進行修改一下。 #zlib.o: $(top_srcdir)/include/ruby.h zlib.o: ../../include/ruby.h
make make install
2.安裝
[root@localhost tools]# gem install -l redis-4.0.1.gem
gem list --check redis gem
cp /usr/local/redis/src/redis-trib.rb /usr/local/bin/

3. 安裝ruby環境後,執行redis-trib.rb命令確認是否正確
[root@localhost src]# redis-trib.rb Usage: redis-trib <command> <options> <arguments ...>   create host1:port1 ... hostN:portN                   --replicas <arg> ......
可以使用redi-trib.rb create命令可以快速搭建叢集
4.準備節點 配置設定檔,並啟動
port 6000 daemonize yes
logfile "6000.log"
dir "/data/redis/data/"
dbfilename dump-6000.rdb  
cluster-enabled yes                      #開啟叢集模式 cluster-node-timeout 15000               #節點逾時時間,單位毫秒 cluster-config-file "nodes-6000.conf"    #叢集內部設定檔

5.啟動所有節點
redis-server /data/redis/conf/redis-6001.conf
redis-server /data/redis/conf/redis-6002.conf
redis-server /data/redis/conf/redis-6003.conf
redis-server /data/redis/conf/redis-6004.conf
redis-server /data/redis/conf/redis-6005.conf redis-server /data/redis/conf/redis-6006.conf

6.建立叢集 啟動好6個節點後,使用redis-trib.rb create命令完成握手和分配槽的過程
 redis-trib.rb create --replicas 1 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 127.0.0.1:6004 127.0.0.1:6005 127.0.0.1:6006
>>> Creating cluster >>> Performing hash slots allocation on 6 nodes... Using 3 masters: 127.0.0.1:6001 127.0.0.1:6002 127.0.0.1:6003 Adding replica 127.0.0.1:6004 to 127.0.0.1:6001 Adding replica 127.0.0.1:6005 to 127.0.0.1:6002 Adding replica 127.0.0.1:6006 to 127.0.0.1:6003 M: be3270c92ba98c1b67ce4c76569680e1ce873a10 127.0.0.1:6001    slots:0-5460 (5461 slots) master M: 59fe00990b0675fbf9b5693aa875ab94b1a642ce 127.0.0.1:6002
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.