CPU | 4核(推荐) |
---|---|
内存 | 16GB 建议使用 32GB 以上才能稳定运行。用8GB启动服务器是可以的,但是玩得越久,服务器就会因为内存不足而崩溃。 |
网络 | UDP 端口 8211(默认) |
作者使用的是腾讯云轻量应用服务器4C8G配置,系统镜像为CentOS7.6
首先在轻量应用服务器控制台防火墙中放通tcp1194
sudo yum install epel-release
sudo yum install -y open easy-rsa
sudo mkdir /etc/open/easy-rsa
sudo mkdir /etc/open/ccd
sudo cp -ai /usr/share/easy-rsa/3/* /etc/open/easy-rsa/
cd /etc/open/easy-rsa
sudo ./easyrsa init-pki
sudo ./easyrsa build-ca nopass
sudo ./easyrsa build-server-full server nopass
sudo ./easyrsa gen-dh
sudo cp /etc/open/easy-rsa/pki/ca.crt /etc/open/
sudo cp /etc/open/easy-rsa/pki/issued/server.crt /etc/open/
sudo cp /etc/open/easy-rsa/pki/private/server.key /etc/open/
sudo cp /etc/open/easy-rsa/pki/dh.pem /etc/open/
创建配置文件
vim /etc/open/server.conf
port 1194 #端口
proto tcp #协议
dev tun #采用路由隧道模式
ca ca.crt #ca证书的位置
cert server.crt #服务端公钥的位置
key server.key #服务端私钥的位置
dh dh.pem #证书校验算法
server 10.8.0.0 255.255.255.0 #给客户端分配的地址池
ifconfig-pool-persist ipp.txt #地址池记录文件位置,未来让open客户端固定ip地址使用的
keepalive 10 120 #存活时间,10秒ping一次,120秒如果未收到响应则视为短线
max-clients 100 #最多允许100个客户端连接
status open-status.log #日志位置,记录open状态
log /var/log/open.log #open日志记录位置
verb 3 #open版本
client-to-client #允许客户端与客户端之间通信
persist-key #通过keepalive检测超时后,重新启动VPN,不重新读取
persist-tun #检测超时后,重新启动VPN,一直保持tun是linkup的,否则网络会先linkdown然后再linkup
duplicate-cn #客户端密钥(证书和私钥)是否可以重复
comp-lzo #启动lzo数据压缩格式
client-config-dir /etc/open/ccd #配置客户端配置文件目录
启动服务端
sudo systemctl start open@server
设置开机自启
sudo systemctl enable open@server
服务端配置完成
官方地址https://open.net/client/client-connect--for-windows/
cd /etc/open/easy-rsa
./easyrsa build-client-full client_name pwd
之后将ca.crt client_name.crt client_name.key都下载下来
文件位置
ca.crt >> /etc/open/easy-rsa/pki
client_name.crt >> /etc/open/easy-rsa/pki/issued
client_name.key >> /etc/open/easy-rsa/pki/private
sudo systemctl restart open@server
client
dev tun
proto tcp
remote 服务端ip 1194
resolv-retry infinite
nobind
ca ca.crt
cert client_name.crt
key client_name.key
verb 3
persist-key
comp-lzo
将ca.crt client_name.crt client_name.key与client_name.o放置在同一个文件夹中
双击文件即可链接
yum install glibc.i686 libstdc++.i686
sudo useradd -m steam
sudo passwd steam
sudo -u steam -s
cd /home/steam
mkdir ~/Steam && cd ~/Steam
curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
官方教程地址https://tech.palworldgame.com/dedicated-server-guide#linux
./steamcmd.sh +login anonymous +app_update 2394010 validate +quit
下载完成后 进入到游戏目录中 尝试运行(务必执行一次PalServer.sh)
cd steamapps/common/PalServer
./PalServer.sh
如果出现报错
.steam/sdk64/steamclient.so: cannot open shared object file: No such file or directory
则回到steamcmd目录
cd /home/steam/Steam
mkdir -p ~/.steam/sdk64/
./steamcmd.sh +login anonymous +app_update 1007 +quit
cp ~/Steam/steamapps/common/Steamworks\ SDK\ Redist/linux64/steamclient.so ~/.steam/sdk64/
然后重新尝试运行即可
cd steamapps/common/PalServer
./PalServer.sh
运行后若出现下面的报错为正常情况
sh: xdg-user-dir: command not found
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')
CAppInfoCacheReadFromDiskThread took 1 milliseconds to initialize
Setting breakpad minidump AppID = 2394010
[S_API FAIL] Tried to access Steam interface SteamUser021 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamFriends017 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface STEAMAPPS_INTERFACE_VERSION008 before SteamAPI_Init succeeded.
[S_API FAIL] Tried to access Steam interface SteamNetworkingUtils004 before SteamAPI_Init succeeded.
默认配置文件位置/home/steam/Steam/steamapps/common/PalServer/DefaultPalWorldSettings.ini
cp /home/steam/Steam/steamapps/common/PalServer/DefaultPalWorldSettings.ini
/home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
vim /home/steam/Steam/steamapps/common/PalServer/Pal/Saved/Config/LinuxServer/PalWorldSettings.ini
配置文件参数(使用OpenVPN,无需填写PublicIP):
Difficulty | 英文 | 机翻 |
---|---|---|
DayTimeSpeedRate | Day time speed | 白天速度 |
NightTimeSpeedRate | Night time speed | 夜间速度 |
ExpRate | EXP rate | 经验率 |
PalCaptureRate | Pal capture rate | 好友捕获率 |
PalSpawnNumRate | Pal appearance rate | Pal出现率 |
PalDamageRateAttack | Damage from pals multipiler | 好友倍增器造成的伤害 |
PalDamageRateDefense | Damage to pals multipiler | 对好友倍增器造成伤害 |
PlayerDamageRateAttack | Damage from player multipiler | 玩家倍增造成的伤害 |
PlayerDamageRateDefense | Damage to player multipiler | 对玩家造成的伤害乘数 |
PlayerStomachDecreaceRate | Player hunger depletion rate | 玩家饥饿消耗率 |
PlayerStaminaDecreaceRate | Player stamina reduction rate | 玩家体力减少率 |
PlayerAutoHPRegeneRate | Player auto HP regeneration rate | 玩家自动HP回复率 |
PlayerAutoHpRegeneRateInSleep | Player sleep HP regeneration rate | 玩家睡眠HP回复率 |
PalStomachDecreaceRate | Pal hunger depletion rate | 伙伴饥饿消耗率 |
PalStaminaDecreaceRate | Pal stamina reduction rate | 帕尔耐力减少率 |
PalAutoHPRegeneRate | Pal auto HP regeneration rate | Pal自动HP回复率 |
PalAutoHpRegeneRateInSleep | Pal sleep health regeneration rate (in Palbox) | Pal 睡眠健康恢复率(Palbox 中) |
BuildObjectDamageRate | Damage to structure multipiler | 多层结构损坏 |
BuildObjectDeteriorationDamageRate | Structure determination rate | 结构测定率 |
CollectionDropRate | Getherable items multipiler | 可收集物品倍增器 |
CollectionObjectHpRate | Getherable objects HP multipiler | 可收集的物体 HP 倍增器 |
CollectionObjectRespawnSpeedRate | Getherable objects respawn interval | 可收集物体的重生间隔 |
EnemyDropItemRate | Dropped Items Multipiler | 掉落物品倍增器 |
DeathPenalty | Death penalty None : No lost, Item : Lost item without equipment, ItemAndEquipment : Lost item and equipment, All : Lost All item, equipment, pal(in inventory) | 死刑 None : 没有丢失, Item : 丢失的没有装备的物品, ItemAndEquipment : 丢失的物品和装备, All : 丢失所有物品、装备、朋友(库存中) |
GuildPlayerMaxNum | Max player of Guild | 公会最大玩家数 |
PalEggDefaultHatchingTime | Time(h) to incubate massive egg | 孵化大蛋的时间(h) |
ServerPlayerMaxNum | Maximum number of people who can join the server | 服务器最多可加入人数 |
ServerName | Server name | 服务器名称 |
ServerDescription | Server description | 服务器描述 |
AdminPassword | AdminPassword | 管理员密码 |
ServerPassword | Set the server password. | 设置服务器密码。 |
PublicPort | Public port number | 公共端口号 |
PublicIP | Public IP | 公共IP |
RCONEnabled | Enable RCON | 启用RCON |
RCONPort | Port number for RCON | RCON 的端口号 |
若使用OpenVPN,连接后在专用服务器IP地址处填10.8.0.1:8211即可
若未使用OpenVPN,需要在轻量应用服务器控制台防火墙放通udp8211。
按下Enter
调出聊天框,输入/adminpassword 你设置的管理员密码 即可获得管理员权限
管理员命令
命令 | 描述 | 机翻描述 |
---|---|---|
/Shutdown {Seconds} {MessageText} | The server is shut down after the number of Seconds Will be notified of your MessageText. | 服务器关闭后的秒数将通知您的 MessageText。 |
/DoExit | Force stop the server. | 强制停止服务器。 |
/Broadcast {MessageText} | Send message to all player in the server. | 向服务器中的所有玩家发送消息。 |
/KickPlayer {SteamID} | Kick player from the server. | 将玩家从服务器中踢出。 |
/BanPlayer {SteamID} | BAN player from the server. | 从服务器禁止玩家。 |
/TeleportToPlayer {SteamID} | Teleport to current location of target player. | 传送到目标玩家的当前位置。 |
/TeleportToMe {SteamID} | Target player teleport to your current location | 目标玩家传送到您当前的位置 |
/ShowPlayers | Show information on all connected players. | 显示所有已连接玩家的信息。 |
/Info | Show server information. | 显示服务器信息。 |
/Save | Save the world data. | 保存世界数据。 |
在获取管理员权限后,按下 ESC
后点击 选项
即可看到steamid,右键单击两次即可复制
先Ctrl+C将服务停止,然后输入下方命令即可对程序进行挂起
切到root用户
sudo su
sudo usermod -aG wheel steam
vim /etc/systemd/system/palserver.service
填写以下配置
[Unit]
Description=PalServer
After=network.target
[Service]
User=steam
ExecStart=/usr/bin/sudo -u steam /home/steam/Steam/steamapps/common/PalServer/Pal/Binaries/Linux/PalServer-Linux-Test Pal ""
Restart=always
[Install]
WantedBy=default.target
设置开机自启
sudo systemctl enable palserver
启动
sudo systemctl start palserver
查看状态
sudo systemctl status palserver
查看当前虚拟内存空间
free -h
设置虚拟内存为12G,建议根据机型调整
内存小于等于 2GB: 设置为内存的两倍。
内存大于 2GB 且小于 8GB: 设置为内存的1.5倍。
内存大于 8GB 且小于 64GB:等于内存大小。
内存大于 64GB: 设置为64GB。
sudo fallocate -l 12G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
再次查看虚拟内存空间
free -h
vim clean.sh
#!/bin/bash
sync
echo 1 > /proc/sys/vm/drop_caches
vim /etc/crontab
这里设置的是每2h执行一次,可以根据自身机型进行调整执行周期
0 */2 * * * root /path/to/sync.sh
教程到这里就结束了 各位可以享受自己的游戏之旅