使用阿里云服务器为我的小伙伴们创建游戏服务器~

简介: steamCMD在linux上可以很方便的创建游戏服务器文件,只需要按照步骤安装和配置,之后启动服务器脚本就可以开启服务器了,1核2G的服务器,我们俩人玩了三个小时,之后开始变得不流畅起来,所以要想保障体验的话最好是2核4G的服务器估计能满足正常的时间分布。

Valheim server on Linux
Here is a step-by-step guide for setting up a Valheim server on Linux. Having done it twice now I thought it would be a good idea to capture this somewhere so that next time I don't have to look any of this up again.

The only assumptions being made here is that your server is running Ubuntu of some semi-recent version and a basic understanding of Linux.

SteamCMD
The SteamCMD utility from Valve will help us install the gamefiles on the server. Follow the instructions on the wiki to get it up and running.

Valheim
Now that SteamCMD is available, we can use it to download the gamefiles to the server.

steamcmd +login anonymous +force_install_dir

/home/steam/.steam/steamapps/common/valheim +app_update 896660 validate +exit

Some things to note here:

I've forced the install directory to something without spaces or other special crap in the name. This will make setting up systemd easier later.
896660 is the steam identifier for Valheim.
You can re-use this command later when you need to update the gamefiles when the devs release an update.
For quick re-use, create an sh file and put the command in there. I've named my update_game.sh, mark the file as executable and you're all set.

There are some last changes before we can run the server.

Valheim server configuration
There is not a lot to change but it's a requirement if you want to set up things correctly. Browse to the folder where you installed the game and look for a file called start_server.sh. As instructed in the file, make a copy of it (for simplicity I've named mine start_valheim.sh). Here's what mine looks like:

export TERM=xterm
export templdpath=$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=./linux64:$LD_LIBRARY_PATH
export SteamAppId=892970

echo "Starting server PRESS CTRL-C to exit"

./valheim_server.x86_64 -name "Helheim" -port 2456 -world "Dedicated" -password "..."
export LD_LIBRARY_PATH=$templdpath

I've added an additional export at the top (found after a bunch of searching for specific problems) to prevent some warnings and errors while the game starts. You could maybe get by without it, it'll depend on the rest of your system. If you see weird stuff in the game output, it's worth a shot.

Update the value for the -name argument to something you nice and of course set the -password value. Make sure it is longer than 5 characters and is not your server name.

Port configuration
This step will depend on your network infrastructure, I'm running my server on the Azure cloud platform which has its own way of configuring ports for VMs. Your setup is probably different but the gist of all of it is that you need op open the port range 2456-2458 for incoming traffic.

Running the server
It's tempting now to just run the > start_valheim.sh> file and start gaming but that comes with a drawback. When you close your SSH session, your server will stop. To fix that we'll use systemd to run the gameserver for us (and even try to restart it should it for some
reason crash or shut down).

Here is the config file I'm using:

[Unit]
Description=Valheim service
Wants=network.target
After=syslog.target network-online.target

[Service]
Type=simple
Restart=on-failure
RestartSec=10
User=steam
WorkingDirectory=/home/steam/.steam/steamapps/common/valheim/
ExecStart=/bin/sh /home/steam/.steam/steamapps/common/valheim/start_valheim.sh

[Install]
WantedBy=multi-user.target
If you've stuck with the same names for files and directories you can copy-paste this into a file called valheim.service and roll with that, or change it, if needed.

Given the systemd config file above, we can now hand this over to systemd to hand off the running and monitoring of the server. First step is to install the service file.

