Dubhe GNSS测试应用平台

部署Linux服务配置介绍

服务部署

目前执行文件dubhe程序只支持Linux的x86平台,需要安装mysql 8.0 server用于坐标数据存储

安装mysql 8.0 server以 ubuntu 24.04 为例

apt install mysql-server

关于mTLS

上报数据使用mTLS,关于mTLS 是 双向传输层安全性协议(Mutual Transport Layer Security)的缩写。简单来说,mTLS 就是“双向认证”的 TLS(HTTPS)。特点:

  • 客户端 验证服务器 的身份(依然保留)。
  • 服务器 也要求验证客户端的身份(额外增加的)。

客户端必须出示一张由服务器信任的机构颁发的客户端证书。如果客户端没有证书,或者证书无效,服务器直接拒绝连接,总结: mTLS 就是把原本“只查证件”的 HTTPS,升级为“互相查证件”的安全协议。

初始化数据库

数据库名默认使用gps,在 MySQL 中创建数据库并执行:

CREATE DATABASE gps DEFAULT CHARSET=utf8mb4;

配置文件

启动参数从 config.json 读取(在项目根目录)。

关键字段说明:

  • admin_http_addr 管理后台 HTTP 监听地址,默认 :8082
  • admin_https_addr 管理后台 HTTPS 监听地址,默认 :8443
  • ingest_https_addr 上报 HTTPS 监听地址,默认 :19909
  • tencent_maps_api_key 腾讯地图 API Key
  • map_provider 地图提供商:googlebaidutencent
  • max_query_limit 最大查询数量
  • default_query_limit 默认查询数量
  • insert_table 数据表名(默认 gps_points
  • auto_migrate 启动时使用 GORM 自动建表(默认 true)
  • debug_ingest 上报调试日志(默认 false)
  • enable_request_log 是否开启请求日志
  • ingest_php_alias 是否启用 /index.php
  • allowed_origin CORS 允许来源(可选)
  • dsn 如果不为空将直接使用(优先于 db
  • db 用于生成 DSN

浏览器访问:

  • http://YOURSERVER:8080/https://YOURSERVER:8443/

默认账号/密码:

  • admin / 123456

脚本对接

上报使用 HTTPS + mTLS + Token,注意 URL:

POST https://YOURSERVER:19909/api/ingest

Header:

  • X-Token: <token>Authorization: Bearer <token>

证书:

  • 在管理后台「系统参数」下载 CA + 客户端证书/私钥并导入 RouterOS。

Linux Service服务配置

Linux下创建Service服务启动配置,以Debian配置为例,使用systemctl启动service服务,创建程序运行目录 /usr/local/dubhe。

mkdir /usr/local/dubhe

上传dubhe执行文件到/usr/local/dubhe目录下,例如,使用Windows的Power Shell通过scp上传

scp .\dubhe root@YOU_SERVER_IP:/usr/local/dubhe

在/usr/local/dubhe目录下,创建config.json文件,输入如下配置

{
  "admin_http_addr": ":8082",
  "admin_https_addr": ":8443",
  "ingest_https_addr": ":19909",
  "google_maps_api_key": "YOUR_GOOGLE_MAPS_API_KEY",
  "baidu_maps_api_key": "YOUR_BAIDU_MAPS_AK",
  "tencent_maps_api_key": "YOUR_TENCENT_MAPS_API_KEY",
  "map_provider": "tencent",
  "max_query_limit": 5000,
  "default_query_limit": 1000,
  "insert_table": "gps_points",
  "auto_migrate": true,
  "enable_request_log": true,
  "debug_ingest": true,
  "allowed_origin": "",
  "ingest_php_alias": true,
  "dsn": "",
  "db": {
    "user": "gps",
    "pass": "gps",
    "host": "127.0.0.1",
    "port": 3306,
    "name": "gps",
    "params": "parseTime=true&charset=utf8mb4&loc=Local"
  }
}

在/lib/systemd/system/dubhe.service,使用vi创建和编辑dubhe.service服务

vi /lib/systemd/system/dubhe.service

在dubhe.service写入下面内容:

[Unit]
Description=dubhe service
After=network.target network-online.target
Wants=network.target network-online.target
[Service]
User=root
Group=root
Type=simple
WorkingDirectory=/usr/local/dubhe

#启动服务的命令(命令必须写绝对路径)
ExecStart=/usr/local/dubhe/dubhe

[Install]
WantedBy=multi-user.target

使用systemctl配置开机启动服务

systemctl enable dubhe.service

启动服务

systemctl start dubhe.service