Az újabb példányok létrehozása

  • Beküldve: 2016. január 07, 14:31
  • Szerző: Bolemányi Attila

Miután megfelelően előkészítettük az egyes kiszolgáló példányok konfigurációs fájljait, itt az idő elkészíteni a konkrét kiszolgálókat és leellenőrizni azok futását. Először is jöjjön az új példányok telepítése:

mysql_install_db --user=mysql --basedir=/usr --datadir=/srv/db/mysql3307 --defaults-file=/etc/mysql/conf.d/my3307.cnf
mysql_install_db --user=mysql --basedir=/usr --datadir=/srv/db/mysql3308 --defaults-file=/etc/mysql/conf.d/my3308.cnf
mysql_install_db --user=mysql --basedir=/usr --datadir=/srv/db/mysql3309 --defaults-file=/etc/mysql/conf.d/my3309.cnf

A /srv/db/mysqlxxxx mappákban elkészültek a kiszolgálók fájljai és mappái, ezt érdemes leellenőrizni. Maguk a kiszolgálók azonban - a fájlok létrehozása után - le lettek állítva. Az egyes kiszolgáló-példányok elindításához, leállításához és állapotuk lekérdezéséhez egy új szkriptre lesz szükségünk, amelyet a /etc/init.d mappában fogunk elhelyezni. Készítsük el a /etc/init.d/mysqld_multi.server.sh fájlt az alábbi tartalommal:

#!/bin/sh
#
# A simple startup script for mysqld_multi by Tim Smith and Jani Tolonen.
# This script assumes that my.cnf file exists either in /etc/my.cnf or
# /root/.my.cnf and has groups [mysqld_multi] and [mysqldN]. See the
# mysqld_multi documentation for detailed instructions.
#
# This script can be used as /etc/init.d/mysql.server
#
# Comments to support chkconfig on RedHat Linux
# chkconfig: 2345 64 36
# description: A very fast and reliable SQL database engine.
#
# Version 1.0
#

### BEGIN INIT INFO
# Provides:          mysqld_multi
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Should-Start:      $network $named $time
# Should-Stop:       $network $named $time
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start and stop multiple mysql database server daemon instances
# Description:       Controls multiple MariaDB database server daemon instances
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mysqld_multi
DESC=mysqld_multi

basedir=/usr
bindir=/usr/bin

if test -x $bindir/mysqld_multi
then
  mysqld_multi="$bindir/mysqld_multi";
else
  echo "Can't execute $bindir/mysqld_multi from dir $basedir";
  exit;
fi

case "$1" in
    'start' )
        "$mysqld_multi" start $2
        ;;
    'stop' )
        "$mysqld_multi" stop $2
        ;;
    'report' )
        "$mysqld_multi" report $2
        ;;
    'restart' )
        "$mysqld_multi" stop $2
        "$mysqld_multi" start $2
        ;;
    *)
        echo "Usage: $0 {start|stop|report|restart}" >&2
        ;;
esac

Adjunk a fájlnak futási jogot:

chmod +x /etc/init.d/mysqld_multi.server.sh

Mentsük el a régi /etc/init.d/mysql szkriptet:

mv /etc/init.d/mysql /etc/init.d/mysql.old

Készítsünk szimbolikus linket /etc/init.d/mysql néven:

ln -s /etc/init.d/mysqld_multi.server.sh /etc/init.d/mysql

Indítsuk el a MariaDB kiszolgálókat:

/etc/init.d/mysql start

Ellenőrizzülk le a futásukat:

/etc/init.d/mysql report

Az eredmény valami hasonló lesz:

Reporting MariaDB servers
MariaDB server from group: mysqld3306 is running
MariaDB server from group: mysqld3307 is running
MariaDB server from group: mysqld3308 is running
MariaDB server from group: mysqld3309 is running

A syslogban is leellenőrizhetjük, mi újság az egyes példányokkal:

