本文介绍在银河麒麟 V11 Server 版上安装系统运行环境的完整步骤,包括 JDK 1.8、东方通 TongWeb、TiDB 和 Nginx。请先完成系统安装和磁盘挂载(参见 [麒麟 V11 Server 版安装教程](/2026/05/11/麒麟 V11 Server 版安装教程))。
1. 创建安装目录
如果已挂载独立数据盘,使用 /data 路径;否则使用 /opt 路径。以下以 /data 为例。
1 2 3
| mkdir -p /data/install mkdir -p /data/software cd /data/install
|
2. 上传安装包
将以下安装包上传至 /data/install 目录:
| 软件 |
文件名示例 |
说明 |
| JDK 1.8 |
jdk-8u281-linux-aarch64.tar.gz 或 jdk-8u281-linux-x64.tar.gz |
根据 CPU 架构选择 arm64 或 x64 版本 |
| 东方通 TongWeb |
Install_TW7.0.4.1_Enterprise_Linux.bin |
国产应用服务器,需提前获取授权 |
| TiDB |
在线安装 |
分布式 HTAP 数据库,PingCAP 出品 |
| Nginx |
在线安装 |
Web 服务器 / 反向代理 |
3. 确认系统架构
aarch64 → ARM 架构(如飞腾、鲲鹏处理器)
x86_64 → x64 架构(如 Intel、AMD 处理器)
一、安装 JDK 1.8
1. 解压安装
1 2
| cd /data/install tar -zxvf jdk-8u281-linux-x64.tar.gz -C /data/software/
|
2. 配置环境变量
写入以下内容:
1 2 3 4
| export JAVA_HOME=/data/software/jdk1.8.0_281 export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$JAVA_HOME/bin:$PATH
|
3. 生效并验证
1 2
| source /etc/profile java -version
|
如果系统之前已安装 OpenJDK,需要替换默认 java:
1 2 3 4
| alternatives --install /usr/bin/java java /data/software/jdk1.8/bin/java 2000 alternatives --install /usr/bin/javac javac /data/software/jdk1.8/bin/javac 2000 alternatives --set java /data/software/jdk1.8/bin/java alternatives --set javac /data/software/jdk1.8/bin/javac
|
在线安装 JDK 1.8(如系统源中有):
1
| yum install java-1.8.0-openjdk -y
|
二、安装东方通 TongWeb
1. 准备安装文件
将 Install_TW7.0.4.1_Enterprise_Linux.bin 上传至服务器,并赋予执行权限:
1
| chmod +x Install_TW7.0.4.1_Enterprise_Linux.bin
|
2. 静默安装
东方通提供图形化安装向导和静默安装两种方式。服务器上推荐使用静默模式:
1
| ./Install_TW7.0.4.1_Enterprise_Linux.bin -i silent -DUSER_INSTALL_DIR=/data/software/tongweb
|
静默安装会将 TongWeb 安装到 /data/software/tongweb 目录。如需图形安装界面,需要先配置 DISPLAY 或使用 VNC 远程桌面。
3. 安装 License
将 TongWeb 授权文件(通常为 license.dat)放置到 TongWeb 的 license 目录:
1
| cp /path/to/license.dat /data/software/tongweb/license/
|
如果没有正式 License,可先使用试用 License,联系东方通获取授权文件。
4. 配置环境变量
写入:
1 2
| export TONGWEB_HOME=/data/software/tongweb export PATH=$TONGWEB_HOME/bin:$PATH
|
5. 配置 JVM 参数
编辑 TongWeb 启动配置文件,调整 JVM 内存参数:
1
| vi $TONGWEB_HOME/bin/startserver.sh
|
找到 JAVA_OPTS 相关配置,建议设置:
1
| JAVA_OPTS="-Xms512m -Xmx1024m -XX:MaxPermSize=256m"
|
根据服务器实际内存调整 -Xms 和 -Xmx 的值。
6. 启动 TongWeb
1 2
| cd $TONGWEB_HOME/bin ./startserver.sh
|
首次启动后,TongWeb 管理控制台默认地址:
1
| http://192.168.40.18:9060/console
|
默认管理员账号:thanos / thanos123(如版本不同请参考安装时设置的密码)。
7. 配置开机自启
1
| vi /etc/systemd/system/tongweb.service
|
写入:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| [Unit] Description=TongWeb Application Server After=network.target
[Service] Type=forking User=root Group=root ExecStart=/data/software/tongweb/bin/startserver.sh ExecStop=/data/software/tongweb/bin/stopserver.sh Restart=on-failure
[Install] WantedBy=multi-user.target
|
启用并启动:
1 2 3 4
| systemctl daemon-reload systemctl enable tongweb systemctl start tongweb systemctl status tongweb
|
三、安装 TiDB
TiDB 是 PingCAP 开源的分布式 HTAP 数据库,兼容 MySQL 和 PostgreSQL 协议。推荐使用官方工具 TiUP 进行部署,支持单机测试和集群生产两种模式。
TiUP 部署
1. 安装 TiUP
1 2
| curl --proto '=https' --tlsv1.2 -sSf https://tiup-mirrors.pingcap.com/install.sh | sh source ~/.bash_profile
|
2. 安装 TiDB 组件
首次运行会自动下载 cluster 组件及相关依赖。
3. 单机测试部署(开发/验证环境)
1
| tiup playground --host 0.0.0.0
|
默认会启动一个包含 TiDB、TiKV、PD、TiFlash 等组件的单机集群。TiDB 默认监听 4000 端口。
后台运行方式:
1
| tiup playground --host 0.0.0.0 --mode tikv-slim &
|
4. 集群生产部署
创建集群拓扑配置文件:
1 2 3
| cd /data mkdir -p /data/install vi /data/install/topology.yaml
|
单机精简版拓扑(开发/验证环境,不可用于生产):
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| global: user: "root" ssh_port: 22 deploy_dir: "/data/software/tidb-deploy" data_dir: "/data/software/tidb-data"
pd_servers: - host: 192.168.40.18
tidb_servers: - host: 192.168.40.18
tikv_servers: - host: 192.168.40.18
|
单机生产版拓扑(推荐):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| global: user: "root" ssh_port: 22 deploy_dir: "/data/software/tidb-deploy" data_dir: "/data/software/tidb-data"
monitored: node_exporter_port: 9100 blackbox_exporter_port: 9115
server_configs: tidb: instance.tidb_slow_log_threshold: 300 tikv: readpool.storage.use-unified-pool: false readpool.coprocessor.use-unified-pool: true pd: replication.enable-placement-rules: true replication.location-labels: ["host"]
pd_servers: - host: 192.168.40.18
tidb_servers: - host: 192.168.40.18
tikv_servers: - host: 192.168.40.18 port: 20160 status_port: 20180 config: server.labels: { host: "logic-host-1" } - host: 192.168.40.18 port: 20161 status_port: 20181 config: server.labels: { host: "logic-host-2" } - host: 192.168.40.18 port: 20162 status_port: 20182 config: server.labels: { host: "logic-host-3" }
monitoring_servers: - host: 192.168.40.18
grafana_servers: - host: 192.168.40.18
|
所有 IP 替换为实际服务器地址。3 个 TiKV 实例用不同端口区分,通过 labels 标记为独立逻辑节点,满足 PD 至少 3 副本的要求。
执行部署(输入服务器密码):
1
| tiup cluster deploy tidb-test v8.1.0 /data/install/topology.yaml --user root -p
|
启动集群:
1 2 3
| tiup cluster start tidb-test # 这个命令更多是用于部署时初始化密码,对已运行集群效果不直接 tiup cluster init-password --cluster tidb-test --password '你的新密码'
|
查看集群状态:
1
| tiup cluster display tidb-test
|
5. 验证连接
1 2 3 4 5 6 7
| yum install mysql -y # 或者 yum install mariadb-server -y # 通过 MySQL 客户端连接 TiDB mysql -h192.168.40.18 -P4000 -u root # 有密码 mysql -h192.168.40.18 -P4000 -u root -p
|
6. 管理界面访问
部署完成后,可通过浏览器访问以下管理界面:
| 界面 |
地址 |
默认用户名 |
默认密码 |
| TiDB Dashboard |
http://<服务器IP>:2379/dashboard |
root |
数据库密码 |
| Prometheus |
http://<服务器IP>:9090 |
— |
— |
| Grafana |
http://<服务器IP>:3000 |
admin |
admin |
如果 TiDB 部署在远程服务器,建议通过 SSH 端口转发访问:
1
| ssh -L 2379:192.168.40.18:2379 -L 9090:192.168.40.18:9090 -L 3000:192.168.40.18:3000 root@<服务器IP>
|
然后在本地浏览器访问 http://192.168.40.18:2379/dashboard、http://192.168.40.18:9090、http://192.168.40.18:3000。
7. 配置开机自启(集群模式)
使用 TiUP 部署的集群默认已自动创建 systemd 服务,各组件会随系统启动:
1 2 3 4
| # 启用 TiDB 服务 systemctl enable tidb-4000 systemctl enable tikv-20160 systemctl enable pd-2379
|
常用 TiUP 命令
1 2 3 4 5 6 7 8 9 10 11 12
| # 查看集群列表 tiup cluster list
# 启动/停止集群 tiup cluster start tidb-test tiup cluster stop tidb-test
# 重启集群 tiup cluster restart tidb-test
# 销毁集群 tiup cluster destroy tidb-test
|
新建数据库
1 2
| mysql -h192.168.40.18 -P4000 -u root mysql -h192.168.40.18 -P4000 -u root -p
|
1 2 3
| CREATE DATABASE lenglian; CREATE DATABASE db_ccoms;
|
导入表结构
1 2 3 4 5 6 7 8 9 10 11
| use lenglian; source /data/software/sql_init/lenglian.sql; source /data/software/sql_init/base_setting.sql; source /data/software/sql_init/insert.sql; # 或者 mysql -h192.168.40.18 -P4000 -u root lenglian < /data/software/sql_init/lenglian.sql mysql -h192.168.40.18 -P4000 -u root lenglian < /data/software/sql_init/base_setting.sql mysql -h192.168.40.18 -P4000 -u root lenglian < /data/software/sql_init/insert.sql
use db_ccoms; source /data/software/sql_init/db_ccoms.sql;
|
修改密码
1 2 3 4 5
| ALTER USER 'root'@'%' IDENTIFIED BY '你的新密码';
FLUSH PRIVILEGES;
|
四、安装 Nginx
1. 在线安装 Nginx
启用并启动:
1 2 3
| systemctl enable nginx systemctl start nginx systemctl status nginx
|
2. Nginx 反向代理到 TongWeb
1
| vi /etc/nginx/nginx.conf
|
在 http 块中添加:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| upstream tongweb { server 127.0.0.1:8088; }
server { listen 80; server_name localhost;
location / { proxy_pass http://tongweb; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } }
|
修改后重新加载:
五、验证所有服务
安装完成后,检查所有服务状态:
1 2 3 4 5 6 7 8 9 10 11 12
| # 检查 Java java -version
# 检查 TongWeb systemctl status tongweb
# 检查 TiDB tiup cluster display tidb-test
# 检查 Nginx systemctl status nginx nginx -t
|
查看各服务端口:
1
| netstat -tlnp | grep -E '(80|443|9060|8088|4000)'
|
| 服务 |
默认端口 |
说明 |
| Nginx |
80 |
HTTP 服务 |
| TongWeb 管理 |
9060 |
管理控制台 |
| TongWeb 应用 |
8088 |
应用访问端口 |
| TiDB |
4000 |
分布式 HTAP 数据库(MySQL 协议兼容) |
| TiDB Dashboard |
2379 |
PD 管理接口 / Dashboard |
| Prometheus |
9090 |
监控数据查询 |
| Grafana |
3000 |
可视化监控面板 |