标签:mysql
1、安装mysql主,将mysql的配置文件保存到include目录下在安装过程中直接执行就可以了。
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 << EOF grant replication slave on *.* to ‘replication‘@‘%‘ identified by ‘replication‘; flush privileges; EOF
2、安装mysql从
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 << EOF change 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
本文出自 “xwb” 博客,请务必保留此出处http://xiewb.blog.51cto.com/11091636/1792287
标签:mysql
原文地址:http://xiewb.blog.51cto.com/11091636/1792287