iModel 企业级数据分析平台
部署手册(银河麒麟 V11 2503 x86_64 专版)
适用系统: Kylin V11 (2503) x86_64
JDK 版本: OpenJDK 1.8.x
数据库: MySQL 8.0 (3306)
Nginx 版本: Nginx 1.26.x
一、基础环境与防火墙配置
1.1 安装 OpenJDK 1.8
# 安装 JDK 1.8
dnf install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel
# 切换默认 Java 版本(如预装了 JDK 11/17)
alternatives --config java
# 配置系统级环境变量
echo 'export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk' >> /etc/profile.d/java.sh
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile.d/java.sh
source /etc/profile.d/java.sh
1.2 配置 Firewalld 开放端口
# 批量放行业务端口
for p in 9000 8080 3306 51020 50000 50200 4646; do
firewall-cmd --zone=public --permanent --add-port=${p}/tcp
done
firewall-cmd --reload
# 验证开放状态
firewall-cmd --zone=public --list-ports
1.3 解压软件包与重命名
cd /opt
tar -zxvf IModel-bundle.tar.gz
# 重命名主服务脚本以契合 Systemd 配置
mv /opt/IModel-bundle/bin/imodelabi-server.sh /opt/IModel-bundle/bin/imodel-server.sh
# 赋权可执行脚本
chmod +x /opt/IModel-bundle/bin/*.sh \
/opt/IModel-bundle/executor/*.sh \
/opt/IModel-bundle/ftpserve/*.sh
二、MySQL 8.0 数据库配置与初始化
2.1 在线获取与安装(RHEL9 生态包)
mkdir -p /opt/mysql-rpm && cd /opt/mysql-rpm
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-8.0/mysql-8.0.40-1.el9.x86_64.rpm-bundle.tar
tar -xvf mysql-8.0.40-1.el9.x86_64.rpm-bundle.tar
# 清理冲突库
dnf remove -y mariadb-libs --skip-broken 2>/dev/null || true
# 安装依赖与服务端
dnf install -y mysql-community-common-*.el9.x86_64.rpm \
mysql-community-client-plugins-*.el9.x86_64.rpm \
mysql-community-libs-*.el9.x86_64.rpm \
mysql-community-client-*.el9.x86_64.rpm \
mysql-community-icu-data-files-*.el9.x86_64.rpm \
mysql-community-server-*.el9.x86_64.rpm
2.2 编辑服务配置并启动
编辑 /etc/my.cnf 的 [mysqld] 段落,追加:
[mysqld]
port=3306
character-set-server=utf8mb4
collation-server=utf8mb4_unicode_ci
bind-address=0.0.0.0
systemctl enable --now mysqld
2.3 数据库初始化 & 授权
# 提取临时密码
TEMP_PASS=$(grep 'temporary password' /var/log/mysqld.log | awk '{print $NF}')
# 登录并执行命令
mysql -uroot -p"${TEMP_PASS}" --connect-expired-password
于 MySQL 终端执行(替换强密码):
ALTER USER 'root'@'localhost' IDENTIFIED BY 'Your_Strong_Root_Password';
CREATE DATABASE imodel CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'imodel'@'%' IDENTIFIED BY 'Your_iModel_Password';
GRANT ALL PRIVILEGES ON imodel.* TO 'imodel'@'%';
FLUSH PRIVILEGES;
EXIT;
2.4 导入初始 Schema & 配置连接
# 导入主结构
mysql -uroot -p'Your_Strong_Root_Password' imodel < /opt/IModel-bundle/db/i-model.sql
编辑 /opt/IModel-bundle/app/config/datart.conf:
# ===== datasource config =====
datasource.ip=localhost
datasource.port=3306
datasource.database=imodel
datasource.username=imodel
datasource.password=Your_iModel_Password
# ===== datart config =====
datart.address=http://<您的应用服务器IP>:8080
三、Nginx 1.26.x 配置
dnf install -y nginx
覆盖写入全局配置文件 /etc/nginx/nginx.conf:
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
map $http_upgrade $connection_upgrade {
default keep-alive;
'websocket' upgrade;
}
server {
listen 9000;
server_name localhost;
client_max_body_size 200m;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $http_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;
}
location /api/v1/models/quick/run {
proxy_pass http://localhost:8080;
proxy_buffering off;
proxy_cache off;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
}
location /socket.io/ {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_pass http://localhost:51020/socket.io/;
}
}
}
nginx -t && systemctl enable --now nginx
四、Systemd 开机自启配置
创建以下 4 个 .service 系统单元配置:
1. FTP 服务 (/etc/systemd/system/imodel-ftp.service)
[Unit]
Description=iModel FTP Server
After=network.target
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/opt/IModel-bundle/ftpserve
ExecStart=/opt/IModel-bundle/ftpserve/ftpd-server.sh start
ExecStop=/opt/IModel-bundle/ftpserve/ftpd-server.sh stop
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
TimeoutStartSec=120
[Install]
WantedBy=multi-user.target
2. iModel 主服务 (/etc/systemd/system/imodel.service)
[Unit]
Description=iModel Main Server
After=network.target imodel-ftp.service
Wants=imodel-ftp.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/opt/IModel-bundle/bin
ExecStart=/opt/IModel-bundle/bin/imodel-server.sh start
ExecStop=/opt/IModel-bundle/bin/imodel-server.sh stop
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
TimeoutStartSec=180
[Install]
WantedBy=multi-user.target
3. Executor 服务 (/etc/systemd/system/imodel-executor.service)
[Unit]
Description=iModel Executor Server
After=network.target imodel.service
Wants=imodel.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/opt/IModel-bundle/executor
ExecStart=/opt/IModel-bundle/executor/executor-server.sh start
ExecStop=/opt/IModel-bundle/executor/executor-server.sh stop
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
TimeoutStartSec=180
[Install]
WantedBy=multi-user.target
4. Modern 服务 (/etc/systemd/system/imodel-modern.service)
[Unit]
Description=iModel Modern Server
After=network.target imodel-executor.service
Wants=imodel-executor.service
[Service]
Type=oneshot
RemainAfterExit=yes
WorkingDirectory=/opt/IModel-bundle/executor
ExecStart=/opt/IModel-bundle/executor/modern-server.sh start
ExecStop=/opt/IModel-bundle/executor/modern-server.sh stop
Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
TimeoutStartSec=180
[Install]
WantedBy=multi-user.target
加载并开机激活服务
systemctl daemon-reload
systemctl enable imodel-ftp imodel imodel-executor imodel-modern
# 链式启动
systemctl start imodel-modern
五、Cron 进程生命周期守护配置
由于启动脚本为 oneshot 架构,设置系统级别的 crontab 以防止 JVM 异常奔溃:
crontab -e
追加以下定时检测配置(每分钟调用一次脚本的 start 锁检测):
* * * * * cd /opt/IModel-bundle/ftpserve && /opt/IModel-bundle/ftpserve/ftpd-server.sh start >/dev/null 2>&1
* * * * * cd /opt/IModel-bundle/bin && /opt/IModel-bundle/bin/imodel-server.sh start >/dev/null 2>&1
* * * * * cd /opt/IModel-bundle/executor && /opt/IModel-bundle/executor/executor-server.sh start >/dev/null 2>&1
* * * * * cd /opt/IModel-bundle/executor && /opt/IModel-bundle/executor/modern-server.sh start >/dev/null 2>&1
六、日常运维极速查询
6.1 链式健康监测
# 服务活跃指标检测
systemctl is-active imodel-ftp imodel imodel-executor imodel-modern nginx mysqld
# 端口绑定追踪
ss -tlnp | grep -E ':(9000|8080|4646|51020|50000)'
6.2 一键全套重置脚本
可直接在服务器创建 /opt/IModel-bundle/scripts/restart-imodel.sh 脚本用于重启维护:
#!/bin/bash
BUNDLE="/opt/IModel-bundle"
# 优雅停止
systemctl stop nginx 2>/dev/null
bash "${BUNDLE}/executor/modern-server.sh" stop 2>/dev/null
bash "${BUNDLE}/executor/executor-server.sh" stop 2>/dev/null
bash "${BUNDLE}/bin/imodel-server.sh" stop 2>/dev/null
bash "${BUNDLE}/ftpserve/ftpd-server.sh" stop 2>/dev/null
sleep 3
# 强制清理僵尸进程与锁文件
ps -ef | grep -E 'IModel-bundle|KNIME_BATCH_APPLICATION|DatartServerApplication' | grep -v grep | awk '{print $2}' | xargs -r kill -9 2>/dev/null
find "${BUNDLE}/executor" -name "*.lock" -type f -delete 2>/dev/null
rm -f "${BUNDLE}/executor/workspace/.metadata/.lock" 2>/dev/null
rm -f "${BUNDLE}/executor/modern-workspace/.metadata/.lock" 2>/dev/null
# 顺序拉起
cd "${BUNDLE}/ftpserve" && ./ftpd-server.sh start
sleep 10
cd "${BUNDLE}/bin" && ./imodel-server.sh start
sleep 30
cd "${BUNDLE}/executor" && ./executor-server.sh start
sleep 20
cd "${BUNDLE}/executor" && ./modern-server.sh start
sleep 15
systemctl start nginx
echo "iModel 全套服务重载成功."