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

简介: 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
相关文章
|
3天前
|
存储 弹性计算 安全
阿里云服务器ECS详解:云服务器是什么,云服务器优势和应用场景及价格参考
云服务器ECS是阿里云众多云产品中,最受用户关注的产品,阿里云服务器提供多样化的计算能力,支持x86、Arm架构,涵盖CPU、GPU等多种服务器类型,满足各种用户需求。本文为大家详细介绍阿里云服务器是什么?云服务器的优势和应用场景,以及最新价格情况,以供大家参考。
|
6天前
|
弹性计算 固态存储 Linux
阿里云服务器、轻量应用服务器、gpu云服务器收费标准与实时活动价格参考
云服务器ECS、轻量应用服务器和gpu云服务器是阿里云的主要云服务器产品,目前轻量应用服务器2核2G收费标准为60元/月,活动价格只要36元/1年或68元1年,云服务器1核1G包月收费标准最低为24.0元/月,GPU云服务器中gn6i实例4核15G配置月付1681.00/1个月起,gn6v实例8核32G配置月付3817.00/1个月起。本文为大家整理汇总了阿里云服务器、轻量应用服务器、gpu云服务器的最新收费标准与活动价格情况,以表格形式展示给大家,以供参考。
|
11天前
|
人工智能 弹性计算 编解码
阿里云GPU云服务器性能、应用场景及收费标准和活动价格参考
GPU云服务器作为阿里云提供的一种高性能计算服务,通过结合GPU与CPU的计算能力,为用户在人工智能、高性能计算等领域提供了强大的支持。其具备覆盖范围广、超强计算能力、网络性能出色等优势,且计费方式灵活多样,能够满足不同用户的需求。目前用户购买阿里云gpu云服务器gn5 规格族(P100-16G)、gn6i 规格族(T4-16G)、gn6v 规格族(V100-16G)有优惠,本文为大家详细介绍阿里云gpu云服务器的相关性能及收费标准与最新活动价格情况,以供参考和选择。
|
16天前
|
机器学习/深度学习 人工智能 弹性计算
什么是阿里云GPU云服务器?GPU服务器优势、使用和租赁费用整理
阿里云GPU云服务器提供强大的GPU算力,适用于深度学习、科学计算、图形可视化和视频处理等多种场景。作为亚太领先的云服务提供商,阿里云的GPU云服务器具备灵活的资源配置、高安全性和易用性,支持多种计费模式,帮助企业高效应对计算密集型任务。
|
18天前
|
存储 分布式计算 固态存储
阿里云2核16G、4核32G、8核64G配置云服务器租用收费标准与活动价格参考
2核16G、8核64G、4核32G配置的云服务器处理器与内存比为1:8,这种配比的云服务器一般适用于数据分析与挖掘,Hadoop、Spark集群和数据库,缓存等内存密集型场景,因此,多为企业级用户选择。目前2核16G配置按量收费最低收费标准为0.54元/小时,按月租用标准收费标准为260.44元/1个月。4核32G配置的阿里云服务器按量收费标准最低为1.08元/小时,按月租用标准收费标准为520.88元/1个月。8核64G配置的阿里云服务器按量收费标准最低为2.17元/小时,按月租用标准收费标准为1041.77元/1个月。本文介绍这些配置的最新租用收费标准与活动价格情况,以供参考。
|
16天前
|
机器学习/深度学习 人工智能 弹性计算
阿里云GPU服务器全解析_GPU价格收费标准_GPU优势和使用说明
阿里云GPU云服务器提供强大的GPU算力,适用于深度学习、科学计算、图形可视化和视频处理等场景。作为亚太领先的云服务商,阿里云GPU云服务器具备高灵活性、易用性、容灾备份、安全性和成本效益,支持多种实例规格,满足不同业务需求。
|
17天前
|
存储 固态存储 安全
阿里云服务器最新收费标准与云服务器活动价格参考
阿里云服务器最新收费标准参考,入门级1核2G配置收费标准最低64.06/月,2核4G收费标准最低68.0/月,4核8G收费标准最低216.0/月,8核16G收费标准最低432.0/月,目前在阿里云的活动中,2核2G最低36元1年,2核4G企业最低199元1年,2核8G活动价格最低652.32元1年,4核8G活动价格最低955.58元1年,8核16G活动价格最低3815.03元1年。更多不同实例规格及配置的阿里云服务器最新收费标准,活动价格如下文所示。
|
20天前
|
监控 Ubuntu Linux
使用VSCode通过SSH远程登录阿里云Linux服务器异常崩溃
通过 VSCode 的 Remote - SSH 插件远程连接阿里云 Ubuntu 22 服务器时,会因高 CPU 使用率导致连接断开。经排查发现,VSCode 连接根目录 ".." 时会频繁调用"rg"(ripgrep)进行文件搜索,导致 CPU 负载过高。解决方法是将连接目录改为"root"(或其他具体的路径),避免不必要的文件检索,从而恢复正常连接。
|
21天前
|
弹性计算
阿里云2核16G云服务器多少钱?亲测ECS内存型r8i租赁价格
阿里云2核16G云服务器,内存型r8i实例1年6折优惠后价格为1901元,月付334.19元,按小时计费0.696221元。更多配置及优惠详情,请访问阿里云ECS页面。
|
弹性计算 网络协议 Java
阿里云ECS十五日体验记录
本文作于2022/6/4,是为了发表自己的看法和免费续费而撰写.