How to use Mysqld_multi

Source: Internet
Author: User

How to use Mysqld_multi:


Official document: Https://dev.mysql.com/doc/refman/5.7/en/mysqld-multi.html "There are some problems with this document, Mysqld_multi cannot close the instance according to its configuration"



Mysqld_multi The workaround for the instance cannot be closed:

https://bugs.mysql.com/bug.php?id=77227


I have the same problem. After adding some traces in Mysqld_multi, I has found the problem:since 5.6.25, my_print_defaults no longer returns PAS Sword in readable form (we had to use the "--show" option to obtain it). Mysqld_multi call My_print_default to obtain the user and password to use with Mysqladmin.


Also, to is able to stop instances with Mysqld_multi, I has made a modification in the "Defaults_for_group" function of M Ysqld_multi. I have changed the following line:

My $com = Join ', ' my_print_defaults ', @defaults_options, $group;

With:

My $com = Join ', ' my_print_defaults-s ', @defaults_options, $group;





Direct paste Operation Note:

Mkdir/data/mysqlcd/data/mysqlmkdir 3306/{data,tmp}-pvmkdir 3307/{data,tmp}-PV



/ETC/MY.CNF configuration file:

[client]port            = 3306socket           = /tmp/mysql.sockuser = root[mysql] no-auto-rehash#safe-updatesprompt= "[\\d] > " [mysqld_multi]mysqld     =  /usr/local/mysql/bin/mysqld_safemysqladmin = /usr/local/mysql/bin/mysqladminlog = / var/log/mysqld_multi.loguser       = multi_adminpassword    = 123456[mysqld]character-set-server = utf8default_storage_engine =  Innodbtransaction_isolation  = read-committedskip_name_resolve = onskip_external_ Lockingmax_connections = 1500sort_buffer_size = 512kread_buffer_size = 512kread_ Rnd_buffer_size = 512kjoin_buffer_size = 256kthread_stack = 256kbinlog_cache_ size = 2mconnect_timeout = 20wait_timeout = 14400interactive_timeout = 14400net_write_timeout =  180lock_wait_timeout = 120thread_cache_size = 64open_files_limit = 65535innodb_ Open_files = 4000skip-innodb_adaptive_hash_indexquery_cache_type = offquery_cache_size  = 0expire_logs_days = 5sync_binlog = 1innodb_support_xa =  1relay-log-purge=1relay_log_info_repository = tablerelay_log_recovery = onmaster_info_ Repository = tableslave_net_timeout = 30skip-slave-start = onlog_slave_updates  = oninnodb_use_native_aio = oninnodb_file_per_table  = oninnodb_flush_log_ at_trx_commit = 1innodb_flush_method=o_directinnodb_max_dirty_pages_pct    =  50innodb_lock_wait_timeout      = 50innodb_stats_persistent =  oninnodb_stats_persistent_sample_pages = 64sql_mode=no_engine_substitution,strict_trans_tables[mysqld3306]socket      = /tmp/mysql.sock3306port       = 3306pid-file    = /data/mysql/3306/data/mysql.pid3306datadir    = /data/mysql/3306/ datatmpdir     = /data/mysql/3306/tmp/user        = rootserver-id = 111log-bin = mysql-binbinlog_format = rowmax_binlog _size = 256mlog_bin_trust_function_creators = on[mysqld3307]socket      = /tmp/mysql.sock3307port       = 3307pid-file    = /data/mysql/3307/data/mysql.pid3307datadir    = /data/mysql/3307/ datatmpdir     = /data/mysql/3307/tmp/user        = rootserver-id = 222log-bin = mysql-binbinlog_format = rowmax_binlog_size = 256mlog_bin_ Trust_function_creators = on




When initializing an instance, we first build 2 template files/data/3307.cnf/data/3306.cnf write the configuration files required for the 3307 and 3306 instances ( or do not have the template file directly initialized, but this is not recommended ), and then initialize:


/usr/local/mysql/scripts/mysql_install_db--defaults-file=/data/3307.cnf--user=mysql--basedir=/usr/local/mysql- -datadir=/data/mysql/3307/data/usr/local/mysql/scripts/mysql_install_db--defaults-file=/data/3306.cnf--user= MySQL--basedir=/usr/local/mysql--datadir=/data/mysql/3306/data


Start 2 instances

Mysqld_multi reportmysqld_multi start 3307mysqld_multi start 3306



# Create an account for MySQL shutdown:

Mysql-uroot-s/tmp/mysql.sock3307create USER ' multi_admin ' @ ' localhost ' identified by ' 123456 '; GRANT SHUTDOWN on *. * to ' multi_admin ' @ ' localhost ';



Mysql-uroot-s/tmp/mysql.sock3306create USER ' multi_admin ' @ ' localhost ' identified by ' 123456 '; GRANT SHUTDOWN on *. * to ' multi_admin ' @ ' localhost ';


At this point, we can start the MySQL instance mysqld_multi, but we can't close the instance. The reasons are as follows:



# Output Details (note the following 2 output results)

# my_print_defaults Mysqld_multi mysql3307--mysqld=/usr/local/mysql/bin/mysqld_safe--mysqladmin=/usr/local/mysql/ bin/mysqladmin--log=/var/log/mysql/mysqld_multi.log--user=multi_admin--password=*****# My_print_defaults Mysqld_ Multi mysql3307-s--mysqld=/usr/local/mysql/bin/mysqld_safe--mysqladmin=/usr/local/mysql/bin/mysqladmin--log=/ var/log/mysql/mysqld_multi.log--user=multi_admin--password=123456----You can see the code here.



Vim/usr/local/mysql/bin/mysqld_multi +216, add a-s after My_print_defaults and then save the exit.

My $com = Join ', 'my_print_defaults-s', @defaults_options, $group;



Then, perform the following:

Mysqld_multi Stop 3307


Mysqld_multi Report

You can see that the 3307 instance is closed.


In the same way, we can also start stopping other instances.



How to use Mysqld_multi

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.