【sonic】使用docker搭建单机sonic-server-1.5.0-release

1、官网

https://sonic-cloud.gitee.io/#/Deploy

 

2、github

https://github.com/SonicCloudOrg

 

3、下载

https://download.sonic-cloud.wiki/sonic/sonic-server/v1.5.0-release/sonic-server-v1.5.0-release.zip

 

4、解压到指定目录

创建目录sonic-server

mkdir sonic-server

移动sonic-server-v1.5.0-release.zip到sonic-server,并解压

cd sonic-server
unzip sonic-server-v1.5.0-release.zip

 

5、使用docker创建mysql数据库

创建映射目录

mkdir mysql8
cd mysql8
mkdir logs data conf

 

创建运行容器

docker run -d \
  -p 3306:3306 \
  --name mysql8 \
  -v $HOME/Tools/mysql8/conf:/etc/mysql/conf.d \
  -v $HOME/Tools/mysql8/logs:/logs \
  -v $HOME/Tools/mysql8/data:/var/lib/mysql \
  -e MYSQL_ROOT_PASSWORD=123456 \
  --restart always \
  --privileged=true \
  mysql

 

6、使用gui或者直接进入容器创建sonic数据库

 

 

可能会连不上,报错“ublic Key Retrieval is not allowed”

 

 

 然后应该就可以连上了

 

7、修改解压目录里的配置

主要是数据库配置,其他的自己看着配 

################################################
#         Do you need any help?                #
# Visit https://sonic-cloud.gitee.io/#/Deploy  #
################################################

##################
# Service Config #
##################
SONIC_SERVER_HOST=192.168.183.104
SONIC_SERVER_PORT=3000
SONIC_EUREKA_USERNAME=sonic
SONIC_EUREKA_PASSWORD=sonic
SONIC_EUREKA_PORT=9090

################
# MySQL Config #
################
MYSQL_HOST=192.168.183.104
MYSQL_PORT=3306
MYSQL_DATABASE=sonic
MYSQL_USERNAME=root
MYSQL_PASSWORD=123456

################
# User Config  #
################
SECRET_KEY=sonic
EXPIRE_DAY=14
PERMISSION_ENABLE=true
PERMISSION_SUPER_ADMIN=sonic
REGISTER_ENABLE=true
NORMAL_USER_ENABLE=true
LDAP_USER_ENABLE=false
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://192.168.183.104:10389

 

8、启动服务

进入sonic-server目录

docker-compose up -d

过程

workerdeMacBook-Pro sonic-server % docker-compose up -d
Creating network "sonic-server_sonic-network" with driver "bridge"
Creating sonic-server_sonic-server-eureka_1 ... done
Creating sonic-server_sonic-server-controller_1 ... done
Creating sonic-server_sonic-server-gateway_1    ... done
Creating sonic-server_sonic-server-folder_1     ... done
Creating sonic-server_sonic-client-web_1        ... done

大概要等待3-5分钟初始化结束

修改配置重新初始化,可以执行

% docker-compose down
Stopping sonic-server_sonic-client-web_1        ... done
Stopping sonic-server_sonic-server-folder_1     ... done
Stopping sonic-server_sonic-server-gateway_1    ... done
Stopping sonic-server_sonic-server-controller_1 ... done
Stopping sonic-server_sonic-server-eureka_1     ... done
Removing sonic-server_sonic-client-web_1        ... done
Removing sonic-server_sonic-server-folder_1     ... done
Removing sonic-server_sonic-server-gateway_1    ... done
Removing sonic-server_sonic-server-controller_1 ... done
Removing sonic-server_sonic-server-eureka_1     ... done
Removing network sonic-server_sonic-network

 

 

9、访问web服务:http://[ip]:3000

 

 

 

10、注册一个用户,然后登陆即可

 

 

 

 

11、问题定位

可以使用docker-desktop查看容器日志

 

 

 也可以使用命令行查看日志

查看容器名称

% docker ps
CONTAINER ID   IMAGE                                                                                  COMMAND                  CREATED        STATUS        PORTS                                                                      NAMES
01ff69183633   registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-client-web:v1.5.0-release          "/docker-entrypoint.…"   5 hours ago    Up 5 hours    0.0.0.0:3000->80/tcp                                                       sonic-server_sonic-client-web_1
d3617238992a   registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-controller:v1.5.0-release   "java -server -XX:-U…"   5 hours ago    Up 5 hours                                                                               sonic-server_sonic-server-controller_1
7c8790c4cf9b   registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-folder:v1.5.0-release       "java -server -XX:-U…"   5 hours ago    Up 5 hours                                                                               sonic-server_sonic-server-folder_1
54e7f8b90c9d   registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-gateway:v1.5.0-release      "java -server -XX:-U…"   5 hours ago    Up 5 hours                                                                               sonic-server_sonic-server-gateway_1
173494e5e8cf   registry.cn-hangzhou.aliyuncs.com/sonic-cloud/sonic-server-eureka:v1.5.0-release       "java -server -XX:-U…"   5 hours ago    Up 5 hours    0.0.0.0:9090->9090/tcp                                                     sonic-server_sonic-server-eureka_1

查看对应服务日志

docker logs -f 容器名称或id 

 

 

 

 参考链接:

https://blog.csdn.net/weixin_55599565/article/details/125140094

https://blog.csdn.net/LiXueFu727224204/article/details/123717748

 

posted @ 2022-09-16 13:19  代码诠释的世界  阅读(432)  评论(0编辑  收藏  举报