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

简介: 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
相关文章
|
11天前
|
弹性计算 数据挖掘 应用服务中间件
阿里云轻量应用服务器68元与云服务器99元和199元区别及选择参考
目前阿里云有三款特惠云服务器,第一款轻量云服务器2核2G68元一年,第二款经济型云服务器2核2G3M带宽99元1年,第三款通用算力型2核4G5M带宽199元一年。有的新手用户并不是很清楚他们之间的区别,因此不知道如何选择。本文来介绍一下它们之间的区别以及选择参考。
242 87
|
4天前
|
存储 弹性计算 应用服务中间件
阿里云轻量应用服务器出新品通用型实例了,全球26个地域可选
近日,阿里云再度发力,推出了首款全新升级的轻量应用服务器——通用型实例。这款服务器实例不仅标配了200Mbps峰值公网带宽,更在计算、存储、网络等基础资源上进行了全面优化,旨在为中小企业和开发者提供更加轻量、易用、普惠的云计算服务,满足其对于通用计算小算力的迫切需求。目前,这款新品已在全球26个地域正式上线,为全球用户提供了更加便捷、高效的上云选择。
|
7天前
|
存储 弹性计算 安全
阿里云服务器经济型e实例4核16G和8核32G特惠云服务器测评参考
阿里云有两款特惠云服务器——4核16G10M带宽和4核32G10M带宽,系统盘都是100G ESSD Entry,价格分别仅需70元1个月和160元1个月。那么,这两款云服务器到底性能如何?适用于哪些场景?是否值得购买?本文将全方位深入测评这两款特惠云服务器,并为您提供详细的购买建议。
|
12天前
|
存储 人工智能 网络协议
浅聊阿里云倚天云服务器:c8y、g8y、r8y实例性能详解与活动价格参考
选择一款高性能、高性价比的云服务器对于企业而言至关重要,阿里云推出的倚天云服务器——c8y、g8y、r8y三款实例,它们基于ARM架构,采用阿里自研的倚天710处理器,并基于新一代CIPU架构,通过芯片快速路径加速手段,实现了计算、存储、网络性能的大幅提升。2025年,计算型c8y云服务器活动价格860.65元一年起,通用型g8y云服务器活动价格1187.40元一年起,内存型r8y云服务器活动价格1454.32元一年起。本文将为大家详细解析这三款实例的性能特点、应用场景以及最新的活动价格情况,帮助大家更好地了解阿里云倚天云服务器。
|
5天前
|
人工智能 安全 Linux
阿里云与龙蜥携手打造智算时代最佳服务器操作系统
本次分享的主题是阿里云与龙蜥携手打造智算时代最佳服务器操作系统,由阿里云技术软件部产品总监张鹏程分享。主要分为三个部分: 1.开源社区 2.操作系统 3.云 + AI
阿里云与龙蜥携手打造智算时代最佳服务器操作系统
|
15天前
|
机器学习/深度学习 弹性计算 缓存
简单聊聊,阿里云2核2G3M带宽云服务器与轻量应用服务器区别及选择参考
2核2G3M带宽云服务器与轻量应用服务器是目前阿里云的活动中,入门级走量型云服务器,轻量云服务器2核2G3M带宽68元一年,经济型e实例云服务器2核2G3M带宽99元1年。同样的配置,对于有的新手用户来说,有必要了解一下他们之间的区别,以及各自的购买和续费相关政策,从而选择更适合自己需求的云服务器。本文为大家简单分析一下我们应该选择哪一款。
|
15天前
|
监控 安全 数据库
阿里云国际站:如何使用阿里云国际站服务器
阿里云国际站服务器是一种强大的云计算服务,可以帮助用户轻松搭建和管理自己的网站、应用程序和数据库。本文将介绍如何使用阿里云国际站服务器,包括注册账户、选择服务器配置、安装操作系统、配置网络和安全设置等方面。
|
17天前
|
弹性计算 安全 搜索推荐
阿里云国际站注册教程:阿里云服务器安全设置
阿里云国际站注册教程:阿里云服务器安全设置 在云计算领域,阿里云是一个备受推崇的品牌,因其强大的技术支持和优质的服务而受到众多用户的青睐。本文将为您介绍阿里云国际站的注册过程,并重点讲解如何进行阿里云服务器的安全设置。
|
17天前
|
人工智能 监控 测试技术
阿里云磐久服务器稳定性实践之路
阿里云服务器质量智能管理体系聚焦自研服务器硬件层面的极致优化,应对高并发交付、短稳定性周期、早问题发现和快修复四大挑战。通过“三个重构”(质量标准、开发流程、交付模式)、“六个归一”(架构、硬件、软件、测试、部件、制造)策略,实现芯片、整机和云同步发布,确保快速稳定上量。此外,全场景测试体系与智能预警、分析、修复系统协同工作,保障服务器在萌芽阶段发现问题并及时解决,提升整体质量水平。未来,阿里云将继续深化大数据驱动的质量管理,推动服务器行业硬件质量的持续进步。
|
弹性计算 监控
使用ECS搭建云服务器体验
了解端口的知识,本地配置服务端上传运行服务器,实现服务器24小时开放。
使用ECS搭建云服务器体验