mysql Master-Slaver 配置

IP:

         master:10.30.0.10,slave:10.30.0.11

所需软件包:

         MySQL-client-5.1.42-0.glibc23.x86_64.rpm

         MySQL-server-5.1.42-0.glibc23.x86_64.rpm

关闭防火墙:

         chkconfig iptalbes off

         service iptables stop

安装MySQL*.rpm

rpm -ivh MySQL*.rpm

创建/etc/my.cnf

         我是mysql自带的demo的配置文件,也可新建

[root@localhost /]# cp /usr/share/mysql/my-large.cnf /etc/my.cnf

cp: overwrite `/etc/my.cnf'? y

[root@localhost /]#

 

创建二进制日志目录

         [root@localhost /]# mkdir -p /var/log/mysql

[root@localhost /]# touch /var/log/mysql/mysql-bin.log

设置文件夹最高权限

[root@localhost /] chmod -R 777 /var/log/mysql

以上步骤需要在masterslaver端分别操作

         Master修改/etc/my.cnf

                   //修改二进制日志目录

                   server-id = 1

                  log-bin=/var/log/mysql/mysql-bin.log

                  //如果要复制所有数据库,不加该项

                   binlog-do-db= ’需要备份的数据库名

                  启动数据库并添加用户:replation

                  mysql>grant replication slave on *.* to replation@'10.30.8.11' identified by 'replation';

         Slave:  修改/etc/my.cnf

              server-id = 2

master-host=10.30.8.10   //(master ip)

master-user=replation             (master创建用户)

master-password=replation   ()

master-port=3306

master-connect-retry=60

 //如果要复制所有数据库,不加该项

replicate-do-db=’需要复制的数据库名’          

           

重启 master / slave 的mysql服务
进入 slaver server 的 mysql
start slave;
show slave status;

 

 

如果出现该错误:

100106 10:56:23 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
100106 10:56:23  InnoDB: Started; log sequence number 0 44233

 

解决办法:mysql_install_db --user=mysql --datadir=/var/lib/mysql/ 

 

你可能感兴趣的:(mysql,防火墙)