Redis集群部署


title: Redis集群部署
categories: Linux
tags:
- Redis
- Cluster
timezone: Asia/Shanghai
date: 2019-01-18


1.配置本地YUM并安装开发包和tcl8.6.1依赖(by all)

mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom

cat </etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1
EOF

yum clean all       #清理本地缓存
yum clean plugins   #清理插件缓存
yum makecache       #构建缓存

yum groupinstall -y "Development Tools" 

su - root
tar vxf tcl8.6.1-src.tar.gz
cd /home/monitor/source/tcl8.6.1/unix/
./configure
make
make install

2.分别在4个节点上传redis安装包并安装(by all)

su - root
tar -vxf redis-5.0.0.tar.gz
cd redis-5.0.0
make
make install
make test

3.修改配置文件

在节点1上修改redis.conf配置文件

vim /home/redis-5.0.0/redis.conf
port 20001
bind 0.0.0.0
cluster-enabled yes
cluster-config-file nodes-20001.conf
cluster-node-timeout 5000
appendonly yes
pidfile /var/run/redis_20001.pid

创建运行目录

mkdir -p /home/20001
mkdir -p /home/20002

mkdir -p /home/20003
mkdir -p /home/20004

mkdir -p /home/20005
mkdir -p /home/20006

将配置文件分别copy到每个服务器的相关目录,并修改配置文件

4.首先需要在6个节点启动redis,然后再用下一步命令创建集群()

节点1:(IP为:30)
redis-server /home/monitor/bin/20001/redis.conf &
redis-server /home/monitor/bin/20002/redis.conf &

节点2:(IP为:31)
redis-server /home/monitor/bin/20001/redis.conf &
redis-server /home/monitor/bin/20002/redis.conf &

节点3和4:(IP为:37、38)
redis-server /home/monitor/bin/20001/redis.conf &
redis-server /home/monitor/bin/20001/redis.conf &

5.创建集群并启动

redis-cli --cluster create 10.122.231.30:20001 10.122.231.30:20002 10.122.231.31:20001 10.122.231.31:20002 10.122.231.37:20001 10.122.231.38:20001 --cluster-replicas 1

6.验证

ps aux | grep redis-server
netstat -antp

redis-cli -h 10.122.231.30 -p 20001
cluster nodes
cluster info

附录:

离线包下载:https://pan.baidu.com/s/18X-T8Ef9soVF_aLGjd5eiA

你可能感兴趣的:(Redis集群部署)