MariaDB WolfSSL - anujajakhade/anuja GitHub Wiki

Building MariaDB

Below versions of MariaDB are available in respective distributions at the time of creation of these build instructions:

  • RHEL (7.5, 7.6, 7.7) has 5.5.64
  • RHEL (8.0, 8.1) has 10.3.17
  • SLES (12 SP4, 12SP5, 15 SP1) has 10.2.31
  • Ubuntu 16.04 has 10.0.38
  • Ubuntu 18.04 has 10.1.44
  • Ubuntu 19.10 has 10.3.22

The instructions provided below specify the steps to build MariaDB v10.4.12 on Linux on IBM Z for the following distributions:

  • RHEL (7.5, 7.6, 7.7, 8.0, 8.1)
  • SLES (12 SP4, 12 SP5, 15 SP1)
  • Ubuntu (16.04, 18.04, 19.10)

General Notes:

  • When following the steps below please use a standard permission user unless otherwise specified.

  • A directory /<source_root>/ will be referred to in these instructions, this is a temporary writable directory anywhere you'd like to place it.

Step 1: Build using script

If you want to build mariaDB using manual steps, go to STEP 2.

Use the following commands to build mariaDB using the build script. Please make sure you have wget installed.

wget -q https://raw.githubusercontent.com/linux-on-ibm-z/scripts/master/MariaDB/10.4.12/build_mariadb.sh

# Build MariaDB
bash build_mariadb.sh   [Provide -t option for executing build with tests]

If the build completes successfully, go to STEP 3.7. In case of error, check logs for more details or go to STEP 2 to follow manual build steps.

Step 2: Install following dependencies

export SOURCE_ROOT=/<source_root>/
  • RHEL (7.5, 7.6, 7.7)

    sudo yum install -y git which xz gcc gcc-c++ make wget tar cmake openssl-devel ncurses-devel bison python3 boost-devel check-devel perl-Test-Simple perl-Time-HiRes openssl pcre-devel pam-devel patch hostname
    
  • RHEL (8.0, 8.1)

    sudo yum install -y git gcc which gcc-c++ make wget tar cmake openssl-devel ncurses-devel bison python3 boost-devel check-devel perl-Test-Simple perl-Time-HiRes openssl pcre-devel pam-devel perl-Memoize.noarch patch diffutils hostname
    
  • SLES (12 SP4, 12 SP5)

    sudo zypper install -y git xz which  gcc gcc-c++ make wget tar gzip cmake libopenssl-devel ncurses-devel bison glibc-locale python3 boost-devel check-devel scons gawk pam-devel patch curl
    
  • SLES (15 SP1)

    sudo zypper install -y which git gcc gcc-c++ make wget tar gzip cmake libopenssl-devel ncurses-devel bison glibc-locale python3 boost-devel libboost_program_options-devel check-devel gawk pam-devel patch python3-pip hostname
    
  • Ubuntu (16.04, 18.04, 19.10)

    sudo apt-get update
    sudo apt-get install -y git gcc g++ make wget tar cmake  libncurses-dev bison libboost-dev libboost-program-options-dev check libpam0g-dev python3 python3-pip
    
  • Build WolfSSL 4.3.0

     cd $SOURCE_ROOT
     git clone https://github.com/wolfSSL/wolfssl.git
     cd wolfssl
     git checkout 4.3.0
     bash autogen.sh
    
    • Modify the file wolfssl/wolfcrypt/types.h
    @@ -104,7 +104,7 @@
     /* These platforms have 64-bit CPU registers.  */
     #if (defined(__alpha__) || defined(__ia64__) || defined(_ARCH_PPC64) || \
          defined(__mips64)  || defined(__x86_64__) || defined(_M_X64)) || \
     -         defined(__aarch64__) || defined(__sparc64__) || \
     +         defined(__aarch64__) || defined(__sparc64__) || defined(__s390x__ ) || \
         (defined(__riscv_xlen) && (__riscv_xlen == 64))
         typedef word64 wolfssl_word;
         #define WC_64BIT_CPU
    
    ./configure
     make && sudo make install
    
  • Install python 3.5.2 as scons required it (For SLES 12 SP4, 12 SP5)

    cd $SOURCE_ROOT
    curl -SLO https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tar.xz
    tar -xvf Python-3.5.2.tar.xz
    
    cd Python-3.5.2
    ./configure
    
    make
    sudo make install
    
    which python
    python --version
    

