spark 项目初始化

Last updated on July 1, 2026 am

🧙 Questions

初始化至轻云服务器

☄️ Ideas

修改hostname防止看错服务器

hostnamectl set-hostname zhiqingyun

创建下载目录

ssh-copy-id root@zhiqingyun.isxcode.com
mkdir -p /tmp/downloads

下载并安装openjdk

scp /Users/ispong/OneDrive/Downloads/linux/java/zulu17.66.19-ca-jdk17.0.19-linux_x64.tar.gz root@zhiqingyun.isxcode.com:/tmp/downloads

tar -vzxf /tmp/downloads/zulu17.66.19-ca-jdk17.0.19-linux_x64.tar.gz -C /opt/
ln -s /opt/zulu17.66.19-ca-jdk17.0.19-linux_x64 /opt/java

tee -a /etc/profile <<-'EOF'
export JAVA_HOME=/opt/java
export PATH=$PATH:$JAVA_HOME/bin
EOF
source /etc/profile

java -version

安装H2数据库

scp /Users/ispong/OneDrive/Downloads/linux/h2/h2-2024-08-11.zip root@zhiqingyun.isxcode.com:/tmp/downloads

unzip /tmp/downloads/h2-2024-08-11.zip  -d /opt
mkdir -p /data/h2
mkdir -p /opt/h2/logs/

# 构建服务脚本
vim /etc/systemd/system/h2.service

[Unit]
Description=H2 Database Server
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/h2

ExecStart=/bin/bash -c '/opt/java/bin/java -Xmx128m -cp /opt/h2/bin/h2-2.3.232.jar org.h2.tools.Server \
  -web \
  -webAllowOthers \
  -webPort 8888 \
  -webExternalNames 47.103.49.180 \
  -tcp \
  -tcpAllowOthers \
  -tcpPort 9999 \
  -tcpPassword "admin123" \
  -baseDir /data/h2 2>&1 | tee -a /opt/h2/logs/h2.log'

ExecStop=/opt/java/bin/java -cp /opt/h2/bin/h2-2.3.232.jar org.h2.tools.Server \
  -tcpShutdown tcp://localhost:9999 \
  -tcpPassword "admin123"

Restart=always
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target

systemctl daemon-reload
systemctl enable h2
systemctl start h2
systemctl status h2

# 日志归档
cat > /etc/logrotate.d/h2 <<'EOF'
/opt/h2/logs/h2.log {
    daily
    rotate 15
    missingok
    notifempty
    copytruncate
    compress
    delaycompress
    dateext
    dateformat -%Y%m%d
    create 0644 root root
}
EOF

# 初始化数据库
java -cp /opt/h2/bin/h2-2.3.232.jar org.h2.tools.Shell \
  -url "jdbc:h2:/data/h2/zhiqingyun_db" \
  -user admin \
  -password "admin123"

项目打包,推送到/tmp目录

scp /Users/ispong/isxcode/zhiqingyun-platform/dist/build/distributions/zhiqingyun.tar.gz root@zhiqingyun.isxcode.com:/tmp/downloads

tar -vzxf /tmp/downloads/zhiqingyun.tar.gz -C /opt/
mkdir -p /opt/zhiqingyun/resources

修改配置文件

vim /opt/zhiqingyun/conf/application-local.yml
server:
  port: 8080

spring:
  security:
    user:
      name: admin
      password: admin123

  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:tcp://172.19.234.5:9999/zhiqingyun_db
    username: admin
    password: admin123

app:
  resources-path: /opt/zhiqingyun/resources
  admin-passwd: admin123
  use-port: true
  use-ssl: false
  docker-mode: false
  open-file-path: /data/file

spark-yun:
  agent-retry-count: 3
  agent-retry-interval: 2000
  default-agent-port: 30177
  tmp-dir: /tmp

启动后端

bash /opt/zhiqingyun/bin/start.sh

安装pm2

scp /Users/ispong/OneDrive/Downloads/linux/fnm/fnm-linux.zip root@zhiqingyun.isxcode.com:/tmp/downloads

unzip /tmp/downloads/fnm-linux.zip -d /bin

eval "$(fnm env --use-on-cd)"
fnm install v22.22.3
fnm use v22.22.3
fnm default v22.22.3

npm config set registry https://registry.npmmirror.com/
npm install pm2 -g
pm2 -version

打包官网代码部署

scp /Users/ispong/isxcode/zhiqingyun-platform/dist/build/distributions/zhiqingyun-website.zip root@zhiqingyun.isxcode.com:/tmp/downloads

mkdir -p /opt/website
unzip /tmp/downloads/zhiqingyun-website.zip -d /opt/website

HOST=0.0.0.0 PORT=3000 NODE_ENV=production pm2 start /opt/website/zhiqingyun-website/server/index.mjs --name website

安装nginx

yum install -y yum-utils
vim /etc/yum.repos.d/nginx.repo

