Debian手动部署幻兽帕鲁服务端
安装依赖apt-get install lib32gcc-s1
创建&切换用户
创建用户steam,并设置密码,修改用户默认的Shell为Bash
useradd -m steam
passwd steam
usermod -s /bin/bash steam
切换到steam用户su - steam
下载SteamCMD
在steam用户的主文件夹下面,创建文件夹SteamCMD,并且进入文件夹SteamCMDmkdir ~/SteamCMD && cd ~/SteamCMD
下载并解压SteamCMDcurl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
下载&运行服务端
下载帕鲁服务端./steamcmd.sh +login anonymous +app_update 2394010 validate +quit
以上命令也可用于服务端部署后的版本更新
进入帕鲁服务端目录,并运行服务端
cd ~/Steam/steamapps/common/PalServer
./PalServer.sh
运行会报错,提示找不到steamclient.so,错误信息如下:
/home/steam/.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
解决方法
mkdir -p ~/.steam/sdk64/
~/SteamCMD/steamcmd.sh +login anonymous +app_update 1007 +quit
cp ~/Steam/steamapps/common/Steamworks\ SDK\ Redist/linux64/steamclient.so ~/.steam/sdk64/
再次运行服务端,出现以下信息,表示运行正常
./PalServer.sh
Shutdown handler: initalize.
Increasing per-process limit of core file size to infinity.
dlopen failed trying to load:
steamclient.so
with error:
steamclient.so: cannot open shared object file: No such file or directory
[S_API] SteamAPI_Init(): Loaded '/home/steam/.steam/sdk64/steamclient.so' OK. (First tried local 'steamclient.so')
部署Systemd服务(root权限操作)vim /etc/systemd/system/palserver.service
粘贴以下内容
[Unit]
Description=Palworld Server
Wants=network-online.target
After=syslog.target network.target nss-lookup.target network-online.target
[Service]
WorkingDirectory=/home/steam/Steam/steamapps/common/PalServer
ExecStart=/bin/bash -c "/home/steam/Steam/steamapps/common/PalServer/PalServer.sh -port=8211 -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS"
LimitNOFILE=100000
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s INT $MAINPID
Restart=always
RestartSec=10
User=steam
Group=steam
[Install]
WantedBy=multi-user.target
PalServer.sh后面的运行参数,可以参考下面的链接进行修改
https://github.com/1024HQ/Fix-Palworld-Dedicated-Optimize-Server-FPS
服务启动、停止、重启、状态
systemctl start palserver
systemctl stop palserver
systemctl restart palserver
systemctl status palserver
存档备份、恢复
脚本根据实际路径进行修改,可以通过cron定时执行备份脚本,自动进行备份
备份脚本
#!/bin/bash
# 设置时区为东八区
export TZ="Asia/Shanghai"
# 设置备份目录
backup_dir="/home/Backup/PalSave"
# 设置服务端配置、存档备份文件名,以当前日期和时间为后缀
game_backup_file="${backup_dir}/Backup_$(date +\%Y\%m\%d_\%H\%M\%S).tar.gz"
config_backup_file="${backup_dir}/Config_Backup_$(date +\%Y\%m\%d_\%H\%M\%S).tar.gz"
# 设置历史备份文件名,用于自动删除
old_game_backup_file="${backup_dir}/Backup_$(date -d -14day +\%Y\%m\%d_*).tar.gz"
old_config_backup_file="${backup_dir}/Config_Backup_$(date -d -14day +\%Y\%m\%d_*).tar.gz"
# 设置服务端配置、存档文件夹路径
game_path=/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames
config_path=/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config
# 创建备份目录
mkdir -p "${backup_dir}"
# 复制、压缩保存文件夹到备份目录
cp -r "${game_path}" "${backup_dir}"
tar -czf "${game_backup_file}" -C "${backup_dir}" SaveGames
cp -r "${config_path}" "${backup_dir}"
tar -czf "${config_backup_file}" -C "${backup_dir}" Config
# 删除原始复制的文件夹
rm -r "${backup_dir}/SaveGames"
rm -r "${backup_dir}/Config"
# 删除历史备份文件
rm -f ${old_game_backup_file}
rm -f ${old_config_backup_file}
恢复脚本
#!/bin/bash
# 存档目录
savegames_dir="/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames"
# 备份目录
backup_dir="/home/Backup/PalSave"
# 列出存档备份文件,不显示服务端配置备份
backup_files=("${backup_dir}"/Backup_*.tar.gz)
# 打印备份文件列表供用户选择
echo "可用的备份:"
for ((i=0; i<${#backup_files[@]}; i++)); do
echo "$((i+1)). $(basename ${backup_files[$i]})"
done
# 提示用户选择备份文件
read -p "请输入要还原的备份编号: " choice
# 获取用户选择的备份文件路径
selected_backup="${backup_files[$((choice-1))]}"
# 提示用户确认
read -p "确定要从 ${selected_backup} 还原吗?(y/n): " confirm
# 如果用户确认进行恢复
if [[ $confirm == "y" || $confirm == "Y" ]]; then
# 删除存档目录中的原有 SaveGames 文件夹
rm -rf "${savegames_dir}/SaveGames"
# 解压缩备份文件到存档目录的上一级
tar -xzf "${selected_backup}" -C "$(dirname ${savegames_dir})"
# 修改存档目录权限
chmod -R 777 "${savegames_dir}"
echo "还原成功。"
else
echo "还原已取消。"
fi
服务端配置
服务端配置文件路径/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
服务端配置文件参数说明
https://tech.palworldgame.com/settings-and-operation/configuration
可以通过下面的这个工具,调整设置并生成配置文件
https://dysoncheng.github.io/PalWorldSettingGenerator/setting.html
管理员指令
成为管理员:/AdminPassword 管理员密码
/Shutdown {Seconds} {MessageText} 服务器关闭数秒后将收到您的 MessageText 通知
/DoExit 强制停止服务器
/Broadcast {MessageText} 向服务器中的所有玩家发送消息
/KickPlayer {SteamID} 将玩家从服务器中踢出
/BanPlayer {SteamID} 从服务器禁止玩家
/TeleportToPlayer {SteamID} 传送到目标玩家的当前位置
/TeleportToMe {SteamID} 目标玩家传送到您当前的位置
/ShowPlayers 显示所有已连接玩家的信息
/Info 显示服务器信息
/Save 保存世界数据
服务端迁移
1. 恢复游戏存档SaveGames
2. 恢复服务端配置PalWorldSettings.ini
3. 进入游戏存档路径SaveGames/0,复制下面文件夹的名称(为一个长字符串,这个是服务端的GUID)
4. 修改GameUserSettings.ini,路径:/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/GameUserSettings.ini
替换DedicatedServerName=
后面的服务端GUID
其他问题
游戏的地图开图存档是保存在客户端本地,建议开启Steam的存档云同步,或者手动备份恢复存档;本地存档丢失,进游戏会出现地图为未开图状态(地图未探索,已解锁的传送点、标记的地点都不显示,跟第一次进游戏一样)
本地存档路径%localappdata%\Pal\Saved\SaveGames
相关工具
服务端面板
https://github.com/Hoshinonyaruko/palworld-go
服务端工具包
https://github.com/magicbear/palworld-server-toolkit
幻兽帕鲁互动地图
https://map.caimogu.cc/palworld/paru_islands.html
来源:
https://blog.miku.su/article/palserver
https://tech.palworldgame.com/dedicated-server-guide
https://developer.valvesoftware.com/wiki/SteamCMD#Manually
https://xgamingserver.com/blog/the-ultimate-guide-to-migrating-your-palworld-dedicated-server/