Step 3: Build and Install MariaDB

3.1 Get MariaDB source

cd $SOURCE_ROOT
git clone https://github.com/MariaDB/server.git
cd server
git checkout mariadb-10.4.12

3.2 Build and install

 git submodule update --init --recursive
 mkdir $SOURCE_ROOT/build_mariadb
 cd $SOURCE_ROOT/build_mariadb
 cmake $SOURCE_ROOT/server
 make
 sudo make install 

3.3 Create a user and group with name mysql

sudo groupadd mysql
sudo useradd -g mysql mysql

3.4 Give owner permission to the mysql directory

cd /usr/local/mysql
sudo chown -R mysql .
sudo chmod -R o+rwx .

3.5 Create database and populate test data into database

sudo scripts/mysql_install_db --user=mysql

3.6 Copy script to start and stop MySQL server

sudo cp support-files/mysql.server /etc/init.d/mysql

3.7 Start MySQL server

sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

3.8 Display version

sudo -u mysql bin/mysqladmin version --user=mysql

The output should look similar to this:

bin/mysqladmin  Ver 9.1 Distrib 10.4.12-MariaDB, for Linux on s390x
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version		10.4.12-MariaDB
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/tmp/mysql.sock
Uptime:			7 sec

Threads: 7  Questions: 1  Slow queries: 0  Opens: 16  Flush tables: 1  Open tables: 10  Queries per second avg: 0.142

Step 4: Execute MariaDB test cases(Optional)

cd $SOURCE_ROOT/build_mariadb/mysql-test
./mtr --suite=unit --force --max-test-fail=0

Note: All test cases should pass successfully.

Step 5: Building the Galera wsrep Provider

The Galera wsrep ("write set replication") provider is a library that extends a number of database products (including MariaDB) with replication capabilities. It will need to be installed before MariaDB clustering can be enabled.

5.1 Building Galera requires SCons. Scons requires python >= 3.5

  • Install SCons
    sudo env PATH=$PATH:/usr/local/bin python3 -m pip install scons ( for all RHEL and SLES 12 SP4, SLES 12 SP5)
    
    or
    sudo pip3 install scons ( SLES 15 SP1)
    
    or
    sudo pip3 install scons ( For all Ubuntu)
    
    # make sure we got with python3 
    alias scons3="/usr/bin/env python3 $(which scons)"
    

5.2 Clone the Galera source code from the official GitHub repository, then check out 26.4.3 release:

cd $SOURCE_ROOT
git clone git://github.com/codership/galera.git
cd galera
git checkout release_26.4.3
git submodule init
git submodule update

5.3 Issue following command to build the code:

scons3

5.4 Issue following commands to install the Galera arbitration daemon (garbd) and the wsrep provider library:

sudo cp garb/garbd /usr/local/sbin/
sudo cp libgalera_smm.so /usr/local/lib64/
sudo /sbin/ldconfig -v

_Note: For Ubuntu, if /usr/local/lib64/ path does not exist, then we can create sudo mkdir -p /usr/local/lib64/ path and copy libgalera_smm.so.

The MariaDB configuration file, for example /etc/mysql/conf.d/galera.cnf, needs to be updated as well. The exact configuration values will be different for each installation. The following is an example for a two-node cluster:

[mysqld]
binlog_format=row
innodb_autoinc_lock_mode=2
query_cache_size=0
wsrep_provider=/usr/local/lib64/libgalera_smm.so
wsrep_cluster_address='gcomm://192.168.0.101,192.168.0.102'
wsrep_cluster_name='mariacluster'
wsrep_node_address='192.168.0.101'
wsrep_node_name='dbnode1'
wsrep_sst_method=rsync
wsrep_sst_auth=root:rootpw

MariaDB is now ready for clustering. Refer to following tutorials and documentation for more information on setting up and configuring a Galera cluster:

References

https://mariadb.org/get-involved/getting-started-for-developers/get-code-build-test/
https://mariadb.com/kb/en/library/generic-build-instructions/
https://mariadb.com
https://galeracluster.com