GA

2024/12/04

ConoHa VPSでMySQLをビルドする 2024年

この記事は ConoHa Advent Calendar 2024 の4日目の記事で、 MySQL Advent Calendar 2024 の4日目の記事です。

ConoHa Advent Calendarの昨日の記事は narikakunさんConoHa VPSを使っておひとり様Misskeyサーバーを作る , MySQL Advent Calendarの昨日の記事は hmatsu47さん今年 1 年の個人的な MySQL 関連ネタ登壇を振り返る でした。


去年までのあらすじ。

今年はRocky Linux9でビルドします。

普段使いは今もまだVer. 2.0のVPSを使っているけれど、せっかくなのでVer. 3.0のマシンを使ってみました。性能比較とかはしない。プランは メモリ 1GB/CPU 2Core で変わらず。


$ cat /etc/os-release

NAME="Rocky Linux"

VERSION="9.4 (Blue Onyx)"

ID="rocky"

ID_LIKE="rhel centos fedora"

VERSION_ID="9.4"

PLATFORM_ID="platform:el9"

PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"

ANSI_COLOR="0;32"

LOGO="fedora-logo-icon"

CPE_NAME="cpe:/o:rocky:rocky:9::baseos"

HOME_URL="https://rockylinux.org/"

BUG_REPORT_URL="https://bugs.rockylinux.org/"

SUPPORT_END="2032-05-31"

ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"

ROCKY_SUPPORT_PRODUCT_VERSION="9.4"

REDHAT_SUPPORT_PRODUCT="Rocky Linux"

REDHAT_SUPPORT_PRODUCT_VERSION="9.4"

まずメインストリームではなくなったけどまだ現役のMySQL 8.0.40

$ wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-boost-8.0.40.tar.gz
$ tar xf mysql-boost-8.0.40.tar.gz
$ cd mysql-8.0.40/

cmakeが無かったので入れる。もうcmake3じゃなくてcmakeだけで3系が入るのね。

$ cmake .
-bash: cmake: command not found

$ sudo dnf install cmake

$ cmake .
-- Running cmake version 3.26.5
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- This is .el9. as found from 'rpm -qf /'
-- Looking for a devtoolset compiler
CMake Warning at CMakeLists.txt:407 (MESSAGE):
  Could not find devtoolset compiler/linker in /opt/rh/gcc-toolset-12

CMake Warning at CMakeLists.txt:409 (MESSAGE):
  You need to install the required packages:

   yum install gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12-annobin-annocheck gcc-toolset-12-annobin-plugin-gcc

CMake Error at CMakeLists.txt:411 (MESSAGE):
  Or you can set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.

-- Configuring incomplete, errors occurred!

他にgcc-toolset(devtoolsetではなくなったのか)が必要だと言われるのでインストール。
yumでまだ動くのかとは思ったけどシンボリックリンクでdnf-3に渡されてた。

$ sudo yum install gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12-annobin-annocheck gcc-toolset-12-annobin-plugin-gcc

$ cmake .
..
CMake Error at CMakeLists.txt:642 (MESSAGE):
  Please do not build in-source.  Out-of source builds are highly
  recommended: you can have multiple builds for the same source, and there is
  an easy way to do cleanup, simply remove the build directory (note that
  'make clean' or 'make distclean' does *not* work)

  You *can* force in-source build by invoking cmake with
  -DFORCE_INSOURCE_BUILD=1

-- Configuring incomplete, errors occurred!

ビルドディレクトリを分けないといけないアレ。面倒だけど分けておく(いつもは -DFORCE_INSOUCE_BUILD=1 派)

$ cd ../
$ mkdir 8.0.40-build
$ cd 8.0.40-build

$ cmake ../mysql-8.0.40
..
CMake Error at CMakeLists.txt:642 (MESSAGE):
  Please do not build in-source.  Out-of source builds are highly
  recommended: you can have multiple builds for the same source, and there is
  an easy way to do cleanup, simply remove the build directory (note that
  'make clean' or 'make distclean' does *not* work)

  You *can* force in-source build by invoking cmake with
  -DFORCE_INSOURCE_BUILD=1

-- Configuring incomplete, errors occurred!

む、 mysql-8.0.40/CMakeCache.txt が変なのを残している気がするので消す。

$ rm ../mysql-8.0.40/CMakeCache.txt
$ cmake ../mysql-8.0.40
..
CMake Error at cmake/boost.cmake:109 (MESSAGE):
  You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=<directory>

  This CMake script will look for boost in <directory>.  If it is not there,
  it will download and unpack it (in that directory) for you.

  You can also download boost manually, from
  https://archives.boost.io/release/1.77.0/source/boost_1_77_0.tar.bz2

  If you are inside a firewall, you may need to use an https proxy:

  export https_proxy=http://example.com:80