[nginx-stable]
name=nginx stable repo
baseurl=https://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

[nginx-mainline]
name=nginx mainline repo
baseurl=https://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true

yum-config-manager --enable nginx-mainline
yum install nginx -y

systemctl enable nginx
systemctl start nginx
systemctl status nginx

配置ssl

scp -r /Users/ispong/OneDrive/Downloads/linux/acme/acme.sh.zip root@zhiqingyun.isxcode.com:/tmp/downloads
unzip /tmp/downloads/acme.sh.zip -d /tmp/downloads
cd /tmp/downloads/acme.sh
./acme.sh --install -m ispong@outlook.com
source /root/.acme.sh/acme.sh.env
acme.sh -v

配置nginx

vim /etc/nginx/conf.d/zhiqingyun-demo.conf
# ------------------------------ 至轻云demo演示环境 ------------------------------
server {
    listen             80;
    listen             [::]:80;
    server_name        zhiqingyun-demo.isxcode.com;

    location /.well-known/acme-challenge/ {
      root /var/www/html;
    }
}
vim /etc/nginx/conf.d/zhiqingyun-website.conf
# ------------------------------ 至轻云官网 ------------------------------
server {
    listen             80;
    listen             [::]:80;
    server_name        zhiqingyun.isxcode.com;

    location /.well-known/acme-challenge/ {
      root /var/www/html;
    }
}
mkdir -p /var/www/html

acme.sh --set-default-ca --server letsencrypt

# 申请许可证
acme.sh --issue -d zhiqingyun.isxcode.com -w /var/www/html
acme.sh --issue -d zhiqingyun-demo.isxcode.com -w /var/www/html
acme.sh --list

# 重定向
mkdir -p /opt/ssl
acme.sh --install-cert -d zhiqingyun.isxcode.com \
--key-file       /opt/ssl/zhiqingyun.isxcode.com.key \
--fullchain-file /opt/ssl/zhiqingyun.isxcode.com.pem \
--reloadcmd     "nginx -s reload"

acme.sh --install-cert -d zhiqingyun-demo.isxcode.com \
--key-file       /opt/ssl/zhiqingyun-demo.isxcode.com.key \
--fullchain-file /opt/ssl/zhiqingyun-demo.isxcode.com.pem \
--reloadcmd     "nginx -s reload"
vim /etc/nginx/conf.d/zhiqingyun-demo.conf
# ------------------------------ 至轻云demo演示环境 ------------------------------
server {
    listen             80;
    listen             [::]:80;
    server_name        zhiqingyun-demo.isxcode.com;
    rewrite ^(.*)$ https://${server_name}$1 permanent;
}

server {
    listen          443 ssl;
    listen          [::]:443 ssl;
    server_name     zhiqingyun-demo.isxcode.com;

    ssl_certificate             "/opt/ssl/zhiqingyun-demo.isxcode.com.pem";
    ssl_certificate_key         "/opt/ssl/zhiqingyun-demo.isxcode.com.key";
    ssl_session_cache           shared:SSL:1m;
    ssl_session_timeout         10m;
    ssl_ciphers                 HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;

    client_max_body_size 50M;
      
    location / {
        proxy_pass http://172.19.234.5:8080/;
        
        # 建议添加以下代理头,让后端获取真实客户端信息
        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;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }
    
    error_page 404 /404.html;
    location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
vim /etc/nginx/conf.d/zhiqingyun-website.conf
# ------------------------------ 至轻云官网 ------------------------------
server {
    listen             80;
    listen             [::]:80;
    server_name        zhiqingyun.isxcode.com;
    rewrite ^(.*)$ https://${server_name}$1 permanent;
}

server {
    listen          443 ssl;
    listen          [::]:443 ssl;
    server_name     zhiqingyun.isxcode.com;

    ssl_certificate             "/opt/ssl/zhiqingyun.isxcode.com.pem";
    ssl_certificate_key         "/opt/ssl/zhiqingyun.isxcode.com.key";
    ssl_session_cache           shared:SSL:1m;
    ssl_session_timeout         10m;
    ssl_ciphers                 HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers   on;
    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;

    location / {
        proxy_pass http://172.19.234.5:3000/;
        
        # 建议添加以下代理头,让后端获取真实客户端信息
        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;
    }

    location /.well-known/acme-challenge/ {
        root /var/www/html;
    }
   
    location = /google61d307ee156197a1.html {
       alias /data/nginx/google61d307ee156197a1.html;
    }   

    location = /sitemap.xml {
       alias /data/nginx/sitemap.xml;
    }
 
    error_page 404 /404.html;
    location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
    }
}
nginx -t
systemctl reload nginx

拷贝图片资源

mkdir -p /data/file

系统测试一下服务


spark 项目初始化
https://ispong.isxcode.com/hadoop/spark/spark 项目初始化/
Author
ispong
Posted on
July 1, 2026
Licensed under