在Ubuntu 22.04上搭建MineOS环境

最初

您是否熟悉一个名为MineOS的Minecraft服务器管理工具?
它是一个便利的工具,可以通过Web用户界面来创建、启动、停止服务器以及定期备份等等。
虽然我已经使用它很久了,但每次重新构建时我都会忘记步骤,所以我会写下备忘录来记录这些步骤。

以下的网址是公式网站
https://wiki.codeemo.com/

环境

這次將在ESXi8.0虛擬機上進行構建。

項目詳細OSUbuntu22.04LTSCPU6vCPURAM30GBStorageSAS HDD 100GB

建造

基本的には公式ドキュメント通りに進める

安装 Ubuntu 操作系统

放弃

安装Curl

user@localhost:~$ sudo apt -y install curl
[sudo] password for user: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
curl is already the newest version (7.81.0-1ubuntu1.6).
curl set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 53 not upgraded.

进去了… …)

安装Node.js

参照 NodeJS 的官方网站
https://github.com/nodesource/distributions

user@localhost:~$ curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash

## Installing the NodeSource Node.js 14.x repo...


## Populating apt-get cache...

+ apt-get update
Hit:1 http://jp.archive.ubuntu.com/ubuntu jammy InRelease
Hit:2 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:3 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:4 http://jp.archive.ubuntu.com/ubuntu jammy-security InRelease
Reading package lists... Done

## Confirming "jammy" is supported...

+ curl -sLf -o /dev/null 'https://deb.nodesource.com/node_14.x/dists/jammy/Release'

## Adding the NodeSource signing key to your keyring...

+ curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | gpg --dearmor | tee /usr/share/keyrings/nodesource.gpg >/dev/null

## Creating apt sources list file for the NodeSource Node.js 14.x repo...

+ echo 'deb [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x jammy main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src [signed-by=/usr/share/keyrings/nodesource.gpg] https://deb.nodesource.com/node_14.x jammy main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Hit:1 http://jp.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 https://deb.nodesource.com/node_14.x jammy InRelease [4,563 B]
Hit:3 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease
Hit:4 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease
Hit:5 http://jp.archive.ubuntu.com/ubuntu jammy-security InRelease
Get:6 https://deb.nodesource.com/node_14.x jammy/main amd64 Packages [773 B]
Fetched 5,336 B in 2s (2,666 B/s) 
Reading package lists... Done

## Run `sudo apt-get install -y nodejs` to install Node.js 14.x and npm
## You may also need development tools to build native addons:
     sudo apt-get install gcc g++ make
## To install the Yarn package manager, run:
     curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg | gpg --dearmor | sudo tee /usr/share/keyrings/yarnkey.gpg >/dev/null
     echo "deb [signed-by=/usr/share/keyrings/yarnkey.gpg] https://dl.yarnpkg.com/debian stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
     sudo apt-get update && sudo apt-get install yarn
user@localhost:~$ sudo apt -y install nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 53 not upgraded.
Need to get 25.7 MB of archives.
After this operation, 125 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_14.x jammy/main amd64 nodejs amd64 14.21.1-deb-1nodesource1 [25.7 MB]
Fetched 25.7 MB in 1s (20.0 MB/s) 
Selecting previously unselected package nodejs.
(Reading database ... 73556 files and directories currently installed.)
Preparing to unpack .../nodejs_14.21.1-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (14.21.1-deb-1nodesource1) ...
Setting up nodejs (14.21.1-deb-1nodesource1) ...
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...                                                                                                                          
Scanning linux images...                                                                                                                       

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

安装Java

因为我想要构建所需服务器版本,所以需要安装与之兼容的Java。这次我想要搭建Minecraft1.19的服务器,因此需要安装Java17。版本的兼容性可以在以下网址找到相关总结:https://mcpoteton.com/mcserver/official-server#index_id5

インストール可能なバージョンの確認

user@localhost:~$ sudo apt search "^openjdk.*jdk$"
Sorting... Done
Full Text Search... Done
openjdk-11-jdk/jammy-updates,jammy-security 11.0.17+8-1ubuntu2~22.04 amd64
  OpenJDK Development Kit (JDK)

openjdk-17-jdk/jammy-updates,jammy-security 17.0.5+8-2ubuntu1~22.04 amd64
  OpenJDK Development Kit (JDK)

openjdk-18-jdk/jammy-updates,jammy-security 18.0.2+9-2~22.04 amd64
  OpenJDK Development Kit (JDK)

openjdk-19-jdk/jammy-updates,jammy-security 19.0.1+10-1ubuntu1~22.04 amd64
  OpenJDK Development Kit (JDK)

