Server migration
This article explains the applicable scenarios, operation steps, and key configurations of server migration to help users complete environment deployment and verification.
For example, the installation directory:/opt/zhiqingyun
Back up data
cd /opt/zhiqingyun
# 压缩数据
tar -czvf resources.tar.gz resources
tar -czvf resources_bak.tar.gz resources_bak
# 下载数据
scp root@127.0.0.1:/opt/zhiqingyun/resources.tar.gz ~/Downloads/
scp root@127.0.0.1:/opt/zhiqingyun/resources_bak.tar.gz ~/Downloads/
Back up project configuration files
scp root@127.0.0.1:/root/application-local.yml ~/Downloads/
backup ssl certificate
scp root@127.0.0.1:/root/zhiqingyun-demo.isxcode.com.key ~/Downloads/
scp root@127.0.0.1:/root/zhiqingyun-demo.isxcode.com.pem ~/Downloads/
scp root@127.0.0.1:/root/zhiqingyun.isxcode.com.key ~/Downloads/
scp root@127.0.0.1:/root/zhiqingyun.isxcode.com.pem ~/Downloads/
Back up NGINX configuration files
scp root@127.0.0.1:/etc/nginx/nginx.conf ~/Downloads/
New server port number open check
- System: CentOS8.5
- Open port numbers: 22, 80, 443
New server - offline installation of java
scp /Users/ispong/OneDrive/Downloads/linux/java/zulu17.66.19-ca-jdk17.0.19-linux_x64.tar.gz root@127.0.0.1:/tmp
tar -vzxf /tmp/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 ~/.bashrc <<-'EOF'
export JAVA_HOME=/opt/java
export PATH=$PATH:$JAVA_HOME/bin
EOF
source ~/.bashrc
rm -f /tmp/zulu17.66.19-ca-jdk17.0.19-linux_x64.tar.gz
java -version
New server-install nodejs offline
scp /Users/ispong/OneDrive/Downloads/linux/node/node-v18.20.5-linux-x64.tar.xz root@127.0.0.1:/tmp
cd /tmp
tar -xvJf node-v18.20.5-linux-x64.tar.xz
mv node-v18.20.5-linux-x64 /opt/
ln -s /opt/node-v18.20.5-linux-x64 /opt/node
tee -a ~/.bashrc <<-'EOF'
export NODE_HOME=/opt/node
export PATH=$PATH:${NODE_HOME}/bin
EOF
source ~/.bashrc
npm config set registry https://registry.npmmirror.com/
npm install pm2 -g
rm -f /tmp/node-v18.20.5-linux-x64.tar.xz
pm2 -version
New Server - Installing NGINX Offline
scp /Users/ispong/OneDrive/Downloads/linux/nginx/nginx-1.26.2-1.el8.ngx.x86_64.rpm root@127.0.0.1:/tmp
cd /tmp
rpm -ivh nginx-1.26.2-1.el8.ngx.x86_64.rpm
rm -f /tmp/nginx-1.26.2-1.el8.ngx.x86_64.rpm
nginx
Upload files
scp /Users/ispong/Downloads/zhiqingyun-demo.isxcode.com.pem root@127.0.0.1:/root
scp /Users/ispong/Downloads/zhiqingyun-demo.isxcode.com.key root@127.0.0.1:/root
scp /Users/ispong/Downloads/zhiqingyun.isxcode.com.key root@127.0.0.1:/root
scp /Users/ispong/Downloads/zhiqingyun.isxcode.com.pem root@127.0.0.1:/root
scp /Users/ispong/Downloads/application-local.yml root@127.0.0.1:/root
scp /Users/ispong/Downloads/resources.tar.gz root@127.0.0.1:/root
scp /Users/ispong/Downloads/nginx.conf root@127.0.0.1:/root
Move files
mkdir -p /data/nginx/ssl/
cp /root/zhiqingyun-demo.isxcode.com.pem /data/nginx/ssl/
cp /root/zhiqingyun-demo.isxcode.com.key /data/nginx/ssl/
cp /root/zhiqingyun.isxcode.com.pem /data/nginx/ssl/
cp /root/zhiqingyun.isxcode.com.key /data/nginx/ssl/
mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf_bak
mv /root/nginx.conf /etc/nginx/nginx.conf
mkdir -p /opt/zhiqingyun
mkdir -p /opt/zhiqingyun/resources_bak
tar -vzxf /root/resources.tar.gz -C /opt/zhiqingyun
rm -f /root/resources.tar.gz
Fix NGINX.pid
ps -C nginx -o pid= | head -n 1 | awk '{print $1}' > /run/nginx.pid
cat /run/nginx.pid
