spark 项目初始化
Last updated on July 22, 2026 am
🧙 Questions
初始化至轻云服务器
☄️ Ideas
修改hostname防止看错服务器
ssh-copy-id root@zhiqingyun.isxcode.com
ssh root@zhiqingyun.isxcode.com
hostnamectl set-hostname zhiqingyun创建下载目录
mkdir -p /tmp/downloads下载并安装openjdk17
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数据库 2.3.232
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目录
gradle package
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.ymlserver:
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/zhiqingyun
spark-yun:
agent-retry-count: 3
agent-retry-interval: 2000
default-agent-port: 30177
tmp-dir: /tmp启动项目
bash /opt/zhiqingyun/bin/start.sh安装fnm + node22 + 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
echo 'eval "$(fnm env --use-on-cd)"' | tee -a /etc/profile
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安装acme
scp /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;
}
}申请ssl证书
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"
# 查看定时器是否开启
cat /var/spool/cron/root配置ssl证书
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
vim /etc/nginx/nginx.confuser 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;
charset utf-8;
server_tokens off;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
keepalive_requests 500;
client_max_body_size 50m;
# ============ gzip ===============
gzip on;
gzip_buffers 16 8k;
gzip_comp_level 4;
gzip_disable "MSIE [1-6]\.";
gzip_http_version 1.1;
gzip_min_length 1024;
gzip_proxied any;
gzip_vary on;
gzip_types
text/plain
text/css
text/xml
text/javascript
application/javascript
application/json
application/xml
application/rss+xml
application/atom+xml
image/svg+xml
font/ttf
font/otf
font/woff
font/woff2;
# ============ proxy defaults for PM2 / Nuxt ===============
proxy_http_version 1.1;
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;
proxy_connect_timeout 30s;
proxy_send_timeout 60s;
proxy_read_timeout 60s;
proxy_buffering on;
proxy_buffer_size 16k;
proxy_buffers 8 16k;
proxy_busy_buffers_size 32k;
include /etc/nginx/conf.d/*.conf;
}重新启动nginx
nginx -t
systemctl reload nginx拷贝官网所需资源上传
mkdir -p /data/zhiqingyun
scp -r /Users/ispong/OneDrive/Downloads/zhiqingyun root@zhiqingyun.isxcode.com:/data系统测试
清理安装资源
rm -rf /tmp/downloads/🔗 Links
spark 项目初始化
https://ispong.isxcode.com/hadoop/spark/spark 项目初始化/