1 Installing MySQL
Yum install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool* openssl*-y
Groupadd MySQL
Useradd mysql-g MySQL
Mkdir/usr/local/mysql
Mkdir/usr/local/mysql/data
Chown-r mysql.mysql/usr/local/mysql/data/
Cmake-dcmake_install_prefix=/usr/local/mysql \
-DSYSCONFDIR=/USR/LOCAL/MYSQL/ETC \
-dmysql_datadir=/usr/local/mysql/data \
-dmysql_tcp_port=3306 \
-dmysql_unix_addr=/tmp/mysqld.sock \
-dmysql_user=mysql \
-dextra_charsets=all \
-dwith_readline=1 \
-dwith_ssl=system \
-dwith_embedded_server=1 \
-denabled_local_infile=1 \
-dwith_innobase_storage_engine=1
Make && make install
./mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/usr/local/mysql/data/&
Cp.. /support-files/mysql.server/etc/init.d/mysql
chmod +x/etc/init.d/mysql
Mv/etc/my.cnf/etc/my.cnf_bak
Cp.. /support-files/my-default.cnf/etc/my.cnf
Add the following to MY.CNF:
Log-bin=mysql-bin
Server-id=1
Innodb_flush_log_at_trx_commit=1
Sync_binlog=1
#binlog-do-db=mysql
#binlog_ignore_db =mysql
Do not add the above comment two lines, identify the replication of all databases
Restart MySQL
To create a Slave user:
Create user ' slave ' @10.0.0.3 identified by ' slave ';
Grant Replication Slave on * * to [e-mail protected] identified by ' salve ';
Flush tables with read lock; Execute the following command to lock the database to prevent writing data
Do not close the current window, open a new window:
Mysqldump-uroot-p--all-databases>all.sql
Mysql-uroot-p
Show master status; remember
Mysql> Show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | binlog_do_db | binlog_ignore_db | Executed_gtid_set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 494 | MySQL | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in Set (0.00 sec)
Then unlock the Lock database table window:
Unlock tables;
From the database:
Mysql-uroot-p <all.sql
Mysql> Change Master to
Master_host= ' 10.0.0.2 ',
Master_user= ' Salve ',
master_password= ' Salve ',
master_port=3306,
Master_log_file= ' mysql-bin.000001 ',
master_log_pos=494,
master_connect_retry=10;
New MySQL Database test synchronization
This article is from the "King Good Handsome" blog, please be sure to keep this source http://dawang.blog.51cto.com/4927689/1657975
MySQL synchronous replication