LoginSignup
2
1

More than 5 years have passed since last update.

CentOS6上にredis clusterの環境を構築する

Last updated at Posted at 2015-10-23

環境

・Linuxサーバー2台(192.168.0.1,192.168.0.2)
・使用ポート(:6379,:6380,:6381)
・Master3インスタンス、SLAVE3インスタンス
・CentOS6.7
・redis-3.0.5

redisをダウンロードする

wget http://download.redis.io/releases/redis-3.0.5.tar.gz
tar xzvf redis-3.0.5.tar.gz
cd redis-3.0.5

redisをインストールする

cd /redis-3.0.5/utils/
./install_server.sh
・redisの使用ポートを入力してEnter
Please select the redis port for this instance: [6379]

今回他の項目はEnter連打で進めてます

redis.confを修正する

/etc/6379.conf
/etc/6380.comf
/etc/6381.conf
を下記の様に修正する

cluster-enabled yes
appendonly yes

設定変更後は、各インスタンスを再起動する
/etc/init.d/redis_6379 stop
/etc/init.d/redis_6379 start

※cluster-node-timeoutはデフォルトだと15秒とわりと長いので、
適宜調整する

rubyとかもろもろをインストールする

yum -y install ruby.x86_64
yum -y install rubygems.noarch
gem install redis

クラスタを構築する

cd /redis-3.0.5/src/
./redis-trib.rb create --replicas 1 192.168.0.1:6379 192.168.0.1:6380 192.168.0.1:6381 192.168.0.2:6379 192.168.0.2:6380 192.168.0.2:6381

上記のスクリプトを実行すると、各インスタンスに自動的にMASTER,SLAVEが割り当てられるので、yesを入力してEnterを入力
これで1MASTERにつき1SLAVEが紐付いたクラスタ環境の構築が完了

2
1
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
2
1