openjdk-8-jdk/jammy-updates,jammy-security 8u352-ga-1~22.04 amd64
  OpenJDK Development Kit (JDK)
user@localhost:~$ sudo apt install -y openjdk-17-jdk
[sudo] password for user: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done

// 中略

Setting up libgtk2.0-0:amd64 (2.24.33-2ubuntu2) ...
Setting up humanity-icon-theme (0.6.16) ...
Setting up libgail18:amd64 (2.24.33-2ubuntu2) ...
Setting up libgtk2.0-bin (2.24.33-2ubuntu2) ...
Setting up libgail-common:amd64 (2.24.33-2ubuntu2) ...
Setting up openjdk-17-jre:amd64 (17.0.5+8-2ubuntu1~22.04) ...
Setting up ubuntu-mono (20.10-0ubuntu2) ...
Setting up openjdk-17-jdk:amd64 (17.0.5+8-2ubuntu1~22.04) ...
update-alternatives: using /usr/lib/jvm/java-17-openjdk-amd64/bin/jconsole to provide /usr/bin/jconsole (jconsole) in auto mode
Processing triggers for ca-certificates (20211016ubuntu0.22.04.1) ...
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...

done.
done.
Processing triggers for libglib2.0-0:amd64 (2.72.1-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
Processing triggers for man-db (2.10.2-1) ...
Setting up at-spi2-core (2.44.0-3) ...
Processing triggers for libgdk-pixbuf-2.0-0:amd64 (2.42.8+dfsg-1ubuntu0.2) ...
Scanning processes...                                                                                                                          
Scanning linux images...                                                                                                                       

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

No VM guests are running outdated hypervisor (qemu) binaries on this host.

依存関係のインストール

# sudo apt -y install git rdiff-backup screen
# sudo apt -y install build-essential

WebUIファイルをインストール

# cd /usr/games
# git clone https://github.com/hexparrot/mineos-node minecraft
# cd minecraft
# git config core.filemode false
# chmod +x generate-sslcert.sh mineos_console.js webui.js
# cp mineos.conf /etc/mineos.conf
# cd /usr/games/minecraft
# npm install
[sudo] password for user: 

> diskusage@1.1.3 install /usr/games/minecraft/node_modules/diskusage
> node-gyp rebuild

gyp WARN EACCES current user ("user") does not have permission to access the dev dir "/root/.cache/node-gyp/14.21.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/games/minecraft/node_modules/diskusage/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/games/minecraft/node_modules/diskusage/.node-gyp'
gyp ERR! System Linux 5.15.0-56-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/games/minecraft/node_modules/diskusage
gyp ERR! node -v v14.21.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! diskusage@1.1.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the diskusage@1.1.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-12-24T17_08_21_286Z-debug.log

因为我对Node.js一无所知,所以我只写下了查询网站和结果。

请参考以下链接:https://qiita.com/zaburo/items/12f99aa07ab934d07d75#%E3%81%82%E3%82%8B%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB%E3%81%A7%E3%82%A8%E3%83%A9%E3%83%BC

rootユーザーで–unsafe-permを付けたらとりあえず実行できました。

root@localhost:/usr/games/minecraft# npm install --unsafe-perm

> diskusage@1.1.3 install /usr/games/minecraft/node_modules/diskusage
> node-gyp rebuild

make: Entering directory '/usr/games/minecraft/node_modules/diskusage/build'
  CXX(target) Release/obj.target/diskusage/src/main.o
In file included from ../src/main.cpp:3:
../../nan/nan.h: In function ‘void Nan::AsyncQueueWorker(Nan::AsyncWorker*)’:
../../nan/nan.h:2298:7: warning: cast between incompatible function types from ‘void (*)(uv_work_t*)’ {aka ‘void (*)(uv_work_s*)’} to ‘uv_after_work_cb’ {aka ‘void (*)(uv_work_s*, int)’} [-Wcast-function-type]
 2298 |     , reinterpret_cast<uv_after_work_cb>(AsyncExecuteComplete)
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../nan/nan.h:54,
                 from ../src/main.cpp:3:
../src/main.cpp: At global scope:
/root/.cache/node-gyp/14.21.1/include/node/node.h:793:7: warning: cast between incompatible function types from ‘void (*)(v8::Local<v8::Object>)’ to ‘node::addon_register_func’ {aka ‘void (*)(v8::Local<v8::Object>, v8::Local<v8::Value>, void*)} [-Wcast-function-type]
  793 |       (node::addon_register_func) (regfunc),                          \
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/root/.cache/node-gyp/14.21.1/include/node/node.h:827:3: note: in expansion of macro ‘NODE_MODULE_X’
  827 |   NODE_MODULE_X(modname, regfunc, NULL, 0)  // NOLINT (readability/null_usage)
      |   ^~~~~~~~~~~~~
../src/main.cpp:42:1: note: in expansion of macro ‘NODE_MODULE’
   42 | NODE_MODULE(diskusage, Init)
      | ^~~~~~~~~~~
  CXX(target) Release/obj.target/diskusage/src/diskusage_posix.o
  SOLINK_MODULE(target) Release/obj.target/diskusage.node
  COPY Release/diskusage.node
make: Leaving directory '/usr/games/minecraft/node_modules/diskusage/build'
added 1 package from 1 contributor and audited 582 packages in 11.16s

2 packages are looking for funding
  run `npm fund` for details

found 70 vulnerabilities (9 low, 18 moderate, 35 high, 8 critical)
  run `npm audit fix` to fix them, or `npm audit` for details
root@localhost:/usr/games/minecraft# 

生成证书

そのまま

# cd /usr/games/minecraft
# ./generate-sslcert.sh

配置修改

修改语言设置

root@localhost:/usr/games/minecraft# vi /etc/mineos.conf

#webui_locale = ‘en_US’をコメントアウトして下にwebui_locale = ‘ja_JP’を追加。

#webui_locale = 'en_US'
webui_locale = 'ja_JP'

服务的自动启动设置

写着让选择喜欢的systemd或supervisord,但我没有特别偏好,所以就直接使用可用的systemd吧。

root@localhost:/usr/games/minecraft# cp /usr/games/minecraft/init/systemd_conf /etc/systemd/system/mineos.service
root@localhost:/usr/games/minecraft# systemctl enable mineos
root@localhost:/usr/games/minecraft# systemctl start mineos
root@localhost:/usr/games/minecraft# systemctl status mineos
。・mineos.service - Start MineOS minecraft front-end
     Loaded: loaded (/etc/systemd/system/mineos.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-12-24 17:59:42 UTC; 3s ago
    Process: 2867 ExecStart=/usr/bin/node service.js start (code=exited, status=0/SUCCESS)
   Main PID: 2874 (mineos)
      Tasks: 11 (limit: 35973)
     Memory: 34.7M
        CPU: 1.115s
     CGroup: /system.slice/mineos.service
             ィヲィ。2874 mineos "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >

Dec 24 17:59:41 localhost systemd[1]: Starting Start MineOS minecraft front-end...
Dec 24 17:59:41 localhost node[2867]: Starting mineos daemon...
Dec 24 17:59:42 localhost node[2867]: mineos daemon started. PID: 2874
Dec 24 17:59:42 localhost systemd[1]: Started Start MineOS minecraft front-end.
root@localhost:/usr/games/minecraft# 

移动

登錄

image.png

粗略检查过后,

    • 稼働率グラフ

 

    • プロファイルダウンロードページ

 

    • 表示言語変更

 

    新規サーバー作成

辺りが動いていない模様

故障排除

トラブルシューティングページを参考に
https://wiki.codeemo.com/maint/webui.html

请根据上述页面进行参考并执行下列操作。

# cd /usr/games/minecraft
# git fetch
# git reset --hard origin/master
# git checkout master
# rm -rf ./node_modules
# npm install --unsafe-perm

sudoではなくルートユーザーでnpm install –unsafe-permを実行したら成功しました。

重新启动服务

root@localhost:/usr/games/minecraft# systemctl start mineos
root@localhost:/usr/games/minecraft# systemctl status mineos
● mineos.service - Start MineOS minecraft front-end
     Loaded: loaded (/etc/systemd/system/mineos.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2022-12-24 20:45:51 UTC; 1s ago
    Process: 2314 ExecStart=/usr/bin/node service.js start (code=exited, status=0/SUCCESS)
   Main PID: 2321 (mineos)
      Tasks: 11 (limit: 35973)
     Memory: 26.5M
        CPU: 695ms
     CGroup: /system.slice/mineos.service
             └─2321 mineos "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" >

Dec 24 20:45:50 localhost systemd[1]: Starting Start MineOS minecraft front-end...
Dec 24 20:45:50 localhost node[2314]: Starting mineos daemon...
Dec 24 20:45:51 localhost node[2314]: mineos daemon started. PID: 2321
Dec 24 20:45:51 localhost systemd[1]: Started Start MineOS minecraft front-end.

请重新登录

https://サーバーIP:8443にアクセス
Ubuntuのユーザーでログイン

image.png

总结

因为当前的Ubuntu 22.04操作系统上缺乏构建指南,所以一直处于摸索的状态,但好在最终还是成功构建了。然而,在NodeJS中仍然存在一些安全漏洞的问题,所以还需要对一些细节进行修正。中途遇到不懂npm的情况,让我意识到需要更加深入学习。

最后,请认真阅读文件。

bannerAds