游戏安装
Linux环境准备 基于Centos7安装七日杀游戏服务器,配置为2核4G。首先安装常用的依赖环境,如下
1 2 3 4 5 6 7 8 9 10 11 12 yum install -y net-tools yum install -y wget yum install -y glibc.i686 libstdc++.i686 yum install -y gcc gcc-c++ yum install -y cmake yum install -y ncurses-devel yum install -y bison yum install -y perl perl-devel yum install -y pcre-devel openssl openssl-devel yum install -y autoconf yum install -y vim yum install -y telnet
另外如果服务器内存低于8G强烈建议开启swap,七日杀游戏优化极差,亲测游戏初期4G内存还绰绰有余,但到游戏中期后期4G内存已经捉襟见肘甚至偶尔因为内存不足而炸服。因此强烈建议内存较低的服务器开启swap。
1 2 3 4 # 配置4G大小的swap分区 dd if=/dev/zero of=/var/swap bs=1024 count=4096000 mkswap -f /var/swap swapon /var/swap
依赖环境安装完毕后创建非root用户,并使用该用户管理游戏安装,避免root权限泄漏。
1 2 3 4 5 6 # 创建用户 useradd webapp passwd webapp chown webapp:webapp /opt/ su - webapp
steam安装 https://developer.valvesoftware.com/wiki/SteamCMD:zh-cn
1 2 3 4 cd /opt mkdir steamcmd cd steamcmd curl -sqL "https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz" | tar zxvf -
游戏安装 1 2 3 4 5 6 7 # 启动steamcmd /opt/steamcmd/steamcmd.sh # 登录steam账号 Steam> login 用户名 # 下载安装七日杀 Steam> app_update 294420 validate
配置 游戏参数配置 七日杀安装完毕后,默认游戏安装路径为~/Steam/steamapps/common/7 Days to Die Dedicated Server
,存档位置默认为~/.local/share/7DaysToDie
。
由于七日杀的默认游戏配置部分参数不合理,建议修改,配置文件为~/Steam/steamapps/common/7 Days to Die Dedicated Server/serverconfig.xml
,其中比较重要的配置如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 <ServerSettings > <property name ="ServerName" value ="7 day to die server" /> <property name ="ServerPassword" value ="12345678" /> <property name ="ServerPort" value ="26900" /> <property name ="ServerVisibility" value ="2" /> <property name ="ServerMaxWorldTransferSpeedKiBs" value ="1024" /> <property name ="ServerMaxPlayerCount" value ="12" /> <property name ="GameWorld" value ="West Xuyofu Territory" /> <property name ="WorldGenSeed" value ="asdf" /> <property name ="WorldGenSize" value ="6144" /> <property name ="GameDifficulty" value ="2" /> <property name ="BlockDamagePlayer" value ="300" /> <property name ="BlockDamageAI" value ="100" /> <property name ="BlockDamageAIBM" value ="100" /> <property name ="XPMultiplier" value ="300" /> <property name ="DayNightLength" value ="60" /> <property name ="DropOnDeath" value ="0" /> <property name ="DropOnQuit" value ="0" /> <property name ="MaxSpawnedZombies" value ="32" /> <property name ="MaxSpawnedAnimals" value ="50" /> <property name ="ServerMaxAllowedViewDistance" value ="12" /> <property name ="EnemySpawnMode" value ="true" /> <property name ="EnemyDifficulty" value ="0" /> <property name ="ZombieFeralSense" value ="0" /> <property name ="ZombieMove" value ="0" /> <property name ="ZombieMoveNight" value ="1" /> <property name ="ZombieFeralMove" value ="1" /> <property name ="ZombieBMMove" value ="1" /> <property name ="BloodMoonFrequency" value ="7" /> <property name ="LootAbundance" value ="300" /> <property name ="AirDropMarker" value ="true" /> <property name ="PlayerKillingMode" value ="0" /> </ServerSettings >
更多配置信息见七日杀wiki文档 。
防火墙配置
端口
协议
说明
26900
TCP
serverconfig中指定端口
26900-26903
UDP
客户端连接端口
8081
TCP
Telnet端口(可以不开放,仅本地连接)
管理服务器 启动游戏 1 nohup ~/Steam/steamapps/common/7\ Days\ to\ Die\ Dedicated\ Server/startserver.sh -configfile=serverconfig.xml &
管理游戏 1 2 3 4 5 # 连接游戏Telnet telnet 127.0.0.1 8081 # 关闭游戏 > shutdown
存档自动备份 搭建游戏私服,必然需要对游戏存档进行自动备份,防止由于各种原因需要回档时有备份存档可以会用。
1 2 3 4 5 6 # 安装crontab yum install vixie-cron yum install crontabs # 启动定时任务服务 service crond start
配置自动化备份脚本,将七日杀的存档自动打包复制到/home/webapp/backup
路径下
1 2 3 4 5 6 #!/bin/bash filename=$(date +%Y%m%d_%H%M%S).zip # 七日杀存档备份 zip -r /home/webapp/backup/"$filename" /home/webapp/.local/share/7DaysToDie/Saves/
然后配置定时任务,设置每日凌晨4点执行一次备份脚本,配置如下:
1 2 # 每日凌晨4点执行backup.sh脚本 0 4 * * * /home/webapp/backup/backup.sh