在从服务器上过滤:
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 使用通配符忽略哪些表

主从复制实现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 中添加
重启服务;

开始制作证书:
先将主服务器配置成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

[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

[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的配置:
编辑/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 中添加
重启服务;

[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

[root@station26 certs]# scp slave.csr 192.168.1.11:/tmp
CA的私钥,从服务的私钥和证书都已准备好了:

