diff options
author | Hongxu Jia <hongxu.jia@windriver.com> | 2015-11-25 10:04:31 +0800 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2015-12-20 14:26:37 -0800 |
commit | 956089410906c7efdbebdee68c4b5daaeaebbaaf (patch) | |
tree | 019aabf288ded65d56d8865d9120de700e563017 /meta-oe/recipes-support/mysql/mariadb.inc | |
parent | 9af04860be7697694ecd1cfb0a948a186ac86727 (diff) | |
download | meta-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.inc | 51 |
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 | ||
24 | inherit cmake gettext binconfig update-rc.d useradd systemd | 27 | inherit cmake gettext binconfig update-rc.d useradd systemd |
25 | 28 | ||
26 | INITSCRIPT_PACKAGES = "${PN}-server" | 29 | INITSCRIPT_PACKAGES = "${PN}-server ${PN}-setupdb" |
27 | INITSCRIPT_NAME = "mysqld" | 30 | INITSCRIPT_NAME_${PN}-server = "mysqld" |
28 | INITSCRIPT_PARAMS = "start 45 5 . stop 45 0 6 1 ." | 31 | INITSCRIPT_PARAMS_${PN}-server ?= "start 45 5 . stop 45 0 6 1 ." |
29 | 32 | ||
30 | USERADD_PACKAGES = "${PN}-server" | 33 | USERADD_PACKAGES = "${PN}-server" |
31 | USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql" | 34 | USERADD_PARAM_${PN}-server = "--system --home-dir /var/mysql -g mysql --shell /bin/false mysql" |
32 | GROUPADD_PARAM_${PN}-server = "--system mysql" | 35 | GROUPADD_PARAM_${PN}-server = "--system mysql" |
33 | 36 | ||
34 | SYSTEMD_PACKAGES = "${PN}-server" | 37 | INITSCRIPT_NAME_${PN}-setupdb = "install_db" |
38 | INITSCRIPT_PARAMS_${PN}-setupdb ?= "defaults 44 44" | ||
39 | |||
40 | SYSTEMD_PACKAGES = "${PN}-server ${PN}-setupdb" | ||
35 | SYSTEMD_SERVICE_${PN}-server = "mysqld.service" | 41 | SYSTEMD_SERVICE_${PN}-server = "mysqld.service" |
36 | SYSTEMD_AUTO_ENABLE_${PN}-server = "disable" | 42 | SYSTEMD_AUTO_ENABLE_${PN}-server ?= "disable" |
43 | |||
44 | SYSTEMD_SERVICE_${PN}-setupdb = "install_db.service" | ||
45 | SYSTEMD_AUTO_ENABLE_${PN}-setupdb ?= "enable" | ||
46 | ALLOW_EMPTY_${PN}-setupdb ?= "1" | ||
47 | FILES_${PN}-setupdb = "${sysconfdir}/init.d/install_db" | ||
37 | 48 | ||
38 | EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'" | 49 | EXTRA_OEMAKE = "'GEN_LEX_HASH=${STAGING_BINDIR_NATIVE}/gen_lex_hash'" |
39 | 50 | ||
40 | PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}" | 51 | PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)} setupdb" |
41 | PACKAGECONFIG_class-native = "" | 52 | PACKAGECONFIG_class-native = "" |
42 | PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam" | 53 | PACKAGECONFIG[pam] = ",-DWITHOUT_AUTH_PAM=TRUE,libpam" |
43 | PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind" | 54 | PACKAGECONFIG[valgrind] = "-DWITH_VALGRIND=TRUE,-DWITH_VALGRIND=FALSE,valgrind" |
44 | PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit" | 55 | PACKAGECONFIG[libedit] = "-DLIBEDIT_INTERFACE=TRUE,-DLIBEDIT_INTERFACE=FALSE,libedit" |
45 | PACKAGECONFIG[krb5] = ", ,krb5" | 56 | PACKAGECONFIG[krb5] = ", ,krb5" |
57 | PACKAGECONFIG[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} | |
130 | pkg_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 | ||
146 | PACKAGES = "${PN}-dbg ${PN} \ | 148 | PACKAGES = "${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" |
150 | CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf" | 152 | CONFFILES_${PN}-server += "${sysconfdir}/my.cnf ${sysconfdir}/my.cnf.d/server.cnf" |
151 | CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf" | 153 | CONFFILES_${PN}-client += "${sysconfdir}/my.cnf.d/mysql-clients.cnf" |
152 | CONFFILES_libmysqlclient += "${sysconfdir}/my.cnf.d/client.cnf" | 154 | CONFFILES_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" |