一、安装
1.Mysql5.5.28版本需要用cmake安装,所以需要首先yum –y install cmake
2.tar -zxvf mysql-5.5.28.tar.gz
3.cd mysql-5.5.28 &&cmake . \
-DCMAKE_INSTALL_PREFIX=/usr/local/webserver/mysql/ \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_UNIX_ADDR=/data/mysql/mysqld.sock \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_TCP_PORT=3306 \
-DEXTRA_CHARSETS=all \-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DMYSQL_USER=mysql \
-DWITH_DEBUG=0
4.make && make install
5. cp support-files/my-medium.cnf/etc/my.cnf
6. cp support-files/mysql.server/etc/init.d/mysqld
7. chmod 755 /etc/init.d/mysqld
8.bash scripts/mysql_install_db --user=mysql--basedir=/usr/local/webserver/mysql --datadir=/data/mysql
二、MASTER配置
1.官方配置文档在http://dev.mysql.com/doc/refman/5.5/en/replication-howto-masterbaseconfig.html
2.vi /etc/my.cnf修改以下内容
[mysqld]
log-bin=mysql-bin
server-id=1
3.创建slave访问master的帐号
grant replication slave on *.* to slave@'172.16.100.11' identified by '123456';
grant replication slave on *.* to slave@'localhost' identified by'123456';
flush privileges;
4.show master status后记录下显示内容
5.master内容传至slave
可将主库停掉直接scp到slave中
/etc/init.d/mysqld stop
scp -r /data/mysql/ root@172.16.100.11:/data/mysql
三、SLAVE配置
1.官方配置文档在http://dev.mysql.com/doc/refman/5.5/en/replication-howto-slavebaseconfig.html
2.vi /etc/my.cnf修改如下内容
server-id= 11
replicate-ignore-db = mysql
log-slave-updates
进入mysql后输入
change master to
MASTER_HOST='172.16.100.31 ',
MASTER_USER='slave',
MASTER_PASSWORD='123456',
MASTER_LOG_FILE='mysql-bin.000002',
MASTER_LOG_POS=106;
mysql> slave start;
3.查看slave状态
show slave status;