优惠购买链接:
https://developer.aliyun.com/topic/ecs/huanshou?userCode=qhtxv10l
https://developer.aliyun.com/topic/ecs/huanshou?userCode=qhtxv10l
https://developer.aliyun.com/topic/ecs/huanshou?userCode=qhtxv10l
容器部署引导
Docker安装(中国大陆外区域用户)
sudo apt update sudo apt upgrade -y sudo apt install lsb-release ca-certificates apt-transport-https software-properties-common -y curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt -y install docker.io sudo systemctl enable docker --now
拉取镜像运行PalServer(中国大陆外区域用户)
sudo docker pull thijsvanloef/palworld-server-docker:latest # 创建 /palworld 用于在 ECS 上存储服务器配置和存档 sudo groupadd steam && sudo useradd steam|| echo "ignore" sudo mkdir /PalSaved && sudo chown -R steam:steam /PalSaved docker run -d \ --name palworld-server \ -p 8211:8211/udp \ -p 27015:27015/udp \ -v /PalSaved:/palworld/Pal/Saved/ \ -e PUID=1000 \ -e PGID=1000 \ -e PORT=8211 \ -e PLAYERS=16 \ -e MULTITHREADING=true \ -e RCON_ENABLED=true \ -e RCON_PORT=25575 \ -e TZ=UTC \ -e COMMUNITY=false \ -e SERVER_NAME="World of Pals" \ -e SERVER_DESCRIPTION="Awesome World of Pal" \ --restart unless-stopped \ --stop-timeout 30 \ thijsvanloef/palworld-server-docker:latest
Docker安装及拉取镜像运行PalServer(中国大陆区域用户)
sudo dnf config-manager --add-repo=https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo sudo dnf -y install dnf-plugin-releasever-adapter --repo alinux3-plus sudo dnf -y install docker-ce --nobest sudo systemctl start docker sudo systemctl enable docker # 获取 Palworld 服务器 docker 镜像。 REGION=`curl -s 100.100.100.200/latest/meta-data/region-id` # 某些地域没有镜像仓库,就近获取 if [ "$REGION" = "cn-nanjing" ] || [ "$REGION" = "cn-fuzhou" ]; then REGION=.cn-shanghai; elif [ "$REGION" = "cn-wuhan" ]; then REGION=.cn-chengdu; elif [ "$REGION" = "ap-northeast-2" ]; then REGION=.ap-northeast-1; elif [ "$REGION" = "ap-southeast-6" ] || [ "$REGION" = "ap-southeast-6" ]; then REGION=.ap-southeast-1; else REGION=-vpc.$REGION; fi DOCKER_IMAGE_URL=registry${REGION}.aliyuncs.com/imbolo/palworld-server:latest sudo docker pull $DOCKER_IMAGE_URL # 创建 /PalSaved 用于在 ECS 上存储服务器配置和存档 sudo groupadd -g 1000 steam && sudo useradd -u 1000 -g steam -m steam || echo "ignore" sudo mkdir /PalSaved && sudo chown -R 1000:1000 /PalSaved sudo docker run --restart=always --user 1000:1000 -v /PalSaved:/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/ --name palworld-server --net host -dit $DOCKER_IMAGE_URL echo '运行成功'
游戏连接示例
备份及迁移
数据备份
全备份
# 备份到当前用户所在目录 zip -r PalWorld-$(date +"%Y-%m-%d_%H-%M-%S").zip /PalSaved/
仅备份用户数据
zip -r PalWorld-SaveGames-$(date +"%Y-%m-%d_%H-%M-%S").zip /PalSaved/SaveGames/
自动备份
# 全备份+用户备份,如果只需要一个,那么请在另一个命令行前加上 # cat > /root/pal-backup.sh << EOF zip -r /root/PalWorld-\$(date +"%Y-%m-%d_%H-%M-%S").zip /PalSaved/ zip -r /root/PalWorld-SaveGames-\$(date +"%Y-%m-%d_%H-%M-%S").zip /PalSaved/SaveGames/ echo `date` --- backup successful >> /root/pal-backup.log EOF chmod +x /root/pal-backup.sh # 以每五分钟备份一次 echo "*/5 * * * * /root/pal-backup.sh" >> /var/spool/cron/crontabs/root # 若是每小时备份一次 # echo "0 * * * * /root/pal-backup.sh" >> /var/spool/cron/crontabs/root
数据恢复
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
注意,导入备份数据千万不能在备份数据时,增加额外的文件层,例如
解压Save其层级为 xxx/Saved/Saved/
一定要是单纯的 Saved目录中的内容
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
全备份恢复(Saved)
sudo cat > /root/pal-restore.sh << EOF echo "请输入Saved存档的绝对路径(eg: /root/pal-arch.zip): " read ziploc unzip -o \${ziploc} -d /PalSaved LSN=\$(ls -tr /PalSaved/SaveGames/0/|awk 'NR==1{print \$1}') sed -i "s/^DedicatedServerName=.*/DedicatedServerName=\$LSN/" /PalSaved/Config/LinuxServer/GameUserSettings.ini sudo groupadd steam && sudo useradd steam|| echo "steam user or group already exists, ignore" chown -R steam:steam /PalSaved sudo docker restart palworld-server docker ps EOF chmod +x /root/pal-restore.sh sudo bash /root/pal-restore.sh
用户数据恢复(SaveGames)
sudo cat > /root/pal-restore.sh << EOF echo "请输入SaveGames存档的绝对路径(eg: /root/pal-arch.zip): " read ziploc unzip -o \${ziploc} -d /PalSaved/ LSN=\$(ls -tr /PalSaved/SaveGames/0/|awk 'NR==1{print \$1}') sed -i "s/^DedicatedServerName=.*/DedicatedServerName=\$LSN/" /PalSaved/Config/LinuxServer/GameUserSettings.ini sudo groupadd steam && sudo useradd steam|| echo "steam user or group already exists, ignore" chown -R steam:steam /PalSaved sudo docker restart palworld-server docker ps EOF chmod +x /root/pal-restore.sh sudo bash /root/pal-restore.sh
第三方patch优化(1.3.0版本|中国大陆用户无法使用github)
风险操作,请备份后再操作
# 下载并替换文件 bindir=/palworld/Pal/Binaries/Linux/ docker exec palworld-server mv $bindir/PalServer-Linux-Test $bindir/PalServer-Linux-Test.bak docker exec palworld-server wget -O $bindir/PalServer-Linux-Test https://github.com/VeroFess/PalWorld-Server-Unoffical-Fix/releases/download/1.3.0-Update-3/PalServer-Linux-Test-Patch-Update-3 docker exec palworld-server chmod 755 $bindir/PalServer-Linux-Test sudo docker restart palworld-server
自动释放内存
cat > /root/auto-release-mem.sh << EOF freemem=\$(free -m|awk 'NR==2{print \$7}') if [ \$freemem -lt 100 ];then sudo docker restart palworld-server; sudo echo \$(date +"%Y-%m-%d_%H-%M-%S")---auto release memory successfully ! >> /root/release-mem.log; new_mem=\$(free -m|awk 'NR==2{print $7}') sudo echo \$(date +"%Y-%m-%d_%H-%M-%S")---current free memory is: \${new_mem}MB >> /root/release-mem.log; fi EOF chmod +x /root/auto-release-mem.sh echo "*/1 * * * * /root/auto-release-mem.sh" >> /var/spool/cron/crontabs/root
添加Swap内存
不建议操作,此设置有宕机风险,重启后开机过程会变长
# 根据自己的需求调整大小 此处为8G fallocate -l 8G /swapfile mkswap /swapfile && swapon /swapfile echo "/swapfile none swap sw 0 0" >> /etc/fstab