Mysqld_multi Multi-instance Boot tool

Source: Internet
Author: User

First, MySQL multi-instance Introduction


MySQL Multi-instance, simply put, is to open a number of different service ports on a single server (such as: 3306 , 3307 ), while running multiple MySQL service processes, these service processes pass through different Socket monitoring from different ports to provide services;

Multi-instance not only saves the cost of the physical host, but also improves the CPU and disk I/O efficiency of a single physical host, and can also be used to deploy the database ha scheme between multiple instances.


As the number of instances increases, we are faced with a unified management problem, so we need to use MySQL's own management program Mysqld_multi to manage ...


Second, the MySQL startup process

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/83/B8/wKioL1d7UVDRBFnvAABihw6E3-g022.png "title=" MySQL startup process (1). png "alt=" Wkiol1d7uvdrbfnvaabihw6e3-g022.png "/>

Mysqld_multi #多实例管理程序mysqld #以前老版本的MySQL最主要的启动方式, there are many parameters, and now using multiple instances requires a new mysql_safe to start the Mysqlmysql_safe #实则还是调用mys Qld, and will read the MY.CNF configuration parameters in Mysqld to start the Mysql,mysql_safe itself also has many parameters, but these parameters will take precedence over the my.cnfmy.cnf #mysql的配置文件my. Sock #mysql创建的sock文件 , opening, stopping, logging in, and managing MySQL are all through this interface file



Third, next, use Mysqld_multi to configure a multi-instance ...


 installation Environment: centos 6.7 _64 download mysql-5.5.32.tar.gz compile the installation package Yum install  -y ncurses-devel libaio-develyum install -y cmaketar zxf  mysql-5.5.32.tar.gzcd mysql-5.5.32cmake .-dcmake_install_prefix=/application/mysql-5.5.32 - Dmysql_datadir=/application/mysql-5.5.32/data -dmysql_unix_addr=/application/mysql-5.5.32/tmp/mysql.sock  -ddefault_charset=utf8 -ddefault_collation=utf8_general_ci -dextra_charsets=gbk,gb2312,utf8, Ascii -denabled_local_infile=on -dwith_innobase_storage_engine=1 -dwith_federated_storage_ Engine=1 -dwith_blackhole_storage_engine=1 -dwithout_example_storage_engine=1 -dwithout_ Partition_storage_engine=1 -dwith_fast_mutexes=1 -dwith_zlib=bundled -denabled_local_infile=1  -dwith_readline=1 -dwith_embedded_server=1 -dwith_debug=0 
make && make installln -s /application /mysql-5.5.32/ /application/mysqlmkdir -p /data/{3306,3307,3308}/data  #创建单独实例数据文件夹useradd  mysql -s /sbin/nologin -mchown -r mysql.mysql /datacp /application/ mysql/bin/* /usr/local/sbin/        #添加环境变量cd  /application/mysql/ scripts/  #初始化数据库./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3306/data/  --user=mysql./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3307/data/ - -user=mysql./mysql_install_db --basedir=/application/mysql/ --datadir=/data/3308/data/ --user= mysql/bin/cp /application/mysql/support-files/my-medium.cnf /etc/my.cnf   #拷贝my. CNF configuration file CP  /application/mysql/support-files/mysql.server /etc/init.d/mysqld.server  #拷贝启动文件 
cp /application/mysql/support-files/mysqld_multi.server /etc/ init.d/mysqld_multi.server  #拷贝mysqld_multi程序文件 # Modify Mysqld_multi.server path configuration sed -i  ' s#basedir=/usr/ Local/mysql#basedir=/application/mysql#g '  /etc/init.d/mysqld_multi.serversed -i  ' s#bindir=/usr/ Local/mysql/bin#bindir=/application/mysql/bin#g '  /etc/init.d/mysqld_multi.server 
#添加mysqld_multi用到的/etc/mysqld_multi.cnf config file # This template file can be exported with command mysqld_multi --example [[email protected]  scripts]# vim /etc/mysqld_multi.cnf [mysqld_multi]mysqld     =  /application/mysql-5.5.32/bin/mysqld_safemysqladmin = /application/mysql-5.5.32/bin/mysqladmin #user        = multi_admin#password   = my_password [mysqld2]socket     = /data/3306/mysql.sockport        = 3306pid-file   = /data/3306/mysql.piddatadir    =  /data/3306/data#language   = /application/mysql-5.5.32/share/mysql/englishuser        = mysql[mysqld3]socket     = /data/3307 /mysql.sockport       = 3307pid-file   = /data/ 3307/mysql.piddatadir&Nbsp;   = /data/3307/data#language   = /application/mysql-5.5.32/share /mysql/english
user = Mysql[mysqld4]socket =/data/3308/mysql.sockport = 3308pid-file =/data/3308/mysql.piddatadir =/data/3308/data#language =/application/mysql-5.5.32/share/mysql/englishuser = MySQL

Then you start the multi-instance:

#查看数据库状态  mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf report[[email protected]  etc]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf reportreporting mysql  serversMySQL server from group: mysqld2 is not runningMySQL  Server from group: mysqld3 is not runningmysql server from group:  mysqld4 is not running# start Database [[email protected] etc]# mysqld_multi -- Defaults-extra-file=/etc/mysqld_multi.cnf start 2,3,4[[email protected] etc]# mysqld_ multi --defaults-extra-file=/etc/mysqld_multi.cnf reportreporting mysql serversmysql  server from group: mysqld2 is runningmysql server from group:  mysqld3 is runningmysql server from group: mysqld4 is running# Stop Database [[ Email protected] etc]# mysqld_multi --defaults-extra-file=/etc/mysqld_multi.cnf stop 2,3,4# Login database mysql -uroot -h127.0.0.1 -p3306 or specify socket login [[Email protected] etc]# mysql  -s /data/3306/mysql.sock


This article comes from the "change from every day" blog, so be sure to keep this source http://lilongzi.blog.51cto.com/5519072/1796014

Mysqld_multi Multi-instance Boot tool

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.