CentOS6.5 source installation of multiple MySQL instances and copy building

Source: Internet
Author: User
Tags parent directory

Multi-Instance Installation
This section is based on the CentOS6.5 source installation MySQL5.6.35, adding a MySQL instance to the same machine. Refer to the configuration example of installing multiple MySQL data in CentOS, the installation directory is/usr/local/mysql3307/

6, Directory Creation (-P Parent Directory does not exist then create this directory) [[Email protected]~]# CD mysql-5.6. *[[email protected] MySQL-5.6. *]#mkdir-p/usr/local/mysql3307/Data7, compile and install [[email protected] MySQL-5.6. *]# CMake-dcmake_install_prefix=/usr/local/mysql3307-dmysql_datadir=/usr/local/mysql3307/Data-dsysconfdir=/etc-dwith_myisam_storage_engine=1 -dwith_innobase_storage_engine=1 -dwith_memory_storage_engine=1 -dwith_readline=1 -dmysql_unix_addr=/usr/local/mysql3307/Mysql.sock-dmysql_tcp_port=3307 -denabled_local_infile=1 -dwith_partition_storage_engine=1 -dextra_charsets= All-ddefault_charset=UTF8-ddefault_collation=utf8_general_ci[[email protected] MySQL-5.6. *]# Make&& Make Install[[email protected] MySQL-5.6. *]# Make Clean8, set permissions modification/usr/local/mysql3307 permissions [[email protected] MySQL-5.6. *]#Chown-R mysql:mysql/usr/local/mysql33079, initialize the configuration into the installation path [[email protected] MySQL-5.6. *]# cd/usr/local/mysql3307 Execute initialization configuration script to create the system's own database and table [[email protected] mysql3307]# scripts/mysql_install_db--basedir=/usr/local/mysql3307--datadir=/usr/local/mysql3307/data--port=3307--user=MySQLTen, start the MySQL add service, copy the service script to the INIT.D directory [[email protected] mysql3307]#CPsupport-files/mysql.server/etc/init.d/mysql3307[[email protected] mysql3307]# vim/etc/init.d/mysql3307 Modify the following parameters Basedir =/usr/local/ mysql3307datadir =/usr/local/mysql3307/ Dataconf =/usr/local/mysql3307/ my.cnf$bindir/mysqld_safe--defaults-file= $conf--datadir= $datadir--pid-file=$server _pid_file [[email protected] mysql3307]# chkconfig--add mysql3307[[email protected] mysql3307]# service mysql3307 start--start MySQL One, configure user to change root password [[email protected] mysql3307]# MySQL-p3307-s/usr/local/mysql3307/mysql.sock-Urootmysql> SET PASSWORD = PASSWORD ('mysql5635'); Set MYDBA users can access MySQL remotely> GRANT All privileges on * * to'MYDBA'@'%'Identified by'mysql5635'With GRANT OPTION, firewall settings can refer to http://www.cnblogs.com/ShanFish/p/6519950.html

The overall configuration is very simple, only need to adjust the installation directory, port and other information, the Code Red font is added part

#本地登录如果不带-s/usr/local/mysql3307/-p3307-uroot-p# local /telnet using-H,-p, enter the 3307 instance cmd> mysql-h192. 168.85. 129 -p3307-umydba-p

Copy and Build (Master-slave)
Next in the above environment to build Master-slave copy, refer to Mycat+mysql master-slave replication, 3306 as master,3307 as slave

mkdir -p/usr/local/mysql/mkdir -p/usr/local/mysql3307/chown -R MySQL: mysql/usr/local/mysql/chown -R mysql:mysql/usr/local/mysql3307/log

First, the operation for master

1, Edit master config file [[email protected]~]# vim/usr/local/mysql/My.cnf[mysqld] #repl masterserver-ID=6Log-bin=/usr/local/mysql/log/mysql-binmax_binlog_size=100Mbinlog-format=MIXED2, restart master instance [email protected]~]# service MySQL restart3, create a replication user MySQL>Use ' mysql '; MySQL> GRANT REPLICATION SLAVE on * * to'Repl'@'localhost'Identified by'Repl';4, get Master status information # in Session1 lock table MySQL>FLUSH TABLES with READ LOCK, if master already has data and needs to be synchronized to slave, back up here. databak# in Session2 view state MySQL>SHOW MASTER STATUS;5, release read lock mysql on master>UNLOCK TABLES; After master releases the read lock, the new data can be written to MySQL> Source e:/mysql/exampledatabases/sakila-db/sakila-Schema.sqlmysql> Source E:/mysql/exampledatabases/sakila-db/sakila-data.sql

Second, for the operation of Slave

6, edit slave configuration file [email protected]~]# vim/usr/local/mysql3307/My.cnf[mysqld] #repl slaveserver-ID=7Relay_log=/usr/local/mysql3307/log/mysql-relay-Binmaster-Info-file=/usr/local/mysql3307/log/master.InfoRelay-log-Info-file=/usr/local/mysql3307/log/relay-log.InfoSkip-slave-Start7, restarting slave instances [email protected]~]# Service mysql3307 Restart if there is backup data, restore it here. Databak8, setting the master configuration on slave MySQL>Change Master Tomaster_host='127.0.0.1', Master_port=3306, Master_user='Repl', Master_password='Repl', Master_log_file='mysql-bin.000001', Master_log_pos= -;9, start the slave thread, and view the status MySQL>Start Slave;mysql> Show Slave status\g

This article is in the previous two articles on the basis of the expansion, the operation of the steps may be jumping, it is recommended to read CentOS6.5 source installation MySQL5.6.35, Mycat+mysql master-slave replication to understand the basic environment.

CentOS6.5 source installation of multiple MySQL instances and copy building

Related Article

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.