Window環境下的Redis集羣部署

Windows環境部署Redis集羣

 

1、準備文件html

1. 下載Redis for windows 的最新版本node

  下載地址:https://github.com/MSOpenTech/redis/releases git

    安裝到 c:\Redis 目錄下(Redis-x64-3.2.100.msi <Windows服務版>)github

2. 下載 RubyInstallerredis

    下載地址:http://rubyinstaller.org/downloads/數據庫

   安裝時,勾選:(所使用版本rubyinstaller-2.3.1-x64.exe)windows

         Install Td/Tk Supportruby

         Add Ruby executables to your PATH服務器

         Associate .rb and .rbw files with this Ruby installationapp

3. 下載 redis-trib.rb

    下載地址:https://raw.githubusercontent.com/antirez/redis/unstable/src/redis-trib.rb

    複製源碼,新建文本,修改文件名

    複製到 c:\redis 目錄下(redis-trib.rb)

4. 下載redis-3.2.1.gem

    下載地址:https://rubygems.org/

2、部署


1. 在服務器上用HAPER-V新建6臺服務器(虛擬機)

    01:192.168.0.71,02:192.168.0.109,03:192.168.0.148

    04:192.168.0.187,05:192.168.0.240,06:192.168.0.25

    關閉防火牆並確保每臺機子都是互通

  

2. 每臺服務器安裝Redis-x64-3.2.100.msi

3. 替換配置文件

    新建記事本修更名稱和擴展名:redis.windows-service.conf(注意文件編碼要和安裝redis後的配置文件編碼一致)

    編寫其下內容(其中在bind是該機IP地址,文件名可改可不改)

    綠色字體爲開啓集羣功能

        port 999

        bind 192.168.0.111

        cluster-enabled yes

        cluster-config-file nodes-cache01.conf

        cluster-node-timeout 5000

        appendonly yes

        save 900 1

        save 300 10

        save 60 10000

        dbfilename dump.rdb

        maxmemory 3999mb

    替換c:\Redis\ redis.windows-service.conf文件

    重啓Redis服務(任務管理器中)啓動完成會在Redis文件夾下生成appendonly.aof文件和nodes-cache01文件

4. 在第一臺(操做集羣的)安裝如下內容

    rubyinstaller-2.3.1-x64.exe

    複製redis-trib.rb文件到 c:\redis 目錄下(redis-trib.rb是用ruby語言編寫的,因此運行須要在服務器上安裝Ruby程序)

    redis-3.2.1.gem文件複製到C:/Redis中

    命令控制檯,cd/redis 進入C盤的redis文件夾Start-Server 啓動redis實例

    修改gem的源

      命令gem sources 查看當前源的地址

      

      命令 gem sources –r https://rubygems.org/刪除當前源

      

    命令 gem sources –a http://gems.github.com (淘寶源不能用了這裏找了一個新的)

      

      命令gem install redis

      

3、建立集羣

1. 啓動其他Rredis的客戶端(命令 start redis-server)

    

2. 輸入命令建立集羣

    redis-trib.rb create --replicas1 192.168.0.71:999 192.168.0.109:999 192.168.0.148:999 192.168.0.187:999 192.168.0.240:999 192.168.0.25:999

    --replicas 1 表示每一個主數據庫擁有從數據庫個數爲1。以前遇到錯誤提示master節點不能少於3個

    

3. 輸入yes

    

4. 最後測試

    命令 redis-cli –c –h 」地址」 –p "端口號"

    

    此處必須-c

相關文章
相關標籤/搜索