Redis集羣搭建(CentOS7)

1、在每臺服務器分別編譯安裝redis:https://blog.csdn.net/FromTheWind/article/details/88379708
2、修改redis配置文件,這裏修改的配置項和單機版略有不同:
      port 端口
     bind 本機ip  #每臺不同
     daemonize yes
     pidfile pid文件位置
     cluster-enabled yes
     cluster-config-file #集羣節點信息文件位置
     cluster-node-timeout
     logfile 日誌文件位置
     dir ../db/    #appendonly.aof、dump.rdb文件位置
     dbfilename dump.rdb
     appendonly yes
3、將修改好的配置文件分別發送到其他節點,注意修改配置文件bind的ip,然後逐個啓動
4、安裝ruby、zlib、rubygems、oopenssl、redis.gem
   4.1)分別下載ruby、zlib、rubygems、openssl、redis.gem安裝包
       ruby: http://www.ruby-lang.org/en/downloads/ 或 http://cache.ruby-lang.org/pub/ruby/2.3/
       zlib: http://www.zlib.net/fossils/
       rubygems: https://rubygems.org/pages/download/
       openssl: http://distfiles.macports.org/openssl/
       redis.gem: https://rubygems.org/gems/redis
   4.2)安裝(將安裝包拷貝到/opt下使用root安裝,xyz爲具體版本號),嚴格按照一下順序安裝,因爲rubygems需要依賴zlib,gem依賴openssl
     ruby:
       方式一(不刪除系統本身的ruby情況下):
         cd /opt; tar zxf ruby-x.y.z.tar.gz; cd ruby-x.y.z;
         ./configure --prefix=/opt/ruby; make && make install; 
         ln -s /opt/ruby/bin/ruby /usr/bin/ruby; ln -s /opt/ruby/bin/gem /usr/bin/gem
         注意:如果在這裏將/opt/ruby/bin/裏的gem連接到/usr/bin下時不用安裝下面的rubygem-x.y.z.tar.gz
       方式二:
         cd /opt; tar zxf ruby-x.y.z.tar.gz; cd ruby-x.y.z;
     ./configure
     make && make install
     ln -s /usr/local/bin/ruby /usr/bin/ruby
       驗證:ruby -v
     zlib:
     cd /opt; tar zxf zlib-x.y.z.tar.gz; cd zlib-x.y.z; 
     ./configure --prefix=/usr/local/zlib
     make
     make install
     #編譯ruby中的zlib
     cd /opt/ruby-x.y.z/ext/zlib/
     ruby extconf.rb --with-zlib-include=/usr/local/zlib/include/ --with-zlib-lib=/usr/local/zlib/lib
     #把Makefile中所有的的$(top_srcdir)換成../../
     sed -i 's#$(top_srcdir)#../../#g' Makefile
     make && make install
     rubygems: 
         cd /opt; tar zxf rubygems-x.y.z.tar.gz; cd rubygems-x.y.z
     ruby setup.rb
     ln -s /opt/rubygems-x.y.z/bin/gem /usr/bin/gem
     openssl: 
         cd /opt; tar zxf openssl-x.y.z.tar.gz; cd openssl-x.y.z
     ./config -fPIC --prefix=/usr/local/openssl enable-shared
     ./config -t
     make && make install
     #編譯ruby中的openssl
     cd /opt/ruby-x.y.z/ext/openssl/
     ruby extconf.rb --with-openssl-include=/usr/local/openssl/include/ --with-openssl-lib=/usr/local/openssl/lib
     #把Makefile中所有的 $(top_srcdir) 換成 ../..
     sed -i 's#$(top_srcdir)#../..#g' Makefile
     make && make install
     redis.gem: 
         gem install redis-x.y.z.gem
5、創建集羣(如果提示需要輸入yes,輸入即可):
    #--replicas 從節點數,如果是1,將後面一半的ip:port作爲從節點
    cd redis-x.y.z/src/ #解壓編譯後的redis目錄
    ./redis-trib.rb create --replicas 1 ip:port ip:poort ... ip:port

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章