时间:2021-07-01 10:21:17 帮助过:17人阅读
a) master节点:192.168.36.121
b) slave节点:192.168.36.120
c) CA服务器:192.168.36.47
mkdir -p /etc/my.cnf.d/ssl
cd /etc/my.cnf.d/ssl
( umask 0666;openssl genrsa 2048 > cakey.pem )
openssl req -new -x509 -key cakey.pem -out cacert.pem -days 3650
openssl x509 -in cacert.pem -noout -text
openssl req -newkey rsa:1024 -days 365 -nodes -keyout master.key > master.csr
openssl x509 -req -in master.csr -CA cacert.pem -CAkey cakey.pem -set_serial 01 > master.crt
openssl x509 -in master.crt -noout -text
openssl req -newkey rsa:1024 -days 365 -nodes -keyout slave.key > slave.csr
openssl x509 -req -in slave.csr -CA cacert.pem -CAkey cakey.pem -set_serial 02 > slave.crt
openssl x509 -in master.crt -noout -text
scp -r /etc/my.cnf.d/ssl/ 192.168.36.121:/etc/my.cnf.d/
scp -r /etc/my.cnf.d/ssl/ 192.168.36.120:/etc/my.cnf.d/
注意:
1、颁发过证书后,证书申请文件已无用处
2、正常情况下,应该复制对应的证书和私钥,同时要保护好私钥
cd /etc/my.cnf.d/ssl/
\rm -rf master.*
\rm -rf cakey.pem
\rm -rf slave.csr
[mysqld]
server_id=120
read_only
innodb_file_per_table
skip_name_resolve = on
ssl #有下面3项时,就表示启动ssl
ssl-ca=/etc/my.cnf.d/ssl/cacert.pem
ssl-cert=/etc/my.cnf.d/ssl/master.crt
ssl-key=/etc/my.cnf.d/ssl/master.key
datadir=/var/lib/mysql
systemctl start mariadb
show variables like ‘%ssl%‘;
grant replication slave on *.* to repluser2@‘192.168.36.%‘ identified by ‘123456‘ require ssl;
cd /etc/my.cnf.d/ssl/
\rm -rf slave.*
\rm -rf cakey.pem
\rm -rf master.csr
[mysqld]
server_id=120
read_only
innodb_file_per_table
skip_name_resolve = on
ssl #有下面3项时,就表示启动ssl
ssl-ca=/etc/my.cnf.d/ssl/cacert.pem
ssl-cert=/etc/my.cnf.d/ssl/slave.crt
ssl-key=/etc/my.cnf.d/ssl/slave.key
datadir=/var/lib/mysql
systemctl start mariadb
show variables like ‘%ssl%‘;
CHANGE MASTER TO
MASTER_HOST=‘192.168.36.121‘,
MASTER_USER=‘repluser2‘, #使用加密通讯的帐户
MASTER_PASSWORD=‘123456‘,
MASTER_LOG_FILE=‘mariadb-bin.000019‘,
MASTER_LOG_POS=413,
MASTER_SSL=1; #启动SSL通讯
mysql>start slave;
mysql>show slave status\G
master节点导入创建hellodb的sql语句:
slave节点确认:
mariadb实现主从加密通讯的详细步骤
标签:start 变量 lib scp 实现 mysq 详细步骤 alt 私钥