Teach you how to build minecraft (bedrock version) server on CentOS

Time:2022-5-10

1、 Overview:

  1. Preparation in advance: a cloud server or a personal device equipped with CentOS operating system, such as a virtual machine (this article assumes that you have known and purchased the cloud server and have a certain understanding of Linux operating commands)

  2. Building methods: there are two ways. Let me explain how to build using the official BDS first. Then explain how to build using liteloader BDS (this method supports all Linux environments).
    I personally recommend using liteloaderbds to build it, because it has higher scalability, provides highly customized APIs, can freely install and write plug-ins, supports hot update plug-ins, and better community environment. For details, please refer toLiteLoaderBDS
    If you want to directly refer to the construction method of liteloader BDS, please refer to step 5 directly.

ps: Recently, it seems that more and more people take the server. I thought this article could be kept as a note for reference when I want to open the service in the future. But after I wrote this article, I found a series of abnormal conditions on my server, such as memory leakage, server fake death, etc. In order to prevent future friends from stepping on this pit, I would like to make a statement: at present, the construction method of this article may have a serious memory leakage problem in CentOS server, that is, the memory only increases and does not decrease until it is full and the service collapses. It is impossible to judge whether the problem is caused by liteloader loader or BDS official server. I recommend that you directly install the windows server operating system in the ECs to build the server, which will make your server run more stably. During operation, please avoid clicking CMD terminal window with the mouse. This operation will probably make your server enter the pseudo dead state. If you encounter any problems during the construction process, please leave a message in the comment area. I will answer it as soon as I see it.

2、 Download the official Server package:

  1. get intoDownload from official website, after entering, there is a pop-up window to tell you to go to the Netease national service version. We click the very secret button to turn it off.
    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png

    Scroll down and select Ubuntu server, check the agreement, right-click the download button, and copy the download address:

    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png
  2. Next, use the remote connection tool to connect to the ECS and execute the commanddnf install wget -yDownload WGet tool and wait for the installation to complete. (DNF is a package management tool that comes with centos8. It is more convenient and better than yum. It will automatically download and install the dependencies. If your server is centos7, you can install DNF manually:yum install dnf -y, and then execute the above command. If you don’t want to use DNF, you can also directly use Yum to install it).
  3. create foldermkdir mcbe, enter the foldercd mcbe
  4. Next, execute in this folder:wget https://minecraft.azureedge.net/bin-linux/bedrock-server-1.18.12.01.zip, this is the address you just copied on the official website. Note the version number:1.18.12.01The corresponding version number is the version number of your game client. Check the version number of your client. You can modify the corresponding version number in this address to be consistent with the version number of your client, which will download the server package of the corresponding version.
    Unzip the package after the download is completed:unzip bedrock-server-1.18.12.01.zip, if there is no unzip tool, executednf install unzip -yJust install it.

3、 To create a Ubuntu container running environment using docker:

Because the official package only supports running in Ubuntu environment, running in CentOS will lack public dependency library. Of course, this problem can also be solved through special methods, but it is too troublesome. Therefore, we simply use docker container to create running environment, which not only solves the problem of running environment, but also facilitates management, and can also create multiple servers under multiple containers.

  1. To install docker:dnf install docker-ce -y
  2. Start docker service:systemctl start docker
  3. Set the docker service to start automatically after startup:systemctl enable docker
  4. Pull the Ubuntu image:docker pull ubuntu
  5. View image:
