[Maria-discuss] Multiple Mariadb 10.1 instances on Centos 7
I don’t see a mariadb@.service file on centos 7. I need to install multiple instances of mariadb 10.1 though and have them run from systemd (on the same server). The doc page https://mariadb.com/kb/en/mariadb/systemd/ <https://mariadb.com/kb/en/mariadb/systemd/> says that it’s installed on “some” systems. Apparently, some does not include Centos 7. So, is there a way to obtain a copy of the relevant file(s) needed to run multiple instances? Perhaps from another distribution? Seems like it’s a much better starting point than trying to create all that myself. Or, will it simply not work? What is the best way then to run multiple instances on Centos 7? Steve
Am 09.03.2017 um 20:07 schrieb Sales:
I don’t see a mariadb@.service file on centos 7. I need to install multiple instances of mariadb 10.1 though and have them run from systemd (on the same server). The doc page https://mariadb.com/kb/en/mariadb/systemd/ says that it’s installed on “some” systems. Apparently, some does not include Centos 7.
So, is there a way to obtain a copy of the relevant file(s) needed to run multiple instances? Perhaps from another distribution? Seems like it’s a much better starting point than trying to create all that myself. Or, will it simply not work?
What is the best way then to run multiple instances on Centos 7?
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.... _________________________________________________ [root@testserver:~]$ 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=simple User=mysql Group=mysql ExecStart=/usr/libexec/mysqld --defaults-file=/etc/my.cnf --pid-file=/dev/null ExecStartPost=/usr/libexec/mysqld-wait-ready $MAINPID Environment="LANG=en_GB.UTF-8" Restart=always RestartSec=1 TimeoutSec=300 LimitNOFILE=infinity LimitMEMLOCK=infinity OOMScoreAdjust=-1000 TasksMax=2048 PrivateTmp=yes PrivateDevices=yes NoNewPrivileges=yes CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_DAC_OVERRIDE CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_MODULE CAP_SYS_PTRACE SystemCallFilter=~acct modify_ldt add_key adjtimex clock_adjtime delete_module fanotify_init finit_module get_mempolicy init_module kcmp kexec_load keyctl lookup_dcookie mbind mount open_by_handle_at perf_event_open pivot_root process_vm_readv process_vm_writev ptrace request_key set_mempolicy swapoff swapon umount2 uselib vmsplice RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_INET AF_INET6 SystemCallArchitectures=x86-64 ReadOnlyDirectories=/etc ReadOnlyDirectories=/usr ReadOnlyDirectories=/var/lib ReadWriteDirectories=/var/lib/mysql _________________________________________________ [root@testserver:~]$ cat /usr/lib/systemd/system/mysqld-dbmail.service [Unit] Description=MariaDB DBMail-Database Before=postfix.service dovecot.service dbmail-imapd.service dbmail-lmtpd.service dbmail-pop3d.service dbmail-timsieved.service [Service] Type=simple User=mysql Group=mysql ExecStart=/usr/libexec/mysqld --defaults-file=/etc/my-dbmail.cnf --pid-file=/dev/null ExecStartPost=/usr/libexec/mysqld-dbmail-wait-ready $MAINPID Environment="LANG=en_GB.UTF-8" Restart=always RestartSec=1 TimeoutSec=300 LimitNOFILE=infinity LimitMEMLOCK=infinity OOMScoreAdjust=-1000 TasksMax=2048 PrivateTmp=yes PrivateDevices=yes NoNewPrivileges=yes CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_WRITE CAP_DAC_OVERRIDE CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_SYS_ADMIN CAP_SYS_BOOT CAP_SYS_MODULE CAP_SYS_PTRACE SystemCallFilter=~acct modify_ldt add_key adjtimex clock_adjtime delete_module fanotify_init finit_module get_mempolicy init_module kcmp kexec_load keyctl lookup_dcookie mbind mount open_by_handle_at perf_event_open pivot_root process_vm_readv process_vm_writev ptrace request_key set_mempolicy swapoff swapon umount2 uselib vmsplice RestrictAddressFamilies=AF_UNIX AF_LOCAL AF_INET AF_INET6 SystemCallArchitectures=x86-64 ReadOnlyDirectories=/etc ReadOnlyDirectories=/usr ReadOnlyDirectories=/var/lib ReadWriteDirectories=/var/lib/mysql
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 That and galera recovery which was in the original script that comes in the mariadb repository, I suppose that’s not relevant for us at this time since we don’t use galera.
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
participants (2)
-
Reindl Harald
-
Sales