赞
踩
!!!说明:不只是幻兽帕鲁,后续大家想自己搭私服玩别的Steam游戏,大部分内容都可以做一个参考
下面部署步骤基于腾讯云,阿里云选镜像CentOs7.6操作是一样的,只是管理后台开放端口,绑安全组有点差异
说明:我们是4个人玩,目前3个据点,不到40级,地图基本探索完的状态,仅供参考,欢迎大佬讨论,优化
服务器镜像为Linux CentOs7.6
目前总共搭了3次服务器,做了2次数据迁移:
学生优惠,1080¥ 3年
游戏前期就,内存不够,带宽偶尔不够
339.72¥ 3个月
游戏中后期,带宽经常不够,导致延迟过高
280¥ 1月
内存和带宽基本满足,峰值也不至于导致游戏卡顿
目前的一个游戏状况,供大家思考,我们一般是4个人在玩
服务器一直开着,已经255天,开了3个据点,我个人39级,地图基本全探索,由于迁移服务器导致要重新探索开地图
五天无理由退款,刚退完
3分钟畅玩!一键部署幻兽帕鲁服务器 (aliyun.com)
应该也是五天无理由退款,不太清楚,还没退过
开机登录
我用的腾讯云CentOs 7.6
通过ssh连接,或者直接控制台链接都行
切换root用户
# 进来应该是lighthouse用户,sudo su - 切换到root操作
[lighthouse@VM-4-9-centos ~]$ sudo su -
[root@VM-4-9-centos ~]#
安装包
# 更新包管理工具
[root@VM-4-9-centos ~]# yum update -y
# steamcmd 需要32位操作系统包
[root@VM-4-9-centos ~]# yum install glibc.i686 libstdc++.i686 -y
# screen用来后台挂载启动服务的脚本执行
[root@VM-4-9-centos ~]# yum install screen -y
root创建steam用户,可以配置免密sudo
[root@VM-4-9-centos ~]# useradd -m steam
# 密码需要一定复杂度
[root@VM-4-9-centos ~]# passwd steam
Changing password for user steam.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
配置免密
[root@VM-4-9-centos ~]# visudo
# 打开后 按i编辑这个文件 然后 :wq保存
# steam ALL=(ALL) NOPASSWD: ALL
设置快捷操作别名
[root@VM-4-9-centos ~]# vim ~/.bashrc
# 添加如下快捷命令
# alias ro="sudo su -"
# alias steam="ro steam"
# 刷新
[root@VM-4-9-centos ~]# source ~/.bashrc
切换到steam用户操作
[root@VM-4-9-centos ~]# steam
# 先创建 后面服务启动缺少文件
[steam@VM-4-9-centos ~]$ mkdir -p ~/.steam/sdk64/
[steam@VM-4-9-centos ~]$ mkdir ~/Steam && cd ~/Steam
# 安装steamcmd
[steam@VM-4-9-centos Steam]$ tar -xvzf steamcmd_linux.tar.gz
# 启动steamcmd 下载Pal服务
[steam@VM-4-9-centos Steam]$ ./steamcmd.sh
steamcmd服务启动完成后,服务内操作
# 匿名账户登录,可能由于网络问题登录失败,重试下 Steam>login anonymous Connecting anonymously to Steam Public...OK Waiting for client config...OK Waiting for user info...OK # 安装或更新pal服务 Steam>app_update 2394010 validate # 安装缺少的sdk Steam>app_update 1007 Update state (0x61) downloading, progress: 0.00 (0 / 73781292) Update state (0x61) downloading, progress: 72.37 (53393660 / 73781292) Success! App '1007' fully installed. # 退出 Steam>quit # 补充64位sdk [steam@VM-4-9-centos Steam]$ cp ~/Steam/steamapps/common/Steamworks\ SDK\ Redist/linux64/steamclient.so ~/.steam/sdk64/
一些命令封装,也可以设置成服务通过service管理,具体工具脚本放到最下面
[steam@VM-4-9-centos Steam]$ vim ~/.bashrc
alias editPalConfig="vim /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini"
alias getDefaultPalConfig="cat /home/steam/Steam/steamapps/common/PalServer/DefaultPalWorldSettings.ini"
alias startPalServer="sh /home/steam/Script/startPalServer.sh"
alias stopPalServer="sh /home/steam/Script/stopPalServer.sh"
alias restartPalServer="sh /home/steam/Script/restartPalServer.sh"
alias backupPalServer="sh /home/steam/Script/backupPalServer.sh"
alias updatePalServer="sh /home/steam/Steam/steamcmd.sh"
alias getPalServerPid="ps -ef | grep PalServer-Linux | grep -v grep | awk '{print $2}'"
[steam@VM-4-9-centos Steam]$ source ~/.bashrc
UDP 8211 服务端口
UDP 25575 管理后台端口
[steam@VM-4-9-centos Steam]$ startPalServer
PalServer-S doesn't exist, create and execute start PalServer cmd
# 这个时候才会初始化Saved目录
[steam@VM-4-9-centos Steam]$ ll steamapps/common/PalServer/Pal/Saved
total 12
drwxrwxr-x 4 steam steam 4096 Jan 28 15:57 Config
drwxrwxr-x 2 steam steam 4096 Jan 28 15:57 ImGui
drwxrwxr-x 3 steam steam 4096 Jan 28 15:57 SaveGames
# Config目录是服务配置
# SaveGames是服务器及玩家存档 目录下XXXXXXXXXXXXXXXXXXXX里面的内容就是需要备份和恢复的存档
[steam@VM-4-9-centos Steam]$ ll steamapps/common/PalServer/Pal/Saved/SaveGames/0/
total 4
drwxrwxr-x 2 steam steam 4096 Jan 28 15:57 XXXXXXXXXXXXXXXXXXXX
# 这里停止服务 修改配置后再启动
[steam@VM-4-9-centos Steam]$ stopPalServer
[steam@VM-4-9-centos Steam]$ getDefaultPalConfig
[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=1.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.000000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=1.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=1.000000,CollectionDropRate=1.000000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.000000,DeathPenalty=All,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=72.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=32,ServerName="Default Palworld Server",ServerDescription="",AdminPassword="",ServerPassword="",PublicPort=8211,PublicIP="",RCONEnabled=False,RCONPort=25575,Region="",bUseAuth=True,BanListURL="https://api.palworldgame.com/api/banlist.txt")
这里给大家一个我们服务器的配置参考
[steam@VM-16-4-centos Script]$ editPalConfig
# 第一次是个空文件 直接i进入编辑 复制粘贴
# 这里我建议 每次拷贝出来 编辑完 再整个复制进去
# 输入ggdG删除
# 然后i进入编辑模式 Ctrl+V C复制粘贴新的进去
# :wq保存退出
服务器配置说明(略调高了经验和掉落概率,死亡不掉落,孵蛋没时间)
参数我就不仔细讲了,大家去搜下
注意替换PublicIP为自己服务器的公网ip
建议配置服务密码,否则可能会有陌生人进来
也可以配置admin后天密码,使用一些控制台功能 (查看玩家,剔除玩家,关闭服务器和通告)
游戏里回车进入输入,/AdminPassword 配置的管理员密码
幻兽帕鲁服务器管理员可以用的指令-服务器管理员可以用的指令攻略_3DM单机 (3dmgame.com)
[/Script/Pal.PalGameWorldSettings]
OptionSettings=(Difficulty=None,DayTimeSpeedRate=1.000000,NightTimeSpeedRate=1.000000,ExpRate=2.000000,PalCaptureRate=1.000000,PalSpawnNumRate=1.500000,PalDamageRateAttack=1.000000,PalDamageRateDefense=1.000000,PlayerDamageRateAttack=1.000000,PlayerDamageRateDefense=1.000000,PlayerStomachDecreaceRate=1.000000,PlayerStaminaDecreaceRate=1.000000,PlayerAutoHPRegeneRate=1.000000,PlayerAutoHpRegeneRateInSleep=1.000000,PalStomachDecreaceRate=1.000000,PalStaminaDecreaceRate=1.000000,PalAutoHPRegeneRate=1.000000,PalAutoHpRegeneRateInSleep=5.000000,BuildObjectDamageRate=1.000000,BuildObjectDeteriorationDamageRate=0.100000,CollectionDropRate=1.250000,CollectionObjectHpRate=1.000000,CollectionObjectRespawnSpeedRate=1.000000,EnemyDropItemRate=1.500000,DeathPenalty=None,bEnablePlayerToPlayerDamage=False,bEnableFriendlyFire=False,bEnableInvaderEnemy=True,bActiveUNKO=False,bEnableAimAssistPad=True,bEnableAimAssistKeyboard=False,DropItemMaxNum=3000,DropItemMaxNum_UNKO=100,BaseCampMaxNum=128,BaseCampWorkerMaxNum=15,DropItemAliveMaxHours=1.000000,bAutoResetGuildNoOnlinePlayers=False,AutoResetGuildTimeNoOnlinePlayers=72.000000,GuildPlayerMaxNum=20,PalEggDefaultHatchingTime=0.000000,WorkSpeedRate=1.000000,bIsMultiplay=False,bIsPvP=False,bCanPickupOtherGuildDeathPenaltyDrop=False,bEnableNonLoginPenalty=True,bEnableFastTravel=True,bIsStartLocationSelectByMap=True,bExistPlayerAfterLogout=False,bEnableDefenseOtherGuildPlayer=False,CoopPlayerMaxNum=4,ServerPlayerMaxNum=8,ServerName="XXXXX",ServerDescription="XXXXXX",AdminPassword="xxxxxxxx",ServerPassword="xxxxxxxx",PublicPort=8211,PublicIP="XXX.XXX.XXX.XXX",RCONEnabled=True,RCONPort=25575,Region="China",bUseAuth=True,BanListURL="https://api.palworldgame.com/api/banlist.txt")
[steam@VM-4-9-centos Steam]$ startPalServer
PalServer-S exists, connect and execute start PalServer cmd
# 然后就可以Steam启动游戏 连接私服开玩
如果大家有做存档备份,在上述开服步骤最后,设置完自定义配置文件后,不着急启动游戏
说明!!! 帕鲁的存档迁移会导致地图全黑,需要重新探索,即使传送点已经解锁过。再次进入游戏会进入开场动画,跳过就行
这里简单讲下如何恢复存档
# 首先每次开新的服务器都是不同的服务器ID
# 自己服务器ID去这个目录下看
# 旧服务器备份 找到服务ID
[steam@VM-16-4-centos ~] ll /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/
total 4
drwxrwxr-x 3 steam steam 4096 Jan 21 23:05 XXXXXXXXXXXXXXXXXXXX
# XXXXXXXXXXXXXXXXXXXX就是服务器ID
# cd 进入XXXXXXXXXXXXXXXXXXXX目录 下面的所有目录和文件就是服务和玩家数据 用于备份和恢复的
[steam@VM-16-4-centos 0]$ cd XXXXXXXXXXXXXXXXXXXX/
[steam@VM-16-4-centos XXXXXXXXXXXXXXXXXXXX]$ ll
total 9648
-rw-rw-r-- 1 steam steam 1576 Jan 28 03:41 LevelMeta.sav
-rw-rw-r-- 1 steam steam 9869767 Jan 28 03:42 Level.sav
drwxrwxr-x 2 steam steam 4096 Jan 27 13:21 Players
首先旧服务器需要备份存档,打包,可以参考我下面的备份脚本,执行一下,或者手动操作
[steam@VM-16-4-centos Steam] mkdir ~/backup && cd ~/backup [steam@VM-16-4-centos backup]$ cd /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/XXXXXXXXXXXXXXXXXXXX && tar -czvf "/home/steam/backup/pal_backup_$(date +'%Y%m%d_%H%M%S').tar.gz" . ./ ./LevelMeta.sav ./Level.sav ./Players/ ./Players/aXXXXXXXXXXXXXXXXXXXX.sav ./Players/bXXXXXXXXXXXXXXXXXXXX.sav ./Players/cXXXXXXXXXXXXXXXXXXXX.sav ./Players/dXXXXXXXXXXXXXXXXXXXX.sav # 可以在backup目录里找到压缩文件 [steam@VM-16-4-centos XXXXXXXXXXXXXXXXXXXX]$ ll ~/backup total 27460 -rw-rw-r-- 1 steam steam 9903467 Jan 28 16:49 pal_backup_20240128_164959.tar.gz # 这里直接使用scp传输 旧服务器生成ssh公钥 直接三次回车 # 切换到root用户 [root@VM-16-4-centos-centos ~]# ssh-keygen -t rsa # 旧服务器查看公钥 [root@VM-16-4-centos-centos ~]# cat ~/.ssh/id_rsa.pub # 复制上述公钥粘贴到新服务器 新服务器也使用root用户 [root@VM-4-9-centos ~]# vim ~/.ssh/authorized_keys # ssh 连接测试 旧服务器连接到新服务器 文件传输也是旧的到新的 xxx.xxx.xxx.xxx为新服务器ip [root@VM-16-4-centos ~]# ssh root@xxx.xxx.xxx.xxx The authenticity of host 'xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx)' can't be established. ECDSA key fingerprint is SHA256:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. ECDSA key fingerprint is MD5:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'xxx.xxx.xxx.xxx' (ECDSA) to the list of known hosts. Last login: Sun Jan 28 15:04:51 2024 # 连接到新服务器后退出 回到旧服务器 [root@VM-4-9-centos ~]# exit logout Connection to xxx.xxx.xxx.xxx closed. [root@VM-16-4-centos ~]# # 新服务器Steam用户创建好 backup目录 mkdir ~/backup 如果创建过了可以忽略 # xxx.xxx.xxx.xxx 替换成新服务器 公网ip, 如果是同一家的云服务器可以用内网ip,快一些,不过存档文件也不大 [steam@VM-16-4-centos XXXXXXXXXXXXXXXXXXXX]$ scp /home/steam/backup/pal_backup_20240128_164959.tar.gz root@xxx.xxx.xxx.xxx:/home/steam/backup/ # 下面可能会展示传输进度条 或者只展示个文件名 pal_backup_20240128_164959.tar.gz
然后新服务器接收到备份存档后,修改权限,解压缩,再启动服务
如果大家有定期备份数据,这里也可以用来回档到指定时间的备份文件
# 由于我这里是root用户配置的ssh 所以文件传输过去也是root用户 修改下文件权限 [root@VM-4-9-centos ~]# ll /home/steam/backup/ total 9672 -rw-r--r-- 1 root root 9903467 Jan 28 17:18 pal_backup_20240128_164959.tar.gz [root@VM-4-9-centos ~]# chown -R steam:steam /home/steam/backup [root@VM-4-9-centos ~]# ll /home/steam/backup/ total 9672 -rw-r--r-- 1 steam steam 9903467 Jan 28 17:18 pal_backup_20240128_164959.tar.gz # 切换到steam用户 [root@VM-4-9-centos ~]# steam Last login: Sun Jan 28 15:15:26 CST 2024 on pts/0 # 新服务器恢复 找到服务ID [steam@VM-4-9-centos ~] ll /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/ total 4 drwxrwxr-x 2 steam steam 4096 Jan 28 15:57 XXXXXXXXXXXXXXXXXXXX [steam@VM-4-9-centos ~] rm -rf /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/XXXXXXXXXXXXXXXXXXXX/* && tar -xvf /home/steam/backup/pal_backup_20240128_164959.tar.gz -C /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/XXXXXXXXXXXXXXXXXXXX ./ ./LevelMeta.sav ./Level.sav ./Players/ ./Players/aXXXXXXXXXXXXXXXXXXXX.sav ./Players/bXXXXXXXXXXXXXXXXXXXX.sav ./Players/cXXXXXXXXXXXXXXXXXXXX.sav ./Players/dXXXXXXXXXXXXXXXXXXXX.sav # 然后启动服务 [steam@VM-4-9-centos ~]$ startPalServer PalServer-S exists, connect and execute start PalServer cmd # 然后就可以Steam启动游戏 连接私服开玩
# 使用自带的crontab
[steam@VM-4-9-centos Steam]$ crontab -e
crontab: installing new crontab
# 进入 按i进入编辑
# 以下cron表达式供参考 前面五个字符分别表示 分时日月周 *表示每一个,比如每天
# 每天凌晨4点
0 4 * * * sh /home/steam/Script/restartPalServer.sh
# 这里如果服务器配置低一些 可能重启频率要高一些 不然内存顶不住,重启之后玩家会掉线 需手动重新连接
# 每2两小时
0 */2 * * * sh /home/steam/Script/restartPalServer.sh
# 也可以定时关闭 想玩了再手动开启服务restartPalServer.sh 替换为 stopPalServer.sh
# 由于我将备份脚本执行 放在了 重启或者关闭服务的脚本中 没有单独配置奔赴的 也可以手动配置 比如每30分钟备份一次数据
*/30 * * * * sh /home/steam/Script/backupPalServer.sh
# 先停服务 [steam@VM-4-9-centos Steam]$ stopPalServer # 然后启动steamcmd [steam@VM-4-9-centos Steam]$ ./steamcmd.sh 匿名账户登录,可能由于网络问题登录失败,重试下 Steam>login anonymous Connecting anonymously to Steam Public...OK Waiting for client config...OK Waiting for user info...OK # 更新pal服务 Steam>app_update 2394010 validate # 退出 Steam>quit # 启动服务 [steam@VM-4-9-centos Steam]$ startPalServer
# 重新写一个启动脚本 service的start脚本需要常驻 不再使用screen 只保留服务启动
[steam@VM-16-4-centos ~]$ vim /home/steam/Script/startPalServerBySystemctl.sh
[steam@VM-16-4-centos ~]$ cat /home/steam/Script/startPalServerBySystemctl.sh
#!/bin/bash
sh /home/steam/Steam/steamapps/common/PalServer/PalServer.sh -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS -publicip=xxx.xxx.xxx.xxx -publicport=8211 EpicApp=PalServer
[steam@VM-16-4-centos ~]$ cd /etc/systemd/system/
[steam@VM-16-4-centos system]$ sudo vim pal-server.service
# 写入如下pal-server服务配置
# 服务器开机自启
# 服务失败后重启
# 服务停止后进行备份
[Unit]
Description=QIQiangStudio PalServer
After=network.target
[Service]
ExecStart=/home/steam/Script/startPalServerBySystemctl.sh
ExecStopPost=/home/steam/Script/backupPalServer.sh
User=steam
Group=steam
Restart=always
RestartSec=10 # 服务失败时,10秒后重启
[Install]
WantedBy=multi-user.target
# 给上述service中配置的待执行脚本 赋予执行权限 [steam@VM-16-4-centos system]$ chmod +x /home/steam/Script/startPalServerBySystemctl.sh # 权限从 -rw-rw-r-- 变成 -rwxrwxr-x [steam@VM-16-4-centos system]$ chmod +x /home/steam/Script/backupPalServer.sh [steam@VM-16-4-centos system]$ sudo vim pal-server.service # 每次修改service配置 都要重载 [steam@VM-16-4-centos system]$ sudo systemctl daemon-reload # 允许开机自启 如果想关闭 将命令里的enable换成disable [steam@VM-16-4-centos system]$ sudo systemctl enable pal-server.service Created symlink from /etc/systemd/system/multi-user.target.wants/pal-server.service to /etc/systemd/system/pal-server.service. # 注释掉之前steam用户的脚本执行 行首添加# 关机或重启定时任务 # 或者直接dd删除掉 :wq保存 [steam@VM-16-4-centos system]$ crontab -e # systemctl管理service 均需要root用户 启动关闭重启 # 切换到root用户操作 并重新添加crontab [steam@VM-16-4-centos system]$ sudo su - [root@VM-16-4-centos ~]# crontab -e # 查看当前用户的crontab [root@VM-16-4-centos ~]# crontab -l # 每天凌晨4点重启服务 # 0 4 * * * systemctl restart pal-server.service # 每天凌晨4点关闭服务 0 4 * * * systemctl stop pal-server.service # 启动服务 [root@VM-16-4-centos ~]# systemctl start pal-server.service # 查看服务状态 [root@VM-16-4-centos ~]# systemctl status pal-server.service ● pal-server.service - QIQiangStudio PalServer Loaded: loaded (/etc/systemd/system/pal-server.service; enabled; vendor preset: disabled) Active: active (running) since Mon 2024-01-29 12:53:23 CST; 5s ago Main PID: 30118 (startPalServerB) CGroup: /system.slice/pal-server.service ├─30118 /bin/bash /home/steam/Script/startPalServerBySystemctl.sh ├─30119 sh /home/steam/Steam/steamapps/common/PalServer/PalServer.sh -useperfthreads -NoAsyncLoadingThread... └─30126 /home/steam/Steam/steamapps/common/PalServer/Pal/Binaries/Linux/PalServer-Linux-Test Pal -useperft... Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: dlopen failed trying to load: Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: steamclient.so Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: with error: Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: steamclient.so: cannot open shared object file...ory Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: [S_API] SteamAPI_Init(): Loaded '/home/steam/....o') Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: dlopen failed trying to load: Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: steamclient.so Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: with error: Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: steamclient.so: cannot open shared object file...ory Jan 29 12:53:25 VM-16-4-centos startPalServerBySystemctl.sh[30118]: [S_API] SteamAPI_Init(): Loaded '/home/steam/....o') Hint: Some lines were ellipsized, use -l to show in full. # 关闭服务 [root@VM-16-4-centos ~]# systemctl stop pal-server.service # 查看服务状态 [root@VM-16-4-centos backup]# systemctl status pal-server.service ● pal-server.service - QIQiangStudio PalServer Loaded: loaded (/etc/systemd/system/pal-server.service; enabled; vendor preset: disabled) Active: inactive (dead) since Mon 2024-01-29 12:53:52 CST; 2s ago Process: 30284 ExecStopPost=/home/steam/Script/backupPalServer.sh (code=exited, status=0/SUCCESS) Process: 30118 ExecStart=/home/steam/Script/startPalServerBySystemctl.sh (code=killed, signal=TERM) Main PID: 30118 (code=killed, signal=TERM) Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./ Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./LevelMeta.sav Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./Level.sav Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./Players/ Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./Players/aXXXXXXXXXXXXXXXXXXXX.sav Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./Players/bXXXXXXXXXXXXXXXXXXXX.sav Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./Players/cXXXXXXXXXXXXXXXXXXXX.sav Jan 29 12:53:52 VM-16-4-centos backupPalServer.sh[30284]: ./Players/dXXXXXXXXXXXXXXXXXXXX.sav Jan 29 12:53:52 VM-16-4-centos systemd[1]: Stopped QIQiangStudio PalServer. # 重启服务 [root@VM-16-4-centos ~]# systemctl restart pal-server.service # 查看服务日志 [root@VM-16-4-centos ~]# journalctl -u pal-server.service # 查看关闭服务时的备份文件 [root@VM-16-4-centos backup]# ll /home/steam/backup/ | grep 20240129_12 -rw-r--r-- 1 steam steam 10224178 Jan 29 12:53 pal_backup_20240129_125352.tar.gz
[steam@VM-4-9-centos Steam] mkdir ~/Script && cd ~/Script
[steam@VM-4-9-centos Script] vim xxxPalServer.sh
startPalServer.sh
注意替换成自己的公网ip
#!/bin/bash # 检查是否已存在名为session_name的screen会话 session_name="PalServer-S" cmd_str="sh /home/steam/Steam/steamapps/common/PalServer/PalServer.sh -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS -publicip=xxx.xxx.xxx.xxx -publicport=8211 EpicApp=PalServer" if screen -list | grep -q "${session_name}"; then # 如果存在,则执行命令 echo "${session_name} exists, connect and execute start PalServer cmd" screen -S "${session_name}" -X stuff "${cmd_str}"$'\n' else # 如果不存在,则创建新的会话并执行命令 echo "${session_name} doesn't exist, create and execute start PalServer cmd" screen -dmS "${session_name}" sleep 1 # 等待会话创建完成 screen -S "${session_name}" -X stuff "${cmd_str}"$'\n' fi
这里用了screen来后台执行启动服务的脚本
# 查看当前有哪些后台 [steam@VM-4-9-centos Steam]$ screen -ls There is a screen on: 10863.PalServer-S (Detached) 1 Socket in /var/run/screen/S-steam. # 如果只有一个 可以直接 screen -r 恢复到后台连接 [steam@VM-4-9-centos Steam]$ screen -r # 如果有多个 可以 screen -r 指定名称 [steam@VM-4-9-centos Steam]$ screen -r 10863.PalServer-S # 如果之前的后台异常退出了 可以加 -D 先剔除之前的连接 [steam@VM-4-9-centos Steam]$ screen -D -r 10863.PalServer-S # 进入后可以手动关闭服务 键入 Ctrl + C # 退出后台 键入Ctrl + A + D [detached from 10863.PalServer-S]
stopPalServer.sh
想关闭服务时去备份数据,可以手动取消最下面的注释
#!/bin/bash # 检查是否存在名为 PalServer-Linux 的进程 PID=`ps -ef | grep PalServer-Linux | grep -v grep | awk '{print $2}'` if [ -n "$PID" ]; then # 存在进程,杀死它 kill -9 $PID # 添加错误检查以确保进程已终止 sleep 5s # 给进程一些时间来终止 if ps -p $PID > /dev/null; then echo "Failed to kill the process with PID $PID" exit 1 fi fi # 启动前进行备份 # sh /home/steam/Script/backupPalServer.sh
restartPalServer.sh
注意替换成自己的公网ip
想重启服务时去备份数据,可以手动取消注释
#!/bin/bash # 检查是否存在名为 PalServer-Linux 的进程 PID=`ps -ef | grep PalServer-Linux | grep -v grep | awk '{print $2}'` if [ -n "$PID" ]; then # 存在进程,杀死它 kill -9 $PID # 添加错误检查以确保进程已终止 sleep 10s # 给进程一些时间来终止 if ps -p $PID > /dev/null; then echo "Failed to kill the process with PID $PID" exit 1 fi fi # 启动前进行备份 # sh /home/steam/Script/backupPalServer.sh # 在此处添加剩余的脚本代码,包括启动 PalServer 的部分 session_name="PalServer-S" cmd_str="sh /home/steam/Steam/steamapps/common/PalServer/PalServer.sh -useperfthreads -NoAsyncLoadingThread -UseMultithreadForDS -publicip=xxx.xxx.xxx.xxx -publicport=8211 EpicApp=PalServer" if screen -list | grep -q "${session_name}"; then # 如果存在,则执行命令 echo "${session_name} exists, connect and execute start PalServer cmd" screen -S "${session_name}" -X stuff "${cmd_str}"$'\n' else # 如果不存在,则创建新的会话并执行命令 echo "${session_name} doesn't exist, create and execute start PalServer cmd" screen -dmS "${session_name}" sleep 1 # 等待会话创建完成 screen -S "${session_name}" -X stuff "${cmd_str}"$'\n' fi
创建backup目录
[steam@VM-4-9-centos Script]$ mkdir ~/backup
backupPalServer.sh
注意替换成自己服务器ID目录
# 自己服务器ID去这个目录下看
[steam@VM-4-9-centos Script] ll /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/
total 4
drwxrwxr-x 2 steam steam 4096 Jan 28 15:57 XXXXXXXXXXXXXXXXXXXX
#!/bin/bash
cd /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/SaveGames/0/XXXXXXXXXXXXXXXXXXXX && tar -czvf "/home/steam/backup/pal_backup_$(date +'%Y%m%d_%H%M%S').tar.gz" .
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。