延续上一篇文章,本文将介绍一些稍微少用一点的环境部署。
1.Cerebro
docker pull lmenezes/cerebro docker run --name cerebro -p 9000:9000 -d lmenezes/cerebro
说明:
Cerebro是对于ElasticSearch的可视化工具之一,可以执行相应的API操作以及统计结点信息等。需要注意的是,首页的连接IP地址不能直接访问localhost和127.0.0.1,需要完整输入公网IP,such as: http://192.168.23.1:9200
2.Zookeeper
docker pull zookeeper docker run --privileged=true -d --name zookeeper --publish 2181:2181 -d zookeeper
–publish与-p一致
3.Elasticsearch-head
docker pull docker.io/mobz/elasticsearch-head:5 docker run -d --name es_admin -p 9100:9100 mobz/elasticsearch-head:5
4.MSSQL
docker pull mcr.microsoft.com/mssql/server docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Aa123456" -p 1433:1433 --name mssql -d mcr.microsoft.com/mssql/server
说明:
ACCEPT_EULA = Y(表示接受最终用户许可协议,否则无法启动)
SA_PASSWORD = <强密码> (密码必须符合复杂密码要求,包含大小写字母以及数字或特殊符号,长度不能少于8个字符,否则无法启动)
同时部署MSSQL至少需要2G运行内存
5.Sentinel
docker pull bladex/sentinel-dashboard docker run -p 8858:8858 --name sentinel -d bladex/sentinel-dashboard
6.Seata
docker pull seataio/seata-server docker run -d --restart always --name seata -p 8091:8091 -v /usr/local/docker/seata:/seata-server -e SEATA_IP=192.168.23.1 -e SEATA_PORT=8091 seataio/seata-server
说明:
–restart:重启模式 always:总是尝试重启
SEATA_IP:指定seata-server启动的IP,该IP用于向注册中心注册时使用
SEATA_PORT:指定seata-server启动的端口
Seata默认使用内网IP注册到注册中心,如果是在服务器上部署则需要指定公网IP
7.Canal
docker pull canal/canal-server docker run --name canal -d -p 11111:11111 -v /usr/local/docker/canal:/home/admin/canal-server canal/canal-server
说明:
关于Canal的配置请参考官方文档
需要注意的是在Window系统上的Docker Desktop无法运行Canal,而在服务器上可以成功运行,本人暂时没有搞懂原因,希望有知道原因的大佬分享一下,同时如果我了解了也会及时更新博客。
在分布式环境的需求下,单机环境已经难以满足,但如果又重新生成镜像实例来进行配置又显得麻烦,这时候我们可以使用docker-compose来进行一键部署,以下列举一下搭建ElasticSearch和Redis的集群的例子。
ElasticSearch集群:
version: '2.0' services: es01: image: elasticsearch:7.12.1 container_name: es01 environment: - node.name=es01 - cluster.name=es-docker-cluster - discovery.seed_hosts=es02,es03 - cluster.initial_master_nodes=es01,es02,es03 - "ES_JAVA_OPTS=-Xms512m -Xmx512m" volumes: - /usr/local/docker/elasticsearch/data01:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - elastic es02: image: elasticsearch:7.12.1 container_name: es02 environment: - node.name=es02 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es03 - cluster.initial_master_nodes=es01,es02,es03 - "ES_JAVA_OPTS=-Xms512m -Xmx512m" volumes: - /usr/local/docker/elasticsearch/data02:/usr/share/elasticsearch/data ports: - 9201:9200 networks: - elastic es03: image: elasticsearch:7.12.1 container_name: es03 environment: - node.name=es03 - cluster.name=es-docker-cluster - discovery.seed_hosts=es01,es02 - cluster.initial_master_nodes=es01,es02,es03 - "ES_JAVA_OPTS=-Xms512m -Xmx512m" volumes: - /usr/local/docker/elasticsearch/data03:/usr/share/elasticsearch/data networks: - elastic ports: - 9202:9200 volumes: data01: driver: local data02: driver: local data03: driver: local networks: elastic: driver: bridge
Redis集群:
version: '2.0' services: redis7001: image: 'redis' container_name: redis7001 command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - ./redis-cluster/7001/conf/redis.conf:/usr/local/etc/redis/redis.conf - ./redis-cluster/7001/data:/data ports: - "7001:7001" - "17001:17001" environment: - TZ=Asia/Shanghai redis7002: image: 'redis' container_name: redis7002 command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - ./redis-cluster/7002/conf/redis.conf:/usr/local/etc/redis/redis.conf - ./redis-cluster/7002/data:/data ports: - "7002:7002" - "17002:17002" environment: - TZ=Asia/Shanghai redis7003: image: 'redis' container_name: redis7003 command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - ./redis-cluster/7003/conf/redis.conf:/usr/local/etc/redis/redis.conf - ./redis-cluster/7003/data:/data ports: - "7003:7003" - "17003:17003" environment: - TZ=Asia/Shanghai redis7004: image: 'redis' container_name: redis7004 command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - ./redis-cluster/7004/conf/redis.conf:/usr/local/etc/redis/redis.conf - ./redis-cluster/7004/data:/data ports: - "7004:7004" - "17004:17004" environment: - TZ=Asia/Shanghai redis7005: image: 'redis' container_name: redis7005 command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - ./redis-cluster/7005/conf/redis.conf:/usr/local/etc/redis/redis.conf - ./redis-cluster/7005/data:/data ports: - "7005:7005" - "17005:17005" environment: - TZ=Asia/Shanghai redis7006: image: 'redis' container_name: redis7006 command: ["redis-server", "/usr/local/etc/redis/redis.conf"] volumes: - ./redis-cluster/7006/conf/redis.conf:/usr/local/etc/redis/redis.conf - ./redis-cluster/7006/data:/data ports: - "7006:7006" - "17006:17006" environment: - TZ=Asia/Shanghai
在docker-compose.yml同级目录下在命令行运行以下命令即可生成对应集群
docker-compose up -d
有时候想要挂载文件却不知道具体文件在哪个路径,亦或者想要修改对应的配置却不想重写整份配置文件,可以在Docker生成默认配置的镜像实例后对文件进行拷贝,然后删除实例,重新生成挂载文件后的实例。
以Seato为例子:
# 生成默认实例 docker run --name seata -p 8091:8091 -d seataio/seata-server # docker cp命令进行拷贝 # docker cp [镜像名]:[实例内部对应的文件路径] [想要拷贝到的本机路径] docker cp seata:/seata-server /usr/local/docker/seata # 停止删除原实例 或者可以直接使用docker rm -f seata命令 docker stop seata docker rm seata # 重新生成挂载文件后的实例 docker run -d --restart always --name seata -p 8091:8091 -v /usr/local/docker/seata:/seata-server -e SEATA_IP=120.77.238.28 -e SEATA_PORT=8091 seataio/seata-server
需要注意的是docker cp命令需要管理员权限
本文接续上篇简单地介绍了如何使用Docker部署几种少用的环境,以及使用docker-compose搭建集群和docker cp拷贝实例文件的方法,更多内容可前往DockerHub了解。
原文链接:https://blog.csdn.net/qq905855661/article/details/123984644