安装docker-compose环境
安装docker-compose环境
# 1,启动容器。
- 运行如下命令
#安装git
sudo yum install -y git
#安装maven
sudo yum install -y maven
#安装依赖
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
#设置源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum makecache fast
#安装docker
sudo yum install -y docker-ce
#启动服务
sudo systemctl start docker
#安装docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.6.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
#授权
sudo chmod +x /usr/local/bin/docker-compose
#检测版本号
docker-compose -v
#启动命令(docker-compose文件是需要自己编写的docker容器运行文件)示例见附件
docker-compose up -d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 2、docker-compose案例
version: '3'
services:
mysql:
image: mysql:8.0.28
restart: always
container_name: mysql
volumes:
- ../volumes/data/mysqldata:/var/lib/mysql
- ./config/my.cnf:/etc/mysql/conf.d/my.cnf
# 数据库还原目录 可将需要还原的sql文件放在这里
- ./init/mysql:/docker-entrypoint-initdb.d
environment:
- "MYSQL_ROOT_PASSWORD=lilishop"
- "MYSQL_DATABASE=lilishop"
- "TZ=Asia/Shanghai"
ports:
- 3306:3306
redis:
image: redis:6.2.5
restart: always
container_name: 'redis'
ports:
- 6379:6379
volumes:
- ../volumes/data/redsidata:/data
command: redis-server --port 6379 --requirepass lilishop --appendonly yes
elasticsearch:
image: elasticsearch:7.3.0
restart: always
container_name: elasticsearch
volumes:
# 映射本地目录权限一定要设置为 777 权限,否则启动不成功
# - ../volumes/data/es7/logs:/usr/share/elasticsearch/logs:rw
# - ../volumes/data/es7/data:/usr/share/elasticsearch/data:rw
- /mydate/elasticsearch/ik:/usr/share/elasticsearch/plugins/ik
# - "./elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml"
ports:
- "9200:9200"
- "9300:9300"
environment:
cluster.name: elasticsearch
discovery.type: single-node
ES_JAVA_OPTS: -Xms256m -Xmx256m
logging:
driver: "json-file"
options:
max-size: "50m"
networks:
- stack
ulimits:
nofile:
soft: 65535
hard: 65535
kibana:
image: docker.elastic.co/kibana/kibana:7.3.0
restart: always
container_name: kibana
ports:
- 5601:5601
# volumes:
# - "./config/kibana.yml:/usr/share/kibana/config/kibana.yml"
networks:
- stack
depends_on: ['elasticsearch']
logstash:
image: logstash:7.3.0
restart: always
container_name: logstash
volumes:
- /mydate/logstash/logstash-springboot.conf:/usr/share/logstash/pipeline/logstash.conf #挂载logstash的配置文件
networks:
- stack
depends_on: ['elasticsearch']
ports:
- 4560:4560
# rocket mq name server
rmqnamesrv:
image: foxiswho/rocketmq:server-4.7.0
restart: always
container_name: rocket-server
environment:
JAVA_OPT_EXT: "-server -Xms64m -Xmx64m -Xmn64m"
volumes:
- ../volumes/data/rocket/server/logs:/opt/logs
- ../volumes/data/rocket/server/store:/opt/rmqstore
networks:
- rocketmq
ports:
- 9876:9876
# rocket mq broker
rmqbroker:
image: foxiswho/rocketmq:broker-4.7.0
restart: always
container_name: rocket-broker
volumes:
- ../volumes/data/rocket/broker/logs:/opt/logs
- ../volumes/data/rocket/broker/store:/opt/rmqstore
- ./config/broker.conf:/etc/rocketmq/broker.conf
environment:
- NAMESRV_ADDR=rmqnamesrv:9876
- JAVA_OPTS:=-Duser.home=/opt
- JAVA_OPT_EXT=-server -Xms64m -Xmx64m -Xmn64m
command: mqbroker -c /etc/rocketmq/broker.conf
depends_on:
- rmqnamesrv
networks:
- rocketmq
ports:
- 10909:10909
- 10911:10911
# rocket console 这个可以不需要
rmqconsole:
image: styletang/rocketmq-console-ng:latest
restart: always
container_name: rocket-console
environment:
- JAVA_OPTS=-Drocketmq.config.namesrvAddr=rmqnamesrv:9876 -Dserver.port=8180 -Drocketmq.config.isVIPChannel=false
- JAVA_OPT_EXT=-Xms128m -Xmx128m -Xmn128m
depends_on:
- rmqnamesrv
networks:
- rocketmq
ports:
- 8180:8180
# xxl-job 分布式调度中心
xxl-job:
image: xuxueli/xxl-job-admin:2.3.0
restart: always
container_name: xxl-job
network_mode: host
environment:
- PARAMS=--spring.datasource.url=jdbc:mysql://127.0.0.1:3306/lilishop?Unicode=true&characterEncoding=UTF-8 --spring.datasource.username=root --spring.datasource.password=lilishop --server.port=9001
depends_on:
- mysql
volumes:
- ../volumes/data/xxl-job:/data/applogs
ports:
- 9001:9001
networks:
rocketmq:
driver: bridge
stack:
driver: bridge
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
上次更新: 2024/01/18, 15:19:41