On 05/05/2018 01:42 PM, Reindl Harald wrote:

Am 05.05.2018 um 12:28 schrieb Muhammad Bashir Al-Noimi:
On 05/05/2018 12:49 PM, Reindl Harald wrote:
Am 05.05.2018 um 11:43 schrieb Muhammad Bashir Al-Noimi:
May 03 04:54:01 domain.com systemd[1]: Starting LSB: start and stop
MariaDB...
May 03 04:54:01 domain.com mysqld[17145]: Starting MariaDB
May 03 04:54:01 domain.com mysqld[17145]:
.2018-05-03T01:54:01.525119Z mysqld_safe Logging to
'/var/lib/mysql/domain.com.err'.
May 03 04:54:01 domain.com mysqld[17145]: 2018-05-03T01:54:01.551305Z
mysqld_safe A mysqld process already exists
May 03 04:54:02 domain.com systemd[1]: mariadb.service: Control
process exited, code=exited status=1
May 03 04:54:02 domain.com systemd[1]: Failed to start LSB: start and
stop MariaDB.
May 03 04:54:02 domain.com systemd[1]: mariadb.service: Unit entered
failed state.
May 03 04:54:02 domain.com systemd[1]: mariadb.service: Failed with
result 'exit-code'.
How can I fix this issue?

IMPORTANT:

  * In the attachments you can find *"/opt/mariadb-data/my.cnf"* AND
    *"/etc/init.d/mariadb**files"*
  * Ubuntu Linux 16.04.2 x64
  * Downloaded mariadb-10.2.14-linux-x86_64.tar.gz


Sorry I didn't mention the source of MariaDB documentation
https://mariadb.com/kb/en/library/installing-mariadb-alongside-mysql/
just strip out mysqld_safe at all - we even don't ship it the last 7
years with out packages - since systemd supports "Restart=always" there
is no need for babysitting and you also don't need to fire up anything
as root - would at least have saved one critical secuirty issue in the past

for "Type=notify" you need to have systemd-devel installed at build-time
and it's recommended because After/Before works relieable and start
follow-up services when mysqld is really ready for connections
__________________

[root@srv-rhsoft:~]$ cat /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MariaDB Database
Before=postfix.service dovecot.service dbmail-imapd.service
dbmail-lmtpd.service dbmail-pop3d.service dbmail-timsieved.service

[Service]
Type=notify
KillMode=process
KillSignal=SIGTERM
SendSIGKILL=no

User=mysql
Group=mysql

ExecStart=/usr/libexec/mysqld --defaults-file=/etc/my.cnf
--pid-file=/dev/null
Environment="LANG=en_GB.UTF-8"
Restart=always
RestartSec=1
TimeoutSec=300
LimitNOFILE=infinity
LimitMEMLOCK=infinity
OOMScoreAdjust=-1000
TasksMax=2048
Thanks Reindl

root@hpc-tech:~# systemctl status mariadb.service
● mariadb.service - LSB: start and stop MariaDB
   Loaded: loaded (/etc/init.d/mariadb; bad; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: failed (Result: exit-code) since Sat 2018-05-05 13:23:55
+03; 3s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 21831 ExecStart=/etc/init.d/mariadb start (code=exited,
status=1/FAILURE)
get rid of that damned /etc/init.d/mariadb crap
WTF is "ExecStart=/etc/init.d/mariadb start"

put your service in /etc/systemd/system/mariadb.service and you are done

no idea what you did not understand in the ExecStart from my sample above

I use /etc/systemd/system/mariadb.service as mentioned before but I struggle with a new problem and I spent a whole day trying to fix it but I failed :(

I always get this error message through journalctl -xe although my.cnf already exists and has a prober permissions!

May 06 23:26:41 domain.com mysqld[26621]: Could not open required defaults file: /opt/mariadb-data/my.cnf
May 06 23:26:41 domain.com mysqld[26621]: Fatal error in defaults handling. Program aborted
May 06 23:26:41 domain.com systemd[1]: mariadb.service: Main process exited, code=exited, status=1/FAILURE
May 06 23:26:41 domain.com systemd[1]: mariadb.service: Unit entered failed state.
May 06 23:26:41 domain.com systemd[1]: mariadb.service: Failed with result 'exit-code'.
May 06 23:26:43 domain.com systemd[1]: mariadb.service: Service hold-off time over, scheduling restart.
May 06 23:26:43 domain.com systemd[1]: Stopped MariaDB Database.


How to to fix this issue?

https://gist.github.com/mbnoimi/b9daceca0e0e21da86b048b9883c5edf

https://gist.github.com/mbnoimi/5920301ff79dcb88aab3ef7fa459733e

mkdir mariadb-data
groupadd --system mariadb
useradd -c "MariaDB Server" -d /opt/mariadb -g mariadb --system mariadb
cp my.cnf mariadb-data/my.cnf
chown -R mariadb:mariadb mariadb-10.2.14-linux-x86_64/
chown -R mariadb:mariadb mariadb-data/
chmod -R 700 mariadb-data/
cd mariadb
scripts/mysql_install_db --defaults-file=/opt/mariadb-data/my.cnf
cd ..
cp mariadb.service /etc/systemd/system/
systemctl daemon-reload

-- 
Best Regards,
Muhammad Bashir Al-Noimi
Skype+Telegram+GMail: mbnoimi