文章目录
1、下载zip包
https://download.sonic-cloud.wiki/sonic/sonic-server/v1.4.0-release/sonic-server-v1.4.0-release.zip
2、修改env环境变量,将里面的ip改为服务器的ip,将定时任务的所有取值添加双引号,如下:
################################################
# Do you need any help? #
# Visit https://sonic-cloud.gitee.io/#/Deploy #
################################################
##################
# Service Config #
##################
SERVER_HOST=162.14.119.65
SONIC_EUREKA_USERNAME=sonic
SONIC_EUREKA_PASSWORD=sonic
SONIC_EUREKA_PORT=9090
SONIC_GATEWAY_PORT=8094
SONIC_TRANSPORT_PORT=8095
SONIC_CLIENT_PORT=3000
CLIENT_HOST=http://162.14.119.65:3000
################
# MySQL Config #
################
MYSQL_HOST=162.14.119.65
MYSQL_PORT=3306
MYSQL_DATABASE=sonic
MYSQL_USERNAME=root
MYSQL_PASSWORD=Sonic!@#123
################
# User Config #
################
SECRET_KEY=sonic
EXPIRE_DAY=14
REGISTER_ENABLE=true
NORMAL_USER_ENABLE=true
LDAP_USER_ENABLE=true
LDAP_USER_ID=cn
LDAP_BASE_DN=ou=users
LDAP_BASE=ou=system
LDAP_USERNAME=uid=admin,ou=system
LDAP_PASSWORD=Sonic!@#123
LDAP_URL=ldap://162.14.119.65:10389
####################
# Schedule Config #
####################
FILE_CRON="0 0 12 * * ?"
RESULT_CRON="0 0 12 * * ?"
DAY_CRON="0 0 10 * * ?"
WEEK_CRON="0 0 10 ? * Mon"
FILE_KEEP_DAY="60"
RESULT_KEEP_DAY="60"
3、修改docker-compose.yml内容,配置mysql容器及依赖:
version: '3'
services:
sonic-mysql:
image: "mysql:5.7"
container_name: sonic-mysql
command: mysqld --character-set-server=utf8 --collation-server=utf8_general_ci
environment:
- MYSQL_ROOT_PASSWORD=Sonic!@#123
- MYSQL_DATABASE=sonic
volumes:
- ./mysql/data:/var/lib/mysql
ports:
- "3306:3306"
networks:
- sonic-network
sonic-server-eureka:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.4.0-release"
hostname: sonic-server-eureka
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
- SONIC_EUREKA_PORT
- SONIC_EUREKA_HOST=sonic-server-eureka
volumes:
- ./logs/:/logs/
depends_on:
- sonic-mysql
networks:
- sonic-network
ports:
- "${SONIC_EUREKA_PORT}:${SONIC_EUREKA_PORT}"
sonic-server-gateway:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.4.0-release"
environment:
- SONIC_GATEWAY_PORT
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
- SONIC_EUREKA_PORT
- SONIC_EUREKA_HOST=sonic-server-eureka
- SECRET_KEY
- EXPIRE_DAY
volumes:
- ./logs/:/logs/
depends_on:
- sonic-mysql
- sonic-server-eureka
networks:
- sonic-network
ports:
- "${SONIC_GATEWAY_PORT}:${SONIC_GATEWAY_PORT}"
restart: on-failure
sonic-server-controller:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.4.0-release"
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
- SONIC_EUREKA_PORT
- SONIC_EUREKA_HOST=sonic-server-eureka
- MYSQL_HOST
- MYSQL_PORT
- MYSQL_DATABASE
- MYSQL_USERNAME
- MYSQL_PASSWORD
- SERVER_HOST
- SONIC_GATEWAY_PORT
- SONIC_TRANSPORT_PORT
- CLIENT_HOST
- SECRET_KEY
- EXPIRE_DAY
- REGISTER_ENABLE
- NORMAL_USER_ENABLE
- LDAP_USER_ENABLE
- LDAP_USER_ID
- LDAP_BASE_DN
- LDAP_BASE
- LDAP_USERNAME
- LDAP_PASSWORD
- LDAP_URL
networks:
- sonic-network
volumes:
- ./logs/:/logs/
depends_on:
- sonic-mysql
- sonic-server-eureka
restart: on-failure
ports:
- "${SONIC_TRANSPORT_PORT}:${SONIC_TRANSPORT_PORT}"
sonic-server-folder:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.4.0-release"
environment:
- SONIC_EUREKA_USERNAME
- SONIC_EUREKA_PASSWORD
- SONIC_EUREKA_HOST=sonic-server-eureka
- SONIC_EUREKA_PORT
- SERVER_HOST
- SONIC_GATEWAY_PORT
- SECRET_KEY
- EXPIRE_DAY
networks:
- sonic-network
volumes:
- ./keepFiles/:/keepFiles/
- ./imageFiles/:/imageFiles/
- ./recordFiles/:/recordFiles/
- ./packageFiles/:/packageFiles/
- ./logs/:/logs/
depends_on:
- sonic-mysql
- sonic-server-eureka
restart: on-failure
sonic-client-web:
image: "registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-client-web:v1.4.0-release"
environment:
- SERVER_HOST
- SONIC_GATEWAY_PORT
depends_on:
- sonic-mysql
networks:
- sonic-network
ports:
- "${SONIC_CLIENT_PORT}:80"
networks:
sonic-network:
driver: bridge
4、过程中碰到的问题
- 启动报错1:unexpected character “*” in variable name near,解决办法:是env配置文件中的最后的定时任务取值应该添加双引号
- 启动报错2:mysql没连接上,查看了下日志,mysql容器没启动,原因是字符集:排序规则改为官网的 utf8_general_ci,解决办法:–collation-server=utf8_general_ci
- 启动报错3:Error response from daemon: driver failed programming external connectivity on endpoint sonic-server-v140-release-sonic-server-eureka-1 (d3dca2cb2e94fa5acec0e26aa3779ce6af00bb8e81a6563ce656161b883dc200): Bind for 0.0.0.0:9090 failed: port is already allocated。很明显是9090端口被占用了,解决办法:停止服务器的其他容器。