您的位置:首页 > 数据库 > Redis

linux下postgresql 一主多从、redis集群、rabbitmq等环境搭建 (十一) redis 集群安装

chutao7052 2020-02-12 15:59 52 查看 https://blog.csdn.net/chutao70

redis 集群

准备工作

wget -O /xa-rdmp/temp/redis-4.0.11.tar.gz http://download.redis.io/releases/redis-4.0.11.tar.gz

tar xzvf /xa-rdmp/temp/redis-4.0.11.tar.gz -C /xa-rdmp/temp/

cd /xa-rdmp/temp/redis-4.0.11/

make

mkdir /xa-rdmp/program/redis -p

mkdir /xa-rdmp/user/program/redis/7000/conf -p
mkdir /xa-rdmp/user/data/redis/7000/data -p
mkdir /xa-rdmp/user/data/redis/7000/log -p
mkdir /xa-rdmp/user/program/redis/7001/conf -p
mkdir /xa-rdmp/user/data/redis/7001/data -p
mkdir /xa-rdmp/user/data/redis/7001/log -p
mkdir /xa-rdmp/user/program/redis/7002/conf -p
mkdir /xa-rdmp/user/data/redis/7002/data -p
mkdir /xa-rdmp/user/data/redis/7002/log -p
mkdir /xa-rdmp/user/program/redis/7003/conf -p
mkdir /xa-rdmp/user/data/redis/7003/data -p
mkdir /xa-rdmp/user/data/redis/7003/log -p
mkdir /xa-rdmp/user/program/redis/7004/conf -p
mkdir /xa-rdmp/user/data/redis/7004/data -p
mkdir /xa-rdmp/user/data/redis/7004/log -p
mkdir /xa-rdmp/user/program/redis/7005/conf -p
mkdir /xa-rdmp/user/data/redis/7005/data -p
mkdir /xa-rdmp/user/data/redis/7005/log -p

cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-server /xa-rdmp/program/redis
cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-cli /xa-rdmp/program/redis
cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-benchmark /xa-rdmp/program/redis
cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-check-aof /xa-rdmp/program/redis
cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-check-rdb /xa-rdmp/program/redis
cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-sentinel /xa-rdmp/program/redis
cp -i /xa-rdmp/temp/redis-4.0.11/src/redis-trib.rb /xa-rdmp/program/redis

cp /xa-rdmp/temp/redis-4.0.11/redis.conf /xa-rdmp/user/program/redis/7000/conf

修改配置

vi /xa-rdmp/user/program/redis/7000/conf/redis.conf

bind 127.0.0.1

改为

# bind 127.0.0.1
# cluster-enabled yes

改为

cluster-enabled yes
# cluster-config-file nodes-6379.conf

改为

cluster-config-file /xa-rdmp/user/program/redis/7000/conf/nodes.conf
# cluster-node-timeout 15000

改为

cluster-node-timeout 15000
pidfile /var/run/redis_6379.pid

改为

pidfile /xa-rdmp/user/data/redis/7000/redis.pid
#   save ""

save 900 1
save 300 10
save 60 10000

改为

save ""

# save 900 1
# save 300 10
# save 60 10000
dir ./

改为

dir /xa-rdmp/user/data/redis/7000/data/
# maxmemory-policy noeviction

改为

maxmemory-policy allkeys-lru
# maxmemory-samples 5

改为

maxmemory-samples 1
protected-mode yes

改为

protected-mode no
port 6379

改为

port 7000
daemonize no

改为

daemonize yes

:wq 保存退出

复制并修改

cp /xa-rdmp/user/program/redis/7000/conf/redis.conf /xa-rdmp/user/program/redis/7001/conf
cp /xa-rdmp/user/program/redis/7000/conf/redis.conf /xa-rdmp/user/program/redis/7002/conf
cp /xa-rdmp/user/program/redis/7000/conf/redis.conf /xa-rdmp/user/program/redis/7003/conf
cp /xa-rdmp/user/program/redis/7000/conf/redis.conf /xa-rdmp/user/program/redis/7004/conf
cp /xa-rdmp/user/program/redis/7000/conf/redis.conf /xa-rdmp/user/program/redis/7005/conf

分别修改各配置文件中的 7000为对应目录名称的 7001,7002,7003,7004,7005

启动6个redis实例

/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7000/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7001/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7002/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7003/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7004/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7005/conf/redis.conf

安装 ruby

yum -y install ruby-devel rubygems rpm-build

cd /xa-rdmp/temp

curl -O -L https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.7.tar.gz
tar -xzvf ruby-2.2.7.tar.gz
cd ruby-2.2.7

./configure --prefix=/xa-rdmp/program/ruby

make && make install
/xa-rdmp/program/ruby/bin/gem install redis

ln -s /xa-rdmp/program/ruby/bin/ruby /usr/bin/ruby

/xa-rdmp/temp/redis-4.0.11/src/redis-trib.rb create --replicas 1 127.0.0.1:7000 127.0.0.1:7001 127.0.0.1:7002 127.0.0.1:7003 127.0.0.1:7004 127.0.0.1:7005

添加为自启动

vi /etc/rc.local

增加几行

/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7000/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7001/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7002/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7003/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7004/conf/redis.conf
/xa-rdmp/program/redis/redis-server /xa-rdmp/user/program/redis/7005/conf/redis.conf

设置执行权限

chmod 755 /etc/rc.local

转载于:https://my.oschina.net/cmsmis/blog/1823982

  • 点赞
  • 收藏
  • 分享
  • 文章举报
chutao7052 发布了0 篇原创文章 · 获赞 0 · 访问量 62 私信 关注
标签: 
章节导航