- 安装docker源
1.sudo yum install -y yum-utils
2.sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- 安装docker
sudo yum install -y docker-ce-19.03.15 docker-ce-cli-19.03.15 containerd.io-1.4.3
- 配置docker开机自启
sudo systemctl enable docker --now
- 配置docker从阿里云下载镜像
去自己的阿里云阿里云的容器镜像服务
直接复制就行
- docker就安装成功
- 安装Docker-Compose
1.curl -L “https://github.com/docker/compose/releases/download/1.29.2/docker-compose- ( u n a m e − s ) − (uname -s)- (uname−s)−(uname -m)” -o /usr/local/bin/docker-compose
2.chmod +x /usr/local/bin/docker-compose
3.docker-compose --version
- 开始使用docker-compose批量安装设置中间件
命令docker-compose -f my-compose.yaml up -d
文件名是my-compose.yaml
services:
mysql-master:
image: mysql:5.7
restart: always
ports:
- 3306:3306
volumes:
- mysql-master-log:/var/log/mysql
- mysql-master-data:/var/lib/mysql
- mysql-master-conf:/etc/mysql/conf.d
environment:
- MYSQL_ROOT_PASSWORD=123456
networks:
- mall
mongodb:
image: mongo:6.0
ports:
- 27017:27017
restart: always
volumes:
- mongodb-data:/data/db
- mongodb-logs:/var/log/mongodb
- mongodb-conf:/etc/mongo
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: 123456
networks:
- mall
redis:
image: redis:6.2.5
restart: always
ports:
- 6379:6379
volumes:
- redis-conf:/etc/redis
- redis-data:/data
networks:
- mall
command: redis-server /etc/redis/redis.conf
elasticsearch:
image: elasticsearch:7.13.4
restart: always
ports:
- 9200:9200
- 9300:9300
networks:
- mall
environment:
- discovery.type=single-node
- "ES_JAVA_OPTS=-Xms256m -Xmx256m"
- bootstrap.memory_lock=true
volumes:
- es-config:/usr/share/elasticsearch/config
- es-data:/usr/share/elasticsearch/data
- es-plugins:/usr/share/elasticsearch/plugins
ulimits:
memlock:
soft: -1
hard: -1
nofile:
soft: 65535
hard: 65535
kibana:
image: kibana:7.13.4
restart: always
ports:
- 5601:5601
networks:
- mall
environment:
- ELASTICSEARCH_HOSTS=http://elasticsearch:9200
depends_on:
- elasticsearch
filebeats:
image: elastic/filebeat:7.13.4
restart: always
networks:
- mall
volumes:
- filebeat-conf:/usr/share/filebeat
- /var/log:/var/filebeat-log
rabbitmq:
image: rabbitmq:3.8-management
restart: always
hostname: mall-rabbit
ports:
- 5672:5672
- 15672:15672
networks:
- mall
environment:
- RABBITMQ_DEFAULT_PASS=admin
- RABBITMQ_DEFAULT_USER=admin
volumes:
- rabbit-conf:/etc/rabbitmq
- rabbit-data:/var/lib/rabbitmq
zipkin:
image: openzipkin/zipkin:2
restart: always
ports:
- 9411:9411
networks:
- mall
sentinel:
image: leifengyang/sentinel:1.8.2
restart: always
ports:
- 8858:8080
networks:
- mall
nacos: #nacos把所有数据都保存到mysql
image: nacos/nacos-server:2.0.2
restart: always
ports:
- 8848:8848
networks:
- mall
environment:
- MODE=standalone
- SPRING_DATASOURCE_PLATFORM=mysql
- MYSQL_SERVICE_HOST=mysql-master
- MYSQL_SERVICE_PORT=3306
- MYSQL_SERVICE_DB_NAME=nacos_db
- MYSQL_SERVICE_USER=root
- MYSQL_SERVICE_PASSWORD=123456
- JVM_XMX=256m
- JVM_XMS=256m
depends_on:
- mysql-master
minio:
image: minio/minio
command: server --console-address ":9001" /data
restart: always
networks:
- mall
ports:
- 9000:9000
- 9001:9001
volumes:
- minio-conf:/root/.minio
- minio-data:/data
- /etc/localtime:/etc/localtime:ro
environment:
- MINIO_ACCESS_KEY=admin
- MINIO_SECRET_KEY=admin123456
nginx:
image: nginx
restart: always
networks:
- mall
ports:
- 80:80
volumes:
- nginx-html:/usr/share/nginx/html
- nginx-conf:/etc/nginx
volumes:
mysql-master-log:
mysql-master-data:
mysql-master-conf:
mongodb-data:
mongodb-logs:
mongodb-conf:
redis-conf:
redis-data:
es-config:
es-data:
filebeat-conf:
rabbit-conf:
rabbit-data:
minio-conf:
minio-data:
nginx-html:
nginx-conf:
networks:
mall:
ipam:
driver: default
config:
- subnet: "177.10.0.0/16"
等待安装完成之后
查看docker容器列表 和镜像列表即可