ubuntu 搭建 sonic v2.6.4 平台记录

友情链接:sudo 免密码 小白用Windows(ssh)连接使用 ubuntu(虚拟机)-CSDN博客

1.前后端部署 | Sonic - 开源云真机平台 (sonic-cloud.cn)

sonic.sh 搭建脚本

#!/bin/bash

# 如果外部参数为 ready,则下载 Sonic Server 压缩包
if [ "$1" == "ready" ]; then
    # 设置代理
    export ALL_PROXY=http://172.28.128.1:1081
    
    # 下载 Sonic Server 压缩包
    curl -L https://ghproxy.com/https://github.com/SonicCloudOrg/sonic-server/releases/download/v2.6.4/sonic-server-v2.6.4.zip --output sonic-server-v2.6.4.zip
    
    # 取消代理
    export ALL_PROXY=
    
    # 如果 unzip 命令不存在,则安装 unzip
    if ! command -v unzip &> /dev/null; then
        sudo apt install -y unzip
    fi
    
    # 解压 Sonic Server 压缩包
    unzip sonic-server-v2.6.4.zip
fi

if [ "$1" == "cfg" ]; then
    # 编辑 .env 文件,修改对应值
    sed -i 's/SONIC_SERVER_HOST=.*/SONIC_SERVER_HOST=192.168.23.133/' .env
    sed -i 's#LDAP_URL=.*#LDAP_URL=ldap://192.168.23.133:10389#' .env
    sed -i 's/SONIC_SERVER_PORT=.*/SONIC_SERVER_PORT=3000/' .env
    sed -i 's/MYSQL_HOST=.*/MYSQL_HOST=192.168.23.133/' .env
    sed -i 's/MYSQL_PORT=.*/MYSQL_PORT=3306/' .env
    #mysql
    mkdir -p /home/sonic     
    cp ../mysql/my.cnf /home/sonic/mysql/my.cnf
    old_pwd=$(pwd)
    cd /home/sonic
    mkdir -p mysql/log mysql/data mysql/conf
    mkdir -p /home/sonic/mysql/conf/conf.d
    mkdir -p /home/sonic/mysql/mysql.conf.d 
    cd "$old_pwd" 
fi

if [ "$1" == "compose" ]; then 
    # 安装所需的依赖项
    apt install docker
    apt install docker-compose
fi

# 启动 Docker 容器
if [ "$1" == "up" ]; then
    docker-compose up -d
fi


# 停止 
# systemctl restart docker   
# 查看状态
# sudo docker ps   
#查看日志
# sudo docker logs xxxxx   

附件:../mysql/my.cnf

[mysql]
#设置mysql客户端默认字符集
default-character-set=UTF8MB4
 
[mysqld]
#设置3306端口
port=3306
 
#允许最大连接数
max_connections=200
 
#允许连接失败的次数
max_connect_errors=10
 
#默认使用"mysql_native_password"插件认证
default_authentication_plugin=mysql_native_password
 
#服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=UTF8MB4
 
#开启查询缓存
explicit_defaults_for_timestamp=true
 
#创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
 
#等待超时时间秒
wait_timeout=60
 
#交互式连接超时时间秒
interactive-timeout=600
secure_file_priv=/var/lib/mysql
 
[client]
default-character-set=UTF8MB4

附件:docker-compose.yaml 添加了 mysql

