From 3c56e2eca78dedb17a79b3fce6add03a91ee351f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Honza=20Hor=C3=A1k?= Date: Mon, 2 Sep 2013 17:44:03 +0200 Subject: [PATCH] Re-organize my.cnf to include only generic settings (RHBZ#1003115) Move pid file location to /var/run/mariadb (RHBZ#999589) Make mysqld a symlink to mariadb unit file rather than the opposite way (RHBZ#999589) --- mariadb-config.patch | 20 +++++++ ...d-prepare-db-dir => mariadb-prepare-db-dir | 0 mysqld-wait-ready => mariadb-wait-ready | 0 mysqld.service => mariadb.service | 14 ++--- mariadb.spec | 52 ++++++++++++++----- mariadb.tmpfiles.d | 1 + my.cnf | 16 ++++-- 7 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 mariadb-config.patch rename mysqld-prepare-db-dir => mariadb-prepare-db-dir (100%) rename mysqld-wait-ready => mariadb-wait-ready (100%) rename mysqld.service => mariadb.service (75%) diff --git a/mariadb-config.patch b/mariadb-config.patch new file mode 100644 index 0000000..5034890 --- /dev/null +++ b/mariadb-config.patch @@ -0,0 +1,20 @@ +Settings specific for MariaDB specific are defined in appropriate section in +/etc/my.cnf.d/server.cnf (part of mariadb-server). +It doesn't matter that we set these settings only for [mysqld] here, +because they will be read and used in mysqld_safe as well. +Settings in my.cnf are generic for all MySQL implementations because of +conflict issues. +RHBZ#1003115 + +diff -up mariadb-5.5.32/support-files/rpm/server.cnf.mariaconf mariadb-5.5.32/support-files/rpm/server.cnf +--- mariadb-5.5.32/support-files/rpm/server.cnf.mariaconf 2013-09-02 14:17:37.277833263 +0200 ++++ mariadb-5.5.32/support-files/rpm/server.cnf 2013-09-02 14:18:00.638810223 +0200 +@@ -23,6 +23,8 @@ + # If you use the same .cnf file for MySQL and MariaDB, + # you can put MariaDB-only options here + [mariadb] ++log-error=/var/log/mariadb/mariadb.log ++pid-file=/var/run/mariadb/mariadb.pid + + [mariadb-5.5] + diff --git a/mysqld-prepare-db-dir b/mariadb-prepare-db-dir similarity index 100% rename from mysqld-prepare-db-dir rename to mariadb-prepare-db-dir diff --git a/mysqld-wait-ready b/mariadb-wait-ready similarity index 100% rename from mysqld-wait-ready rename to mariadb-wait-ready diff --git a/mysqld.service b/mariadb.service similarity index 75% rename from mysqld.service rename to mariadb.service index ceb26e2..89cbd1a 100644 --- a/mysqld.service +++ b/mariadb.service @@ -1,19 +1,19 @@ # It's not recommended to modify this file in-place, because it will be # overwritten during package upgrades. If you want to customize, the -# best way is to create a file "/etc/systemd/system/mysqld.service", +# best way is to create a file "/etc/systemd/system/mariadb.service", # containing -# .include /lib/systemd/system/mysqld.service +# .include /lib/systemd/system/mariadb.service # ...make your changes here... -# or create a file "/etc/systemd/system/mysqld.service.d/foo.conf", +# or create a file "/etc/systemd/system/mariadb.service.d/foo.conf", # which doesn't need to include ".include" call and which will be parsed -# after the file mysqld.service itself is parsed. +# after the file mariadb.service itself is parsed. # # For more info about custom unit files, see systemd.unit(5) or # http://fedoraproject.org/wiki/Systemd#How_do_I_customize_a_unit_file.2F_add_a_custom_unit_file.3F # For example, if you want to increase mysql's open-files-limit to 10000, # you need to increase systemd's LimitNOFILE setting, so create a file named -# "/etc/systemd/system/mysqld.service.d/limits.conf" containing: +# "/etc/systemd/system/mariadb.service.d/limits.conf" containing: # [Service] # LimitNOFILE=10000 @@ -32,11 +32,11 @@ Type=simple User=mysql Group=mysql -ExecStartPre=/usr/libexec/mysqld-prepare-db-dir %n +ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n # Note: we set --basedir to prevent probes that might trigger SELinux alarms, # per bug #547485 ExecStart=/usr/bin/mysqld_safe --basedir=/usr -ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID +ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID # Give a reasonable amount of time for the server to start up/shut down TimeoutSec=300 diff --git a/mariadb.spec b/mariadb.spec index 67a11e0..4b7158b 100644 --- a/mariadb.spec +++ b/mariadb.spec @@ -3,7 +3,7 @@ Name: mariadb Version: 5.5.32 -Release: 11%{?dist} +Release: 12%{?dist} Epoch: 1 Summary: A community developed branch of MySQL @@ -29,6 +29,7 @@ License: GPLv2 with exceptions and LGPLv2 and BSD # the beginning of the transaction and mysqld is enabled again in the end # of the transaction in case this flag file exists. %global mysqld_enabled_flag_file %{_localstatedir}/lib/rpm-state/mysqld_enabled +%global mysqld_running_flag_file %{_localstatedir}/lib/rpm-state/mysqld_running Source0: http://ftp.osuosl.org/pub/mariadb/mariadb-%{version}/kvm-tarbake-jaunty-x86/mariadb-%{version}.tar.gz Source3: my.cnf @@ -38,9 +39,9 @@ Source7: README.mysql-license Source8: libmysql.version Source9: mysql-embedded-check.c Source10: mariadb.tmpfiles.d -Source11: mysqld.service -Source12: mysqld-prepare-db-dir -Source13: mysqld-wait-ready +Source11: mariadb.service +Source12: mariadb-prepare-db-dir +Source13: mariadb-wait-ready Source14: rh-skipped-tests-base.list Source15: rh-skipped-tests-arm.list # Working around perl dependency checking bug in rpm FTTB. Remove later. @@ -63,6 +64,7 @@ Patch14: mariadb-basedir.patch Patch15: mariadb-tmpdir.patch Patch17: mariadb-covscan-signexpr.patch Patch18: mariadb-covscan-stroverflow.patch +Patch19: mariadb-config.patch BuildRequires: perl, readline-devel, openssl-devel BuildRequires: cmake, ncurses-devel, zlib-devel, libaio-devel @@ -264,6 +266,7 @@ MariaDB is a community developed branch of MySQL. %patch15 -p1 %patch17 -p1 %patch18 -p1 +%patch19 -p1 # workaround for upstream bug #56342 rm -f mysql-test/t/ssl_8k_key-master.opt @@ -433,7 +436,11 @@ chmod 0750 $RPM_BUILD_ROOT%{_localstatedir}/log/mariadb touch $RPM_BUILD_ROOT%{_localstatedir}/log/mariadb/mariadb.log ln -s %{_localstatedir}/log/mariadb/mariadb.log $RPM_BUILD_ROOT%{_localstatedir}/log/mysqld.log +# current setting in my.cnf is to use /var/run/mariadb for creating pid file, +# however since my.cnf is not updated by RPM if changed, we need to create mysqld +# as well because users can have od settings in their /etc/my.cnf mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/mysqld +mkdir -p $RPM_BUILD_ROOT%{_localstatedir}/run/mariadb install -m 0755 -d $RPM_BUILD_ROOT%{_localstatedir}/lib/mysql mkdir -p $RPM_BUILD_ROOT%{_sysconfdir} @@ -442,7 +449,7 @@ install -p -m 0644 %{SOURCE3} $RPM_BUILD_ROOT%{_sysconfdir}/my.cnf # install systemd unit files and scripts for handling server startup mkdir -p ${RPM_BUILD_ROOT}%{_unitdir} install -p -m 644 %{SOURCE11} ${RPM_BUILD_ROOT}%{_unitdir}/ -ln -s mysqld.service ${RPM_BUILD_ROOT}%{_unitdir}/mariadb.service +ln -s mariadb.service ${RPM_BUILD_ROOT}%{_unitdir}/mysqld.service install -p -m 755 %{SOURCE12} ${RPM_BUILD_ROOT}%{_libexecdir}/ install -p -m 755 %{SOURCE13} ${RPM_BUILD_ROOT}%{_libexecdir}/ @@ -530,16 +537,29 @@ if /bin/systemctl is-enabled mysqld.service >/dev/null 2>&1 ; then touch %mysqld_enabled_flag_file >/dev/null 2>&1 || : fi +# Since mysqld.service became a symlink to mariadb.service, turning off +# the running mysqld service doesn't work fine (BZ#1002996). As a work-around +# we explicitly stop mysqld before upgrade and start after it again. +if [ ! -L %{_unitdir}/mysqld.service ] && /bin/systemctl is-active mysqld.service &>/dev/null ; then + touch %mysqld_running_flag_file >/dev/null 2>&1 || : + /bin/systemctl stop mysqld.service >/dev/null 2>&1 || : +fi + %posttrans server -if [ -f %mysqld_enabled_flag_file ]; then - /bin/systemctl enable mysqld.service >/dev/null 2>&1 || : +if [ -f %mysqld_enabled_flag_file ] ; then + /bin/systemctl enable mariadb.service >/dev/null 2>&1 || : rm -f %mysqld_enabled_flag_file >/dev/null 2>&1 || : fi +if [ -f %mysqld_running_flag_file ] ; then + /bin/systemctl start mariadb.service >/dev/null 2>&1 || : + rm -f %mysqld_running_flag_file >/dev/null 2>&1 || : +fi + %post libs -p /sbin/ldconfig %post server -%systemd_post mysqld.service +%systemd_post mariadb.service /bin/chmod 0755 %{_localstatedir}/lib/mysql /bin/touch %{_localstatedir}/log/mariadb/mariadb.log @@ -554,12 +574,12 @@ if [ $1 -eq 0 ] ; then fi %preun server -%systemd_preun mysqld.service +%systemd_preun mariadb.service %postun libs -p /sbin/ldconfig %postun server -%systemd_postun_with_restart mysqld.service +%systemd_postun_with_restart mariadb.service if [ $1 -eq 0 ] ; then %{_sbindir}/update-alternatives --remove mysqlbug %{_libdir}/mysql/mysqlbug fi @@ -727,11 +747,12 @@ fi %{_unitdir}/mysqld.service %{_unitdir}/mariadb.service -%{_libexecdir}/mysqld-prepare-db-dir -%{_libexecdir}/mysqld-wait-ready +%{_libexecdir}/mariadb-prepare-db-dir +%{_libexecdir}/mariadb-wait-ready %{_tmpfilesdir}/%{name}.conf %attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mysqld +%attr(0755,mysql,mysql) %dir %{_localstatedir}/run/mariadb %attr(0755,mysql,mysql) %dir %{_localstatedir}/lib/mysql %attr(0750,mysql,mysql) %dir %{_localstatedir}/log/mariadb %attr(0640,mysql,mysql) %config(noreplace) %verify(not md5 size mtime) %{_localstatedir}/log/mariadb/mariadb.log @@ -767,6 +788,13 @@ fi %{_mandir}/man1/mysql_client_test.1* %changelog +* Mon Sep 2 2013 Honza Horak - 1:5.5.32-12 +- Re-organize my.cnf to include only generic settings + Resolves: #1003115 +- Move pid file location to /var/run/mariadb +- Make mysqld a symlink to mariadb unit file rather than the opposite way + Related: #999589 + * Thu Aug 29 2013 Honza Horak - 1:5.5.32-11 - Move log file into /var/log/mariadb/mariadb.log - Rename logrotate script to mariadb diff --git a/mariadb.tmpfiles.d b/mariadb.tmpfiles.d index 74cd5f8..fbfe4d9 100644 --- a/mariadb.tmpfiles.d +++ b/mariadb.tmpfiles.d @@ -1 +1,2 @@ d /var/run/mysqld 0755 mysql mysql - +d /var/run/mariadb 0755 mysql mysql - diff --git a/my.cnf b/my.cnf index 2a5311b..ac882ac 100644 --- a/my.cnf +++ b/my.cnf @@ -5,13 +5,23 @@ socket=/var/lib/mysql/mysql.sock symbolic-links=0 # Settings user and group are ignored when systemd is used. # If you need to run mysqld under a different user or group, -# customize your systemd unit file for mysqld according to the +# customize your systemd unit file for mysqld/mariadb according to the # instructions in http://fedoraproject.org/wiki/Systemd -[mysqld_safe] -log-error=/var/log/mariadb/mariadb.log +# Currently, there are mariadb and community-mysql packages in Fedora. +# This particular config file is included in respective RPMs of both of them, +# so the following settings are general and will be also used by both of them. +# Otherwise the RPMs would be in conflict. +# Settings for particular implementations like MariaDB are then +# defined in appropriate sections; for MariaDB server in [mariadb] section in +# /etc/my.cnf.d/server.cnf (part of mariadb-server). +# It doesn't matter that we set these settings only for [mysqld] here, +# because they will be read and used in mysqld_safe as well. +log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid +[mysqld_safe] + # # include all files from the config directory #