Jan  7 10:34:19 jessie mysqld_safe: Starting mysqld daemon with databases from /srv/db/mysql3307
Jan  7 10:34:19 jessie mysqld_safe: Starting mysqld daemon with databases from /srv/db/mysql
Jan  7 10:34:19 jessie mysqld_safe: Starting mysqld daemon with databases from /srv/db/mysql3308
Jan  7 10:34:19 jessie mysqld_safe: Starting mysqld daemon with databases from /srv/db/mysql3309
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 140049505118144 [Note] /usr/sbin/mysqld (mysqld 10.1.10-MariaDB-1~jessie-log) starting as process 8548 ...
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 140049505118144 [Note] Using unique option prefix 'myisam_recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 140332467640256 [Note] /usr/sbin/mysqld (mysqld 10.1.10-MariaDB-1~jessie-log) starting as process 8566 ...
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 139917736122304 [Note] /usr/sbin/mysqld (mysqld 10.1.10-MariaDB-1~jessie-log) starting as process 8575 ...
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 140332467640256 [Note] Using unique option prefix 'myisam_recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 140267101366208 [Note] /usr/sbin/mysqld (mysqld 10.1.10-MariaDB-1~jessie-log) starting as process 8577 ...
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 139917736122304 [Note] Using unique option prefix 'myisam_recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
Jan  7 10:34:19 jessie mysqld: 2016-01-07 10:34:19 140267101366208 [Note] Using unique option prefix 'myisam_recover' is error-prone and can break in the future. Please use the full name 'myisam-recover-options' instead.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Using mutexes to ref count buffer pool pages
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: The InnoDB memory heap is disabled
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Memory barrier is not used
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Compressed tables use zlib 1.2.8
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Using Linux native AIO
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Using generic crc32 instructions
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Initializing buffer pool, size = 256.0M
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Using mutexes to ref count buffer pool pages
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: The InnoDB memory heap is disabled
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Memory barrier is not used
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Compressed tables use zlib 1.2.8
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Using Linux native AIO
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Using generic crc32 instructions
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Initializing buffer pool, size = 256.0M
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Using mutexes to ref count buffer pool pages
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Using mutexes to ref count buffer pool pages
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: The InnoDB memory heap is disabled
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Memory barrier is not used
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: The InnoDB memory heap is disabled
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Compressed tables use zlib 1.2.8
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Using Linux native AIO
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Memory barrier is not used
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Compressed tables use zlib 1.2.8
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Using Linux native AIO
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Using generic crc32 instructions
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Initializing buffer pool, size = 256.0M
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Using generic crc32 instructions
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Initializing buffer pool, size = 256.0M
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Completed initialization of buffer pool
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Completed initialization of buffer pool
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Completed initialization of buffer pool
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Completed initialization of buffer pool
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Highest supported file format is Barracuda.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Highest supported file format is Barracuda.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Highest supported file format is Barracuda.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Highest supported file format is Barracuda.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: 128 rollback segment(s) are active.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB: Waiting for purge to start
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: 128 rollback segment(s) are active.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB: Waiting for purge to start
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: 128 rollback segment(s) are active.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB: Waiting for purge to start
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.26-76.0 started; log sequence number 1616819
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.26-76.0 started; log sequence number 1616819
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.26-76.0 started; log sequence number 1616819
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: 128 rollback segment(s) are active.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB: Waiting for purge to start
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140266455402240 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917090850560 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140048859105024 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.26-76.0 started; log sequence number 1616985
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] Plugin 'FEEDBACK' is disabled.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] Plugin 'FEEDBACK' is disabled.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140331819435776 [Note] InnoDB: Dumping buffer pool(s) not yet started
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] Plugin 'FEEDBACK' is disabled.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] Plugin 'FEEDBACK' is disabled.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] Server socket created on IP: '127.0.0.1'.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] Server socket created on IP: '127.0.0.1'.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] Server socket created on IP: '127.0.0.1'.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] Server socket created on IP: '127.0.0.1'.
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] Reading of all Master_info entries succeded
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] Added new Master_info '' to hash table
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 139917736122304 [Note] /usr/sbin/mysqld: ready for connections.
Jan  7 10:34:20 jessie mysqld: Version: '10.1.10-MariaDB-1~jessie-log'  socket: '/var/run/mysqld3308/mysqld3308.sock'  port: 3308  mariadb.org binary distribution
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] Reading of all Master_info entries succeded
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] Added new Master_info '' to hash table
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] Reading of all Master_info entries succeded
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] Added new Master_info '' to hash table
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140267101366208 [Note] /usr/sbin/mysqld: ready for connections.
Jan  7 10:34:20 jessie mysqld: Version: '10.1.10-MariaDB-1~jessie-log'  socket: '/var/run/mysqld3309/mysqld3309.sock'  port: 3309  mariadb.org binary distribution
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] Reading of all Master_info entries succeded
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] Added new Master_info '' to hash table
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140049505118144 [Note] /usr/sbin/mysqld: ready for connections.
Jan  7 10:34:20 jessie mysqld: Version: '10.1.10-MariaDB-1~jessie-log'  socket: '/var/run/mysqld3307/mysqld3307.sock'  port: 3307  mariadb.org binary distribution
Jan  7 10:34:20 jessie mysqld: 2016-01-07 10:34:20 140332467640256 [Note] /usr/sbin/mysqld: ready for connections.
Jan  7 10:34:20 jessie mysqld: Version: '10.1.10-MariaDB-1~jessie-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  mariadb.org binary distribution
Jan  7 10:34:30 jessie mysqld: 2016-01-07 10:34:30 140332466841344 [Warning] Access denied for user 'multi_admin'@'localhost' (using password: YES)
Jan  7 10:34:30 jessie mysqld: 2016-01-07 10:34:30 140049504319232 [Warning] Access denied for user 'multi_admin'@'localhost' (using password: YES)
Jan  7 10:34:30 jessie mysqld: 2016-01-07 10:34:30 139917735323392 [Warning] Access denied for user 'multi_admin'@'localhost' (using password: YES)
Jan  7 10:34:30 jessie mysqld: 2016-01-07 10:34:30 140267100567296 [Warning] Access denied for user 'multi_admin'@'localhost' (using password: YES)

Úgy néz ki, minden rendben van, egy kivétellel: még nem létezik egyik kiszolgálónál sem a multi_admin felhasználó. De ezt hamarosan pótolni fogjuk. Ami fontos, hogy mind a négy kiszolgáló-példány hiba nélkül működik.