version: '3'
services:
  sonic-server-eureka:
    image: "sonicorg/sonic-server-eureka:v2.6.4"
    hostname: sonic-server-eureka
    environment:
      - SONIC_EUREKA_USERNAME
      - SONIC_EUREKA_PASSWORD
      - SONIC_EUREKA_PORT
      - SONIC_EUREKA_HOST=sonic-server-eureka
    volumes:
      - ./logs/:/logs/
    networks:
      - sonic-network
    ports:
      - "${SONIC_EUREKA_PORT}:${SONIC_EUREKA_PORT}"
  sonic-server-gateway:
    image: "sonicorg/sonic-server-gateway:v2.6.4"
    hostname: sonic-server-gateway
    environment:
      - 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-server-eureka
    networks:
      - sonic-network
    restart: on-failure
  sonic-server-controller:
    image: "sonicorg/sonic-server-controller:v2.6.4"
    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
      - SONIC_SERVER_HOST
      - SONIC_SERVER_PORT
      - 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
      - LDAP_OBJECT_CLASS
    networks:
      - sonic-network
    volumes:
      - ./logs/:/logs/
    depends_on:
      - sonic-server-eureka
    restart: on-failure
  sonic-server-folder:
    image: "sonicorg/sonic-server-folder:v2.6.4"
    environment:
      - SONIC_EUREKA_USERNAME
      - SONIC_EUREKA_PASSWORD
      - SONIC_EUREKA_HOST=sonic-server-eureka
      - SONIC_EUREKA_PORT
      - SONIC_SERVER_HOST
      - SONIC_SERVER_PORT
      - SECRET_KEY
      - EXPIRE_DAY
    networks:
      - sonic-network
    volumes:
      - ./keepFiles/:/keepFiles/
      - ./imageFiles/:/imageFiles/
      - ./recordFiles/:/recordFiles/
      - ./packageFiles/:/packageFiles/
      - ./logs/:/logs/
    depends_on:
      - sonic-server-eureka
    restart: on-failure
  sonic-client-web:
    image: "sonicorg/sonic-client-web:v2.6.4"
    environment:
      - SONIC_SERVER_HOST
      - SONIC_SERVER_PORT
    networks:
      - sonic-network
    depends_on:
      - sonic-server-gateway
    restart: on-failure
    ports:
      - "${SONIC_SERVER_PORT}:80"
  sonic-mysql:
      image: "mysql:5.7"
      command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
      environment:
        - MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD}
        - MYSQL_DATABASE
      volumes:
        - /home/sonic/mysql/log:/var/log/mysql
        - /home/sonic/mysql/data:/var/lib/mysql
        - /home/sonic/mysql/conf:/etc/mysql
        - /home/sonic/mysql/my.cnf:/etc/mysql/my.cnf
        - /home/sonic/mysql/mysql.conf.d/:/etc/mysql/mysql.conf.d/
      ports:
        - "3306:3306"
      networks:
        - sonic-network
networks:
  sonic-network:
    driver: bridge

避坑:3306:3306 端口只能是3306 不能其他的

2.Agent 端部署 | Sonic - 开源云真机平台 (sonic-cloud.cn)

agent.sh 搭建脚本

#!/bin/bash
 

# 如果外部参数为 ready,则下载 Sonic Server 压缩包
if [ "$1" == "ready" ]; then
    # 设置代理
    export ALL_PROXY=http://172.28.128.1:1081
    
    # 下载 Sonic Server 压缩包
    curl -L https://ghproxy.com/https://github.com/SonicCloudOrg/sonic-agent/releases/download/v2.6.4/sonic-agent-v2.6.4-linux_x86_64.zip --output sonic-agent-v2.6.4-linux_x86_64.zip
    
    # # 取消代理
    export ALL_PROXY=
    
    # # 如果 unzip 命令不存在,则安装 unzip
    if ! command -v unzip &> /dev/null; then
        sudo apt install -y unzip
    fi
    
    # 解压 Sonic Server 压缩包
    unzip sonic-agent-v2.6.4-linux_x86_64.zip
    chmod -R 777 ../agent
fi

if [ "$1" == "cfg" ]; then
    export ALL_PROXY=http://172.28.128.1:1081
    # curl -L https://ghproxy.com/https://github.com/SonicCloudOrg/sonic-agent/releases/download/v2.6.4/docker-compose.yml --output docker-compose.yml 
    curl -L  https://github.com/SonicCloudOrg/sonic-agent/releases/download/v2.6.4/docker-compose.yml --output docker-compose.yml 
    export ALL_PROXY=
    # 前端界面【设备中心】的【Agent 中心】新增 Agent,记录 Agent 的 Key
fi

# 如果外部参数不为 ready,则启动 Docker 容器
if [ "$1" == "up" ]; then
    docker-compose up -d
fi

# 查看连接状态
if [ "$1" == "test" ]; then
    docker exec -it agent_sonic-agent_1 /bin/bash
    # 查看连接状态
    #adb devices
fi
相关推荐
卓琢6 分钟前
(九)Shell 脚本(四):正则表达式、sed 和 awk 详解
linux·mysql·正则表达式
iangyu31 分钟前
docker常用命令
运维·docker·容器
一切皆是定数1 小时前
Linux驱动开发——LED驱动开发
linux·驱动开发·b树
小小不董1 小时前
图文深入理解Oracle DB Scheduler
linux·运维·服务器·数据库·oracle
不烦下雨c2 小时前
[网络]抓包工具介绍 tcpdump
linux·tcpdump
南瓜小米粥、2 小时前
通过fdisk初始化Linux数据盘
linux·运维·服务器
秋风起,再归来~2 小时前
【Linux庖丁解牛】—Linux基本指令(中)!
linux·指令
Eternal-Student2 小时前
预处理、编译、汇编、链接
linux·汇编·windows
sp_wxf3 小时前
Stream流
linux·服务器·windows
LYK_HAHA4 小时前
centos常用知识和命令
linux·运维·centos