手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

MySQL复制和性能优化

[日期:2011-05-17] 来源:51cto  作者:lyp0909 [字体:大 中 小]

在从服务器上过滤:

replicate-do-db=db:仅复制哪些数据库

If the current database of the statement is db, execute the statement

replicate-ignore-db=db:忽略哪些数据库

If the current database of the statement is db, discard the statement

replicate-do-table=table and replicate-wild-do-table=db_pattern.tbl_pattern

If the name of the table being updated is table or matches the pattern, execute updates to the table 使用通配符指定仅复制哪些表

replicate-ignore-table=table and replicate-wild-ignore-table=db_pattern.tbl_pattern

If the name of the table being updated is table or matches the pattern, discard updates to the table 使用通配符忽略哪些表

MySQL

主从复制实现SSL加密功能:

主服务器兼做CA:

编辑/etc/hosts文件:

192.168.1.11    master.a.com            master

192.168.1.13    slave.a.com             slave

[root@station39 ~]# vim /etc/my.cnf

ssl  //** MySQLd 中添加

重启服务;

MySQL

开始制作证书:

先将主服务器配置成CA:

[root@station39 CA]# vim ../tls/openssl.cnf

dir             = /etc/pki/CA

[root@station39 CA]# umask 077;openssl genrsa 2048 > private/cakey.pem

[root@station39 CA]# openssl req -x509 -new -key private/cakey.pem -out cacert.pem

MySQL

[root@station39 CA]# mkdir certs newcerts crl

[root@station39 CA]# touch index.txt serial

[root@station39 CA]# echo 01 >serial

CA已经创建完毕!

[root@station39 CA]# mkdir -pv /etc/mysql/certs

[root@station39 CA]# cd /etc/mysql/certs/

[root@station39 certs]# openssl genrsa 2048 >master_key.pem

[root@station39 certs]# openssl req -new -key master_key.pem -out master.csr

MySQL

[root@station39 certs]# openssl ca -in master.csr -out master_cert.pem

给从服务器签署证书请求:

[root@station39 certs]# openssl ca -in /tmp/slave.csr -out slave_cert.pem

[root@station39 certs]# scp slave_cert.pem 192.168.1.13:/etc/mysql/certs

[root@station39 certs]# cp /etc/pki/CA/cacert.pem ./

[root@station39 certs]# scp /etc/pki/CA/cacert.pem 192.168.1.13:/etc/mysql/certs/

CA的私钥,主服务的私钥和证书都已准备好了:

MySQL

开始MySQL的配置:

编辑/etc/my.cnf主配置文件:

ssl-ca = /etc/mysql/certs/cacert.pem

ssl-cert = /etc/mysql/certs/master_cert.pem

ssl-key = /etc/mysql/certs/master_key.pem

保存退出,重启服务;

mysql> grant replication slave,replication client on *.* to rep@'%.a.com' identified by 'RedHat' require ssl;

mysql> flush privileges;

从服务器:

编辑/etc/hosts文件:

192.168.1.11    master.a.com            master

192.168.1.13    slave.a.com             slave

[root@station26 ~]# vim /etc/my.cnf

ssl  //**mysqld 中添加

重启服务;

MySQL

[root@station26 ~]# mkdir -pv /etc/mysql/certs

[root@station26 ~]# cd /etc/mysql/certs/

[root@station26 certs]# openssl genrsa 2048 > slave_key.pem

[root@station26 certs]# openssl req -new -key slave_key.pem -out slave.csr

MySQL

[root@station26 certs]# scp slave.csr 192.168.1.11:/tmp

CA的私钥,从服务的私钥和证书都已准备好了:

MySQL

linux
相关资讯       MySQL教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款