mysql> drop database test;
mysql> use mysql;
mysql> delete from db; mysql> delete from user where not(host="localhost" anduser="root"); mysql> flush privileges;3、Master 机器设置权限,赋予Slave机器FILE及Replication Slave权利,并打包要同步的数据库结构。
Master# ./mysql -u root -p 51cto.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.1.60
Type 'help;'or '\h' for help. Type '\c' to clear the buffer.
mysql> GRANT FILE ON*.* TO slaverep@172.19.1.3 IDENTIFIEDBY ‘slaverep’;
mysql> GRANT REPLICATION SLAVE ON *.* TO slaverep@172.19.1.3 IDENTIFIEDBY ‘51cto.com’;
mysql> Flush privilege;赋予192.19.11.3也就是Slave 机器有File权限, 这个5.1.60版对replication的权限好像做了调整,只赋予Slave机器有File权限还不行,还要给它REPLICATION SLAVE的权限才可以。
Master# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 5.1.60
Type 'help;'or '\h' for help. Type '\c' to clear the buffer.
mysql> use cdn;
Database changed
mysql> INSERT INTO rep_table VALUES ('test1', '4321', 'T',24);
Query OK, 1 row affected (0.00 sec)
mysql> 然后查看Slave机器的reptest数据库:
Slave# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12 to server version: 5.1.49
Type 'help;'or '\h' for help. Type '\c' to clear the buffer.
mysql> use cdn;
Database changed
mysql>select * from reptable;
+------+------+------+------+
| id | name| sex | age |
+------+------+------+------+
| test1|4321 | T | 24 |
+------+------+------+------+
1 row in set(0.00 sec)
mysql> source /root/etc/cdn.sql #导入压缩包中的cdn.sql这样就ok了。接下来是一些性能方面的调优。
wget http://google-perftools.googleco ... erftools-1.6.tar.gz
tar zxvf google-perftools-1.6.tar.gz
cd google-perftools-1.6/
./configure
make && make install
echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf
/sbin/ldconfig3、修改MySQL启动脚本(根据你的MySQL安装位置而定):
vi /usr/local/mysql/bin/mysqld_safe在# executingmysqld_safe的下一行,加上:
cd /usr/local/bind/etc
../sbin/rndc-confgen >rndc.conf
tail -n10 rndc.conf | head -n9 | sed -e s/#\//g >named.conf
# vilocalhost.zone
ttl 86400
@ IN SOA localhost. root.localhost. (
1997022700 ; Serial
28800 ; Refresh
14400 ; Retry
3600000 ; Expire
86400 ) ; Minimum
IN NS localhost.
1 IN PTR localhost.
# dig >named.root编辑named.conf:
#vi named.conf最下面加入:
include"/usr/local/bind/etc/cnc_acl.conf"; //网通ACL
include "/usr/local/bind/etc/telecom_acl.conf"; //电信ACL
include "/usr/local/bind/etc/view.conf"; //DLZ相关的配3、配置DNSTSIG