Call Stack (most recent call first):
  cmake/boost.cmake:278 (COULD_NOT_FIND_BOOST)
  CMakeLists.txt:1593 (INCLUDE)

boost同梱版をダウンロードしていたけど -DWITH_BOOST を指定し忘れていたというアレ。

$ cmake -DWITH_BOOST=../mysql-8.0.40/boost ../mysql-8.0.40

..
Not a supported openssl version in WITH_SSL=system.
Make sure you have specified a supported SSL version.
Valid options are :
openssl[0-9]+ (use alternative system library)
yes (synonym for system)
</path/to/custom/openssl/installation>

CMake Error at cmake/ssl.cmake:84 (MESSAGE):
  Please install the appropriate openssl developer package.

Call Stack (most recent call first):
  cmake/ssl.cmake:380 (FATAL_SSL_NOT_FOUND_ERROR)
  CMakeLists.txt:1825 (MYSQL_CHECK_SSL)

openssl-develが入っていなかったアレ。

$ sudo dnf install -y openssl-devel
$ cmake -DWITH_BOOST=../mysql-8.0.40/boost ../mysql-8.0.40

..
CMake Error at cmake/readline.cmake:93 (MESSAGE):
  Curses library not found.  Please install appropriate package,

      remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
  cmake/readline.cmake:127 (FIND_CURSES)
  cmake/readline.cmake:221 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:1929 (MYSQL_CHECK_EDITLINE)

今度はncurses-develが入っていなかったアレ(しかし何か足りないにせよ毎回エラーメッセージが違うなあ…)

$ sudo dnf install -y ncurses-devel
$ cmake -DWITH_BOOST=../mysql-8.0.40/boost ../mysql-8.0.40

..
-- Checking for module 'libtirpc'
--   Package 'libtirpc', required by 'virtual:world', not found
CMake Warning at cmake/rpc.cmake:41 (MESSAGE):
  Cannot find RPC development libraries.  You need to install the required
  packages:

    Debian/Ubuntu:              apt install libtirpc-dev
    RedHat/Fedora/Oracle Linux: yum install libtirpc-devel
    SuSE:                       zypper install glibc-devel

Call Stack (most recent call first):
  cmake/rpc.cmake:107 (WARN_MISSING_SYSTEM_TIRPC)
  CMakeLists.txt:2065 (MYSQL_CHECK_RPC)

CMake Error at cmake/rpc.cmake:108 (MESSAGE):
  Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
Call Stack (most recent call first):
  CMakeLists.txt:2065 (MYSQL_CHECK_RPC)

前はncurses-devel入れた後にCMakeCache.txtを消さないといけなかったような気がするけどそのままいけて次のエラー。libtirpc-develでしょ。 知ってるよ。

$ sudo dnf install -y libtirpc-devel

Last metadata expiration check: 0:27:55 ago on Mon 02 Dec 2024 04:29:48 PM JST.
No match for argument: libtirpc-devel
Error: Unable to find a match: libtirpc-devel

$ sudo dnf install -y --enablerepo=crb libtirpc-devel

$ cmake -DWITH_BOOST=../mysql-8.0.40/boost ../mysql-8.0.40

..
CMake Warning at cmake/rpc.cmake:30 (MESSAGE):
  Cannot find rpcgen executable.  You need to install the required packages:

    Debian/Ubuntu:              apt install rpcsvc-proto
    RedHat/Fedora/Oracle Linux: yum install rpcgen
    SuSE:                       zypper install glibc-devel

Call Stack (most recent call first):
  plugin/group_replication/libmysqlgcs/cmake/rpcgen.cmake:113 (WARN_MISSING_RPCGEN_EXECUTABLE)
  plugin/group_replication/libmysqlgcs/CMakeLists.txt:51 (INCLUDE)

CMake Error at plugin/group_replication/libmysqlgcs/cmake/rpcgen.cmake:114 (MESSAGE):
  Could not find rpcgen
Call Stack (most recent call first):
  plugin/group_replication/libmysqlgcs/CMakeLists.txt:51 (INCLUDE)

rpcgen。これも知ってる。

$ sudo dnf install -y --enablerepo=crb rpcgen

$ cmake -DWITH_BOOST=../mysql-8.0.40/boost ../mysql-8.0.40
..

-- Build files have been written to: /home/yoku0825/8.0.40-build

じゃあmake。メモリ 1GB/CPU 2CoreのプランだとOOM Killerでやられるかswapファイルを積んでもスラッシングでやられるだけなので大人しく1コアで。

