← Back to team overview

maria-discuss team mailing list archive

Re: Multiple Mariadb 10.1 instances on Centos 7

 



Am 09.03.2017 um 20:41 schrieb Sales:

just write your systemd-units below /etc/systemd/system/ and you are done - you don't need @.service for that at all

the location in the samples below is /usr/lib/systemd becaus ewe shp both with our own rpm-build....
_________________________________________________


Ok, similar to what we used to do on 5.5. Seems like the multi instance would have been ok, but, we don’t have it so be it. I see nothing wrong with this method you suggest.

The only thing missing is the wait files. I don’t have those either on Centos 7.

ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID

it's for a) use type=simple and b) not use mysqld_safe at all since systemd can do that job better and combined with directly starting as user "mysql" since we only have a high port a ton of theoretical security issues are gone
______________________________________

[root@srv-rhsoft:~]$ cat /usr/libexec/mysqld-wait-ready
#!/usr/bin/bash

# Service file passes us the daemon's PID
daemon_pid="$1"

# Wait for the server to come up or for the mysqld process to disappear
ret=0
while /usr/bin/true; do
RESPONSE=`/usr/bin/mysqladmin --defaults-file=/etc/my.cnf --socket=/var/lib/mysql/mysql.sock --user=UNKNOWN_MYSQL_USER ping 2>&1`
 mret=$?
 if [ $mret -eq 0 ]; then
  break
 fi
 # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
 # anything else suggests a configuration error
 if [ $mret -ne 1 -a $mret -ne 11 ]; then
  ret=1
  break
 fi
 # "Access denied" also means the server is alive
 echo "$RESPONSE" | grep -q "Access denied for user" && break

 # Check process still exists
 if ! /usr/bin/kill -0 $daemon_pid 2>/dev/null; then
  ret=1
  break
 fi
 usleep 100000
done

exit $ret
______________________________________

[root@srv-rhsoft:~]$ cat /usr/libexec/mysqld-dbmail-wait-ready
#!/usr/bin/bash

# Service file passes us the daemon's PID
daemon_pid="$1"

# Wait for the server to come up or for the mysqld process to disappear
ret=0
while /usr/bin/true; do
RESPONSE=`/usr/bin/mysqladmin --defaults-file=/etc/my-dbmail.cnf --socket=/var/lib/mysql/mysqld_dbmail.sock --user=UNKNOWN_MYSQL_USER ping 2>&1`
 mret=$?
 if [ $mret -eq 0 ]; then
  break
 fi
 # exit codes 1, 11 (EXIT_CANNOT_CONNECT_TO_SERVICE) are expected,
 # anything else suggests a configuration error
 if [ $mret -ne 1 -a $mret -ne 11 ]; then
  ret=1
  break
 fi
 # "Access denied" also means the server is alive
 echo "$RESPONSE" | grep -q "Access denied for user" && break

 # Check process still exists
 if ! /usr/bin/kill -0 $daemon_pid 2>/dev/null; then
  ret=1
  break
 fi
 usleep 100000
done

exit $ret


References