部署线上服务器过程
服务器配置(准备)
- 配置与线上时间一致(安装ntdate–每小时同步)
1. 安装ntpdate工具 # sudo yum install ntpdate
2. 设置系统时间与网络时间同步 # ntpdate cn.pool.ntp.org
3. 将系统时间写入硬件时间 # hwclock --systohc
4. vim /etc/crontab结尾添加每小时同步一次
- 目录挂载(已完成)
- docker安装(docker和docker-compose即可)
按照docker部署文档安装
直接安装docker-compose
curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/bin/docker-compose
项目部署
1.映射目录
说明:
1.build:代码的存放目录
2.file目录是映射的nginx的静态文件(详情请看docker-compose.yml配置文件)
3.除file和build外都是映射的配置文件,便于管理重启
2.docker-compose.yml文件
version: "3"
services:
nginx:
container_name: nginx
image: nginx
privileged: true
ports:
- 80:80
- 443:443
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- ${DOCKER_DATA_HOME}docker/nginx/conf:/etc/nginx/conf
- ${DOCKER_DATA_HOME}docker/nginx/logs:/var/log/nginx
- ${DOCKER_DATA_HOME}docker/nginx/html:/home/web
- ${DOCKER_DATA_HOME}docker/nginx/conf/nginx.conf:/etc/nginx/nginx.conf
- ${DOCKER_DATA_HOME}docker/file:/home/file
- ${DOCKER_DATA_HOME}docker/fastdfs/store_path/data:/fastdfs/storage/data
# - /qn/file/cwcd:/mnt/file/cwcd
# - ${DOCKER_DATA_HOME}docker/file:/mnt/file/cwcd
network_mode: "host"
redis:
container_name: redis
image: redis
privileged: true
ports:
- 6379:6379
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- ${DOCKER_DATA_HOME}docker/redis/redis.conf:/etc/redis/redis.conf
# command: redis-server /etc/redis/redis.conf
# depends_on:
# - nginx
network_mode: "host"
mysql:
container_name: mysql
image: mysql:5.7
privileged: true
environment:
- MYSQL_ROOT_PASSWORD=835677
ports:
- 3306:3306
restart: always
volumes:
- /etc/localtime:/etc/localtime:ro
- ${DOCKER_DATA_HOME}docker/mysql/mysqldata:/var/lib/mysql
- ${DOCKER_DATA_HOME}docker/mysql/my.cnf:/etc/mysql/my.cnf
- ${DOCKER_DATA_HOME}docker/mysql/init:/docker-entrypoint-initdb.d/
depends_on:
- nginx
network_mode: "host"
nacos:
container_name: nacos
image: docker.io/nacos/nacos-server
privileged: true
ports:
- 8848:8848
restart: always
environment:
- JVM_XMS=256m
- JVM_MMS=320m
- JVM_XMX=512m
- JVM_XMN=512m
- MODE=standalone
volumes:
- /etc/localtime:/etc/localtime:ro
- ${DOCKER_DATA_HOME}docker/nacos/logs:/home/nacos/logs
- ${DOCKER_DATA_HOME}docker/nacos/data:/home/nacos/data
depends_on:
- nginx
network_mode: "host"
fastdfs-tracker:
hostname: fastdfs-tracker
container_name: fastdfs-tracker
image: season/fastdfs:1.2
command: tracker
volumes:
- ${DOCKER_DATA_HOME}docker/fastdfs/tracker_data:/fastdfs/tracker/data
network_mode: "host"
fastdfs-storage:
hostname: fastdfs-storage
container_name: fastdfs-storage
image: season/fastdfs:1.2
volumes:
- ${DOCKER_DATA_HOME}docker/fastdfs/storage_data:/fastdfs/storage/data
- ${DOCKER_DATA_HOME}docker/fastdfs/store_path:/fastdfs/store_path
environment:
- TRACKER_SERVER=47.103.214.20:22122
command: storage
depends_on:
- fastdfs-tracker
network_mode: "host"
canal-server:
image: canal/canal-server:v1.1.4
container_name: canal-server
ports:
- 11111:11111
environment:
- canal.instance.mysql.slaveId=12
- canal.auto.scan=false
- canal.destinations=example
- canal.instance.master.address=47.103.214.20:3306
- canal.instance.dbUsername=canal
- canal.instance.dbPassword=canal
- canal.mq.topic=example
- canal.instance.filter.regex=.*\\..*
volumes:
- ${DOCKER_DATA_HOME}docker/canal-server/conf/:/admin/canal-server/conf/
- ${DOCKER_DATA_HOME}docker/canal-server/logs/:/admin/canal-server/logs/
# fastdfs-nginx:
# hostname: fastdfs-nginx
# container_name: fastdfs-nginx
# image: season/fastdfs:1.2
# volumes:
# - ${DOCKER_DATA_HOME}docker/fastdfs/nginx.conf:/etc/nginx/conf/nginx.conf
# - ${DOCKER_DATA_HOME}docker/fastdfs/store_path:/fastdfs/store_path
# environment:
# - TRACKER_SERVER=47.103.214.20:22122
# command: fastdfs-nginx
# network_mode: "host"
# cwcd-service-gateway:
# container_name: cwcd-service-gateway
# image: java:8
# privileged: true
# ports:
# - 8310:8310
# depends_on:
# - mysql
# - nginx
# - redis
# - nacos
# restart: always
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - ${DOCKER_DATA_HOME}docker/jar/gateway/logs:/home/logs
# - ${DOCKER_DATA_HOME}docker/jar/gateway/cwcd-service-gateway-1.0-SNAPSHOT.jar:/cwcd-service-gateway.jar
# - ${DOCKER_DATA_HOME}docker/file:/home/file
# command: java -Xms512m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -Dspring.cloud.nacos.discovery.weight=10 -jar cwcd-service-gateway.jar
# network_mode: "host"
# cwcd-service-utils:
# container_name: cwcd-service-utils
# image: java:8
# privileged: true
# ports:
# - 8333:8333
# depends_on:
# - cwcd-service-gateway
# restart: always
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - ${DOCKER_DATA_HOME}docker/jar/utils/logs:/home/logs
# - ${DOCKER_DATA_HOME}docker/jar/utils/cwcd-service-utils-1.0-SNAPSHOT.jar:/cwcd-service-utils.jar
# command: java -Xms512m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -Dspring.cloud.nacos.discovery.weight=10 -jar cwcd-service-utils.jar
# network_mode: "host"
# cwcd-service-edu:
# container_name: cwcd-service-edu
# image: java:8
# privileged: true
# ports:
# - 8010:8010
# restart: always
# depends_on:
# - cwcd-service-gateway
# - cwcd-service-pay
# - cwcd-service-push
# - cwcd-service-utils
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - ${DOCKER_DATA_HOME}docker/jar/edu/logs:/home/logs
# - ${DOCKER_DATA_HOME}docker/jar/edu/cwcd-service-edu-1.0-SNAPSHOT.jar:/cwcd-service-edu.jar
# # - /qn/file/cwcd:/mnt/file/cwcd
# - ${DOCKER_DATA_HOME}docker/file:/mnt/file/cwcd
# command: java -Xms512m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -Dspring.cloud.nacos.discovery.weight=10 -jar cwcd-service-edu.jar
# network_mode: "host"
# cwcd-service-push:
# container_name: cwcd-service-push
# image: java:8
# privileged: true
# ports:
# - 8390:8390
# depends_on:
# - cwcd-service-gateway
# - cwcd-service-utils
# restart: always
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - ${DOCKER_DATA_HOME}docker/jar/push/logs:/home/logs
# - ${DOCKER_DATA_HOME}docker/jar/push/cwcd-service-push-1.0-SNAPSHOT.jar:/cwcd-service-push.jar
# command: java -Xms512m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -Dspring.cloud.nacos.discovery.weight=10 -jar cwcd-service-push.jar
# network_mode: "host"
# cwcd-service-pay:
# container_name: cwcd-service-pay
# image: java:8
# privileged: true
# ports:
# - 8300:8300
# depends_on:
# - cwcd-service-gateway
# - cwcd-service-utils
# restart: always
# volumes:
# - ${DOCKER_DATA_HOME}docker/jar/pay/servicecert/apiclient_cert.p12:/mnt/servicecert/apiclient_cert.p12
# - /etc/localtime:/etc/localtime:ro
# - ${DOCKER_DATA_HOME}docker/jar/pay/logs:/home/logs
# - ${DOCKER_DATA_HOME}docker/jar/pay/cwcd-service-pay-1.0-SNAPSHOT.jar:/cwcd-service-pay.jar
# command: java -Xms512m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -Dspring.cloud.nacos.discovery.weight=10 -jar cwcd-service-pay.jar
# network_mode: "host"
# cwcd-service-task:
# container_name: cwcd-service-task
# image: java:8
# privileged: true
# ports:
# - 8400:8400
# depends_on:
# - cwcd-service-gateway
# - cwcd-service-utils
# - cwcd-service-edu
# restart: always
# volumes:
# - /etc/localtime:/etc/localtime:ro
# - ${DOCKER_DATA_HOME}docker/jar/task/logs:/home/logs
# - ${DOCKER_DATA_HOME}docker/jar/task/cwcd-service-task-1.0-SNAPSHOT.jar:/cwcd-service-task.jar
# command: java -Xms512m -Xmx2048m -XX:PermSize=128M -XX:MaxPermSize=256M -Dspring.cloud.nacos.discovery.weight=10 -jar cwcd-service-task.jar
# network_mode: "host"
# zookeeper:
# image: wurstmeister/zookeeper
# container_name: zookeeper
# volumes:
# - /qn/kafka/data:/data
# ports:
# - 2182:2181
# network_mode: "host"
# kafka:
# image: wurstmeister/kafka
# container_name: kafka
# ports:
# - 9092:9092
# environment:
# KAFKA_BROKER_ID: 0
# KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://219.221.212.16:9092
# KAFKA_CREATE_TOPICS: "kafeidou:2:0" #kafka启动后初始化一个有2个partition(分区)0个副本名叫kafeidou的topic
# KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
# KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
# volumes:
# - /qn/kafka/logs:/kafka
# depends_on:
# - zookeeper
持续更新中...........
版权声明:本文为weixin_45387269原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。