With the development of hardware, multi-core Linux systems have become a general trend, while MySQL is a single-process multi-thread, so the exploitation of multi-process is not very high.
With the development of hardware, multi-core Linux systems have become a general trend, while MySQL is a single-process multi-thread, so the exploitation of multi-process is not very high.
With the development of hardware, multi-core Linux systems have become a general trend, while MySQL is a single-process multi-thread, so the exploitation of multi-process is not very high, although MySQL 5.6 has improved a lot in this aspect, it has not reached 100%. to make full use of system resources, MySQL has its own supplement, that is, it can deploy multiple instances, one instance and one port.
1. Prepare the mysql Environment
Mysql reference and source package for source code installation:
1.1. Prepare the installation environment
Groupaddmysql
Useradd-g mysql
Autoreconf -- force -- install
Libtoolize -- automake -- force
Automake -- force -- add-missing
Yuminstall-y libtoolize
Yuminstall cmake-y
Yuminstall gcc-c ++-y
Yuminstall-y ncurses-devel.x86_64
Yuminstall-y cmake. x86_64
Yuminstall-y libaio. x86_64
Yuminstall-y bison. x86_64
Yuminstall-y gcc-c ++. x86_64
Yuminstall make-y
1.2. Create the mysql compiling root directory
Mkdir-p/usr/local/mysql
1.3 decompress the source code package
Tar-xvf mysql-5.6.12.tar.gz
Cd mysql-5.6.12
1.4. Compile and install
Timecmake. -DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_DATADIR =/home/data/mysql/data-DWITH_INNOBASE_STORAGE_ENGINE = 1-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock-DMYSQL_USER = mysql-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci
Since time make takes a long time, it has been installed in advance
Timemake
Timemake install
2. Prepare the first instance 3307
2.1 create a directory
Mkdir/usr/local/mysql3307
Chown-R mysql. mysql/usr/local/mysql3307/
Mkdir-p/home/data/mysql3307/data
Chown-R mysql. mysql/home/data/mysql3307
Chown-R mysql. mysql/home/data/mysql3307/data
Mkdir-p/home/data/mysql3307/binlog
Chown-R mysql. mysql/home/data/mysql3307
Mkdir-p/home/data/mysql3307/relay_log/
Chown-R mysql. mysql/home/data/mysql3307/
2.2 configuration file
[Mysqld_multi]
Mysqld =/usr/local/mysql/bin/mysqld_safe
Mysqladmin =/usr/local/mysql/bin/mysqladmin
Log =/home/mysql/mydata/log/mysqld_multi.log
[Mysqld1]
Socket =/usr/local/mysql3307/mysql. sock
Port = 3307
Pid-file =/usr/local/mysql3307/mysqld. pid
Datadir =/home/data/mysql3307/data
Log_bin =/home/data/mysql3307/binlog
Servers-id = 1230
Relay_log =/home/data/mysql3307/relay_log/mysql-relay-bin
Log_slave_updates = 1
Read_only = 0
Innodb_buffer_pool_size = 128 M
Innodb_flush_log_at_trx_commit = 0
2.3 initialize the database
/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql3307/data
3. Prepare the second instance 3308
3.1 create a directory
Mkdir/usr/local/mysql3308
Chown-R mysql. mysql/usr/local/mysql3308/
Mkdir-p/home/data/mysql3308/data
Chown-R mysql. mysql/home/data/mysql3308
Chown-R mysql. mysql/home/data/mysql3308/data
Mkdir-p/home/data/mysql3308/binlog
Chown-R mysql. mysql/home/data/mysql3308
Mkdir-p/home/data/mysql3308/relay_log/
Chown-R mysql. mysql/home/data/mysql3308/
3.2 configuration file
[Mysqld2]
Socket =/usr/local/mysql3308/mysql. sock
Port = 3308
Pid-file =/usr/local/mysql3308/mysqld. pid
Datadir =/home/data/mysql3308/data
Log_bin =/home/data/mysql3308/binlog
Servers-id = 2230
Relay_log =/home/data/mysql3308/relay_log/mysql-relay-bin
Log_slave_updates = 1
Read_only = 0
Innodb_buffer_pool_size = 128 M
Innodb_flush_log_at_trx_commit = 0
3.3 initialize the database
/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql3308/data
4. Prepare the third instance 3309
4.1 create a directory
Mkdir/usr/local/mysql3309
Chown-R mysql. mysql/usr/local/mysql3309/
Mkdir-p/home/data/mysql3309/data
Chown-R mysql. mysql/home/data/mysql3309
Chown-R mysql. mysql/home/data/mysql3309/data
Mkdir-p/home/data/mysql3309/binlog
Chown-R mysql. mysql/home/data/mysql3309
Mkdir-p/home/data/mysql3309/relay_log/
Chown-R mysql. mysql/home/data/mysql3309/
4.2 configuration file
[Mysqld3]
Socket =/usr/local/mysql3309/mysql. sock
Port = 3309
Pid-file =/usr/local/mysql3309/mysqld. pid
Datadir =/home/data/mysql3309/data
Log_bin =/home/data/mysql3309/binlog
Servers-id = 3230
Relay_log =/home/data/mysql3309/relay_log/mysql-relay-bin
Log_slave_updates = 1
Read_only = 0
Innodb_buffer_pool_size = 128 M
Innodb_flush_log_at_trx_commit = 0
4.3 initialize the database
/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql3309/data
The initialization information is as follows:
[Mysql @ data02 ~] $/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/home/data/mysql3309/data
WARNING: cocould not write to config file/usr/local/mysql/my-new.cnf: insufficient Permissions
Installing MySQL system tables... 2015-05-14 09:31:20 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
09:31:20 12307 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
09:31:20 12307 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)
09:31:20 12307 [Note] InnoDB: The InnoDB memory heap is disabled
09:31:20 12307 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
09:31:20 12307 [Note] InnoDB: Compressed tables use zlib 1.2.3
09:31:20 12307 [Note] InnoDB: Using CPU crc32 instructions
09:31:20 12307 [Note] InnoDB: Initializing buffer pool, size = 128.0 M
09:31:20 12307 [Note] InnoDB: Completed initialization of buffer pool
09:31:20 12307 [Note] InnoDB: The first specified data file./ibdata1 did not exist: a new database to be created!
09:31:20 12307 [Note] InnoDB: Setting file./ibdata1 size to 12 MB
09:31:20 12307 [Note] InnoDB: Database physically writes the file full: wait...
09:31:20 12307 [Note] InnoDB: Setting log file./ib_logfile101 size to 48 MB
09:31:20 12307 [Note] InnoDB: Setting log file./ib_logfile1 size to 48 MB
09:31:21 12307 [Note] InnoDB: Renaming log file./ib_logfile101 to./ib_logfile0
09:31:21 12307 [Warning] InnoDB: New log files created, LSN = 45781
09:31:21 12307 [Note] InnoDB: Doublewrite buffer not found: creating new
09:31:21 12307 [Note] InnoDB: Doublewrite buffer created
09:31:21 12307 [Note] InnoDB: 128 rollback segment (s) are active.
09:31:21 12307 [Warning] InnoDB: Creating foreign key constraint system tables.
09:31:21 12307 [Note] InnoDB: Foreign key constraint system tables created
09:31:21 12307 [Note] InnoDB: Creating tablespace and datafile system tables.
09:31:21 12307 [Note] InnoDB: Tablespace and datafile system tables created.
09:31:21 12307 [Note] InnoDB: Waiting for purge to start
09:31:21 12307 [Note] InnoDB: 5.6.12 started; log sequence number 0
09:31:21 12307 [Note] Binlog end
09:31:21 12307 [Note] InnoDB: FTS optimize thread exiting.
09:31:21 12307 [Note] InnoDB: Starting shutdown...
09:31:22 12307 [Note] InnoDB: Shutdown completed; log sequence number 1625977
OK
Filling help tables... 2015-05-14 09:31:22 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use -- explicit_defaults_for_timestamp server option (see documentation for more details ).
09:31:22 12332 [Warning] Buffered warning: Changed limits: max_open_files: 1024 (requested 5000)
09:31:22 12332 [Warning] Buffered warning: Changed limits: table_cache: 431 (requested 2000)
09:31:22 12332 [Note] InnoDB: The InnoDB memory heap is disabled
09:31:22 12332 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
09:31:22 12332 [Note] InnoDB: Compressed tables use zlib 1.2.3
09:31:22 12332 [Note] InnoDB: Using CPU crc32 instructions
09:31:22 12332 [Note] InnoDB: Initializing buffer pool, size = 128.0 M
09:31:22 12332 [Note] InnoDB: Completed initialization of buffer pool
09:31:22 12332 [Note] InnoDB: Highest supported file format is Barracuda.
09:31:22 12332 [Note] InnoDB: 128 rollback segment (s) are active.
09:31:22 12332 [Note] InnoDB: Waiting for purge to start
09:31:22 12332 [Note] InnoDB: 5.6.12 started; log sequence number 1625977
09:31:22 12332 [Note] Binlog end
09:31:22 12332 [Note] InnoDB: FTS optimize thread exiting.
09:31:22 12332 [Note] InnoDB: Starting shutdown...
09:31:24 12332 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
To start mysqld at boot time you have to copy
Support-files/mysql. server to the right place for your system
Please remember to set a password for the MySQL root USER!
To do so, start the server, then issue the following commands:
/Usr/local/mysql/bin/mysqladmin-u root password 'new-password'
/Usr/local/mysql/bin/mysqladmin-u root-h data02 password 'new-password'
Alternatively you can run:
/Usr/local/mysql/bin/mysql_secure_installation
Which will also give you the option of removing the test
Databases and anonymous user created by default. This is
Stronugly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon:
Cd.;/usr/local/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
Cd mysql-test; perl mysql-test-run.pl
Please report any problems with the./bin/mysqlbug script!
The latest information about MySQL is available on the web
Support MySQL by buying support/licenses
WARNING: cocould not copy config file template/usr/local/mysql/support-files/my-default.cnf
/Usr/local/mysql/my-new.cnf, may not have access rights to do so.
You may want to copy the file manually, or create your own,
It will then be used by default by the server when you start it.
WARNING: Default config file/etc/my. cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use
-- Defaults-file argument to mysqld_safe when starting the server
5. Start a multi-instance Database
Mkdir-p/home/mysql/data/log
[Mysql @ data02 data] $ mysqld_multi -- defaults-extra-file =/etc/my. cnf start 1, 2, 3
[Mysql @ data02 data] $
Background log information: