Install MariaDB on AlmaLinux
Preparation
Make sure your system is up-to-date and wget
is installed. The
instructions use wget
to download scripts from our GitHub repository.
Alternatively, if you are familiar with curl
you can replace wget with
curl.
sudo yum -y update
sudo yum -y install wget.
During this installation some files will need to be edited manually. If you are familiar with vim set it as default editor with the commands below. If you are not familiar with vim please skip this and keep using the default editor. |
sudo yum -y install vim
sudo update-alternatives --install /usr/bin/editor editor /usr/bin/vim 100
(Optional) Install a password generator
By default pwgen
(password generator) is not available on
AlmaLinux. To use it, you have to enable the epel
(Extra Packages
Enterprise Linux) repository first. Since this is an unsupported 3rd
party repository, you have to install it manually. If you do not want to
install these packages on your server, you can skip this step and
generate secure passwords on another machine.
sudo yum -y install epel-release
sudo yum -y install pwgen
Install MariaDB
Download the MariaDB Repo Script:
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
Install the latest MariaDB Server & Client:
sudo yum install MariaDB-server MariaDB-client
Configure MariaDB for Relution
Download the relution.cnf
template from our GitHub repository and safe
it to /etc/my.cnf.d/relution.cnf
.
sudo wget https://raw.githubusercontent.com/relution-io/relution-setup/master/native/Linux/etc/my.cnf.d/relution.cnf.template
sudo mv relution.cnf.template /etc/my.cnf.d/relution.cnf
sudo chmod og-w /etc/my.cnf.d/relution.cnf
If SELinux is in enforcing mode (default) the file’s security context is wrong after the move. Run the command below to fix it. Otherwise SELinux will prevent the service from accessing the file for security reasons.
sudo restorecon -v /etc/my.cnf.d/relution.cnf
Start MariaDB and make sure the service is started automatically after a system reboot.
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Check installation
You should now be able to connect to this MariaDB instance. Note that
for backwards compatibility reasons the command line tools still use
mysql
, this is not an error.
mysql
You should see output similar to the one below:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.5.10-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
Enter this command to verify that server and database collation are set to utf8mb4 as desired:
SHOW VARIABLES LIKE '%collation%';
Make sure collation_database
and collation_server
show
utf8mb4_general_ci
.
Press Ctrl+D
to disconnect from MariaDB and return to the command
prompt.
Create Relution database
Next, we are going to create the relution
database and an associated
database user. This user is going to be used by the Relution service to
connect to the database. Download the script from GitHub.
sudo wget https://raw.githubusercontent.com/relution-io/relution-setup/master/native/Linux/scripts/create_database.sh --directory-prefix=/opt
Ensure the file is executable by root:
sudo chmod 700 /opt/create_database.sh
(Optional) Use pwgen
to generate a secure random password
pwgen -snc 48 1
Execute the script to create the database:
sudo /opt/create_database.sh "relution" "<password>"
This creates a new database called relution
and a new database user
with the name relution
that has full privileges on this database. This
user is used by the Relution service to access the database. If
administrative access to the database is needed for maintenance purposes
we recommended to create a separate database user for this.
Make sure you save the password (excluding the quotation marks) in a secure location. You will need to configure this password later to grant Relution access to the database.
Verify that you can connect to the database as this user:
mysql -u relution -p relution
Enter the password when prompted. You should see the MariaDB prompt as
above. Use Ctrl+D
to sign out again.
Firewall configuration
If you’re going to install Relution on another machine, you need to open
port 3306
on this machine, so Relution can talk to MariaDB. If
Relution is going to be installed on the same machine you can skip these
steps.
Replace ADDRESS with the IP address and netmask of the
machine or network you want to grant access to this MariaDB instance.
Examples: Use 192.168.0.1/32 to grant access to the machine with the
IP address 192.168.0.1. Use 192.168.0.0/24 to grant access to any
machine in the IP address range 192.168.0.x. When in doubt, consult
your network administrator.
|
sudo firewall-cmd --permanent --zone=public --add-rich-rule='rule family="ipv4" source address="###ADDRESS###" port protocol="tcp" port="3306" accept'
sudo firewall-cmd --reload