summaryrefslogtreecommitdiffstats
path: root/meta-oe/recipes-support/mysql/mariadb.inc
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2015-11-25 10:04:31 +0800
committerArmin Kuster <akuster808@gmail.com>2015-12-20 14:26:37 -0800
commit956089410906c7efdbebdee68c4b5daaeaebbaaf (patch)
tree019aabf288ded65d56d8865d9120de700e563017 /meta-oe/recipes-support/mysql/mariadb.inc
parent9af04860be7697694ecd1cfb0a948a186ac86727 (diff)
downloadmeta-openembedded-956089410906c7efdbebdee68c4b5daaeaebbaaf.tar.gz
mariadb.inc: fix mysqld hung at first init time based on systemd
While SYSTEMD_AUTO_ENABLE_mariadb-server = "enable", the mysqld service hungs. ... [ **] A start job is running for Run pending postinsts (25s / no limit) [ OK ] Stopped MariaDB database server. ... In mariadb-server's pkg_postinst, it install db at first runtime. And the following 'systemctl mysqld restart' casued the hunging. So the fix idea is to reomove pkg_postinst and still install db at first runtime. Introduce mysql-systemd-start from ${S}/packaging/rpm-oel/. For review convenience, we add them as file. The mysql-systemd-start provides two functions: the install_db is to install db at fist runtime (the first runtime means if a db existed, the install_db will directly exit); the pinger is to wait for mysqld service startup completed. The mysqld.service add ExecStartPost than previous which invoke 'mysql-systemd-start post' to wait for mysqld service startup completed. We add a package to provide install_db, so the user could choose it to install database for mariadb at first boot before mysqld started. It also fix another issue: When you manually restart mysqld and do mysql test to connect the server, the return of the restart could make sure mysqld is ready, and the following db connect will not fail with: ... Can't connect to local MySQL server through socket ... Tweak my.cnf to remove obsolete/incorrect parameter. Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Armin Kuster <akuster808@gmail.com>
Diffstat (limited to 'meta-oe/recipes-support/mysql/mariadb.inc')
-rw-r--r--meta-oe/recipes-support/mysql/mariadb.inc51
1 files changed, 27 insertions, 24 deletions
diff --git a/meta-oe/recipes-support/mysql/mariadb.inc b/meta-oe/recipes-support/mysql/mariadb.inc
index 42a4eda65..a6826c31e 100644
--- a/meta-oe/recipes-support/mysql/mariadb.inc
+++ b/meta-oe/recipes-support/mysql/mariadb.inc
@@ -10,6 +10,9 @@ SRC_URI = "http://archive.mariadb.org/mariadb-${PV}/source/mariadb-${PV}.tar.gz
10 file://fix-mysqlclient-r-version.patch \ 10 file://fix-mysqlclient-r-version.patch \
11 file://my.cnf \ 11 file://my.cnf \
12 file://mysqld.service \ 12 file://mysqld.service \
13 file://install_db.service \
14 file://install_db \
15 file://mysql-systemd-start \
13 file://configure.cmake-fix-valgrind.patch \ 16 file://configure.cmake-fix-valgrind.patch \
14 file://fix-a-building-failure.patch \ 17 file://fix-a-building-failure.patch \
15 " 18 "
@@ -23,26 +26,35 @@ BINCONFIG_GLOB = "mysql_config"
23 26
24inherit cmake gettext binconfig update-rc.d useradd systemd 27inherit cmake gettext binconfig update-rc.d useradd systemd
25 28
26INITSCRIPT_PACKAGES = "${PN}-server" 29INITSCRIPT_PACKAGES = "${PN}-server ${PN}-setupdb"
27INITSCRIPT_NAME = "mysqld" 30INITSCRIPT_NAME_${PN}-server = "mysqld"
28INITSCRIPT_PARAMS = "start 45 5 . stop 45 0 6 1 ." 31INITSCRIPT_PARAMS_${PN}-server ?= "start 45 5 . stop 45 0 6 1 ."
29 32
30USERADD_PACKAGES = "${PN}-server" 33USERADD_PACKAGES = "${PN}-server"
31USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql" 34USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql"
32GROUPADD_PARAM_${PN}-server = "--system mysql" 35GROUPADD_PARAM_${PN}-server = "--system mysql"
33 36
34SYSTEMD_PACKAGES = "${PN}-server" 37INITSCRIPT_NAME_${PN}-setupdb = "install_db"
38INITSCRIPT_PARAMS_${PN}-setupdb ?= "defaults 44 44"
39
40SYSTEMD_PACKAGES = "${PN}-server ${PN}-setupdb"
35SYSTEMD_SERVICE_${PN}-server = "mysqld.service" 41SYSTEMD_SERVICE_${PN}-server = "mysqld.service"
36SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" 42SYSTEMD_AUTO_ENABLE_${PN}-server ?= "disable"
43
44SYSTEMD_SERVICE_${PN}-setupdb = "install_db.service"
45SYSTEMD_AUTO_ENABLE_${PN}-setupdb ?= "enable"
46ALLOW_EMPTY_${PN}-setupdb ?= "1"
47FILES_${PN}-setupdb = "${sysconfdir}/init.d/install_db"
37 48
38EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'" 49EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'"
39 50
40PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" 51PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)} setupdb"
41PACKAGECONFIG_class-native = "" 52PACKAGECONFIG_class-native = ""
42PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam" 53PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam"
43PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind" 54PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind"
44PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit" 55PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit"
45PACKAGECONFIG[krb5] = ", ,krb5" 56PACKAGECONFIG[krb5] = ", ,krb5"
57PACKAGECONFIG[setupdb] = ", ,,${PN}-setupdb"
46 58
47# MariaDB doesn't link properly with gold 59# MariaDB doesn't link properly with gold
48# https://mariadb.atlassian.net/browse/MDEV-5982 60# https://mariadb.atlassian.net/browse/MDEV-5982
@@ -114,39 +126,29 @@ do_install() {
114 126
115 install -d ${D}/${sysconfdir}/init.d 127 install -d ${D}/${sysconfdir}/init.d
116 install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/ 128 install -m 0644 ${WORKDIR}/my.cnf ${D}/${sysconfdir}/
129 install -m 0755 ${WORKDIR}/install_db ${D}/${sysconfdir}/init.d/
117 mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld 130 mv ${D}/${sysconfdir}/init.d/mysql ${D}/${sysconfdir}/init.d/mysqld
118 131
119 install -d ${D}${systemd_unitdir}/system 132 install -d ${D}${systemd_unitdir}/system
120 install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system 133 install -m 0644 ${WORKDIR}/mysqld.service ${D}${systemd_unitdir}/system
121 sed -i -e 's,@BINDIR@,${bindir},g' -e 's,@PREFIX@,${prefix},g' ${D}${systemd_unitdir}/system/mysqld.service 134 install -m 0644 ${WORKDIR}/install_db.service ${D}${systemd_unitdir}/system
135 sed -i -e 's,@BINDIR@,${bindir},g' -e 's,@PREFIX@,${prefix},g' ${D}${systemd_unitdir}/system/mysqld.service \
136 ${D}${systemd_unitdir}/system/install_db.service
122 137
123 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then 138 if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
124 install -d ${D}${sysconfdir}/tmpfiles.d 139 install -d ${D}${sysconfdir}/tmpfiles.d
125 echo "f /var/log/mysqld.err 0640 mysql mysql -" \ 140 echo "f /var/log/mysqld.err 0640 mysql mysql -" \
126 > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf 141 > ${D}${sysconfdir}/tmpfiles.d/99-mysqld.conf
127 fi 142 fi
128} 143 install -d ${D}${bindir}
129 144 install -m 755 ${WORKDIR}/mysql-systemd-start ${D}${bindir}
130pkg_postinst_${PN}-server () {
131 if [ "x$D" != "x" ]; then
132 exit 1
133 fi
134
135 #Install the database
136 test -d /usr/bin || mkdir -p /usr/bin
137 test -e /usr/bin/hostname || ln -s /bin/hostname /usr/bin/hostname
138 mkdir /var/lib/mysql
139 chown mysql.mysql /var/lib/mysql
140
141 mysql_install_db --basedir=${prefix} --user=mysql
142 145
143 [ -x /sbin/restorecon ] && /sbin/restorecon -RF /var/lib/mysql
144} 146}
145 147
146PACKAGES = "${PN}-dbg ${PN} \ 148PACKAGES = "${PN}-dbg ${PN} \
147 libmysqlclient-r libmysqlclient-r-dev libmysqlclient-r-staticdev libmysqlclient-r-dbg \ 149 libmysqlclient-r libmysqlclient-r-dev libmysqlclient-r-staticdev libmysqlclient-r-dbg \
148 libmysqlclient libmysqlclient-dev libmysqlclient-staticdev libmysqlclient-dbg \ 150 libmysqlclient libmysqlclient-dev libmysqlclient-staticdev libmysqlclient-dbg \
149 libmysqld libmysqld-dev ${PN}-client ${PN}-server ${PN}-leftovers" 151 libmysqld libmysqld-dev ${PN}-client ${PN}-server ${PN}-setupdb ${PN}-leftovers"
150CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf" 152CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf"
151CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf" 153CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf"
152CONFFILES_libmysqlclient += "${sysconfdir}/my.cnf.d/client.cnf" 154CONFFILES_libmysqlclient += "${sysconfdir}/my.cnf.d/client.cnf"
@@ -236,6 +238,7 @@ FILES_${PN}-server = "\
236 ${bindir}/mysql_install_db \ 238 ${bindir}/mysql_install_db \
237 ${bindir}/mysql_secure_installation \ 239 ${bindir}/mysql_secure_installation \
238 ${bindir}/mysql_setpermission \ 240 ${bindir}/mysql_setpermission \
241 ${bindir}/mysql-systemd-start \
239 ${bindir}/mysql_tzinfo_to_sql \ 242 ${bindir}/mysql_tzinfo_to_sql \
240 ${bindir}/mysql_upgrade \ 243 ${bindir}/mysql_upgrade \
241 ${bindir}/mysql_plugin \ 244 ${bindir}/mysql_plugin \
@@ -268,7 +271,7 @@ FILES_${PN}-server = "\
268 ${libdir}/plugin/*.so \ 271 ${libdir}/plugin/*.so \
269 ${datadir}/mysql/ \ 272 ${datadir}/mysql/ \
270 ${localstatedir}/mysql/ \ 273 ${localstatedir}/mysql/ \
271 ${sysconfdir}/init.d \ 274 ${sysconfdir}/init.d/mysqld \
272 ${sysconfdir}/my.cnf \ 275 ${sysconfdir}/my.cnf \
273 ${sysconfdir}/my.cnf.d/server.cnf \ 276 ${sysconfdir}/my.cnf.d/server.cnf \
274 ${sysconfdir}/tmpfiles.d" 277 ${sysconfdir}/tmpfiles.d"