MySQL multi-instance Common configuration method:
Install MySQL-dependent packages
Yum Install Ncurses-devel libaio-devel-y
MySQL configuration file: Pull to Server
[Email protected] ~]# tree
.
|--3306
| |--my.cnf
| '--MySQL
|--3307
| |--my.cnf
| '--MySQL
Copy configuration file
[Email protected] ~]# mkdir-p/data/3306
[Email protected] ~]# mkdir-p/data/3307
[email protected] ~]# CP 3306/my.cnf/data/3306
[email protected] ~]# CP 3306/mysql/data/3306
[email protected] ~]# CP 3307/my.cnf/data/3307
[email protected] ~]# CP 3307/mysql/data/3307
[Email protected] 3306]# VI my.cnf
Server-id = 12 configuration file Server-id or else.
Authorized:
[Email protected] 3306]# chmod +x/data/3306/mysql
[Email protected] 3306]# chmod +x/data/3307/mysql
[Email protected] ~]# chown-r mysql.mysql/data
[Email protected] 3306]# pwd
/data/3306
[email protected] 3306]# LL
Total 12
Drwxr-xr-x 2 mysql mysql 4096 Mar 22:28 data
-rw-r--r--1 MySQL MySQL 1899 Mar 04:15 my.cnf
-rw-r--r--1 mysql mysql 1307 Mar 04:15 MySQL
Startup of multi-instance startup files MySQL Service essence:
Mysqld_safe--defaults-file=/data/3306/my.cnf >/dev/null 2&>1
Mysqld_safe--defaults-file=/data/3307/my.cnf >/dev/null 2&>1
Multi-instance startup file stop MySQL service in essence:
Mysqladmin-uroot-p123456-s/data/3306/mysql.sock shutdown
Mysqladmin-uroot-p123456-s/data/3307/mysql.sock shutdown
To set the MySQL startup command environment variable, you can use which MySQL and then use the CP
Initializing a MySQL multi-instance database file
First: The initialization command is:
mysql5.1.x Initialization command:
mysql_install_db--basedir=/usr/local/mysql--datadir=/data/3306/data--user=mysql
mysql5.5.x Initialization command:
Cd/usr/local/mysql/scripts is different from the path of 5.1 and is not under the MySQL bin path.
./mysql_install_db--basedir=/usr/local/mysql--datadir=/data/3306/data--user=mysql
Operation
[Email protected] ~]# cd/usr/local/mysql/scripts/
[email protected] scripts]# LL
Total 16
-rwxr-xr-x 1 7161 wheel 14816 June mysql_install_db
[Email protected] scripts]#/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/3306/data--user=mysql
[Email protected] scripts]#/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/3307/data--user=mysql
Second: Start the database
[[email protected] scripts]#/data/3306/mysql start
Starting MySQL ...
[[email protected] scripts]#/data/3307/mysql start
Starting MySQL ...
[[email protected] scripts]# netstat-lnptu |grep-tcp 0 0 0.0.0.0:330 7 0.0.0.0:* LISTEN 6668/mysqld
TCP 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1367/mysqld
View Directory after startup
[email protected] 3306]# LL
Total 36
Drwxr-xr-x 5 mysql mysql 4096 Mar 23:11 data
-rw-r--r--1 MySQL MySQL 1891 Mar 23:05 my.cnf
-rwxr-xr-x 1 mysql mysql 1305 Mar 22:51 MySQL
-RW-RW----1 MySQL mysql 126 Mar 23:07 mysql-bin.000001
-RW-RW----1 MySQL mysql 107 Mar 23:11 mysql-bin.000002
-RW-RW----1 MySQL mysql 23:11 mysql-bin.index
srwxrwxrwx 1 mysql mysql 0 Mar 23:11 mysql.sock
-rw-r-----1 mysql root 2792 Mar 23:11 mysql_3306.err
-RW-RW----1 MySQL mysql 5 Mar 23:11 mysqld.pid
[email protected] 3307]# LL
Total 28
Drwxr-xr-x 5 mysql mysql 4096 Mar 23:07 data
-rw-r--r--1 MySQL MySQL 1893 Mar 23:04 my.cnf
-rwxr-xr-x 1 mysql mysql 1305 Mar 22:52 MySQL
srwxrwxrwx 1 mysql mysql 0 Mar 23:07 mysql.sock
-rw-r-----1 mysql root 1403 Mar 23:07 Mysql_3307.err
-RW-RW----1 MySQL mysql 5 Mar 23:07 mysqld.pid
Log in to Database
After the MySQL database is installed, by default, the administrator account is a five-password.
[Email protected] 3306]# mysql-s/data/3306/mysql.sock
mysql> system ls = = does not exit execution command
Data MySQL mysql-bin.000002 mysql.sock mysql_oldboy3306.err
MY.CNF mysql-bin.000001 Mysql-bin.index Mysql_3306.err mysqld.pid
System Mysql-s/data/3307/mysql.sock; Log in directly to another database
Restart database
[[email protected] scripts]#/data/3306/mysql stop
[[email protected] scripts]#/data/3306/mysql start
MySQL Multi-instance configuration complete
This article is from the "Bill Linux Operations Notes" blog, please be sure to keep this source http://chenshoubiao.blog.51cto.com/6159058/1884113
MySQL Multi-instance configuration