From a117d027bca79d3f6af96a761e9bae88289be910 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 15:48:21 +0100 Subject: [PATCH 1/8] mariadb: use system libedit for mysql libedit changed its interface a while back. mariadb currently does not recognize this interface and instead uses a static old readline version. It does not link in the system readline due to licence incompatibility. This commit adds a patch that enables mariadb to detect and use the system libedit. The patch was sent upstream already ([1]). [1] https://github.com/MariaDB/server/pull/1001 Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 4 +- utils/mariadb/patches/180-libedit.patch | 105 ++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 utils/mariadb/patches/180-libedit.patch diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index b501e7e0f9..01626b00b6 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -219,7 +219,7 @@ define Package/mariadb-client TITLE:=MariaDB database core client binaries DEPENDS:= \ $(MARIADB_COMMON_DEPENDS) \ - +libncursesw + +libedit endef define Package/mariadb-client/description @@ -361,13 +361,11 @@ CMAKE_OPTIONS += \ -DWITH_INNODB_LZMA=ON \ -DWITH_INNODB_LZO=OFF \ -DWITH_INNODB_SNAPPY=OFF \ - -DWITH_LIBEDIT=OFF \ -DWITH_LIBNUMA=NO \ -DWITH_LIBWRAP=OFF \ -DWITH_LIBWSEP=OFF \ -DWITH_MARIABACKUP=ON \ -DWITH_PCRE=system \ - -DWITH_READLINE=OFF \ -DWITH_SAFEMALLOC=OFF \ -DWITH_SSL=system \ -DWITH_SYSTEMD=no \ diff --git a/utils/mariadb/patches/180-libedit.patch b/utils/mariadb/patches/180-libedit.patch new file mode 100644 index 0000000000..5227928503 --- /dev/null +++ b/utils/mariadb/patches/180-libedit.patch @@ -0,0 +1,105 @@ +commit 2220f7458ef90829eacc457167a28aeba75ca1bc +Author: Sebastian Kemper +Date: Sun Dec 9 21:19:24 2018 +0100 + + cmake: support new libedit interface + + libedit changed it's interface a while ago. MariaDB's cmake file doesn't + recognize the new interface, the compile test fails: + + /mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx: In function 'int main(int, char**)': + /mariadb-10.2.19/CMakeFiles/CMakeTmp/src.cxx:6:47: error: invalid conversion from 'char*' to 'int' [-fpermissive] + int res= (*rl_completion_entry_function)(0,0); + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ + + Fix this by adding a detection for the new interface as well. + + In client/mysql.cc the ifdefs for the new readline interface are + extended to also check for the new libedit interface. They work the same + way. + + Run-tested on a MIPS machine. + + Signed-off-by: Sebastian Kemper + +--- a/client/mysql.cc ++++ b/client/mysql.cc +@@ -2577,7 +2577,7 @@ C_MODE_END + if not. + */ + +-#if defined(USE_NEW_READLINE_INTERFACE) ++#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE) + static int fake_magic_space(int, int); + extern "C" char *no_completion(const char*,int) + #elif defined(USE_LIBEDIT_INTERFACE) +@@ -2659,7 +2659,7 @@ static int not_in_history(const char *li + } + + +-#if defined(USE_NEW_READLINE_INTERFACE) ++#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE) + static int fake_magic_space(int, int) + #else + static int fake_magic_space(const char *, int) +@@ -2676,7 +2676,7 @@ static void initialize_readline (char *n + rl_readline_name = name; + + /* Tell the completer that we want a crack first. */ +-#if defined(USE_NEW_READLINE_INTERFACE) ++#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE) + rl_attempted_completion_function= (rl_completion_func_t*)&new_mysql_completion; + rl_completion_entry_function= (rl_compentry_func_t*)&no_completion; + +@@ -2706,7 +2706,7 @@ static char **new_mysql_completion(const + int end __attribute__((unused))) + { + if (!status.batch && !quick) +-#if defined(USE_NEW_READLINE_INTERFACE) ++#if defined(USE_NEW_READLINE_INTERFACE) || defined(USE_NEW_LIBEDIT_INTERFACE) + return rl_completion_matches(text, new_command_generator); + #else + return completion_matches((char *)text, (CPFunction *)new_command_generator); +--- a/cmake/readline.cmake ++++ b/cmake/readline.cmake +@@ -160,8 +160,20 @@ MACRO (MYSQL_FIND_SYSTEM_LIBEDIT) + int res= (*rl_completion_entry_function)(0,0); + completion_matches(0,0); + }" +- LIBEDIT_INTERFACE) +- SET(USE_LIBEDIT_INTERFACE ${LIBEDIT_INTERFACE}) ++ LIBEDIT_HAVE_COMPLETION_INT) ++ ++ CHECK_CXX_SOURCE_COMPILES(" ++ #include ++ #include ++ int main(int argc, char **argv) ++ { ++ char res= *(*rl_completion_entry_function)(0,0); ++ completion_matches(0,0); ++ }" ++ LIBEDIT_HAVE_COMPLETION_CHAR) ++ IF(LIBEDIT_HAVE_COMPLETION_INT OR LIBEDIT_HAVE_COMPLETION_CHAR) ++ SET(USE_LIBEDIT_INTERFACE 1) ++ ENDIF() + ENDIF() + ENDMACRO() + +@@ -187,6 +199,7 @@ MACRO (MYSQL_CHECK_READLINE) + IF(USE_LIBEDIT_INTERFACE) + SET(MY_READLINE_INCLUDE_DIR ${LIBEDIT_INCLUDE_DIR}) + SET(MY_READLINE_LIBRARY ${LIBEDIT_LIBRARY} ${CURSES_LIBRARY}) ++ SET(USE_NEW_LIBEDIT_INTERFACE ${LIBEDIT_HAVE_COMPLETION_CHAR}) + ELSE() + MYSQL_USE_BUNDLED_READLINE() + ENDIF() +--- a/config.h.cmake ++++ b/config.h.cmake +@@ -113,6 +113,7 @@ + /* Readline */ + #cmakedefine HAVE_HIST_ENTRY 1 + #cmakedefine USE_LIBEDIT_INTERFACE 1 ++#cmakedefine USE_NEW_LIBEDIT_INTERFACE 1 + #cmakedefine USE_NEW_READLINE_INTERFACE 1 + + #cmakedefine FIONREAD_IN_SYS_IOCTL 1 From c0dba8cfa67060294a1598b0edd2b11b3e19f8e3 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 15:49:27 +0100 Subject: [PATCH 2/8] mariadb: refresh plugins This commit deals with changes related to plugins and how they're built or disabled. Currently a lot of plugins are packaged which are merely for tests or plain examples. Other distros do not bundle these, hence this commit does away with them. A few new plugins are added related to PAM and Kerberos (auth_gssapi, auth_gssapi_client and auth_pam). The BuildPlugin template is refactored to also allow building of library plugins (needed for auth_gssapi_client). The template is also cleaned up - some extraneous dollar signs are removed and the install function is now defined outside the template. Unwanted plugins/engines are now turned off efficiently (without using cmake variables) by blanking CMakeLists.txt files in the associated folders. The idea was lifted from Gentoo. ha_sequence is now built into the server. This is an upstream preference. The plugin is about 30 kbytes in size, so there is no harm adding it into the server, which weighs in at about 15 Mbytes anyway. Last but not least the auth_socket plugin is now also built into the server. This allows the local root user to login to the database without a password being set. This makes maintenance easier without being detrimental to security. The idea was lifted from Debian. Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 208 ++++++++++++++++++++--------------------- 1 file changed, 101 insertions(+), 107 deletions(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 01626b00b6..51a4f9a927 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -35,37 +35,46 @@ CMAKE_INSTALL:=1 PLUGIN_DIR:=/usr/lib/mysql/plugin -MARIADB_SERVER_PLUGINS := \ - adt_null \ - auth_0x0100 \ - auth_ed25519 \ - auth_socket \ - auth_test_plugin \ - client_ed25519 \ +MARIADB_DISABLE_ENGINES := \ + cassandra \ + example \ + mroonga \ + oqgraph \ + rocksdb \ + test_sql_discovery \ + tokudb + +MARIADB_DISABLE_PLUGINS := \ + audit_null \ + auth_examples \ + aws_key_management \ + cracklib_password_check \ + daemon_example \ debug_key_management \ - dialog_examples \ - disks \ example_key_management \ + fulltext + +MARIADB_LIB_PLUGINS := \ + auth_gssapi_client + +MARIADB_SERVER_PLUGINS := \ + auth_ed25519 \ + auth_gssapi \ + auth_pam \ + client_ed25519 \ + disks \ feedback \ file_key_management \ ha_archive \ ha_blackhole \ ha_connect \ - ha_example \ ha_federated \ ha_federatedx \ - ha_sequence \ ha_sphinx \ ha_spider \ - ha_test_sql_discovery \ handlersocket \ - libdaemon_example \ locales \ metadata_lock_info \ - mypluglib \ - qa_auth_client \ - qa_auth_interface \ - qa_auth_server \ query_cache_info \ query_response_time \ semisync_master \ @@ -76,39 +85,29 @@ MARIADB_SERVER_PLUGINS := \ wsrep_info PKG_CONFIG_DEPENDS := \ + $(patsubst %,CONFIG_PACKAGE_lib$(PKG_NAME)-plugin-%,$(subst _,-,$(MARIADB_LIB_PLUGINS))) \ $(patsubst %,CONFIG_PACKAGE_$(PKG_NAME)-server-plugin-%,$(subst _,-,$(MARIADB_SERVER_PLUGINS))) \ CONFIG_PACKAGE_mariadb-server -plugin-adt_null := PLUGIN_AUDIT_NULL -plugin-auth_0x0100 := PLUGIN_AUTH_0X0100 +plugin-auth_gssapi_client := PLUGIN_AUTH_GSSAPI_CLIENT + plugin-auth_ed25519 := PLUGIN_AUTH_ED25519 -plugin-auth_socket := PLUGIN_AUTH_SOCKET -plugin-auth_test_plugin := PLUGIN_AUTH_TEST_PLUGIN +plugin-auth_gssapi := PLUGIN_AUTH_GSSAPI +plugin-auth_pam := PLUGIN_AUTH_PAM plugin-client_ed25519 := PLUGIN_CLIENT_ED25519 -plugin-debug_key_management := PLUGIN_DEBUG_KEY_MANAGEMENT -plugin-dialog_examples := PLUGIN_DIALOG_EXAMPLES plugin-disks := PLUGIN_DISKS -plugin-example_key_management := PLUGIN_EXAMPLE_KEY_MANAGEMENT plugin-feedback := PLUGIN_FEEDBACK plugin-file_key_management := PLUGIN_FILE_KEY_MANAGEMENT plugin-ha_archive := PLUGIN_ARCHIVE plugin-ha_blackhole := PLUGIN_BLACKHOLE plugin-ha_connect := PLUGIN_CONNECT -plugin-ha_example := PLUGIN_EXAMPLE plugin-ha_federated := PLUGIN_FEDERATED plugin-ha_federatedx := PLUGIN_FEDERATEDX -plugin-ha_sequence := PLUGIN_SEQUENCE plugin-ha_sphinx := PLUGIN_SPHINX plugin-ha_spider := PLUGIN_SPIDER -plugin-ha_test_sql_discovery := PLUGIN_TEST_SQL_DISCOVERY plugin-handlersocket := PLUGIN_HANDLERSOCKET -plugin-libdaemon_example := PLUGIN_DAEMON_EXAMPLE plugin-locales := PLUGIN_LOCALES plugin-metadata_lock_info := PLUGIN_METADATA_LOCK_INFO -plugin-mypluglib := PLUGIN_FTEXAMPLE -plugin-qa_auth_client := PLUGIN_QA_AUTH_CLIENT -plugin-qa_auth_interface := PLUGIN_QA_AUTH_INTERFACE -plugin-qa_auth_server := PLUGIN_QA_AUTH_SERVER plugin-query_cache_info := PLUGIN_QUERY_CACHE_INFO plugin-query_response_time := PLUGIN_QUERY_RESPONSE_TIME plugin-semisync_master := PLUGIN_SEMISYNC_MASTER @@ -180,10 +179,22 @@ MARIADB_COMMON_DEPENDS := \ # ignore them. TARGET_CFLAGS+=$(TARGET_CPPFLAGS) +define Package/mariadb/disable/engine + echo > $(1)/storage/$(2)/CMakeLists.txt +endef + +define Package/mariadb/disable/plugin + echo > $(1)/plugin/$(2)/CMakeLists.txt +endef + define Package/mariadb/install/bin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/$(2) $(1)/usr/bin endef +define Package/mariadb/install/plugin + $(INSTALL_BIN) $(PKG_INSTALL_DIR)$(PLUGIN_DIR)/$(2).so $(1)$(PLUGIN_DIR) +endef + define Package/mariadb/description/Default MariaDB is a fast, stable and true multi-user, multi-threaded SQL database server. SQL (Structured Query Language) is the most popular @@ -191,12 +202,17 @@ database query language in the world. The main goals of MariaDB are speed, robustness and ease of use. endef -define Package/libmariadb +define Package/libmariadb/Default SECTION:=libs CATEGORY:=Libraries + URL:=https://mariadb.org/ +endef + +define Package/libmariadb +$(call Package/libmariadb/Default) DEPENDS:=$(MARIADB_COMMON_DEPENDS) TITLE:=MariaDB database client library - URL:=https://mariadb.org/ + MENU:=1 PROVIDES:=libmariadbclient libmysqlclient libmysqlclient-r endef @@ -310,10 +326,6 @@ CMAKE_OPTIONS += -DWITH_UNIT_TESTS=0 # time. CMAKE_OPTIONS += -DSTACK_DIRECTION=-1 -# Jemalloc was added for TokuDB. Since its configure script seems somewhat broken -# when it comes to cross-compilation we shall disable it and also disable TokuDB. -CMAKE_OPTIONS += -DWITH_JEMALLOC=no -DWITHOUT_TOKUDB=1 - # Make it explicit that we are cross-compiling CMAKE_OPTIONS += -DCMAKE_CROSSCOMPILING=1 @@ -326,7 +338,9 @@ CMAKE_OPTIONS += -DSECURITY_HARDENED=OFF ifeq ($(CONFIG_PACKAGE_mariadb-server),) CMAKE_OPTIONS += -DWITHOUT_SERVER=ON else -CMAKE_OPTIONS += -DWITHOUT_SERVER=OFF +# Enable the auth_socket plugin and let unix user root access MariaDB without a +# separate password. +CMAKE_OPTIONS += -DWITHOUT_SERVER=OFF -DPLUGIN_AUTH_SOCKET=STATIC endif CMAKE_OPTIONS += \ @@ -372,18 +386,6 @@ CMAKE_OPTIONS += \ -DWITH_VALGRIND=OFF \ -DWITH_ZLIB=system -# Default-disable some modules -CMAKE_OPTIONS += \ - -DPLUGIN_CASSANDRA=NO \ - -DPLUGIN_MROONGA=NO \ - -DPLUGIN_OQGRAPH=NO \ - -DPLUGIN_ROCKSDB=NO \ - -DPLUGIN_TOKUDB=NO \ - -DPLUGIN_AUTH_PAM=NO \ - -DPLUGIN_AUTH_GSSAPI=NO \ - -DPLUGIN_AUTH_GSSAPI_CLIENT=OFF \ - -DPLUGIN_CRACKLIB_PASSWORD_CHECK=NO - # Help MariaDB find the correct libiconv. # nls.mk sets it up so that with CONFIG_BUILD_NLS libiconv-full would be used, # otherwise libiconv-stub (independent of the selected libc). MariaDB needs a @@ -393,6 +395,7 @@ CMAKE_OPTIONS += \ -DICONV_LIBRARIES=$(ICONV_PREFIX)/lib/libiconv.$(if $(CONFIG_BUILD_NLS),so,a) CMAKE_OPTIONS += \ + $(foreach p,$(MARIADB_LIB_PLUGINS),-D$(plugin-$(p))=$(if $(CONFIG_PACKAGE_lib$(PKG_NAME)-plugin-$(subst _,-,$(p))),DYNAMIC,OFF)) \ $(foreach p,$(MARIADB_SERVER_PLUGINS),-D$(plugin-$(p))=$(if $(CONFIG_PACKAGE_$(PKG_NAME)-server-plugin-$(subst _,-,$(p))),DYNAMIC,NO)) # Set CMAKE_FIND_ROOT_PATH_MODE_INCLUDE and CMAKE_FIND_ROOT_PATH_MODE_LIBRARY @@ -407,8 +410,7 @@ CMAKE_HOST_OPTIONS += \ -DCMAKE_FIND_ROOT_PATH_MODE_LIBRARY=BOTH \ -DCMAKE_INSTALL_RPATH="$(STAGING_DIR_HOSTPKG)/lib" \ -DCMAKE_SKIP_RPATH=FALSE \ - -DWITHOUT_SERVER=OFF \ - -DWITHOUT_TOKUDB=1 + -DWITHOUT_SERVER=OFF # Some helpers must be compiled for host in order to crosscompile mariadb for # the target. They are then included by import_executables.cmake which is @@ -420,6 +422,13 @@ CMAKE_HOST_OPTIONS += \ CMAKE_OPTIONS += -DIMPORT_EXECUTABLES=$(STAGING_DIR_HOSTPKG)/share/mariadb/import_executables.cmake +# Disable some engines/plugins here as well - decreases the number of cmake checks. +define Host/Prepare + $(call Host/Prepare/Default) + $(foreach e,$(MARIADB_DISABLE_ENGINES),$(call Package/mariadb/disable/engine,$(HOST_BUILD_DIR),$(e));) + $(foreach p,$(MARIADB_DISABLE_PLUGINS),$(call Package/mariadb/disable/plugin,$(HOST_BUILD_DIR),$(p));) +endef + define Host/Compile $(call Host/Compile/Default,import_executables) endef @@ -445,6 +454,8 @@ endef define Build/Prepare $(call Build/Prepare/Default) $(SED) '/ADD_DEFINITIONS(-DLIBICONV_PLUG)/d' $(PKG_BUILD_DIR)/libmariadb/libmariadb/CMakeLists.txt + $(foreach e,$(MARIADB_DISABLE_ENGINES),$(call Package/mariadb/disable/engine,$(PKG_BUILD_DIR),$(e));) + $(foreach p,$(MARIADB_DISABLE_PLUGINS),$(call Package/mariadb/disable/plugin,$(PKG_BUILD_DIR),$(p));) endef define Build/InstallDev @@ -494,8 +505,6 @@ define Package/mariadb-server/install $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld $(INSTALL_CONF) conf/my.cnf $(1)/etc/mysql $(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld - $(INSTALL_DIR) $(1)$(PLUGIN_DIR) - $(INSTALL_CONF) $(PKG_INSTALL_DIR)$(PLUGIN_DIR)/daemon_example.ini $(1)$(PLUGIN_DIR) $(INSTALL_DIR) $(1)/usr/share/mysql/english $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/english/errmsg.sys $(1)/usr/share/mysql/english $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/fill_help_tables.sql $(1)/usr/share/mysql @@ -513,28 +522,25 @@ endef define Package/mariadb-server/conffiles /etc/default/mysqld /etc/mysql/my.cnf -$(PLUGIN_DIR)/daemon_example.ini endef define BuildPlugin - define Package/$(PKG_NAME)-server-plugin-$(subst _,-,$(1)) - $$(call Package/mariadb/Default) - TITLE:=MariaDB database plugin - DEPENDS:=mariadb-server $(patsubst +%,+PACKAGE_$(PKG_NAME)-server-plugin-$(subst _,-,$(1)):%,$(2)) + define Package/$(1)-plugin-$(subst _,-,$(2)) + $(call Package/$(subst mariadb-server,mariadb,$(1))/Default) + TITLE:=$(1) plugin + DEPENDS:=$(1) $(patsubst +%,+PACKAGE_$(1)-plugin-$(subst _,-,$(2)):%,$(3)) endef - define Package/$(PKG_NAME)-server-plugin-$(subst _,-,$(1))/description - $$(call Package/mariadb/description/Default) + define Package/$(1)-plugin-$(subst _,-,$(2))/description + $(call Package/mariadb/description/Default) -This package provides the $(1) plugin. +This package provides the $(2) plugin. endef - define Package/$(PKG_NAME)-server-plugin-$(subst _,-,$(1))/install - $(INSTALL_DIR) $$(1)$(PLUGIN_DIR) - $(INSTALL_BIN) \ - $(PKG_INSTALL_DIR)$(PLUGIN_DIR)/$(1).so \ - $$(1)$(PLUGIN_DIR) + define Package/$(1)-plugin-$(subst _,-,$(2))/install + $(INSTALL_DIR) $$(1)$(PLUGIN_DIR) + $(call Package/mariadb/install/plugin,$$(1),$(2)) endef - $$(eval $$(call BuildPackage,$(PKG_NAME)-server-plugin-$(subst _,-,$(1)))) + $$(eval $$(call BuildPackage,$(1)-plugin-$(subst _,-,$(2)))) endef $(eval $(call HostBuild)) @@ -545,41 +551,29 @@ $(eval $(call BuildPackage,mariadb-extra-charsets)) $(eval $(call BuildPackage,mariadb-server)) $(eval $(call BuildPackage,mariadb-server-extra)) -$(eval $(call BuildPlugin,adt_null,)) -$(eval $(call BuildPlugin,auth_0x0100,)) -$(eval $(call BuildPlugin,auth_ed25519,)) -$(eval $(call BuildPlugin,auth_socket,)) -$(eval $(call BuildPlugin,auth_test_plugin,)) -$(eval $(call BuildPlugin,client_ed25519,)) -$(eval $(call BuildPlugin,debug_key_management,)) -$(eval $(call BuildPlugin,dialog_examples,)) -$(eval $(call BuildPlugin,disks,)) -$(eval $(call BuildPlugin,example_key_management,)) -$(eval $(call BuildPlugin,feedback,)) -$(eval $(call BuildPlugin,file_key_management,)) -$(eval $(call BuildPlugin,ha_archive,)) -$(eval $(call BuildPlugin,ha_blackhole,)) -$(eval $(call BuildPlugin,ha_connect,+libxml2)) -$(eval $(call BuildPlugin,ha_example,)) -$(eval $(call BuildPlugin,ha_federated,)) -$(eval $(call BuildPlugin,ha_federatedx,)) -$(eval $(call BuildPlugin,ha_sequence,)) -$(eval $(call BuildPlugin,ha_sphinx,)) -$(eval $(call BuildPlugin,ha_spider,)) -$(eval $(call BuildPlugin,ha_test_sql_discovery,)) -$(eval $(call BuildPlugin,handlersocket,)) -$(eval $(call BuildPlugin,libdaemon_example,)) -$(eval $(call BuildPlugin,locales,)) -$(eval $(call BuildPlugin,metadata_lock_info,)) -$(eval $(call BuildPlugin,mypluglib,)) -$(eval $(call BuildPlugin,qa_auth_client,)) -$(eval $(call BuildPlugin,qa_auth_interface,)) -$(eval $(call BuildPlugin,qa_auth_server,)) -$(eval $(call BuildPlugin,query_cache_info,)) -$(eval $(call BuildPlugin,query_response_time,)) -$(eval $(call BuildPlugin,semisync_master,)) -$(eval $(call BuildPlugin,semisync_slave,)) -$(eval $(call BuildPlugin,server_audit,)) -$(eval $(call BuildPlugin,simple_password_check,)) -$(eval $(call BuildPlugin,sql_errlog,)) -$(eval $(call BuildPlugin,wsrep_info,)) +$(eval $(call BuildPlugin,libmariadb,auth_gssapi_client,+krb5-libs)) +$(eval $(call BuildPlugin,mariadb-server,auth_ed25519,)) +$(eval $(call BuildPlugin,mariadb-server,auth_gssapi,+krb5-libs)) +$(eval $(call BuildPlugin,mariadb-server,auth_pam,+libpam)) +$(eval $(call BuildPlugin,mariadb-server,client_ed25519,)) +$(eval $(call BuildPlugin,mariadb-server,disks,)) +$(eval $(call BuildPlugin,mariadb-server,feedback,)) +$(eval $(call BuildPlugin,mariadb-server,file_key_management,)) +$(eval $(call BuildPlugin,mariadb-server,ha_archive,)) +$(eval $(call BuildPlugin,mariadb-server,ha_blackhole,)) +$(eval $(call BuildPlugin,mariadb-server,ha_connect,+libxml2)) +$(eval $(call BuildPlugin,mariadb-server,ha_federated,)) +$(eval $(call BuildPlugin,mariadb-server,ha_federatedx,)) +$(eval $(call BuildPlugin,mariadb-server,ha_sphinx,)) +$(eval $(call BuildPlugin,mariadb-server,ha_spider,)) +$(eval $(call BuildPlugin,mariadb-server,handlersocket,)) +$(eval $(call BuildPlugin,mariadb-server,locales,)) +$(eval $(call BuildPlugin,mariadb-server,metadata_lock_info,)) +$(eval $(call BuildPlugin,mariadb-server,query_cache_info,)) +$(eval $(call BuildPlugin,mariadb-server,query_response_time,)) +$(eval $(call BuildPlugin,mariadb-server,semisync_master,)) +$(eval $(call BuildPlugin,mariadb-server,semisync_slave,)) +$(eval $(call BuildPlugin,mariadb-server,server_audit,)) +$(eval $(call BuildPlugin,mariadb-server,simple_password_check,)) +$(eval $(call BuildPlugin,mariadb-server,sql_errlog,)) +$(eval $(call BuildPlugin,mariadb-server,wsrep_info,)) From cacd86009bf472b445aaf4bef2d489a98d98aff4 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 15:53:35 +0100 Subject: [PATCH 3/8] mariadb: rename share and plugin directories Rename them from mysql to mariadb. Use variables where possible (also for /etc/mysql). Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 51a4f9a927..727e064b13 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -33,7 +33,9 @@ PKG_BUILD_DEPENDS:=libevent2 mariadb/host CMAKE_INSTALL:=1 -PLUGIN_DIR:=/usr/lib/mysql/plugin +CONF_DIR:=/etc/mysql +PLUGIN_DIR:=/usr/lib/mariadb/plugin +SHARE_DIR:=/usr/share/mariadb MARIADB_DISABLE_ENGINES := \ cassandra \ @@ -355,13 +357,13 @@ CMAKE_OPTIONS += \ -DINSTALL_DOCDIR=share/doc/mariadb \ -DINSTALL_DOCREADMEDIR=share/doc/mariadb \ -DINSTALL_MANDIR=share/man \ - -DINSTALL_MYSQLSHAREDIR=share/mysql \ + -DINSTALL_MYSQLSHAREDIR=share/mariadb \ -DINSTALL_MYSQLTESTDIR="" \ - -DINSTALL_PLUGINDIR=lib/mysql/plugin \ + -DINSTALL_PLUGINDIR=lib/mariadb/plugin \ -DINSTALL_SBINDIR=bin \ -DINSTALL_SCRIPTDIR=bin \ -DINSTALL_SQLBENCHDIR="" \ - -DINSTALL_SUPPORTFILESDIR=share/mysql \ + -DINSTALL_SUPPORTFILESDIR=share/mariadb \ -DINSTALL_UNIX_ADDRDIR=/var/run/mysqld/mysqld.sock \ -DMYSQLD_USER=mariadb \ -DMYSQL_DATADIR=/var/lib/mysql \ @@ -492,8 +494,8 @@ define Package/mariadb-client-extra/install endef define Package/mariadb-extra-charsets/install - $(INSTALL_DIR) $(1)/usr/share/mysql/charsets - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/charsets/* $(1)/usr/share/mysql/charsets + $(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(1)$(SHARE_DIR)/charsets endef define Package/mariadb-server/install @@ -501,17 +503,17 @@ define Package/mariadb-server/install $(foreach b,$(MARIADB_SERVER),$(call Package/mariadb/install/bin,$(1),$(b));) $(INSTALL_DIR) $(1)/etc/default $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_DIR) $(1)/etc/mysql/conf.d + $(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld - $(INSTALL_CONF) conf/my.cnf $(1)/etc/mysql + $(INSTALL_CONF) conf/my.cnf $(1)$(CONF_DIR) $(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld - $(INSTALL_DIR) $(1)/usr/share/mysql/english - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/english/errmsg.sys $(1)/usr/share/mysql/english - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/fill_help_tables.sql $(1)/usr/share/mysql - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/maria_add_gis_sp_bootstrap.sql $(1)/usr/share/mysql - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/mysql_performance_tables.sql $(1)/usr/share/mysql - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/mysql_system_tables.sql $(1)/usr/share/mysql - $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/mysql/mysql_system_tables_data.sql $(1)/usr/share/mysql + $(INSTALL_DIR) $(1)$(SHARE_DIR)/english + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/english/errmsg.sys $(1)$(SHARE_DIR)/english + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/fill_help_tables.sql $(1)$(SHARE_DIR) + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/maria_add_gis_sp_bootstrap.sql $(1)$(SHARE_DIR) + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/mysql_performance_tables.sql $(1)$(SHARE_DIR) + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/mysql_system_tables.sql $(1)$(SHARE_DIR) + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/mysql_system_tables_data.sql $(1)$(SHARE_DIR) endef define Package/mariadb-server-extra/install @@ -521,7 +523,7 @@ endef define Package/mariadb-server/conffiles /etc/default/mysqld -/etc/mysql/my.cnf +$(CONF_DIR)/my.cnf endef define BuildPlugin From cc0a40231d8acce9ab8a18f777943728d22df5de Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 15:55:54 +0100 Subject: [PATCH 4/8] mariadb: improve packaging and configuration At present there are some flaws related to configuration, also related to the packaging of mariadb. For starters there are complaints that the configuration is too static. To address this a new configuration layout is introduced. The primary configuration file (my.cnf) is changed so that it now only includes further configuration files in the directory /etc/mysql/conf.d. More default configuration files are added for the server and the client. This is the new default configuration. With these changes it's possible for the user to select if they want to change the default configuration (in conf.d/*.cnf) or if they want to drop their own files into conf.d instead. If the user .cnf files are read after the default .cnf files (files are included in alphabetical order), they will overwrite the settings from the default configuration. The other flaw is that the my.cnf file is included in mariadb-server. But that doesn't really fit the requirements, as the client also uses the configuration file(s). To accomodate this a new package mariadb-common is added. It installs the shared my.cnf file. The remaining changes add base packages, both for the server and the client. These are meant as foundation for the packages containing the respective binaries. In summary they will install the configuration, small miscellaneous files (SQL scripts etc.) and the user "mariadb". That means that everything is ready for the binaries, like mysql and mysqld. If there is not enough space left on flash memory, the user can just drop the binaries on a pendrive, link them to /usr/bin and get started. The ideas and configuration files were copied from Debian. Some amendments were made. Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 115 ++++++++++++++++---- utils/mariadb/conf/50-client.cnf | 21 ++++ utils/mariadb/conf/50-mysql-clients.cnf | 25 +++++ utils/mariadb/conf/50-server.cnf | 136 ++++++++++++++++++++++++ utils/mariadb/conf/my.cnf | 70 ++++-------- 5 files changed, 293 insertions(+), 74 deletions(-) create mode 100644 utils/mariadb/conf/50-client.cnf create mode 100644 utils/mariadb/conf/50-mysql-clients.cnf create mode 100644 utils/mariadb/conf/50-server.cnf diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 727e064b13..2baab6a8bc 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -211,7 +211,7 @@ define Package/libmariadb/Default endef define Package/libmariadb -$(call Package/libmariadb/Default) + $(call Package/libmariadb/Default) DEPENDS:=$(MARIADB_COMMON_DEPENDS) TITLE:=MariaDB database client library MENU:=1 @@ -234,10 +234,9 @@ endef define Package/mariadb-client $(call Package/mariadb/Default) - TITLE:=MariaDB database core client binaries - DEPENDS:= \ - $(MARIADB_COMMON_DEPENDS) \ - +libedit + TITLE:=MariaDB database client + MENU:=1 + DEPENDS:=mariadb-client-base endef define Package/mariadb-client/description @@ -249,9 +248,30 @@ $(subst $(space),$(newline),$(MARIADB_CLIENT)) endef +define Package/mariadb-client-base + $(call Package/mariadb/Default) + TITLE:=MariaDB database client base + DEPENDS:=mariadb-common \ + $(MARIADB_COMMON_DEPENDS) \ + +libedit +endef + +define Package/mariadb-client-base/conffiles +$(CONF_DIR)/conf.d/50-client.cnf +$(CONF_DIR)/conf.d/50-mysql-clients.cnf +endef + +define Package/mariadb-client-base/description +$(call Package/mariadb/description/Default) + +This package provides the foundation for mariadb-client. It installs the +configuration and the dependencies. + +endef + define Package/mariadb-client-extra $(call Package/mariadb/Default) - TITLE:=MariaDB database extra client binaries + TITLE:=MariaDB database client extra DEPENDS:=mariadb-client endef @@ -264,6 +284,23 @@ $(subst $(space),$(newline),$(MARIADB_CLIENT_EXTRA)) endef +define Package/mariadb-common + $(call Package/mariadb/Default) + TITLE:=MariaDB database common files + DEPENDS:= +endef + +define Package/mariadb-common/conffiles +$(CONF_DIR)/my.cnf +endef + +define Package/mariadb-common/description +$(call Package/mariadb/description/Default) + +This package includes shared files, for example $(CONF_DIR)/my.cnf. + +endef + define Package/mariadb-extra-charsets $(call Package/mariadb/Default) TITLE:=MariaDB database extra character sets @@ -280,16 +317,10 @@ endef define Package/mariadb-server $(call Package/mariadb/Default) - DEPENDS:= \ - $(MARIADB_COMMON_DEPENDS) \ - +!arc:libaio \ - +liblzma \ - +libpcre \ - +resolveip - TITLE:=MariaDB database core server binaries + DEPENDS:=mariadb-server-base + TITLE:=MariaDB database server MENU:=1 PROVIDES:=mysql-server - USERID:=mariadb=376:mariadb=376 endef define Package/mariadb-server/description @@ -301,9 +332,35 @@ $(subst $(space),$(newline),$(MARIADB_SERVER)) endef +define Package/mariadb-server-base + $(call Package/mariadb/Default) + DEPENDS:=mariadb-common \ + $(MARIADB_COMMON_DEPENDS) \ + +!arc:libaio \ + +liblzma \ + +libpcre \ + +resolveip + TITLE:=MariaDB database server base + USERID:=mariadb=376:mariadb=376 +endef + +define Package/mariadb-server-base/conffiles +$(CONF_DIR)/conf.d/50-server.cnf +/etc/default/mysqld +endef + +define Package/mariadb-server-base/description +$(call Package/mariadb/description/Default) + +This package provides the foundation for mariadb-server. It installs the +init script, support files (configuration etc.), the user "mariadb" and +the dependencies. + +endef + define Package/mariadb-server-extra $(call Package/mariadb/Default) - TITLE:=MariaDB database extra server binaries + TITLE:=MariaDB database server extra DEPENDS:=mariadb-server endef @@ -488,11 +545,22 @@ define Package/mariadb-client/install cd $(1)/usr/bin; $(LN) mysqlcheck mysqloptimize endef +define Package/mariadb-client-base/install + $(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d + $(INSTALL_CONF) conf/50-client.cnf $(1)$(CONF_DIR)/conf.d + $(INSTALL_CONF) conf/50-mysql-clients.cnf $(1)$(CONF_DIR)/conf.d +endef + define Package/mariadb-client-extra/install $(INSTALL_DIR) $(1)/usr/bin $(foreach b,$(MARIADB_CLIENT_EXTRA),$(call Package/mariadb/install/bin,$(1),$(b));) endef +define Package/mariadb-common/install + $(INSTALL_DIR) $(1)$(CONF_DIR) + $(INSTALL_CONF) conf/my.cnf $(1)$(CONF_DIR) +endef + define Package/mariadb-extra-charsets/install $(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(1)$(SHARE_DIR)/charsets @@ -501,13 +569,16 @@ endef define Package/mariadb-server/install $(INSTALL_DIR) $(1)/usr/bin $(foreach b,$(MARIADB_SERVER),$(call Package/mariadb/install/bin,$(1),$(b));) +endef + +define Package/mariadb-server-base/install + $(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d + $(INSTALL_DIR) $(1)$(SHARE_DIR)/english $(INSTALL_DIR) $(1)/etc/default $(INSTALL_DIR) $(1)/etc/init.d - $(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld - $(INSTALL_CONF) conf/my.cnf $(1)$(CONF_DIR) + $(INSTALL_CONF) conf/50-server.cnf $(1)$(CONF_DIR)/conf.d $(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld - $(INSTALL_DIR) $(1)$(SHARE_DIR)/english $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/english/errmsg.sys $(1)$(SHARE_DIR)/english $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/fill_help_tables.sql $(1)$(SHARE_DIR) $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/maria_add_gis_sp_bootstrap.sql $(1)$(SHARE_DIR) @@ -521,11 +592,6 @@ define Package/mariadb-server-extra/install $(foreach b,$(MARIADB_SERVER_EXTRA),$(call Package/mariadb/install/bin,$(1),$(b));) endef -define Package/mariadb-server/conffiles -/etc/default/mysqld -$(CONF_DIR)/my.cnf -endef - define BuildPlugin define Package/$(1)-plugin-$(subst _,-,$(2)) $(call Package/$(subst mariadb-server,mariadb,$(1))/Default) @@ -548,9 +614,12 @@ endef $(eval $(call HostBuild)) $(eval $(call BuildPackage,libmariadb)) $(eval $(call BuildPackage,mariadb-client)) +$(eval $(call BuildPackage,mariadb-client-base)) $(eval $(call BuildPackage,mariadb-client-extra)) +$(eval $(call BuildPackage,mariadb-common)) $(eval $(call BuildPackage,mariadb-extra-charsets)) $(eval $(call BuildPackage,mariadb-server)) +$(eval $(call BuildPackage,mariadb-server-base)) $(eval $(call BuildPackage,mariadb-server-extra)) $(eval $(call BuildPlugin,libmariadb,auth_gssapi_client,+krb5-libs)) diff --git a/utils/mariadb/conf/50-client.cnf b/utils/mariadb/conf/50-client.cnf new file mode 100644 index 0000000000..de2b89f5e6 --- /dev/null +++ b/utils/mariadb/conf/50-client.cnf @@ -0,0 +1,21 @@ +# +# This group is read by the client library +# Use it for options that affect all clients, but not the server +# + +[client] +# Default is Latin1, if you need UTF-8 set this (also in server section) +default-character-set = utf8mb4 + +# Example of client certificate usage +# ssl-cert=/etc/mysql/client-cert.pem +# ssl-key=/etc/mysql/client-key.pem +# +# Allow only TLS encrypted connections +# ssl-verify-server-cert=on + +# This group is *never* read by mysql client library +# If you use the same .cnf file for MySQL and MariaDB, use it for +# MariaDB-only client options +[client-mariadb] + diff --git a/utils/mariadb/conf/50-mysql-clients.cnf b/utils/mariadb/conf/50-mysql-clients.cnf new file mode 100644 index 0000000000..b762a766ba --- /dev/null +++ b/utils/mariadb/conf/50-mysql-clients.cnf @@ -0,0 +1,25 @@ +# +# These groups are read by MariaDB command-line tools +# Use it for options that affect only one utility +# + +[mysql] +# Default is Latin1, if you need UTF-8 set this (also in server section) +default-character-set = utf8mb4 + +[mysql_upgrade] + +[mysqladmin] + +[mysqlbinlog] + +[mysqlcheck] + +[mysqldump] + +[mysqlimport] + +[mysqlshow] + +[mysqlslap] + diff --git a/utils/mariadb/conf/50-server.cnf b/utils/mariadb/conf/50-server.cnf new file mode 100644 index 0000000000..d478d1f5ea --- /dev/null +++ b/utils/mariadb/conf/50-server.cnf @@ -0,0 +1,136 @@ +# +# These groups are read by MariaDB server. +# Use it for options that only the server (but not clients) should see +# +# See the examples of server my.cnf files in /usr/share/mysql/ +# + +# this is read by the standalone daemon and embedded servers +[server] + +# this is only for the mysqld standalone daemon +[mysqld] + +# +# * Basic Settings +# +user = mariadb +pid-file = /var/run/mysqld/mysqld.pid +socket = /var/run/mysqld/mysqld.sock +port = 3306 +basedir = /usr +# Don't put this on flash memory +# Figure out where you are going to put the databases and run +# mysql_install_db --force +datadir = /mnt/data/mysql +# tmpdir should also not go on flash memory +tmpdir = /tmp +lc-messages-dir = /usr/share/mariadb + +skip-external-locking + +# Instead of skip-networking the default is now to listen only on +# localhost which is more compatible and is not less secure. +bind-address = 127.0.0.1 + +# +# * Fine Tuning +# +key_buffer_size = 16M +max_allowed_packet = 16M +thread_stack = 192K +thread_cache_size = 8 +# This replaces the startup script and checks MyISAM tables if needed +# the first time they are touched +myisam_recover_options = BACKUP +#max_connections = 100 +#table_cache = 64 +#thread_concurrency = 10 + +# +# * Query Cache Configuration +# +query_cache_limit = 1M +query_cache_size = 16M + +# +# * Logging and Replication +# +# Both location gets rotated by the cronjob. +# Be aware that this log type is a performance killer. +# As of 5.1 you can enable the log at runtime! +#general_log_file = /var/log/mysql/mysql.log +#general_log = 1 +# +# Error log - should be very few entries. +# Note that if unset the errors will go to stdout and can be seen in syslog +# (check "logread") +# +#log_error = /var/log/mysql/error.log +# +# Enable the slow query log to see queries with especially long duration +#slow_query_log_file = /var/log/mysql/mariadb-slow.log +#long_query_time = 10 +#log_slow_rate_limit = 1000 +#log_slow_verbosity = query_plan +# +#log-queries-not-using-indexes +# +# The following can be used as easy to replay backup logs or for replication. +#server-id = 1 +#log_bin = /var/log/mysql/mysql-bin.log +expire_logs_days = 10 +max_binlog_size = 100M +#binlog_do_db = include_database_name +#binlog_ignore_db = exclude_database_name + +# +# * InnoDB +# +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. +# Read the manual for more InnoDB related options. There are many! + +# +# * Security Features +# +# Read the manual, too, if you want chroot! +# chroot = /var/lib/mysql/ +# +# For generating SSL certificates you can use for example the GUI tool "tinyca". +# +# ssl-ca=/etc/mysql/cacert.pem +# ssl-cert=/etc/mysql/server-cert.pem +# ssl-key=/etc/mysql/server-key.pem +# +# Accept only connections using the latest and most secure TLS protocol version. +# ..when MariaDB is compiled with OpenSSL: +# ssl-cipher=TLSv1.2 + +# +# * Character sets +# +# MySQL/MariaDB default is Latin1, but in OpenWrt we rather default to the full +# utf8 4-byte character set. See also client.cnf +# +# Note: In OpenWrt until mariadb 10.2.19-2 the baked-in defaults were +# "DEFAULT_CHARSET=utf8" and "DEFAULT_COLLATION=utf8_general_ci". As MariaDB's +# utf8 (supports three bytes per character) is not really UTF-8 (which needs up +# to four bytes per character) this was changed. Now the baked in-defaults are +# the upstream defaults (Latin1), but in the default configuration (like in the +# file you are currently reading) utf8mb4 is set, which is real UTF-8. +# +# Of course you are free to change this, either here or in a configuration file +# of your own which is read after this .cnf file, see my.cnf in parent folder +# (files are read in alphabetical order). +character-set-server = utf8mb4 +collation-server = utf8mb4_general_ci + +# +# * Unix socket authentication plugin is built-in +# +# Needed so the root database user can authenticate without a password but +# only when running as the unix root user. +# +# Also available for other users if required. +# See https://mariadb.com/kb/en/unix_socket-authentication-plugin/ + diff --git a/utils/mariadb/conf/my.cnf b/utils/mariadb/conf/my.cnf index effa88a771..7583c7cae0 100644 --- a/utils/mariadb/conf/my.cnf +++ b/utils/mariadb/conf/my.cnf @@ -1,54 +1,22 @@ -[client] -port = 3306 -socket = /var/run/mysqld/mysqld.sock +# The MariaDB configuration file +# +# The MariaDB/MySQL tools read configuration files in the following order: +# 1. "/etc/mysql/my.cnf" (this file) to set global defaults, +# 2. "/etc/mysql/conf.d/*.cnf" to set global options. +# 3. "~/.my.cnf" to set user-specific options. +# +# If the same option is defined multiple times, the last one will apply. +# +# One can use all long options that the program supports. +# Run program with --help to get a list of available options and with +# --print-defaults to see which it would actually understand and use. -[mysqld] -user = mariadb -socket = /var/run/mysqld/mysqld.sock -port = 3306 -basedir = /usr - -############ Don't put this on the NAND ############# -# Figure out where you are going to put the databases -# And run mysql_install_db --force -datadir = /mnt/data/mysql/ - -######### This should also not go on the NAND ####### -tmpdir = /mnt/data/tmp/ - -skip-external-locking - -bind-address = 127.0.0.1 - -# Fine Tuning -key_buffer_size = 16M -max_allowed_packet = 16M -thread_stack = 192K -thread_cache_size = 8 - -# Here you can see queries with especially long duration -#log_slow_queries = /var/log/mysql/mysql-slow.log -#long_query_time = 2 -#log-queries-not-using-indexes - -# The following can be used as easy to replay backup logs or for replication. -#server-id = 1 -#log_bin = /var/log/mysql/mysql-bin.log -#expire_logs_days = 10 -#max_binlog_size = 100M -#binlog_do_db = include_database_name -#binlog_ignore_db = include_database_name - - -[mysqldump] -quick -quote-names -max_allowed_packet = 16M - -[mysql] -#no-auto-rehash # faster start of mysql but no tab completition - -[isamchk] -key_buffer = 16M +# +# This group is read both both by the client and the server +# use it for options that affect everything +# +[client-server] +# Import all .cnf files from configuration directory +!includedir /etc/mysql/conf.d/ From 9b8a68cc7be1ba2e85a9c8fbccbba0cf741e07fb Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 15:57:00 +0100 Subject: [PATCH 5/8] mariadb: add extra charsets to server base There is little sense in keeping these charsets in an extra package. The included sets are of the single byte character set variety. They only amount to a few kbytes. Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 2baab6a8bc..07b71604ab 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -301,20 +301,6 @@ This package includes shared files, for example $(CONF_DIR)/my.cnf. endef -define Package/mariadb-extra-charsets - $(call Package/mariadb/Default) - TITLE:=MariaDB database extra character sets - DEPENDS:=mariadb-server -endef - -define Package/mariadb-extra-charsets/description -$(call Package/mariadb/description/Default) - -This package contains single Byte character sets and collations that can -be added at run time. - -endef - define Package/mariadb-server $(call Package/mariadb/Default) DEPENDS:=mariadb-server-base @@ -406,8 +392,6 @@ CMAKE_OPTIONS += \ -DCONNECT_WITH_JDBC=NO \ -DCONNECT_WITH_LIBXML2=system \ -DCONNECT_WITH_ODBC=NO \ - -DDEFAULT_CHARSET=utf8 \ - -DDEFAULT_COLLATION=utf8_general_ci \ -DDISABLE_SHARED=NO \ -DENABLED_PROFILING=OFF \ -DENABLE_STATIC_LIBS=OFF \ @@ -428,7 +412,6 @@ CMAKE_OPTIONS += \ -DSKIP_TESTS=ON \ -DWITH_ASAN=OFF \ -DWITH_EMBEDDED_SERVER=OFF \ - -DWITH_EXTRA_CHARSETS=complex \ -DWITH_INNODB_BZIP2=OFF \ -DWITH_INNODB_LZ4=OFF \ -DWITH_INNODB_LZMA=ON \ @@ -561,11 +544,6 @@ define Package/mariadb-common/install $(INSTALL_CONF) conf/my.cnf $(1)$(CONF_DIR) endef -define Package/mariadb-extra-charsets/install - $(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets - $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(1)$(SHARE_DIR)/charsets -endef - define Package/mariadb-server/install $(INSTALL_DIR) $(1)/usr/bin $(foreach b,$(MARIADB_SERVER),$(call Package/mariadb/install/bin,$(1),$(b));) @@ -573,12 +551,14 @@ endef define Package/mariadb-server-base/install $(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d + $(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets $(INSTALL_DIR) $(1)$(SHARE_DIR)/english $(INSTALL_DIR) $(1)/etc/default $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld $(INSTALL_CONF) conf/50-server.cnf $(1)$(CONF_DIR)/conf.d $(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld + $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(1)$(SHARE_DIR)/charsets $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/english/errmsg.sys $(1)$(SHARE_DIR)/english $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/fill_help_tables.sql $(1)$(SHARE_DIR) $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/maria_add_gis_sp_bootstrap.sql $(1)$(SHARE_DIR) @@ -617,7 +597,6 @@ $(eval $(call BuildPackage,mariadb-client)) $(eval $(call BuildPackage,mariadb-client-base)) $(eval $(call BuildPackage,mariadb-client-extra)) $(eval $(call BuildPackage,mariadb-common)) -$(eval $(call BuildPackage,mariadb-extra-charsets)) $(eval $(call BuildPackage,mariadb-server)) $(eval $(call BuildPackage,mariadb-server-base)) $(eval $(call BuildPackage,mariadb-server-extra)) From 6152c9a0180a42e1d919604746b9a333f5f012fd Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 16:01:31 +0100 Subject: [PATCH 6/8] mariadb: add galera support Add galera support by installing the configuration and including the wsrep scripts in mariadb-server-extra. Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 07b71604ab..c2ebc83d03 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -163,7 +163,8 @@ MARIADB_SERVER_EXTRA := \ mysqlhotcopy \ perror \ replace \ - resolve_stack_dump + resolve_stack_dump \ + wsrep_sst_* include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/host-build.mk @@ -332,6 +333,7 @@ endef define Package/mariadb-server-base/conffiles $(CONF_DIR)/conf.d/50-server.cnf +$(CONF_DIR)/conf.d/60-galera.cnf /etc/default/mysqld endef @@ -556,6 +558,8 @@ define Package/mariadb-server-base/install $(INSTALL_DIR) $(1)/etc/default $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld + $(SED) '/^[a-z]/s/^/#/' $(PKG_INSTALL_DIR)$(SHARE_DIR)/wsrep.cnf + $(INSTALL_CONF) $(PKG_INSTALL_DIR)$(SHARE_DIR)/wsrep.cnf $(1)$(CONF_DIR)/conf.d/60-galera.cnf $(INSTALL_CONF) conf/50-server.cnf $(1)$(CONF_DIR)/conf.d $(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(1)$(SHARE_DIR)/charsets @@ -569,6 +573,7 @@ endef define Package/mariadb-server-extra/install $(INSTALL_DIR) $(1)/usr/bin + $(SED) 's,/bin/bash,/bin/sh,g' $(PKG_INSTALL_DIR)/usr/bin/wsrep_sst_* $(foreach b,$(MARIADB_SERVER_EXTRA),$(call Package/mariadb/install/bin,$(1),$(b));) endef From 556ebfec48e565aa71b0524d4a793d8ee9c6f906 Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 17:11:26 +0100 Subject: [PATCH 7/8] mariadb: small miscellaneous enhancements - correct spelling in comments ("mariadb" to "MariaDB") - remove mysqld_safe and mysqld_safe_helper (not used) - add some extra cmake configuration defines - remove cmake configuration defines that don't exist in the source - don't disable address sanitizer (ASAN) support Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index c2ebc83d03..515d211ca3 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -157,8 +157,6 @@ MARIADB_SERVER_EXTRA := \ mysql_tzinfo_to_sql \ mysqlbinlog \ mysqld_multi \ - mysqld_safe \ - mysqld_safe_helper \ mysqldumpslow \ mysqlhotcopy \ perror \ @@ -379,7 +377,7 @@ CMAKE_OPTIONS += -DCMAKE_CROSSCOMPILING=1 # Explicitly disable dtrace to avoid detection of a host version CMAKE_OPTIONS += -DENABLE_DTRACE=0 -# Prevent mariadb from messing with OpenWrt's C(XX)FLAGS +# Prevent MariaDB from messing with OpenWrt's C(XX)FLAGS CMAKE_OPTIONS += -DSECURITY_HARDENED=OFF ifeq ($(CONFIG_PACKAGE_mariadb-server),) @@ -393,12 +391,14 @@ endif CMAKE_OPTIONS += \ -DCONNECT_WITH_JDBC=NO \ -DCONNECT_WITH_LIBXML2=system \ + -DCONNECT_WITH_MONGO=NO \ -DCONNECT_WITH_ODBC=NO \ -DDISABLE_SHARED=NO \ -DENABLED_PROFILING=OFF \ -DENABLE_STATIC_LIBS=OFF \ -DINSTALL_DOCDIR=share/doc/mariadb \ -DINSTALL_DOCREADMEDIR=share/doc/mariadb \ + -DINSTALL_INFODIR=share/info \ -DINSTALL_MANDIR=share/man \ -DINSTALL_MYSQLSHAREDIR=share/mariadb \ -DINSTALL_MYSQLTESTDIR="" \ @@ -408,20 +408,19 @@ CMAKE_OPTIONS += \ -DINSTALL_SQLBENCHDIR="" \ -DINSTALL_SUPPORTFILESDIR=share/mariadb \ -DINSTALL_UNIX_ADDRDIR=/var/run/mysqld/mysqld.sock \ - -DMYSQLD_USER=mariadb \ -DMYSQL_DATADIR=/var/lib/mysql \ -DMYSQL_UNIX_ADDR=/var/run/mysqld/mysqld.sock \ -DSKIP_TESTS=ON \ - -DWITH_ASAN=OFF \ + -DWITH_DEBUG=OFF \ -DWITH_EMBEDDED_SERVER=OFF \ -DWITH_INNODB_BZIP2=OFF \ -DWITH_INNODB_LZ4=OFF \ -DWITH_INNODB_LZMA=ON \ -DWITH_INNODB_LZO=OFF \ -DWITH_INNODB_SNAPPY=OFF \ - -DWITH_LIBNUMA=NO \ + -DWITH_JEMALLOC=OFF \ + -DWITH_LIBARCHIVE=OFF \ -DWITH_LIBWRAP=OFF \ - -DWITH_LIBWSEP=OFF \ -DWITH_MARIABACKUP=ON \ -DWITH_PCRE=system \ -DWITH_SAFEMALLOC=OFF \ @@ -456,7 +455,7 @@ CMAKE_HOST_OPTIONS += \ -DCMAKE_SKIP_RPATH=FALSE \ -DWITHOUT_SERVER=OFF -# Some helpers must be compiled for host in order to crosscompile mariadb for +# Some helpers must be compiled for host in order to crosscompile MariaDB for # the target. They are then included by import_executables.cmake which is # generated during the build of the host helpers. It is not necessary to build # the whole host package, only the "import_executables" target. @@ -489,7 +488,7 @@ endef # LIBICONV_PLUG is used in GNU's libiconv for redefinition of exports [e.g. # from libiconv_open() to iconv_open()]. But in OpenWrt this variable is not set -# when building libiconv-full. So when mariadb sets LIBICONV_PLUG it expects +# when building libiconv-full. So when MariaDB sets LIBICONV_PLUG it expects # iconv_open() to be available for example, which is not the case - only # libiconv_open() is. To address this prevent the variable from being set. # libiconv-stub does not use this variable, so there is no harm in always doing @@ -632,3 +631,4 @@ $(eval $(call BuildPlugin,mariadb-server,server_audit,)) $(eval $(call BuildPlugin,mariadb-server,simple_password_check,)) $(eval $(call BuildPlugin,mariadb-server,sql_errlog,)) $(eval $(call BuildPlugin,mariadb-server,wsrep_info,)) + From 2de1c6c05f5582f244e8e80b1f799328e09a74eb Mon Sep 17 00:00:00 2001 From: Sebastian Kemper Date: Sat, 15 Dec 2018 17:17:21 +0100 Subject: [PATCH 8/8] mariadb: update init script to use uci Does away with /etc/default/mysqld, introduces uci configuration instead. The init script receives some further brushing up, like a function (copied from Debian) to get mysqld configuration parameters easily and quickly. Signed-off-by: Sebastian Kemper --- utils/mariadb/Makefile | 8 +-- utils/mariadb/conf/mysqld.default | 10 --- utils/mariadb/files/mysqld.config | 7 ++ utils/mariadb/files/mysqld.init | 104 ++++++++++++++++++++++-------- 4 files changed, 87 insertions(+), 42 deletions(-) delete mode 100644 utils/mariadb/conf/mysqld.default create mode 100644 utils/mariadb/files/mysqld.config diff --git a/utils/mariadb/Makefile b/utils/mariadb/Makefile index 515d211ca3..b499769fc7 100644 --- a/utils/mariadb/Makefile +++ b/utils/mariadb/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mariadb PKG_VERSION:=10.2.19 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL := \ @@ -332,7 +332,7 @@ endef define Package/mariadb-server-base/conffiles $(CONF_DIR)/conf.d/50-server.cnf $(CONF_DIR)/conf.d/60-galera.cnf -/etc/default/mysqld +/etc/config/mysqld endef define Package/mariadb-server-base/description @@ -554,13 +554,13 @@ define Package/mariadb-server-base/install $(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d $(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets $(INSTALL_DIR) $(1)$(SHARE_DIR)/english - $(INSTALL_DIR) $(1)/etc/default + $(INSTALL_DIR) $(1)/etc/config $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld $(SED) '/^[a-z]/s/^/#/' $(PKG_INSTALL_DIR)$(SHARE_DIR)/wsrep.cnf $(INSTALL_CONF) $(PKG_INSTALL_DIR)$(SHARE_DIR)/wsrep.cnf $(1)$(CONF_DIR)/conf.d/60-galera.cnf $(INSTALL_CONF) conf/50-server.cnf $(1)$(CONF_DIR)/conf.d - $(INSTALL_CONF) conf/mysqld.default $(1)/etc/default/mysqld + $(INSTALL_CONF) files/mysqld.config $(1)/etc/config/mysqld $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(1)$(SHARE_DIR)/charsets $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/english/errmsg.sys $(1)$(SHARE_DIR)/english $(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/fill_help_tables.sql $(1)$(SHARE_DIR) diff --git a/utils/mariadb/conf/mysqld.default b/utils/mariadb/conf/mysqld.default deleted file mode 100644 index fe9c698ba5..0000000000 --- a/utils/mariadb/conf/mysqld.default +++ /dev/null @@ -1,10 +0,0 @@ -# The user and group that will run the MySQL server. The user mariadb is -# automatically created by the mariadb-server package, hence that is the -# default choice. - -#MY_USER=mariadb -#MY_GROUP=mariadb - -# Additional arguments you want to pass to the MySQL server. - -#MY_ARGS="" diff --git a/utils/mariadb/files/mysqld.config b/utils/mariadb/files/mysqld.config new file mode 100644 index 0000000000..1bfcde6c5b --- /dev/null +++ b/utils/mariadb/files/mysqld.config @@ -0,0 +1,7 @@ + +config mysqld 'general' + option enabled '0' + option log_stderr '1' + option log_stdout '1' + option options '' + diff --git a/utils/mariadb/files/mysqld.init b/utils/mariadb/files/mysqld.init index abc99fc7a9..e55cfce706 100644 --- a/utils/mariadb/files/mysqld.init +++ b/utils/mariadb/files/mysqld.init @@ -8,46 +8,94 @@ USE_PROCD=1 #PROCD_DEBUG=1 -MYSQLD=mysqld +NAME=mysqld -DEFAULT=/etc/default/$MYSQLD -LOGGER="/usr/bin/logger -p user.err -s -t $MYSQLD" -PROG=/usr/bin/$MYSQLD +LOGGER="/usr/bin/logger -p user.err -s -t $NAME" +COMMAND=/usr/bin/$NAME -unset MY_ARGS MY_GROUP MY_USER - -[ -f $DEFAULT ] && . $DEFAULT - -my_user="${MY_USER:-mariadb}" -my_group="${MY_GROUP:-mariadb}" +mysqld_get_param() { + $COMMAND --print-defaults \ + | tr " " "\n" \ + | grep -- "--$1" \ + | tail -n 1 \ + | cut -d= -f2 +} start_service() { - local conf='/etc/mysql/my.cnf' - local datadir="$( sed -nE "s/^\s*datadir\s*=\s*('([^']*)'|\x22([^\x22]*)\x22|(.*\S))\s*$/\2\3\4/p" "$conf" )" + local conf=/etc/mysql/my.cnf + local dir + local user=mariadb - [ -d "$datadir" ] || { - $LOGGER "datadir '$datadir' in '$conf' does not exist" - return 1 - } + local datadir + local logdir=/var/log/mysql + local rundir=/var/run/mysqld + local tmpdir - [ -f "$datadir/mysql/tables_priv.MYD" ] || { + local enabled + local log_stderr + local log_stdout + local options + + if [ ! -x $COMMAND ]; then + $LOGGER $COMMAND is missing + exit 1 + fi + + if [ ! -r $conf ]; then + $LOGGER $conf cannot be read + exit 1 + fi + + config_load $NAME + + config_get_bool enabled general enabled 0 + if [ $enabled -eq 0 ]; then + $LOGGER service not enabled in /etc/config/$NAME + exit 1 + fi + + config_get_bool log_stderr general log_stderr 1 + config_get_bool log_stdout general log_stdout 1 + + config_get options general options + + datadir=$(mysqld_get_param datadir) + tmpdir=$(mysqld_get_param tmpdir) + + if [ -z "$datadir" ]; then + $LOGGER datadir is not set + exit 1 + fi + + if [ -z "$tmpdir" ]; then + $LOGGER tmpdir is not set. + exit 1 + fi + + [ -e "$datadir" ] || mkdir -p "$datadir" + + for dir in "$logdir" "$rundir" "$tmpdir"; do + if [ ! -e "$dir" ]; then + mkdir -p "$dir" + chown $user "$dir" + fi + done + + if [ ! -f "$datadir/mysql/tables_priv.MYD" ]; then $LOGGER "cannot detect privileges table, you might need to" $LOGGER "run 'mysql_install_db --force' to initialize the system tables" - return 1 - } - - mkdir -p /var/lib/mysql - chown "$my_user":"$my_group" /var/lib/mysql - - mkdir -p /var/run/mysqld - chown "$my_user":"$my_group" /var/run/mysqld + exit 1 + fi procd_open_instance - procd_set_param command $PROG $MY_ARGS - procd_set_param pidfile /var/run/mysqld.pid + procd_set_param command $COMMAND $options + # forward stderr to logd - procd_set_param stderr 1 + procd_set_param stderr $log_stderr + # same for stdout + procd_set_param stdout $log_stdout procd_close_instance } +