$ time make
..
..
[ 56%] Generating xdr_gen/xcom_vp.h, xdr_gen/xcom_vp_xdr.c
cannot find C preprocessor: cpp
/usr/bin/rpcgen: C preprocessor failed with exit code 1
cannot find C preprocessor: cpp
/usr/bin/rpcgen: C preprocessor failed with exit code 1
cannot find C preprocessor: cpp
/usr/bin/rpcgen: C preprocessor failed with exit code 1
cannot find C preprocessor: cpp
/usr/bin/rpcgen: C preprocessor failed with exit code 1
cannot find C preprocessor: cpp
..
make[2]: *** [plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/build.make:99: plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/src/bindings/xcom/xcom/pax_msg.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:14466: plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

real    131m30.750s
user    70m33.106s
sys     6m43.641s

たっぷり時間をかけてからエラった。cppコマンドが見つからない。

$ sudo dnf install cpp

$ time make
..
[ 56%] Built target gr_unit_test_resource
[ 56%] Building CXX object plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/src/bindings/xcom/xcom/pax_msg.cc.o
In file included from /home/yoku0825/mysql-8.0.40/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/pax_msg.cc:31:
/home/yoku0825/mysql-8.0.40/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/app_data.h:44:1: error: ‘app_data_ptr’ does not name a type
   44 | app_data_ptr clone_app_data(app_data_ptr a);
      | ^~~~~~~~~~~~
/home/yoku0825/mysql-8.0.40/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/app_data.h:45:1: error: ‘app_data_ptr’ does not name a type
   45 | app_data_ptr clone_app_data_single(app_data_ptr a);
      | ^~~~~~~~~~~~

..
make[2]: *** [plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/build.make:99: plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/src/bindings/xcom/xcom/pax_msg.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:14466: plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

real    0m15.112s
user    0m7.916s
sys     0m3.575s

同じところですぐ転けた。たぶんCMakeFilesディレクトリに変なのが残ってる。
plugin/group_replication/CMakeFiles だけ消せばいい気がするんだけど、間違えて plugin/group_replication/libmysqlgcs を消してしまったので最初から…。

$ make clean
$ time make
..
real    248m20.672s
user    136m41.102s
sys     11m49.462s

たっぷり4時間かけて成功。

$ sudo make install

$ du -sh /usr/local/mysql
1.5G    /usr/local/mysql

8.0.40はこんなもんだったので次。メインストリームの8.4.3。8.4からは(途中のInnovation Releaseからだったかもしれないけどおぼえてない) boost同梱版という概念がなくなって必ず同梱されている。

$ sudo rm -r /usr/local/mysql
$ cd
$ wget https://dev.mysql.com/get/Downloads/MySQL-8.4/mysql-8.4.3.tar.gz

$ tar xf mysql-8.4.3.tar.gz

$ mkdir 8.4.3-build
$ cd 8.4.3-build/
$ cmake ../mysql-8.4.3

8.0.40の時にインストールした諸々だけでcmakeには成功。

$ time make
..
real    310m22.856s
user    164m47.727s
sys     14m17.480s

$ du -sh /usr/local/mysql
1.5G    /usr/local/mysql

うひー6時間オーバー。バイナリサイズは変わらず1.5GB程度…。
最後にInnovation Releaseの9.1.0。

$ sudo rm -r /usr/local/mysql
$ cd
$ wget https://dev.mysql.com/get/Downloads/MySQL-9.1/mysql-9.1.0.tar.gz

$ tar xf mysql-9.1.0.tar.gz
$ mkdir 9.1.0-build
$ cd 9.1.0-build
$ cmake ../mysql-9.1.0
-- Running cmake version 3.26.5
-- Could NOT find Git (missing: GIT_EXECUTABLE)
-- This is .el9. as found from 'rpm -qf /'
-- Looking for a devtoolset compiler
CMake Warning at CMakeLists.txt:396 (MESSAGE):
  Could not find devtoolset compiler/linker in /opt/rh/gcc-toolset-13

CMake Warning at CMakeLists.txt:398 (MESSAGE):
  You need to install the required packages:

   yum install gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ gcc-toolset-13-binutils gcc-toolset-13-annobin-annocheck gcc-toolset-13-annobin-plugin-gcc

CMake Error at CMakeLists.txt:400 (MESSAGE):
  Or you can set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.
-- Configuring incomplete, errors occurred!

9.1はtoolset-12じゃなくて13が必要らしい。

$ sudo yum install gcc-toolset-13-gcc gcc-toolset-13-gcc-c++ gcc-toolset-13-binutils gcc-toolset-13-annobin-annocheck gcc-toolset-13-annobin-plugin-gcc

$ cmake ../mysql-9.1.0
$ time make

..
real    332m51.066s
user    180m36.865s
sys     16m31.190s

$ sudo make install
$ du -sh /usr/local/mysql
1.5G    /usr/local/mysql

MySQL 9.1に至っては6時間半かかった…。
早めに始めておいてよかった…。

明日はConoHa Advent Calendaryamagami2211さん, MySQL Advent Calendarが……募集中です!

0 件のコメント :

コメントを投稿