From 8ec4a2c8a832d77f171493d12abd800cd2fff490 Mon Sep 17 00:00:00 2001 From: Anton Povarov Date: Tue, 17 Dec 2024 23:33:07 +0400 Subject: [PATCH 1/3] Default docker build now uses Ubuntu LTS 24.04 --- Dockerfile | 87 +++++++++++++++++------------------- configure.ac | 36 ++++++++------- docker-entrypoint.sh | 21 ++++----- docker/build-dependencies.sh | 32 +++++++++++++ docker/build-from-source.sh | 36 --------------- docker/build-pinba.sh | 14 ++++++ mysql_engine/handler.cpp | 16 ++++--- mysql_engine/handler.h | 2 + mysql_engine/plugin.cpp | 2 +- mysql_engine/plugin.h | 4 ++ 10 files changed, 134 insertions(+), 116 deletions(-) create mode 100755 docker/build-dependencies.sh delete mode 100755 docker/build-from-source.sh create mode 100755 docker/build-pinba.sh diff --git a/Dockerfile b/Dockerfile index 6e787b1..3b063d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,64 +1,61 @@ -FROM fedora:25 as builder +FROM ubuntu:24.04 AS builder -# https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#sort-multi-line-arguments -RUN dnf install -y \ - autoconf \ - automake \ - boost-devel \ - cmake \ - dnf-plugins-core \ - file \ - gcc \ - gcc-c++ \ - git-core \ - hostname \ - libtool \ - mariadb-devel-3:10.1.26-2.fc25.x86_64 \ - mariadb-server-3:10.1.26-2.fc25.x86_64 \ - rpm-build +SHELL [ "/bin/bash", "-c" ] -RUN dnf builddep -y \ - mariadb +ARG NANOMSG_VERSION=1.2.1 +ARG LZ4_VERSION=1.10.0 -RUN useradd builder -u 1000 -m -G users,wheel && \ - mkdir /home/builder/rpm && \ - chown -R builder /home/builder +COPY <= 5.1]) - AC_TRY_RUN([ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include #include #include @@ -205,9 +212,7 @@ else exit(1); #endif } - ], - [ AC_MSG_RESULT([ok]) ], - [ AC_MSG_ERROR([MySQL 5.1+ is required])]) + ]])],[ AC_MSG_RESULT([ok]) ],[ AC_MSG_ERROR([MySQL 5.1+ is required])],[]) CFLAGS="$CFLAGS_old" CXXFLAGS="$CXXFLAGS_old" @@ -324,4 +329,5 @@ AC_SUBST(INSTALL_STRIP_FLAG) AC_SUBST(EXPERIMENT_DIR) -AC_OUTPUT([Makefile src/Makefile include/Makefile mysql_engine/Makefile experiments/Makefile]) +AC_CONFIG_FILES([Makefile src/Makefile include/Makefile mysql_engine/Makefile experiments/Makefile]) +AC_OUTPUT diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0fdfa98..19db455 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -5,19 +5,13 @@ if [ $1 = "mysqld" ]; then - # fedora mysqld is in special location - ln -snf /usr/libexec/mysqld /usr/local/bin - - # disable gss auth as it's not installed in this container - rm -rf /etc/my.cnf.d/auth_gssapi.cnf - - # create default databases - # too expensive to perform on container startup really - mysql_install_db --rpm - chmod -R 777 /var/lib/mysql + # create dir where mysql.sock will be located + rundir=$(dirname `mysql_config --socket`) + mkdir -p $rundir + chmod 777 $rundir # start mysql server in background for init process - "$@" --skip-networking -umysql & + "$@" --skip-networking -umysql --plugin-maturity=unknown & pid="$!" # legen.... wait for it @@ -65,4 +59,7 @@ if [ $1 = "mysqld" ]; then fi fi -exec "$@" -umysql +exec "$@" -umysql \ + --port=3306 \ + --socket=`mysql_config --socket` \ + --plugin-maturity=unknown diff --git a/docker/build-dependencies.sh b/docker/build-dependencies.sh new file mode 100755 index 0000000..2276c54 --- /dev/null +++ b/docker/build-dependencies.sh @@ -0,0 +1,32 @@ +#!/bin/bash -xe + +# mariadb +cd /_src/mariadb +cmake . + +# don't want to build the whole thing, it takes a long time, just what we need +make -C libservices +# boost tries to include this file globally and includes this one; but mariadb needs this to install +mv VERSION VERSION.backup +# make mysqld_error.h available in non-esoteric location +ln -snf /_src/mariadb/libmariadb/include/mysqld_error.h include/mysqld_error.h + + +# build nanomsg and install (this one is a lil tricky to build statically) +cd /_src/nanomsg +cmake \ + -DNN_STATIC_LIB=ON \ + -DNN_ENABLE_DOC=OFF \ + -DNN_MAX_SOCKETS=4096 \ + -DCMAKE_C_FLAGS="-fPIC -DPIC" \ + -DCMAKE_INSTALL_PREFIX=/_install/nanomsg \ + -DCMAKE_INSTALL_LIBDIR=lib \ + . + +make -j4 +make install + +# build lz4 with PIC static lib +cd /_src/lz4 +make CFLAGS="-fPIC -DPIC" +make install PREFIX=/_install/lz4 diff --git a/docker/build-from-source.sh b/docker/build-from-source.sh deleted file mode 100755 index 719440c..0000000 --- a/docker/build-from-source.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -xe - -# build nanomsg and install (this one is a lil tricky to build statically) -cd /_src/nanomsg -cmake \ - -DNN_STATIC_LIB=ON \ - -DNN_ENABLE_DOC=OFF \ - -DNN_MAX_SOCKETS=4096 \ - -DCMAKE_C_FLAGS="-fPIC -DPIC" \ - -DCMAKE_INSTALL_PREFIX=/_install/nanomsg \ - -DCMAKE_INSTALL_LIBDIR=lib \ - . - -make -j4 -make install - -# build lz4 with PIC static lib -cd /_src/lz4 -make CFLAGS="-fPIC -DPIC" -make install PREFIX=/_install/lz4 - -# pinba -cd /_src/pinba2 -./buildconf.sh -./configure --prefix=/_install/pinba2 \ - --with-mysql=/home/builder/rpm/mariadb-10.1.26 \ - --with-boost=/usr \ - --with-meow=/_src/meow \ - --with-nanomsg=/_install/nanomsg \ - --with-lz4=/_install/lz4 \ - --enable-libmysqlservices -make -j4 - -# FIXME: this needs to be easier -# for install, just copy stuff to mysql plugin dir -cp /_src/pinba2/mysql_engine/.libs/libpinba_engine2.so `mysql_config --plugindir` diff --git a/docker/build-pinba.sh b/docker/build-pinba.sh new file mode 100755 index 0000000..cd77350 --- /dev/null +++ b/docker/build-pinba.sh @@ -0,0 +1,14 @@ +#!/bin/bash -xe + +# Run this after build-dependencies.sh +# pinba +cd /_src/pinba2 +./buildconf.sh +./configure --prefix=/_install/pinba2 \ + --with-boost=/usr \ + --with-mysql=/_src/mariadb \ + --with-meow=/_src/meow \ + --with-nanomsg=/_install/nanomsg \ + --with-lz4=/_install/lz4 \ + --enable-libmysqlservices +make -j4 diff --git a/mysql_engine/handler.cpp b/mysql_engine/handler.cpp index 3ecd7da..6914611 100644 --- a/mysql_engine/handler.cpp +++ b/mysql_engine/handler.cpp @@ -14,10 +14,12 @@ #ifdef PINBA_USE_MYSQL_SOURCE #include // #include // -#include // +#include // +#include // #else #include #include +#include #include #endif // PINBA_USE_MYSQL_SOURCE @@ -150,9 +152,9 @@ struct pinba_view___stats_t : public pinba_view___base_t // mark all fields as writeable to avoid assert() in ::store() calls // got no idea how to do this properly anyway - auto *old_map = dbug_tmp_use_all_columns(table, table->write_set); + auto *old_map = dbug_tmp_use_all_columns(table, &table->write_set); MEOW_DEFER( - dbug_tmp_restore_column_map(table->write_set, old_map); + dbug_tmp_restore_column_map(&table->write_set, old_map); ); for (Field **field = table->field; *field; field++) @@ -404,9 +406,9 @@ struct pinba_view___active_reports_t : public pinba_view___base_t // mark all fields as writeable to avoid assert() in ::store() calls // got no idea how to do this properly anyway - auto *old_map = dbug_tmp_use_all_columns(table, table->write_set); + auto *old_map = dbug_tmp_use_all_columns(table, &table->write_set); MEOW_DEFER( - dbug_tmp_restore_column_map(table->write_set, old_map); + dbug_tmp_restore_column_map(&table->write_set, old_map); ); for (Field **field = table->field; *field; field++) @@ -765,9 +767,9 @@ struct pinba_view___report_snapshot_t : public pinba_view___base_t // mark all fields as writeable to avoid assert() in ::store() calls // got no idea how to do this properly anyway - auto *old_map = dbug_tmp_use_all_columns(table, table->write_set); + auto *old_map = dbug_tmp_use_all_columns(table, &table->write_set); MEOW_DEFER( - dbug_tmp_restore_column_map(table->write_set, old_map); + dbug_tmp_restore_column_map(&table->write_set, old_map); ); for (Field **field = table->field; *field; field++) diff --git a/mysql_engine/handler.h b/mysql_engine/handler.h index 11c613e..73080c7 100644 --- a/mysql_engine/handler.h +++ b/mysql_engine/handler.h @@ -5,8 +5,10 @@ #include "mysql_engine/view_conf.h" #ifdef PINBA_USE_MYSQL_SOURCE +#include #include #else +#include #include #endif // PINBA_USE_MYSQL_SOURCE diff --git a/mysql_engine/plugin.cpp b/mysql_engine/plugin.cpp index 0010d1a..5b652e5 100644 --- a/mysql_engine/plugin.cpp +++ b/mysql_engine/plugin.cpp @@ -314,7 +314,7 @@ static int pinba_engine_init(void *p) } auto *h = static_cast(p); - h->state = SHOW_OPTION_YES; + // h->state = SHOW_OPTION_YES; // mariadb has removed this it seems (checked on 10.11.8) h->flags = HTON_ALTER_NOT_SUPPORTED | HTON_NO_PARTITION | HTON_TEMPORARY_NOT_SUPPORTED; h->create = [](handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root) -> handler* { return new (mem_root) pinba_handler_t(hton, table); diff --git a/mysql_engine/plugin.h b/mysql_engine/plugin.h index 624be1f..cf15811 100644 --- a/mysql_engine/plugin.h +++ b/mysql_engine/plugin.h @@ -4,9 +4,13 @@ #include "mysql_engine/pinba_mysql.h" #ifdef PINBA_USE_MYSQL_SOURCE +# include +# include # include # include #else +# include +# include # include # include #endif // PINBA_USE_MYSQL_SOURCE From dc465005fb04a83df28ad1a387c2ab509e7001b2 Mon Sep 17 00:00:00 2001 From: Anton Povarov Date: Tue, 24 Dec 2024 21:25:30 +0400 Subject: [PATCH 2/3] readme and docs updates --- README.md | 17 +++++++---------- docker-compose.yml | 7 +++---- docker/build-dependencies.sh | 4 ++++ docs/index.md | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e5b51ba..f6cd00c 100644 --- a/README.md +++ b/README.md @@ -64,23 +64,20 @@ We've got some scripts to help [in scripts directory](scripts). Convert mysqldump of your old tables to new format with [this script](scripts/convert_mysqldump.php). - -More Info +Installation -------- - -- [TODO](TODO.md) +- [Dockerfile](Dockerfile) based on Ubuntu 24.04 LTS\ + something like: `docker build -t pinba2:latest .` - [Building](docs/index.md#building) - use docker, really - [Installing](docs/index.md#installation) - use docker, really - [Configuration](docs/index.md#configuration) - optional, should run fine with default settings -- [User-defined reports + examples](#user-defined-reports) -Docker ------- - -### Fedora 25 +More Info +-------- +- [TODO](TODO.md) +- [User-defined reports + examples](#user-defined-reports) -[`Dockerfile`](Dockerfile) Basics ------ diff --git a/docker-compose.yml b/docker-compose.yml index 4a2cdc4..d867165 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,8 @@ -version: '3.2' services: - fedora-25: - image: badoo/pinba2:fedora-25 - container_name: pinba2-fedora-25 + pinba2: + image: pinba2 + container_name: pinba2 build: context: . dockerfile: Dockerfile diff --git a/docker/build-dependencies.sh b/docker/build-dependencies.sh index 2276c54..231b297 100755 --- a/docker/build-dependencies.sh +++ b/docker/build-dependencies.sh @@ -7,7 +7,11 @@ cmake . # don't want to build the whole thing, it takes a long time, just what we need make -C libservices # boost tries to include this file globally and includes this one; but mariadb needs this to install +# mv+rm is a workaround for docker build-ing on macos case-insensitive fs +# VERSION and version are the same file and mv actually leads to both files existing at the same time +# so rm it to avoid the issue with boost described above mv VERSION VERSION.backup +rm -f VERSION # make mysqld_error.h available in non-esoteric location ln -snf /_src/mariadb/libmariadb/include/mysqld_error.h include/mysqld_error.h diff --git a/docs/index.md b/docs/index.md index a07bfd4..4b269ed 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3,7 +3,7 @@ Building **examples** -See [Dockerfile](../Dockerfile) and [build-from-source.sh](../docker/build-from-source.sh).
+See [Dockerfile](../Dockerfile), [build-dependencies.sh](../docker/build-dependencies.sh) and [build-pinba.sh](../docker/build-pinba.sh).
Also there is a rough guide for centos7 in [#17](https://github.com/badoo/pinba2/issues/17) - should be workable for multiple distros really. **requirements** From ec9e7f2addeeaf2d335ad07c4d23ad4c2d08f67d Mon Sep 17 00:00:00 2001 From: Anton Povarov Date: Tue, 24 Dec 2024 21:25:30 +0400 Subject: [PATCH 3/3] readme and docs updates --- docker/build-dependencies.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/docker/build-dependencies.sh b/docker/build-dependencies.sh index 231b297..36faef8 100755 --- a/docker/build-dependencies.sh +++ b/docker/build-dependencies.sh @@ -1,10 +1,14 @@ #!/bin/bash -xe # mariadb +# the annoying part - why we're building mariadb from source at all, +# is that we need internal headers that are not present in regular apt packages +# so the idea here is to avoid building the whole of mariadb, but only the parts we need +# we only need to run initial generation stage with cmake . and build a few libs quickly +# the final tricky part is to build with the same compiler flags as the server itself +# for now - there is no problem, unless mariadb is built with debug, in which case pinba should be configured with --enable-debug cd /_src/mariadb cmake . - -# don't want to build the whole thing, it takes a long time, just what we need make -C libservices # boost tries to include this file globally and includes this one; but mariadb needs this to install # mv+rm is a workaround for docker build-ing on macos case-insensitive fs