Configure Node on CentOS 7 server

Антон Машнин
4 min readFeb 20, 2021

Hello everyone!

Sometimes happens that some users use a “container” type of virtualization, instead of hardware (KVM, Hyper-V, Esxi, etc) where there is no way to put a guest operating system different from the operating system of the node itself. This virtualization cannot be used to install node using a docker container.

That’s why I have decided to create an article that will describe configuring Moonbeam node in the English language, and even without using the standard Ubuntu operating system, which is described by everyone, I chose a server running on the CentOS7 operating system

Usually, container virtualization does not very correctly restrict resources between containers (for example, LXC virtualization), in this case, all system resources are available to all virtual machines at the same time. Anyway, you need to keep in mind that the minimum resources for your container or a full-fledged virtual machine should be equal :

CPU: 8 cores
RAM: 16 GiB
SSD/HDD: 50 GiB
Firewall: Allow traffic for the following TCP ports: 30333, 30334

More details you can find here:
https://docs.moonbeam.network/node-operators/networks/full-node/

Please note that these requirements are relative since according to the project developers themselves, the Moonbeam software has not yet been fully optimized, therefore, over time, the system requirements may be reduced.

Installing and configuring software

First of all, we need to install the following packages that will need to properly configure and install the Moonbeam node:

# yum groupinstall "Development Tools" -y
# yum install git curl cmake pkgconfig openssl-devel git gcc clang clang-devel nano -y

Let’s create a user in order not to install software and running Node on behalf of the “root” user, since Linux is a multiuser system and from the point of view of scalability and security, it is recommended to run and configure different programs on behalf of separate users

# adduser moonbeam

After creating an account, log as a “moonbeam” user:

# su -s /bin/bash moonbeam

Please note after creating a user, I wasn’t able to get shell access due to the following error:

su: failed to execute /bin/bash: Resource temporarily unavailable

If you face the same problem, you will need to increase the “nproc” and “nofile” limits to solve the issue. To do this, open the “limits.conf” file:

# nano /etc/security/limits.conf

And add the following options:

moonbeam soft nproc 10240
moonbeam hard nproc 10240
moonbeam soft nofile 10240
moonbeam hard nofile 10240
# End of file

In my case, the above limits should be enough, if you need, you can increase the current limits also, for example, to 32768 or 65535
Go to the home directory:

$ cd ~

By the way, to make sure you are in the correct directory, you can run the command:

$ pwd

If everything is correct, we need to clone the MoonBeam repository using the “git” command:

$ git clone -b tutorial-v3 https://github.com/PureStake/moonbeam

Go to the “moonbeam” directory:

$ cd moonbeam

Sync the repository to the latest version:

$ git checkout tags/$(git tag | tail -1)

Install the Substrate software component, you need to choose “1” option, which means “default setting”:

$ curl https://sh.rustup.rs -sSf | sh

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1

Set the environment variable:

$ source ~/.cargo/env

We run the initialization script to check and install all the necessary components:

$ ./scripts/init.sh

Install our Node:

$ cargo build --release

Once the installation is completed you should see something like this:

Exit the user shell “moonbeam” with the command:

$ exit

Add the firewall rules:

# firewall-cmd — zone=public — permanent — add-port=30334/tcp
# firewall-cmd — zone=public — permanent — add-port=30334/tcp

Create a “systemd” service with the following parameters:

# nano /etc/systemd/system/moonbeam.service
[Unit]
Description="Moonbase Alpha systemd service"
After=network.target
[Service]
Type=simple
#StartLimitIntervalSec=1
Restart=on-failure
RestartSec=10
User=moonbeam
SyslogIdentifier=moonbeam
SyslogFacility=local7
KillSignal=SIGHUP
ExecStart=/home/moonbeam/moonbeam/target/release/moonbeam \
--parachain-id 1000 \
--no-telemetry \
--port 30333 \
--rpc-port 9933 \
--ws-port 9944 \
--pruning=archive \
--unsafe-rpc-external \
--unsafe-ws-external \
--rpc-methods=Safe \
--rpc-cors all \
--log rpc=info \
--base-path /home/moonbeam/moonbeam/target/release \
--chain alphanet \
--name "CentOS7-Moonbeam-Node" \
-- \
--port 30334 \
--rpc-port 9934 \
--ws-port 9945 \
--pruning=archive \
--name="CentOS7-Moonbeam-Node"
[Install]
WantedBy=multi-user.target

Reload systemd manager configuration:

# systemctl daemon-reload

Then start the service:

# systemctl start moonbeam.service

Check system status:

# systemctl status moonbeam.service

You should see something like this “Active (running)”:

Active: active (running)

I also recommend enabling a service at boot, so that if your virtual machine or server is stopped/restarted, the service will be started automatically during system boot:

# systemctl enable moonbeam.service

That’s all! Thanks for your attention!

--

--