Help us understand the problem. What is going on with this article?

Ubuntu 18.04 LTS で MariaDB Community Server 10.4 をビルド

Ubuntu 18.04 LTS 上でソースコードから MariaDB Community Server 10.4 をビルドする手順をまとめます(GitHub Actions では CentOS 7 が選択できない)。

GitHub レポジトリの 10.4 ブランチから clone

MariaDB Community Server 10.4 のソースコードを GitHub レポジトリから clone します。

git clone --branch 10.4 https://github.com/MariaDB/server.git

依存パッケージのインストール

以下のドキュメントに記載されている,

https://mariadb.com/kb/en/library/building-mariadb-on-ubuntu/

以下の deb パッケージをインストールします。

sudo apt-get -y update
sudo apt-get install -y software-properties-common devscripts equivs

さきほど clone した ソースコードの server/debian ディレクトリにある,autobake-deb.sh を実行します。

cd server
~/server$ ./debian/autobake-deb.sh
Incrementing changelog and starting build scripts
Creating package version 1:10.4.9+maria~bionic ...
dpkg-buildpackage: info: source package mariadb-10.4
dpkg-buildpackage: info: source version 1:10.4.9+maria~bionic
dpkg-buildpackage: info: source distribution bionic
dpkg-buildpackage: info: source changed by vagrant <vagrant@vagrant.vm>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source -I --before-build server
dpkg-checkbuilddeps: error: Unmet build dependencies: bison chrpath cmake (>= 2.7) dh-apparmor dh-systemd gdb libaio-dev libboost-dev libcrack2-dev (>= 2.9.0) libjemalloc-dev (>= 3.0.0~) libjudy-dev libkrb5-dev libncurses5-dev (>= 5.0-6~) libnuma-dev libpam0g-dev libpcre3-dev (>= 2:8.35-3.2~) libreadline-gplv2-dev libsnappy-dev libssl-dev | libssl1.0-dev libsystemd-dev libxml2-dev libzstd-dev unixodbc-dev uuid-dev zlib1g-dev (>= 1:1.1.3-5~)
dpkg-buildpackage: warning: build dependencies/conflicts unsatisfied; aborting
dpkg-buildpackage: warning: (Use -d flag to override.)

dpkg-checkbuilddeps: error: Unmet build dependencies: で始まる行に記載されている不足している依存パッケージをインストールします。

sudo apt-get install -y bison chrpath cmake dh-apparmor dh-systemd \
  gdb libaio-dev libboost-dev libcrack2-dev libjemalloc-dev \
  libjudy-dev libkrb5-dev libncurses5-dev libnuma-dev libpam0g-dev \
  libpcre3-dev  libreadline-gplv2-dev  libsnappy-dev libssl-dev \
  libsystemd-dev libxml2-dev libzstd-dev unixodbc-dev uuid-dev zlib1g-dev

再度 ./debian/autobake-deb.sh を実行します。

~/server$ ./debian/autobake-deb.sh
Incrementing changelog and starting build scripts
Creating package version 1:10.4.9+maria~bionic ...
dpkg-buildpackage: info: source package mariadb-10.4
dpkg-buildpackage: info: source version 1:10.4.9+maria~bionic
dpkg-buildpackage: info: source distribution bionic
dpkg-buildpackage: info: source changed by vagrant <vagrant@vagrant.vm>
dpkg-buildpackage: info: host architecture amd64
 dpkg-source -I --before-build server
 debian/rules clean
dh clean --parallel --with systemd --list-missing
   dh_clean -O--parallel -O--list-missing
        rm -f debian/debhelper-build-stamp
...略...

インストール

make install で /usr/local/mysql にビルドしたバイナリ等がコピーされます。

sudo make install

/usr/local/mysql/INSTALL-BINARY にインストール手順が記載されていますので,

 #!/bin/sh -x

 groupadd mysql
 useradd -g mysql mysql
 cd /usr/local/mysql
 chown -R mysql:mysql .
 scripts/mysql_install_db --user=mysql
 chown -R root .
 chown -R mysql data

で初期データの作成,owner/permission設定が行えます。以下のコマンドで MariaDB Community Server を起動できます。

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

MariaDB monitor を起動します。

$ /usr/local/mysql/bin/mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.4.9-MariaDB Source distribution

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)]> 

debug フラグを付与してビルド

デバッグ用のバイナリをビルドする際には,以下のスクリプトを実行します。

./BUILD/compile-amd64-debug-max

バージョンは以下のように 10.4.9-MariaDB-debug となります。

$ /usr/local/mysql/bin/mariadb
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 10.4.9-MariaDB-debug Source distribution

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)]> SELECT @@version;
+----------------------+
| @@version            |
+----------------------+
| 10.4.9-MariaDB-debug |
+----------------------+
Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away