redis单机搭建
mkdir -p /opt/redis/conf
touch /opt/redis/conf/redis.conf
vim /opt/redis/conf/redis.conf
#开启密码验证(可选)
requirepass 123
#允许Redis外部连接,需要注释掉绑定的IP
#bind 127.0.0.1
#关闭保护模式(可选)
protected-mode no
#注释掉daemonize yes,或者配置成daemonize no。因为该配置和docker run中的-d参数冲突,会导致容器一直启动失败
daemonize no
#开启Redis数据持久化(可选)
appendonly yes
dos2unix /opt/redis/conf/redis.conf
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
redis集群搭建-3主3从
编辑运行多个Redis容器脚本文件
vim redis-cluster.sh
-------------------启动8001至8006合计6个redis容器-----------------------------------
for port in $(seq 8001 8006); \
do \
mkdir -p /mydata/redis/node-${port}/conf
touch /mydata/redis/node-${port}/conf/redis.conf
cat << EOF >/mydata/redis/node-${port}/conf/redis.conf
port ${port}
cluster-enabled yes
cluster-config-file nodes.conf
cluster-node-timeout 5000
cluster-announce-ip 192.168.80.28
cluster-announce-port ${port}
cluster-announce-bus-port 1${port}
appendonly yes
EOF
docker run -p ${port}:${port} -p 1${port}:1${port} --name redis-${port} \
-v /mydata/redis/node-${port}/data:/data \
-v /mydata/redis/node-${port}/conf/redis.conf:/etc/redis/redis.conf \
-d redis:5.0.7 redis-server /etc/redis/redis.conf; \
done
-------------------------------------------------------------------------------------
cat redis-cluster.sh
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
进入容器
rabbitmq
拉取镜像
docker pull rabbitmq:management
启动镜像
docker run -d --name rabbitmq \
-p 5671:5671 \
-p 5672:5672 \
-p 4369:4369 \
-p 25672:25672 \
-p 15671:15671 \
-p 15672:15672 \
-v /opt/rabbitmq:/var/lib/rabbitmq rabbitmq:management
--------------------------------------------------------------------
port -- - - - -
## 4369,25672(发现&集群端口)
## 5672,5671(AMQP端口)
## 15672(web管理后台端口)【登录端口】
## 61613,61614(STOMP协议端口)
## 1883,8883(MQTT协议端口)
# 默认账户密码guest
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.