1:環境
系統:RHEL4.7 MySQL-5.1.34
hostname IP
Master.server 192.168.76.131
Slave.server 192.168.76.132 2:編譯安裝MySQL
#groupadd MySQL
#useradd -g mysql MySQL
#tar zxvf MySQL-5.1.34.tar.tar
#cd MySQL-5.1.34
#./configure --prefix=/usr/local/mysql --localstatedir=/db/mysql --sysconfdir=/etc --without-debug --enable-assembler --enable-thread-safe-client --enable-profiling --with-mysqld-ldflags=-all-static --with-clIEnt-ldflags=-all-static --with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charsets=utf8,gbk --with-pthread --without-ndb-debug --with-mysqld-user=mysql --without-embedded-server --with-unix-socket-path=/usr/local/mysql/sock/MySQL.sock
#make && make install# cp support-files/my-huge.cnf /etc/my.cnf //huge.cnf 高性能模板
#vi /etc/my.cnf 添加如下值
datadir = /db/MySQL
skip-name-resolv
table-cache = 4096#mkdir -p /db/MySQL
#chown mysql.mysql /db/MySQL -R
#./scripts/mysql_install_db --user=MySQL
#cp ./support-files/mysql.server /etc/rc.d/init.d/MySQLd
#chmod +x /etc/rc.d/init.d/MySQLd
#chkconfig --level 235 MySQLd on
#chown -R root.mysql /usr/local/MySQL
//設置環境變量
在 /etc/profile添加一行就 ,在運行MySQL的時候就不用輸入很長的路經了
export PATH=$PATH:/usr/local/MySQL/bin
#MySQLadmin -u root passWord YourPASSWD
#service MySQLd start
//以上步驟在2台機器上都要操作一遍,這樣初始化環境就搭建好了
=========================================== 1:在Master.server上設置 此服務器為主復制服務器。
# MySQL –uroot –pYourPASSWD
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 5.1.34-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
MySQL> GRANT REPLICATION SLAVE,REPLICATION CLIENT,RELOAD,SUPER ON *.* TO IDENTIFIED BY '111111';
#給與從服務器(192.168.76.132)用戶replication的同步權限
mysql>Flush privileges; MySQL>\q \\退出
#vi /etc/my.cnf 設置如下參數
log-bin=MySQL-bin //啟動二進制日志系統
binlog-do-db=db2 //二進制需要同步的數據庫名
server-id = 1 //本機數據庫ID 標示為主
binlog-ignore-db=mysql //避免同步MySQL用戶配置,以免不必要的麻煩
#MySQL –uroot –pYourPASSWD
MySQL>create dabatase db2;
MySQL>use db2;
MySQL>create table test;
MySQL>CREATE TABLE test (a INT NOT NULL AUTO_INCREMENT,PRIMARY KEY (a)) TYPE=MyISAM;