Copy the file to /etc/systemd/system.
Activate the service so that systemd can start the service: sudo systemctl enable valheim (don't include the .service part here).
Start the service: sudo systemctl start valheim.
Check the server status and see if it's actually running: sudo systemctl status valheim.
If everything was set up correctly, the output of step 4 will show a line that looks something like this (truncated for brevity):

● valheim.service - Valheim service
    Loaded: loaded (/etc/systemd/system/valheim.service; enabled; vendor preset: enabled)
    Active: active (running)
journalctl -u valheim -n 20

Wrapping up
At this point you should be able to use the public IP of your server to start playing! I don't know much about the resources required to keep everthing running smoothly but I've been running a server on a fairly modest 2-core/8GB RAM Linux (Standard D2as_v4 on Azure) VM that can easily host a 4 player game.

Now go forth and play the viking game with your friends on your very own Valheim server!

Posted on 2021-09-12
Tagged Gaming, Linux

© 2022 harrewijnen.net

相关实践学习
2分钟自动化部署人生模拟器
本场景将带你借助云效流水线Flow实现人生模拟器小游戏的自动化部署
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情: https://www.aliyun.com/product/ecs
相关文章
|
15天前
|
机器学习/深度学习 弹性计算 运维
云计算系列之阿里云ECS服务器管理实战
本文档介绍了阿里云ECS(Elastic Compute Service)的基本概念、实例管理、磁盘操作、快照与镜像功能及其应用场景,最后通过具体案例解析ECS的实际应用。ECS是阿里云提供的高效、可靠的云计算服务,支持多种业务需求,如Web应用、高并发网站、数据库等,帮助企业快速构建稳定安全的应用,提升运维效率,降低IT成本。文档还详细说明了ECS实例的创建方式、连接方法及日常管理操作,帮助用户更好地利用ECS服务。
51 2
云计算系列之阿里云ECS服务器管理实战
|
6天前
|
弹性计算
阿里云2核16G服务器多少钱一年?亲测价格查询1个月和1小时收费标准
阿里云2核16G服务器提供多种ECS实例规格,内存型r8i实例1年6折优惠价为1901元,按月收费334.19元,按小时收费0.696221元。更多规格及详细报价请访问阿里云ECS页面。
38 9
|
2天前
|
监控 Ubuntu Linux
使用VSCode通过SSH远程登录阿里云Linux服务器异常崩溃
通过 VSCode 的 Remote - SSH 插件远程连接阿里云 Ubuntu 22 服务器时,会因高 CPU 使用率导致连接断开。经排查发现,VSCode 连接根目录 ".." 时会频繁调用"rg"(ripgrep)进行文件搜索,导致 CPU 负载过高。解决方法是将连接目录改为"root"(或其他具体的路径),避免不必要的文件检索,从而恢复正常连接。
|
6天前
|
弹性计算 异构计算
2024年阿里云GPU服务器多少钱1小时?亲测价格查询方法
2024年阿里云GPU服务器每小时收费因实例规格不同而异。可通过阿里云GPU服务器页面选择“按量付费”查看具体价格。例如,NVIDIA A100的gn7e实例为34.742元/小时,NVIDIA A10的gn7i实例为12.710156元/小时。更多详情请访问阿里云官网。
38 2
|
10天前
|
存储 弹性计算 数据库
阿里云服务器ECS产品试用、ECS试用攻略、试用宝典及试用产品续用相关活动介绍
阿里云服务器ECS产品免费试用是阿里云为新手用户提供的免费体验的权益,旨在为新手开发者提供 0 成本高质量的上云体验服务,打造开放,敏捷的开发者环境。阿里云为广大用户提供基础版、企业版试用产品服务(二选一),帮您0门槛轻松体验1个月,基础版最高可试用4核 (vCPU) 8 GiB配置,企业版最高可最高可试用8核 (vCPU) 16 GiB。本文为大家介绍云服务器ECS产品试用、试用宝典、ECS试用攻略及试用产品续用相关活动,以供参考。
|
11天前
|
存储 弹性计算 NoSQL
"从入门到实践,全方位解析云服务器ECS的秘密——手把手教你轻松驾驭阿里云的强大计算力!"
【10月更文挑战第23天】云服务器ECS(Elastic Compute Service)是阿里云提供的基础云计算服务,允许用户在云端租用和管理虚拟服务器。ECS具有弹性伸缩、按需付费、简单易用等特点,适用于网站托管、数据库部署、大数据分析等多种场景。本文介绍ECS的基本概念、使用场景及快速上手指南。
46 3
|
13天前
|
弹性计算 安全 网络安全
阿里云服务器租用流程,四种阿里云服务器租用方式图文教程参考
阿里云服务器可以通过自定义租用、一键租用、云市场租用和活动租用四种方式去租用,不同的租用方式适合不同的用户群体,例如我们只是想租用一款配置较低且可以快速部署应用的云服务器,通常可以选择一键租用或者云市场租用,本文为大家展示不同租用方式的适合对象以及租用流程,以供初次租用阿里云服务器的用户参考和选择。下面是阿里云服务器租用的图文操作步骤。
|
3天前
|
弹性计算
阿里云2核16G云服务器多少钱?亲测ECS内存型r8i租赁价格
阿里云2核16G云服务器,内存型r8i实例1年6折优惠后价格为1901元,月付334.19元,按小时计费0.696221元。更多配置及优惠详情,请访问阿里云ECS页面。
|
6天前
|
机器学习/深度学习 人工智能 弹性计算
阿里云AI服务器价格表_GPU服务器租赁费用_AI人工智能高性能计算推理
阿里云AI服务器提供多种配置选项,包括CPU+GPU、CPU+FPGA等组合,支持高性能计算需求。本文汇总了阿里云GPU服务器的价格信息,涵盖NVIDIA A10、V100、T4、P4、P100等多款GPU卡,适用于人工智能、机器学习和深度学习等场景。详细价格表和实例规格见文内图表。
|
弹性计算 网络协议 Java
阿里云ECS十五日体验记录
本文作于2022/6/4,是为了发表自己的看法和免费续费而撰写.

热门文章

最新文章