请用docker-compose写一个skywalking集群
时间: 2023-07-18 20:48:00 浏览: 137
好的,以下是一个简单的docker-compose文件,以启动一个Skywalking集群:
```
version: '3'
services:
skywalking-oap:
image: apache/skywalking-oap-server:8.6.0-es6
container_name: skywalking-oap
environment:
- SW_CLUSTER=standalone
- SW_STORAGE_TYPE=elasticsearch7
- SW_ES_CLUSTER_NODES=elasticsearch1:9200,elasticsearch2:9200,elasticsearch3:9200
ports:
- 12800:12800
depends_on:
- elasticsearch1
- elasticsearch2
- elasticsearch3
networks:
- skywalking
elasticsearch1:
image: elasticsearch:7.12.0
container_name: elasticsearch1
environment:
- cluster.name=skywalking
- node.name=elasticsearch1
- discovery.seed_hosts=elasticsearch2,elasticsearch3
- cluster.initial_master_nodes=elasticsearch1,elasticsearch2,elasticsearch3
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata1:/usr/share/elasticsearch/data
ports:
- 9200:9200
networks:
- skywalking
elasticsearch2:
image: elasticsearch:7.12.0
container_name: elasticsearch2
environment:
- cluster.name=skywalking
- node.name=elasticsearch2
- discovery.seed_hosts=elasticsearch1,elasticsearch3
- cluster.initial_master_nodes=elasticsearch1,elasticsearch2,elasticsearch3
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata2:/usr/share/elasticsearch/data
networks:
- skywalking
elasticsearch3:
image: elasticsearch:7.12.0
container_name: elasticsearch3
environment:
- cluster.name=skywalking
- node.name=elasticsearch3
- discovery.seed_hosts=elasticsearch1,elasticsearch2
- cluster.initial_master_nodes=elasticsearch1,elasticsearch2,elasticsearch3
- ES_JAVA_OPTS=-Xms512m -Xmx512m
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- esdata3:/usr/share/elasticsearch/data
networks:
- skywalking
volumes:
esdata1:
esdata2:
esdata3:
networks:
skywalking:
```
在这个docker-compose文件中,我们定义了四个服务:`skywalking-oap`、`elasticsearch1`、`elasticsearch2`和`elasticsearch3`。
其中,`skywalking-oap`是Skywalking的OAP服务器,它使用了Skywalking的官方Docker镜像,并且设置了环境变量来连接到Elasticsearch集群。我们将它映射到了主机的12800端口,以便我们可以访问Skywalking的Web界面。
`elasticsearch1`、`elasticsearch2`和`elasticsearch3`是三个Elasticsearch节点,它们使用了官方的Elasticsearch镜像,并且设置了一些环境变量来启用集群功能。我们将它们映射到了主机的9200端口,以便我们可以在浏览器中查看Elasticsearch的状态。
这个docker-compose文件还定义了一个`skywalking`网络,用于连接所有的服务。
最后,我们使用`docker-compose up`命令来启动整个集群。
阅读全文