GA

ラベル ConoHa Advent Calendar の投稿を表示しています。 すべての投稿を表示
ラベル ConoHa Advent Calendar の投稿を表示しています。 すべての投稿を表示

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が……募集中です!

2023/12/05

ConoHaの上でひたすらMySQLをビルドする in 2023

この記事は ConoHaのカレンダー | Advent Calendar 2023 と MySQLのカレンダー | Advent Calendar 2023 の5日目の記事です。

去年は CentOS 9 Stream でビルドしたらしい。

今年は Rocky Linux 8, 9 が正式にMySQLのSupported PlatformになったのでRocky Linux 9でやってみる。

(cppを足しておけば Rocky Linux 9でもビルドできた可能性がある)



$ cat /etc/os-release

NAME="Rocky Linux"

VERSION="9.2 (Blue Onyx)"

ID="rocky"

ID_LIKE="rhel centos fedora"

VERSION_ID="9.2"

PLATFORM_ID="platform:el9"

PRETTY_NAME="Rocky Linux 9.2 (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.2"

REDHAT_SUPPORT_PRODUCT="Rocky Linux"

REDHAT_SUPPORT_PRODUCT_VERSION="9.2"

MySQLは折角だから8.2.0を選ぶぜ!

$ wget https://dev.mysql.com/get/Downloads/MySQL-8.2/mysql-boost-8.2.0.tar.gz
$ tar xf mysql-boost-8.2.0.tar.gz
$ mkdir build
$ cd build
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0
-bash: cmake: command not found

まずはcmake

$ sudo dnf install -y cmake
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0
..
CMake Warning at CMakeLists.txt:397 (MESSAGE):
  Could not find devtoolset compiler/linker in /opt/rh/gcc-toolset-12

CMake Warning at CMakeLists.txt:399 (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:401 (MESSAGE):
  Or you can set CMAKE_C_COMPILER and CMAKE_CXX_COMPILER explicitly.

-- Configuring incomplete, errors occurred!

メッセージの通りgcc, gcc-c++, binutilsとかを突っ込む

$ sudo dnf install -y 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 -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0

..
-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_CRYPTO_LIBRARY OPENSSL_INCLUDE_DIR)
--
Could not find system OpenSSL
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:346 (FATAL_SSL_NOT_FOUND_ERROR)
  cmake/ssl.cmake:518 (FIND_SYSTEM_OPENSSL)
  CMakeLists.txt:1831 (MYSQL_CHECK_SSL)

次はopenssl-devel

