1. docker 启动mysql
docker run -p 3306:3306 --name 12mysql
-v /mydata/mysql/log:/var/log/mysql
-v /mydata/mysql/data:/var/lib/mysql
-v /mydata/mysql/conf:/etc/mysql/conf.d
-e MYSQL_ROOT_PASSWORD=123456
-d mysql:5.7
创建配置文件:
vi /mydata/mysql/conf/my.cnf
内容如下:
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysqld]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
重启mysql
docker restart mysql
2. 启动redis
如果直接挂载的话docker会以为挂载的是一个目录,所以我们先创建一个文件然后再挂载,在虚拟机中。
mkdir -p /mydata/redis/conf
touch /mydata/redis/conf/redis.conf
先配置一个简单的持久化
vim redis.conf
appendonly yes
docker run -p 63790:6379 --name 12redis
-v /12test/redis/data:/data
-v /12test/redis/conf/redis.conf:/etc/redis/redis.conf
-d redis redis-server /etc/redis/redis.conf
redis-server /etc/redis/redis.conf是启动命令,让redis用后面这个配置文件启动
直接进去redis客户端。
docker exec -it redis redis-cli
设置redis容器在docker启动的时候启动
docker update redis --restart=always
3. ES
docker pull elasticsearch:7.4.2
docker pull kibana:7.4.2
将docker里的目录挂载到linux的/mydata目录中
修改/mydata就可以改掉docker里的
mkdir -p /mydata/elasticsearch/config
mkdir -p /mydata/elasticsearch/data
es可以被远程任何机器访问
echo "http.host: 0.0.0.0" >/mydata/elasticsearch/config/elasticsearch.yml
递归更改权限,es需要访问
chmod -R 777 /mydata/elasticsearch/
启动
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 \
-e "discovery.type=single-node" \
-e ES_JAVA_OPTS="-Xms64m -Xmx512m" \
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml \
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data \
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins \
-d elasticsearch:7.4.2
- 9200是用户交互端口 9300是集群心跳端口
- -e指定是单阶段运行
- -e指定占用的内存大小,生产时可以设置32G
设置开机启动elasticsearch
docker update elasticsearch --restart=always
启动Kibabna
# kibana指定了了ES交互端口9200 # 5600位kibana主页端口
docker run --name kibana -e ELASTICSEARCH_HOSTS=http://192.168.2.10:9200 -p 5601:5601 -d kibana:7.4.2
# 设置开机启动kibana
docker update kibana --restart=always
4. RabbitMQ
docker run -d --name rabbitmq -p 5671:5671 -p 5672:5672 -p 4369:4369 -p 25672:25672 -p 15671:15671 -p 15672:15672 rabbitmq:management
http://192.168.2.13:15672/#/users
docker run --name elasticsearch -p 9100:9100 -p 9000:9000
-e "discovery.type=single-node"
-e ES_JAVA_OPTS="-Xms64m -Xmx512m"
-v /mydata/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
-v /mydata/elasticsearch/data:/usr/share/elasticsearch/data
-v /mydata/elasticsearch/plugins:/usr/share/elasticsearch/plugins
-d elasticsearch:7.4.2