三、redis安装配置
3.1、创建目录
主机:172.30.3.231
代码语言:javascript复制mkdir -p /work/redis-cluster/redis-node1/{bin,data,conf,logs}
mkdir -p /work/redis-cluster/redis-node2/{bin,data,conf,logs}
主机:172.30.3.234
代码语言:javascript复制mkdir -p /work/redis-cluster/redis-node3/{bin,data,conf,logs}
mkdir -p /work/redis-cluster/redis-node4/{bin,data,conf,logs}
主机:172.30.3.238
代码语言:javascript复制mkdir -p /work/redis-cluster/redis-node5/{bin,data,conf,logs}
mkdir -p /work/redis-cluster/redis-node6/{bin,data,conf,logs}
3.2、编辑启动脚本
主机:172.30.3.231
代码语言:javascript复制vim /work/redis-cluster/redis-node1/bin/start.sh
内容
代码语言:javascript复制docker run -d --hostname redis-node1
--network=host
-v /work/redis-cluster/redis-node1/data:/data
-v /work/redis-cluster/redis-node1/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /work/redis-cluster/redis-node1/logs:/var/log/redis
--log-opt max-size=10m
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone
--name redis-node1 redis:5.0.8 redis-server /usr/local/etc/redis/redis.conf
代码语言:javascript复制chmod 755 /work/redis-cluster/redis-node1/bin/start.sh
代码语言:javascript复制vim /work/redis-cluster/redis-node2/bin/start.sh
内容
代码语言:javascript复制docker run -d --hostname redis-node2
--network=host
-v /work/redis-cluster/redis-node1/data:/data
-v /work/redis-cluster/redis-node2/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /work/redis-cluster/redis-node2/logs:/var/log/redis
--log-opt max-size=10m
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone
--name redis-node2 redis:5.0.8 redis-server /usr/local/etc/redis/redis.conf
代码语言:javascript复制chmod 755 /work/redis-cluster/redis-node2/bin/start.sh
主机:172.30.3.234
代码语言:javascript复制vim /work/redis-cluster/redis-node3/bin/start.sh
内容
代码语言:javascript复制docker run -d --hostname redis-node3
--network=host
-v /work/redis-cluster/redis-node3/data:/data
-v /work/redis-cluster/redis-node3/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /work/redis-cluster/redis-node3/logs:/var/log/redis
--log-opt max-size=10m
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone
--name redis-node3 redis:5.0.8 redis-server /usr/local/etc/redis/redis.conf
代码语言:javascript复制chmod 755 /work/redis-cluster/redis-node3/bin/start.sh
代码语言:javascript复制vim /work/redis-cluster/redis-node4/bin/start.sh
内容
代码语言:javascript复制docker run -d --hostname redis-node4
--network=host
-v /work/redis-cluster/redis-node4/data:/data
-v /work/redis-cluster/redis-node4/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /work/redis-cluster/redis-node4/logs:/var/log/redis
--log-opt max-size=10m
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone
--name redis-node4 redis:5.0.8 redis-server /usr/local/etc/redis/redis.conf
代码语言:javascript复制chmod 755 /work/redis-cluster/redis-node4/bin/start.sh
主机:172.30.3.238
代码语言:javascript复制vim /work/redis-cluster/redis-node5/bin/start.sh
内容
代码语言:javascript复制docker run -d --hostname redis-node5
--network=host
-v /work/redis-cluster/redis-node5/data:/data
-v /work/redis-cluster/redis-node5/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /work/redis-cluster/redis-node5/logs:/var/log/redis
--log-opt max-size=10m
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone
--name redis-node5 redis:5.0.8 redis-server /usr/local/etc/redis/redis.conf
代码语言:javascript复制chmod 755 /work/redis-cluster/redis-node5/bin/start.sh
代码语言:javascript复制vim /work/redis-cluster/redis-node6/bin/start.sh
内容
代码语言:javascript复制docker run -d --hostname redis-node6
--network=host
-v /work/redis-cluster/redis-node6/data:/data
-v /work/redis-cluster/redis-node6/conf/redis.conf:/usr/local/etc/redis/redis.conf
-v /work/redis-cluster/redis-node6/logs:/var/log/redis
--log-opt max-size=10m
-v /etc/localtime:/etc/localtime:ro
-v /etc/timezone:/etc/timezone
--name redis-node6 redis:5.0.8 redis-server /usr/local/etc/redis/redis.conf
代码语言:javascript复制chmod 755 /work/redis-cluster/redis-node6/bin/start.sh
3.3、编辑配置文件
下载配置文件,将配置文件放在/work/redis-cluster/redis-node{1-6}/conf目录
代码语言:javascript复制下载地址: https://raw.githubusercontent.com/antirez/redis/5.0/redis.conf
主机:172.30.3.231
代码语言:javascript复制vim /work/redis-cluster/redis-node1/conf/redis.conf
需要添加或修改的内容,使用你的密码替代password,其余配置项建议参考实际应用设置例如maxmemory,表示最大使用的内存
代码语言:javascript复制bind 0.0.0.0
port 30001
tcp-backlog 2048
logfile "/var/log/redis/redis-server.log"
masterauth password
requirepass password
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
cluster-enabled yes
cluster-config-file nodes-30001.conf
cluster-node-timeout 15000
代码语言:javascript复制vim /work/redis-cluster/redis-node2/conf/redis.conf
需要添加或修改的内容,使用你的密码替代password,其余配置项建议参考实际应用设置例如maxmemory,表示最大使用的内存
代码语言:javascript复制bind 0.0.0.0
port 30002
tcp-backlog 2048
logfile "/var/log/redis/redis-server.log"
masterauth password
requirepass password
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
cluster-enabled yes
cluster-config-file nodes-30002.conf
cluster-node-timeout 15000
主机:172.30.3.234
代码语言:javascript复制vim /work/redis-cluster/redis-node3/conf/redis.conf
需要添加或修改的内容,使用你的密码替代password,其余配置项建议参考实际应用设置例如maxmemory,表示最大使用的内存
代码语言:javascript复制bind 0.0.0.0
port 30001
tcp-backlog 2048
logfile "/var/log/redis/redis-server.log"
masterauth password
requirepass password
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
cluster-enabled yes
cluster-config-file nodes-30001.conf
cluster-node-timeout 15000
代码语言:javascript复制vim /work/redis-cluster/redis-node4/conf/redis.conf
需要添加或修改的内容,使用你的密码替代password,其余配置项建议参考实际应用设置例如maxmemory,表示最大使用的内存
代码语言:javascript复制bind 0.0.0.0
port 30002
tcp-backlog 2048
logfile "/var/log/redis/redis-server.log"
masterauth password
requirepass password
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
cluster-enabled yes
cluster-config-file nodes-30002.conf
cluster-node-timeout 15000
主机:172.30.3.238
代码语言:javascript复制vim /work/redis-cluster/redis-node5/conf/redis.conf
需要添加或修改的内容,使用你的密码替代password,其余配置项建议参考实际应用设置例如maxmemory,表示最大使用的内存
代码语言:javascript复制bind 0.0.0.0
port 30001
tcp-backlog 2048
logfile "/var/log/redis/redis-server.log"
masterauth password
requirepass password
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
cluster-enabled yes
cluster-config-file nodes-30001.conf
cluster-node-timeout 15000
代码语言:javascript复制vim /work/redis-cluster/redis-node6/conf/redis.conf
需要添加或修改的内容,使用你的密码替代password,其余配置项建议参考实际应用设置例如maxmemory,表示最大使用的内存
代码语言:javascript复制bind 0.0.0.0
port 30002
tcp-backlog 2048
logfile "/var/log/redis/redis-server.log"
masterauth password
requirepass password
maxmemory 1GB
maxmemory-policy allkeys-lru
maxmemory-samples 5
cluster-enabled yes
cluster-config-file nodes-30002.conf
cluster-node-timeout 15000