MySQL multi-instance master-slave installation using

Source: Internet
Author: User

1, install the MySQL master, save the MySQL configuration file to the Include directory in the installation process to execute directly.

Mysql_master_install ()  {    ./include/my_master.sh    mysql_port= $ (cat port)     mysql_home= '/usr/local/mysql '     mysql_cnf=./ my.cnf    mysql_data=./data    mysql_root_pass= ' 123 '      ${mysql_home}/scripts/mysql_install_db --user=mysql --basedir= $Mysql _home --datadir=$ mysql_data    ${mysql_home}/bin/mysqld_safe --defaults-file= $Mysql _cnf --user= mysql --port= $Mysql _port --basedir= $Mysql _home --datadir= $Mysql _data >/dev/null 2 >&1 &    sleep 8    ${mysql_home}/bin/mysqladmin  -uroot -P  $Mysql _port password  ' ${mysql_root_pass} '     ${mysql_ home}/bin/mysql -uroot -p${mysql_root_pass} -p  $Mysql _port -e  ' create  Database if not exists test; '     ${Mysql_Home}/bin/mysql -uroot -p${Mysql_Root_Pass} -P  $Mysql _port   << EOFgrant replication slave on *.* to  ' replication ' @ '% '  identified by  ' Replication ';flush privileges; Eof

2. Install MySQL from

Mysql_slave_install ()  {    ./include/my_slave.sh    mysql_port=$ ( Cat port)     mysql_home= '/usr/local/mysql '     mysql_cnf=./my.cnf     mysql_data=./data    mysql_root_pass= ' 123 '      ${mysql_home}/scripts/mysql_install_db --user=mysql --basedir= $Mysql _home --datadir= $Mysql _data     ${mysql_home}/bin/mysqld_safe --defaults-file= $Mysql _cnf --user=mysql - -port= $Mysql _port --basedir= $Mysql _home --datadir= $Mysql _data >/dev/null 2>&1  &    sleep 8    ${mysql_home}/bin/mysqladmin - uroot -p  $Mysql _port password  ' ${mysql_root_pass} '     ${mysql_home}/ bin/mysql -uroot -p${mysql_root_pass} -p  $Mysql _port -e  ' create database  if not exists test; '     ${Mysql_Home}/bin/mysql -uroot -p${Mysql_Root_Pass} -P  $Mysql _port  << eofchange master to master_host= "$Master _host", master_port= $Mysql _port, Master_user= ' replication ', master_password= ' replication ', master_log_file= ' master-bin.000001 ', master_log_pos=120 ;start slave; Eof


This article is from the "XWB" blog, make sure to keep this source http://xiewb.blog.51cto.com/11091636/1792287

MySQL multi-instance master-slave installation using

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.