基本环境搭建

linux搭建部分环境,并挂载数据目录

redis

docker run -itd -v /mnt/hgfs/redis/conf/redis.conf:/etc/redis.conf -v /mnt/hgfs/redis/data:/data --restart always  --privileged=true --name redis -p 6379:6379 redis --requirepass "cloud_2020"

rabbitmq

docker run -idt --name rabbitmq --restart always --privileged=true -e RABBITMQ_DEFAULT_USER=root -e RABBITMQ_DEFAULT_PASS=cloud_2020 -p 5672:5672 -p 15672:15672 -v /mnt/hgfs/rabbitmq/data/mnesia:/var/lib/rabbitmq/mnesia rabbitmq


## 开启web控制台
rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins list

mongo

docker stop mongo
docker rm mongo

rm -rf /root/docker-data

mkdir /root/docker-data
mkdir /root/docker-data/mongo
mkdir /root/docker-data/mongo/data

# docker run -idt --name mongo --privileged=true -p 27017:27017 -v /root/docker-data/mongo/data:/data/db mongo --auth
docker run -idt --name mongo --privileged=true -p 27017:27017 -v /mnt/hgfs/mongo/data:/data mongo --auth


# 进入容器
# docker exec -it mongo mongo admin

# 添加 超级用户 root root202020
# db.createUser({ user: "root" , pwd: "cloud_2020", roles: ["root"]})

# 添加只拥有某库的用户
# db.createUser({ user:'admin',pwd:'cloud_2020',roles:[ { role:'userAdminAnyDatabase', db: 'admin'}]});

mysql

docker stop mysql
docker rm mysql

rm -rf /mnt/hgfs/mysql/mysql_conf
rm -rf /mnt/hgfs/mysql/mysql_data

mkdir /mnt/hgfs/mysql/mysql_conf
mkdir /mnt/hgfs/mysql/mysql_conf/conf.d
mkdir /mnt/hgfs/mysql/mysql_data


cat>/mnt/hgfs/mysql/mysql_conf/my.cnf<<EOF
user=mysql
character-set-server=utf8
default_authentication_plugin=mysql_native_password
secure_file_priv=/var/lib/mysql
expire_logs_days=7
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION
max_connections=1000

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8
EOF



docker run  --restart always --privileged=true -p 3306:3306 -e MYSQL_ROOT_PASSWORD=cloud_2020 --name mysql  \
-v /mnt/hgfs/mysql/mysql_conf/my.cnf:/etc/my.cnf  \
-v /mnt/hgfs/mysql/mysql_conf/conf.d:/etc/mysql/conf.d  \
-v /mnt/hgfs/mysql/mysql_data:/var/lib/mysql  \
-d mysql

emqx

需要配置初始配置文件在etc中!!
https://www.emqx.io/downloads/broker/v4.1.1/

docker stop emqx
docker rm emqx

mkdir /mnt/hgfs/emqx
mkdir /mnt/hgfs/emqx/data
mkdir /mnt/hgfs/emqx/data/mnesia
mkdir /mnt/hgfs/emqx/data/configs
mkdir /mnt/hgfs/emqx/data/scripts
mkdir /mnt/hgfs/emqx/etc
mkdir /mnt/hgfs/emqx/log
mkdir /mnt/hgfs/emqx/lib



docker run -idt --name emqx --privileged=true \
-v /mnt/hgfs/emqx/data/mnesia:/opt/emqx/data/mnesia \
-v /mnt/hgfs/emqx/data/configs:/opt/emqx/data/configs \
-v /mnt/hgfs/emqx/data/scripts:/opt/emqx/data/scripts \
-v /mnt/hgfs/emqx/etc:/opt/emqx/etc \
-v /mnt/hgfs/emqx/log:/opt/emqx/log \
-v /mnt/hgfs/emqx/lib:/opt/emqx/lib \
 -p 1883:1883 -p 8083:8083 -p 8883:8883 -p 8084:8084 -p 18083:18083 emqx


# docker exec -it emqx sh