LoginSignup
3
2

More than 5 years have passed since last update.

Mac OS XでRedis Clusterを立てる

Last updated at Posted at 2017-10-03

開発環境

  • Mac:10.12.6
  • redis:4.0.0
  • ruby:2.0.0p648

1サーバで3台のRedis Clusterを作る(最低3台から、スレーブをやるには6台から)

1.ディレクトリの用意

$ mkdir ~/cluster-test
$ cd ~/cluster-test
$ mkdir 700{0,1,2}

2.最小構成の設定ファイルを用意する

$ cd 7000
$ vim redis.conf
redis.conf
port 7000
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
appendonly yes 

3.各サーバの起動

terminal A
$ cd 7000
$ redis-server ./redis.conf
terminal B
$ cd 7001
$ redis-server ./redis.conf
terminal C
$ cd 7002
$ redis-server ./redis.conf

4.redisのソースを任意のディレクトリにダウンロード
http://download.redis.io からLatest stable versionの圧縮ファイルをダウンロードして任意のディレクトリに展開する

$ cd 
$ tar zvxf redis.tar

5.gemのredisをインストール

$ sudo gem install redis -v 3.3.3 
(ruby2.0.0なのでversion3.3.3にする)

6.クラスタリング

$ cd ~/redis/src/
$ ./redis-trib.rb create 127.0.0.1:7000 127.0.0.1:7001  127.0.0.1:7002
  • Can I set the above configuration? と聞かれるので yes を入力します
  • [OK] All nodes agree about slots configuration. となれば Cluster の構築は完了です

動作確認

$ redis-cli -c -p 7000

Redis Clusterをredis-commanderで扱うにはどうすれば?(他のツールでもいいけど)

参考URL

追記

上記で展開した、redisのソースにRedis Clusterを作るスクリプトがあるので、それを使うと簡単。
utils/create-clusterディレクトリにcreate-clusterというスクリプトがある。
使い方は同ディレクトリのreadmeを参照する。

開始するとき
$ ./create-cluster start
$ ./create-cluster create
停止するとき
$ ./create-cluster stop
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2