$ sudo dnf install -y openssl-devel
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0
..
CMake Error at cmake/readline.cmake:92 (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:126 (FIND_CURSES)
  cmake/readline.cmake:220 (MYSQL_USE_BUNDLED_EDITLINE)
  CMakeLists.txt:1934 (MYSQL_CHECK_EDITLINE)

ncurses-devel. これはCMaKeCache.txt消してあげないといけないやつ。

$ sudo dnf install -y ncurses-devel
$ rm CMakeCache.txt
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0
..
CMake Warning at cmake/rpc.cmake:40 (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:96 (WARN_MISSING_SYSTEM_TIRPC)
  plugin/group_replication/libmysqlgcs/cmake/configure.cmake:34 (MYSQL_CHECK_RPC)
  plugin/group_replication/libmysqlgcs/CMakeLists.txt:31 (INCLUDE)

CMake Error at cmake/rpc.cmake:97 (MESSAGE):
  Could not find rpc/rpc.h in /usr/include or /usr/include/tirpc
Call Stack (most recent call first):
  plugin/group_replication/libmysqlgcs/cmake/configure.cmake:34 (MYSQL_CHECK_RPC)
  plugin/group_replication/libmysqlgcs/CMakeLists.txt:31 (INCLUDE)

毎年引っかかるrpc.h

$ sudo dnf install -y libtirpc-devel
Last metadata expiration check: 0:10:10 ago on Mon Dec  4 15:11:45 2023.
No match for argument: libtirpc-devel
Error: Unable to find a match: libtirpc-devel

エラーメッセージの通りにやるとそんなものないと言われる… 去年の自分に助けられ て、crbなるリポジトリにあることが判明。

$ sudo dnf install -y --enablerepo=crb libtirpc-devel
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0

..
CMake Warning at cmake/rpc.cmake:29 (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:122 (WARN_MISSING_RPCGEN_EXECUTABLE)
  plugin/group_replication/libmysqlgcs/CMakeLists.txt:50 (INCLUDE)

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

rpcgenと同じものなのかと思ったらrpcgenはrpcgenでいるらしい。

$ sudo dnf install -y --enablerepo=crb rpcgen
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0
..
-- Build files have been written to: /home/yoku0825/build

cmake完了。 今年は ~さっさと終わらせたくて~ 奮発して4コア4GBのインスタンスを使ってるので少しは快適か

$ time make -j$(nproc)
..
[ 52%] 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.2.0/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/pax_msg.cc:30:
/home/yoku0825/mysql-8.2.0/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/app_data.h:43:1: error: ‘app_data_ptr’ does not name a type
   43 | app_data_ptr clone_app_data(app_data_ptr a);
      | ^~~~~~~~~~~~
/home/yoku0825/mysql-8.2.0/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_single(app_data_ptr a);
      | ^~~~~~~~~~~~
/home/yoku0825/mysql-8.2.0/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 new_app_data();
      | ^~~~~~~~~~~~

..
/home/yoku0825/mysql-8.2.0/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/site_def.h:67:22: warning: ‘node_no_exists’ defined but not used [-Wunused-variable]
   67 | static inline bool_t node_no_exists(node_no n, site_def const *site) {
      |                      ^~~~~~~~~~~~~~
/home/yoku0825/mysql-8.2.0/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/synode_no.h:44:19: warning: ‘group_mismatch’ defined but not used [-Wunused-variable]
   44 | static inline int group_mismatch(synode_no x, synode_no y) {
      |                   ^~~~~~~~~~~~~~
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:9709: plugin/group_replication/libmysqlgcs/CMakeFiles/mysqlgcs.dir/all] Error 2
make: *** [Makefile:166: all] Error 2

real    2m5.571s
user    7m22.443s
sys     0m50.147s

あれ、転けた。。

なんかどうもこれと同じような気がするけど解決方法が全く分からない…。

諦めてRocky Linux 8にすることにする!

改めて。

$ cat /etc/os-release
NAME="Rocky Linux"
VERSION="8.7 (Green Obsidian)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.7"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Rocky Linux 8.7 (Green Obsidian)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:8:GA"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-8"
ROCKY_SUPPORT_PRODUCT_VERSION="8.7"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.7"

$ sudo dnf install -y cmake gcc-toolset-12-gcc gcc-toolset-12-gcc-c++ gcc-toolset-12-binutils gcc-toolset-12-annobin-annocheck gcc-toolset-12-annobin-plugin-gcc openssl-devel ncurses-devel --enablerepo=powertools libtirpc-devel rpcgen

$ wget https://dev.mysql.com/get/Downloads/MySQL-8.2/mysql-boost-8.2.0.tar.gz
$ tar xf mysql-boost-8.2.0.tar.gz
$ mkdir build
$ cd build

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

$ time make -j$(nproc)

..
[ 13%] 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
[ 13%] Building CXX object extra/icu/CMakeFiles/icuuc.dir/icu-release-73-1/source/common/ucnv_lmb.cpp.o
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
[ 13%] Building CXX object mysys/CMakeFiles/mysys_objlib.dir/my_kdf.cc.o
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
/usr/bin/rpcgen: C preprocessor failed with exit code 1
[ 13%] Building CXX object extra/icu/CMakeFiles/icui18n.dir/icu-release-73-1/source/i18n/nortrans.cpp.o
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
[ 13%] 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.2.0/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/pax_msg.cc:30:
/home/yoku0825/mysql-8.2.0/plugin/group_replication/libmysqlgcs/src/bindings/xcom/xcom/app_data.h:43:1: error: 'app_data_ptr' does not name a type
   43 | app_data_ptr clone_app_data(app_data_ptr a);
      | ^~~~~~~~~~~~

..

もしかして cannot find C preprocessor: cpp を見落としてた?

$ sudo dnf install cpp
$ time make -j$(nproc)
..

違った。 なんかrpcgenをもう一度やってない気がしたのでビルドディレクトリを綺麗にしてもう一度makeしてみる。

$ rm -r *
$ cmake -DWITH_BOOST=../mysql-8.2.0/boost ../mysql-8.2.0
$ make -j$(nproc)
..
[100%] Building CXX object unittest/gunit/CMakeFiles/merge_large_tests-t.dir/__/__/storage/example/ha_example.cc.o
[100%] Linking CXX executable ../../runtime_output_directory/merge_large_tests-t
[100%] Built target merge_large_tests-t

上手くいったじゃん…。

ということはcppを足してからやり直せばRocky Linux 9でも上手くいくかも知れない。初回で見落として繰り返してしまったか…。

けど、それは来年にでもやるとして今年もお疲れさまでした。

2022/12/09

また今年もConoHaの上でMySQLをビルドする季節がやってきた

この記事は ConoHaのカレンダー | Advent Calendar 2022 - Qiita の9日目の記事で、 MySQLのカレンダー | Advent Calendar 2022 - Qiita の9日目の記事でもあります。

去年は失敗したCentOS 9 Streamでのビルドを今年は成功させました。

去年には MySQL :: Supported Platforms: MySQL Database に載っていなかった気がするCentOS 9 Stream(Streamとは書いてないな…)も今は記述があって、8.0はサポートされている様子。


$ cat /etc/centos-release

CentOS Stream release 9

去年 のCentOS 8 Streamでリポジトリ名が小文字になってハマったpowertools, 9 Streamではどうやら crb なるリポジトリに移った様子。

yum - How to get epel-release / epel-release-next / powertools in CentOS Stream 9 - Unix & Linux Stack Exchange

先人の記録に感謝しながらビルドに必要な一式をインストール。

$ sudo dnf install --enablerepo=crb cmake gcc gcc-c++ openssl-devel ncurses-devel libtirpc-devel rpcgen

MySQLのソースコードを落として展開。

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

ビルド用のディレクトリを掘ってcmake。

$ mkdir build
$ cd build/

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

OOM Killerにやられてもアレなので、swapファイルを足しておく。

$ sudo dd if=/dev/zero of=/swapfile bs=1M count=4096
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
$ sudo swapon /swapfile

で、make。ちょっとバイナリのサイズ小さくなってる?

$ time make

real    245m46.514s
user    195m49.156s
sys     20m46.145s

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

$ sudo useradd mysql
$ cd /usr/local/mysql
$ sudo bin/mysqld --initialize-insecure --user=mysql
2022-12-08T15:53:26.099038Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.31) initializing of server in progress as process 84746
2022-12-08T15:53:26.116373Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-12-08T15:53:26.510757Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-12-08T15:53:28.637373Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

$ sudo bin/mysqld --user=mysql --daemonize
mysqld will log errors to /usr/local/mysql/data/160-251-102-248.err
mysqld is running as pid 84809

起動もOK。

$ bin/mysql -uroot --skip-binary-as-hex

mysql> SELECT CURDATE();
+------------+
| CURDATE()  |
+------------+
| 2022-12-09 |
+------------+
1 row in set (0.00 sec)

mysql> SELECT 0x436F6E6F486120416476656E742043616C656E6465722032303232;
+----------------------------------------------------------+
| 0x436F6E6F486120416476656E742043616C656E6465722032303232 |
+----------------------------------------------------------+
| ConoHa Advent Calender 2022                              |
+----------------------------------------------------------+
1 row in set (0.00 sec)


毎年、仕事で使っている以外の新しいCentOSに触れる唯一の機会になっているなあ。

良いお年を。