Docker 与其 redis rabbitmq 的快速安装与配置
Docker
Docker 安装
下载并安装-自动化
curl -sSL https://get.daocloud.io/docker | sh
配置加速镜像,这里是阿里云的配置,点击获取
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://$(你自己的id).mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Docker 安装 Redis
1、docker 获取 Redis
docker pull redis:5.0.10
2、修改 Redis 默认配置文件
记得将配置文件的 requirepass 改成自己的密码
bind 0.0.0.0
protected-mode yes
requirepass $(your password)
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile ""
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
dir ./
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
aof-rewrite-incremental-fsync yes
3、创建 Redis 挂载目录
mkdir -p /software/redis/data /software/redis/conf
并将配置文件放入到 conf 文件夹中去
4、启动 Redis
docker run -d --name redis -p 6379:6379 -v /software/redis/conf/redis.conf:/redis.conf -v /software/redis/data:/data redis:5.0.10 redis-server /redis.conf --appendonly yes
-d 后台启动
-- name 对这个容器命名
-p 端口映射
-v 挂载目录,前面是本机目录,中间以 :隔开,后面是 docker 的目录
--appendonly yes 启动容器后开启 appendonly 配置
5、修改防火墙
这里是 Centos7
# 查看防火墙开放端口
firewall-cmd --zone=public --list-ports
# 添加端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent
# 重新加载配置文件
firewall-cmd --reload
6、验证 redis
docker exec -it redis /bin/bash
redis-cli
auth $(你的密码)
set key value
远程连接 redis,自行验证吧
Docker 安装 RabbitMQ
1、docker 获取 rabbitmq
docker search rabbitmq
docker pull rabbitmq
2、启动 rabbitmq
docker run -d --hostname rabbitmq --name rabbit -p 15672:15672 -p 5672:5672 rabbitmq
3、安装插件
docker exec -it rabbit /bin/bash
rabbitmq-plugins enable rabbitmq_management
ctrl + p + q 退出
4、验证
curl 127.0.0.1:15672
5、开放防火墙
firewall-cmd --zone=public --add-port=15672/tcp --add-port=5672/tcp --permanent
firewall-cmd --reload
6、windows 验证
服务器 host:15672
user:guest
password:guest
ZGC说:有什么能比不给牛吃草,还挤牛奶更快乐的事情呢?