Browse Source

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 <sebastian_ml@gmx.net>
lilik-openwrt-22.03
Sebastian Kemper 6 years ago
parent
commit
cc0a40231d
5 changed files with 295 additions and 76 deletions
  1. +92
    -23
      utils/mariadb/Makefile
  2. +21
    -0
      utils/mariadb/conf/50-client.cnf
  3. +25
    -0
      utils/mariadb/conf/50-mysql-clients.cnf
  4. +136
    -0
      utils/mariadb/conf/50-server.cnf
  5. +21
    -53
      utils/mariadb/conf/my.cnf

+ 92
- 23
utils/mariadb/Makefile View File

@ -211,7 +211,7 @@ define Package/libmariadb/Default
endef endef
define Package/libmariadb define Package/libmariadb
$(call Package/libmariadb/Default)
$(call Package/libmariadb/Default)
DEPENDS:=$(MARIADB_COMMON_DEPENDS) DEPENDS:=$(MARIADB_COMMON_DEPENDS)
TITLE:=MariaDB database client library TITLE:=MariaDB database client library
MENU:=1 MENU:=1
@ -234,10 +234,9 @@ endef
define Package/mariadb-client define Package/mariadb-client
$(call Package/mariadb/Default) $(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 endef
define Package/mariadb-client/description define Package/mariadb-client/description
@ -249,9 +248,30 @@ $(subst $(space),$(newline),$(MARIADB_CLIENT))
endef 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 define Package/mariadb-client-extra
$(call Package/mariadb/Default) $(call Package/mariadb/Default)
TITLE:=MariaDB database extra client binaries
TITLE:=MariaDB database client extra
DEPENDS:=mariadb-client DEPENDS:=mariadb-client
endef endef
@ -264,6 +284,23 @@ $(subst $(space),$(newline),$(MARIADB_CLIENT_EXTRA))
endef 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 define Package/mariadb-extra-charsets
$(call Package/mariadb/Default) $(call Package/mariadb/Default)
TITLE:=MariaDB database extra character sets TITLE:=MariaDB database extra character sets
@ -280,16 +317,10 @@ endef
define Package/mariadb-server define Package/mariadb-server
$(call Package/mariadb/Default) $(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 MENU:=1
PROVIDES:=mysql-server PROVIDES:=mysql-server
USERID:=mariadb=376:mariadb=376
endef endef
define Package/mariadb-server/description define Package/mariadb-server/description
@ -301,9 +332,35 @@ $(subst $(space),$(newline),$(MARIADB_SERVER))
endef 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 define Package/mariadb-server-extra
$(call Package/mariadb/Default) $(call Package/mariadb/Default)
TITLE:=MariaDB database extra server binaries
TITLE:=MariaDB database server extra
DEPENDS:=mariadb-server DEPENDS:=mariadb-server
endef endef
@ -488,11 +545,22 @@ define Package/mariadb-client/install
cd $(1)/usr/bin; $(LN) mysqlcheck mysqloptimize cd $(1)/usr/bin; $(LN) mysqlcheck mysqloptimize
endef 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 define Package/mariadb-client-extra/install
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin
$(foreach b,$(MARIADB_CLIENT_EXTRA),$(call Package/mariadb/install/bin,$(1),$(b));) $(foreach b,$(MARIADB_CLIENT_EXTRA),$(call Package/mariadb/install/bin,$(1),$(b));)
endef 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 define Package/mariadb-extra-charsets/install
$(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets $(INSTALL_DIR) $(1)$(SHARE_DIR)/charsets
$(INSTALL_DATA) $(PKG_INSTALL_DIR)$(SHARE_DIR)/charsets/* $(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 define Package/mariadb-server/install
$(INSTALL_DIR) $(1)/usr/bin $(INSTALL_DIR) $(1)/usr/bin
$(foreach b,$(MARIADB_SERVER),$(call Package/mariadb/install/bin,$(1),$(b));) $(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/default
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_DIR) $(1)$(CONF_DIR)/conf.d
$(INSTALL_BIN) files/mysqld.init $(1)/etc/init.d/mysqld $(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_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)/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)/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)/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));) $(foreach b,$(MARIADB_SERVER_EXTRA),$(call Package/mariadb/install/bin,$(1),$(b));)
endef endef
define Package/mariadb-server/conffiles
/etc/default/mysqld
$(CONF_DIR)/my.cnf
endef
define BuildPlugin define BuildPlugin
define Package/$(1)-plugin-$(subst _,-,$(2)) define Package/$(1)-plugin-$(subst _,-,$(2))
$(call Package/$(subst mariadb-server,mariadb,$(1))/Default) $(call Package/$(subst mariadb-server,mariadb,$(1))/Default)
@ -548,9 +614,12 @@ endef
$(eval $(call HostBuild)) $(eval $(call HostBuild))
$(eval $(call BuildPackage,libmariadb)) $(eval $(call BuildPackage,libmariadb))
$(eval $(call BuildPackage,mariadb-client)) $(eval $(call BuildPackage,mariadb-client))
$(eval $(call BuildPackage,mariadb-client-base))
$(eval $(call BuildPackage,mariadb-client-extra)) $(eval $(call BuildPackage,mariadb-client-extra))
$(eval $(call BuildPackage,mariadb-common))
$(eval $(call BuildPackage,mariadb-extra-charsets)) $(eval $(call BuildPackage,mariadb-extra-charsets))
$(eval $(call BuildPackage,mariadb-server)) $(eval $(call BuildPackage,mariadb-server))
$(eval $(call BuildPackage,mariadb-server-base))
$(eval $(call BuildPackage,mariadb-server-extra)) $(eval $(call BuildPackage,mariadb-server-extra))
$(eval $(call BuildPlugin,libmariadb,auth_gssapi_client,+krb5-libs)) $(eval $(call BuildPlugin,libmariadb,auth_gssapi_client,+krb5-libs))


+ 21
- 0
utils/mariadb/conf/50-client.cnf View File

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

+ 25
- 0
utils/mariadb/conf/50-mysql-clients.cnf View File

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

+ 136
- 0
utils/mariadb/conf/50-server.cnf View File

@ -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/

+ 21
- 53
utils/mariadb/conf/my.cnf View File

@ -1,54 +1,22 @@
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[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
# 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.
#
# 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/

Loading…
Cancel
Save