What is mysql multi-instance:
Simply put, it is to open a number of different service ports on a machine (such as: 3306,3307), run multiple MySQL service process, the service process through different socket listening port different services to provide their services.
These multiple instances common --- MySQL MySQL installer sets using different (can be the same) my.cnf configuration file, start the program, the data file. In providing services, multi-instance on MySQL in the logic appears to be independent, multiple instances of itself is based on the profile corresponding to the set value, to obtain the relevant hardware resources of the server how much.
To make an analogy, MySQL equivalent of more and more instances of the same bedroom house, each instance can be seen as - a bedroom, the entire house is a set of server, the server's hardware resources (cpu, mem, disk) can be seen as a house bathroom , as in the kitchen, hall, the house is a public resource, the North drift dwelling together, be sure to share these resources. Think we should, that understand.
MySQL Multi-Function and Problems instance:
efficient use of server resources
when a single server resources remaining, can make full use of the remaining resources to provide more services.
Saving server resources
when the company financial strain, but requires its own database and try to provide independent services, and the need master-slave synchronization and other
resources to seize another problem
when a service instance concurrent high or there is slow query, the entire instance will consume more memory, CPU, disk I0 resources, resulting in other instances on the server to provide lower quality services. This is equivalent to everyone lives in a different bedroom of a house, like, up in the morning to go to work, have to brush your teeth, wash your face and so on, so the bathroom will be long-term occupation, others will wait for the same reason.
MySQL configuration options:
1. to implement programs through a multi-multi-instance configuration files and multiple initiators, in configuring multiple instances to be switched off before mysql process
Step 1: Create multi-instance MySQL data files directory
mkdir -p /data/{3306,3307}/data
Step two: Delete the startup file
rm -f /etc/init.d/mysqld
Step Three: Upload my.cnf mysql and the files in the 3306 and 3307
cd /data/3306 cd /data/3307 rz
Step Four: Create multi-instance startup file
vim /data/3306/mysql vim /data/3307/mysql
Multi-instance file mysql start to start services in real terms:
mysqld_ safe --defaults-file=/data/3306/my. cnf 2>81 > /dev/null & mysqld_ safe --defaults-file=/data/3307/my. cnf 2>81> /dev/null &
Multi-instance start and stop mysql service substantive documentation:
mysqladmin -u root -poldboy123 -S /data/3307/mysql.sock shut dowmn mysqladmin -u root -poldboy123 -S /data/3306/mysql.sock shut dowmn
Step Five: Authorization directory
chown -R mysql.mysq /data
Step Six: plus execute permissions for starting mysql
find /data/ -type f -name "mysql"|xargs chmod +x
Step Seven: Initialize MySQL multi-instance database files
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
The main purpose of the foundation is to create a database initialization of the database file, for example: musql generate database table and so on.
Step eight: Start the database
/data/3306/mysql start /data/3307/mysql start
Step 9: landing database, you need to specify sock landed multi-instance file
mysql -S /data/3306/mysql.sock create database d3306; mysql -S /data/3307/mysql.sock create database d3307;
Step 10: increase Password
mysqladmin -u root -S /data/3306/mysql.sock password '123456' mysqladmin -u root -S /data/3307/mysql.sock password '123456'
2. single configuration file
[mysqld_multi] mysql=/usr/bin/mysqld_safe mysqladmin=/usr/bin/mysqladmi user = mysql [Mysqld1] # once analogy, different ports socket = /var/lib/mysql/mysql.sock prot = 3306 pid-file = /var/lib/mysql/mysql.pid --datadir = / in / lib / mysql user = mysql skip-name-resolvee server -id=12 master-connect retry=604 default-storage -engine=innodbe innodb _buffer_ pool size=1G innodb_ addi tional_ _mem pool=10M default_ character_ set=utf8 character set_ server-utf8 read-only relat-log-space-limit=3G expire-logs_day=20
Start:
mysqld_multi --config-file=/data/mysql/my_multi.cnf start 1,2,3, 4,5,6,7