[[email protected] ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED       SIZE
ubuntu       latest    54c9d81cbb44   4 weeks ago   72.8MB
  1. Create containers using Ubuntu images:
    docker run -dit -p 6666:6666/udp -v /mcbe:/mcbe --restart=always ubuntu:latest /bin/bash
    Copy the command directly and execute it.
  • docker runRefers to creating a container.
  • -dIt means that the daemon mode will not enter the container by default,-itOpen the standard input pseudo terminal. These three parameters are indispensable.
  • -p 6666:6666It means mapping the server port in the container (6666 in the back) to the 6666 port of the host (6666 in the front). Note: the two port numbers should be consistent. If they are inconsistent, a bug will be triggered even if the mapping port of the host is opened (the server list in the game shows a red dot of delay, but in fact, the bug that can enter the server does not know whether it is a bug, but I have dealt with this problem for a long time), Minecraft bedrock server uses UDP protocol, so plus/udp
  • -v /mcbe:/mcbeMeans to map (Mount) the mcbe folder (created in the second step) in the host to the mcbe folder in the container, which is convenient for us to manage and configure the server directly in the host. If you need to create multiple servers, repeat the above method to create multiple containers, and then copy multiple copies of the mcbe folder without duplicate names. Multiple containers map to different folders, i.e. (mcbe1, mcbe2), etc. for details, please explore or checkRelated documents
  1. View container:
[[email protected] ~]# docker ps
CONTAINER ID   IMAGE           COMMAND       CREATED          STATUS          PORTS                                         NAMES
5a9e86570a47   ubuntu:latest   "/bin/bash"   23 seconds ago   Up 21 seconds   0.0.0.0:6666->19132/udp, :::6666->19132/udp   jovial_taussig

Copy the printed container ID, mine is5a9e86570a47

  1. Enter container:docker exec -it 5a9e86570a47 /bin/bash
    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png

4、 Modify the configuration and start the server:

  1. Update package management toolapt update
  2. Install VIM editorapt install vim -y
  3. Install TMUX session managerapt install tmux -y
  4. Enter the mcbe foldercd mcbe
  5. Edit server profilevim server.properties: PressiEnter edit mode,
    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png
  • If you want to play hard mode, you will:difficulty=easyChange todifficulty=hard

  • Change hang up kick out toplayer-idle-timeout=0(no matter how long you hang up and don’t kick out, the unit is minute)

  • The maximum thread is modified to:max-threads=0(0 is to keep the maximum number of threads as possible)

  • Modify server port:server-port=6666(the port number here should be consistent with the port number set when the container is opened. The default is 19132)

  • Open whitelist:allow-list=true

  • PressEscAnd enter:wqSave exit
    For other configurations, please check the in the mcbe folderbedrock_server_how_to.htmlEnglish documents, or Baidu other.

  1. implementtmuxCommand to create a new session
  2. Execute under this sessionLD_LIBRARY_PATH=. ./bedrock_serverCommand to start the server. If you see this print message, it indicates that the startup is successful:
    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png
  3. Press<ctrl+b>Then pressdExit the session and keep the background running. If you want to enter the session to view next time, execute it directlytmux attach
  4. Exit container:exit(the container remains running in the background after exiting). Enter or use the command next time:docker exec -it 5a9e86570a47 /bin/bash

Some other commands about TMUX:

  • Create a new session and name ittmux new -s <session-name>
  • To view a list of sessions:tmux ls
  • Kill session process:tmux kill-session -t <session-name>
  • Switch session:tmux switch -t <session-name>
  • Rename session:tmux rename-session -t <old-session-name> <new-session-name>

5、 Build using liteloaderbds:

Construction premise: docker has been installed
If not, follow these steps:

  1. To install docker:dnf install docker-ce -y
  2. Start docker service:systemctl start docker
  3. Set the docker service to start automatically after startup:systemctl enable docker
  • Official description of liteloaderbds:

LiteLoaderBDSIt is an unofficial minecraft server plug-in loader, which is the official server of bedrock versionBedrock Dedicated Server(hereinafter referred to as BDS) provides plug-in development support and plug-in loading services, which makes up for some shortcomings of the official behavior package development interface for a long time.

  1. Pull the liteloader image and execute:docker pull shrbox/liteloaderbds
    The image takes up 2.6g and it takes a little effort to download. If you download slowly like me, you need to replace the docker image source. If you download fast enough, ignore the following steps:
    • Execute commandvim /etc/docker/daemon.jsonEdit daemon JSON file, which does not exist by default, but we can still execute this command because VIM will automatically create this file for us.
    • PressiEnter edit mode and write the following configuration information:
      {
        "registry-mirrors": ["https://registry.docker-cn.com"]
      }
      

      https://registry.docker-cn.comIt is the official image source of China.
      Next pressEscExit edit mode, then press and enter:wqThen press enter to exit saving.

    • Restart docker servicesystemctl restart docker, then executedocker pull shrbox/liteloaderbdsCommand, you will find that the download speed is rising.
  2. After pulling down the mirror, create the container:docker create --name liteloader -p 6666:6666/udp -v liteloaderbds:/home/bds/bds -i -t shrbox/liteloaderbds
[[email protected] _data]# docker create --name liteloader -p 6666:6666/udp -v liteloaderbds:/home/bds/bds -i -t shrbox/liteloaderbds
a02453350504ec839c1c4c5775abc4cf07778ecb4c4e243493394425cc79c72d

Note: don’t mistake a letter of this command.
-vParameters are followed byliteloaderbds:/home/bds/bds, indicating the creation of a named mount volumeliteloaderbds, map to container/home/bds/bdsPath, which is the location of the server package. After mounting, it is convenient for us to directly operate the server configuration file on the host.

  1. After the creation, we make a soft connection to the mounted volume. Go to the main directory, or other directory where you store things.
    cd ~, then execute the command:ln -s /var/lib/docker/volumes/liteloaderbds/_data/ ./liteloaderIn this way, you can directly operate the server files under the home directory in the future. Let’s print the list and check it:

    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png

    Found that the soft connection was created successfully,cd _dataEnter to check:

    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png

    In the list is the server file created by the container.

  2. Edit the server configuration file in the current directoryvim server.properties: PressiEnter edit mode:

    Teach you how to build minecraft (bedrock version) server on CentOS

    image.png
    • If you want to play hard mode, you will:difficulty=easyChange todifficulty=hard
    • Change hang up kick out toplayer-idle-timeout=0(no matter how long you hang up and don’t kick out, the unit is minute)
    • The maximum thread is modified to:max-threads=0(keep maximum threads as possible)
    • Modify server port:server-port=6666(the port number here should be consistent with the port number set when the container is opened. The default is 19132)
    • PressEscAnd enter:wqSave exit
  3. Start the container after modification:docker container start liteloader

  4. Other commands:

    • Force server stop (not recommended):docker container stop liteloader
    • Enter the console (server terminal):docker attach liteloader
    • Exit console: PressCtrl + P + Q。 If pressedCtrl + C, the server process will terminate.
  5. Use of plug-ins: Download plug-ins in the community and put them directly into the server directorypluginsFolder, and then executedocker container restart liteloaderRestart the container. Here I recommend a community that provides plug-insminebbs, you can find and download it yourself.

  6. Some terminal commands of liteloader:

    • ll list
      List all plug-ins currently loaded

    • ll load ./plugins/xxxx.js
      Hot load the plug-in located in the specified path. The path is relative to the BDS root directory.

    • ll unload xxxx.lua
      The hot uninstall is named XXXX in the plug-in list Plugins for Lua

    • ll reload xxxx.dll
      Reload the plugin named XXXX in the list of plugins DLL plug-in

    • ll reload
      Reload all plug-ins in the plug-in list

    • ll version
      Output the currently installed ll version

    • ll upgrade
      Manually check liteloaderbds for automatic updates

6、 Final work:

Enter your own ECS background = > firewall configuration page and open port 6666 (I’m Tencent cloud and Alibaba cloud should be called ‘Security Group’)

Teach you how to build minecraft (bedrock version) server on CentOS

image.png

Note: the protocol is UDP
Next, enter the game, server = > add a server, fill in the server name casually, server address: enter the public IP of ECs, port: 6666. If you can successfully enter the game after saving, it means that the server is successfully built.

7、 Terminal instruction:

Setup administrator:
OP "player ID"

Turn on death without falling:
gamerule keepInventory true

Display coordinates:
gamerule showcoordinates true

Add to the white list:
Allowlist add player name

Remove from whitelist:
Allowlist remove player name

Reload the white list after each deletion or addition:
allowlist reload

8、 Summary:

Building minecraft bedrock server on CentOS is a little troublesome. If windows is built, it’s OK to directly download the package and execute the executable file. For other relevant information, building methods, plug-in download and server configuration tutorial, please go to the community to find:minebbs

If you have any technical problems or want to play with my server, you can add my wechat: bishu0913.

Please indicate the source of reprint.