IP地址白名单
组复制插件具有一个配置选项,用于确定从哪些主机可以接受传入的组通信连接。此选项称为group_replication_ip_whitelist。如果在服务器s1上设置此选项,则当服务器s2正在建立与s1的连接以便进行组通信时,s1在接受s2传过来的连接之前,首先会检查白名单。如果s2在白名单中,则s1接受连接,否则s1拒绝s2的连接尝试。
如果未配置任何白名单,则服务器会自动将白名单设置为服务器具有接口的专用网络。这意味着,即使服务器具有公共IP上的接口,也不会默认允许来自外部主机的连接。 每当IP白名单设置为AUTOMATIC时,在这种情况下可以发出错误日志中的条目,类似于:
2016-07-07T06:40:49.320686Z 4 [Note] Plugin group_replication reported: 'Added automatically \\
IP ranges 10.120.40.237/18,10.178.59.44/22,127.0.0.1/8 to the whitelist'
您可以通过手动设置允许进行组通信连接的IP地址列表来进一步提高组的安全性。可以使用CIDR表示法或简单的IP地址来指定列表。逗号必须分隔每个条目。例如:
mysql> STOP GROUP_REPLICATION;
mysql> SET GLOBAL group_replication_ip_whitelist="10.120.40.237/18,10.178.59.44/22,127.0.0.1/8";
mysql> START GROUP_REPLICATION;
本地主机IP地址(127.0.0.1)始终添加到白名单中。如果没有明确,它是隐式和自动添加。
SSL支持
MySQL组复制支持MySQL服务器的OpenSSL和YaSSL构建。
组通信的连接以及恢复的连接使用SSL进行保护。以下部分说明如何配置连接。
Configuring SSL for Recovery
通过常规异步复制连接执行恢复。一旦选择了复制源,则连接器建立异步复制连接。这都是自动的。
但是,需要SSL连接的用户必须在连接器连接到施主之前创建。通常,这是在服务器准备加入组时设置的。
donor> SET SQL_LOG_BIN=0;
donor> CREATE USER 'rec_ssl_user'@'%' REQUIRE SSL;
donor> GRANT replication slave ON *.* TO 'rec_ssl_user'@'%';
donor> SET SQL_LOG_BIN=1;
假设组中的所有服务器都有一个复制用户设置为使用SSL,您可以配置为在成员加入到复制源时使用这些凭证。这是根据为组复制插件提供的SSL选项的值完成的。
new_member> SET GLOBAL group_replication_recovery_use_ssl=1;
new_member> SET GLOBAL group_replication_recovery_ssl_ca= '.../cacert.pem';
new_member> SET GLOBAL group_replication_recovery_ssl_cert= '.../client-cert.pem';
new_member> SET GLOBAL group_replication_recovery_ssl_key= '.../client-key.pem';
并通过将恢复通道配置为使用需要SSL连接的用户的凭据。
new_member> CHANGE MASTER TO MASTER_USER="rec_ssl_user" FOR CHANNEL "group_replication_recovery";
new_member> START GROUP_REPLICATION;
Configuring SSL for Group Communication
安全套接字可用于在组中的成员之间建立通信。此配置取决于服务器的SSL配置。因此,如果服务器配置了SSL,则组复制插件也配置了SSL。有关配置服务器SSL的选项的详细信息,请参见第7.4.5节“安全连接的命令选项”。配置组复制的选项如下表所示。
Server Configuration | Plugin Configuration Description |
ssl_key | Path of key file. To be used as client and server certificate. |
ssl_cert | Path of certificate file. To be used as client and server certificate. |
ssl_ca | Path of file with SSL CAs that are trusted. |
ssl_capath | Path of directory containing certificates for SSL CAs that are trusted. |
ssl_crl | Path of file containing the certificate revocation lists. |
ssl_crlpath | Path of directory containing revoked certificate lists files. |
ssl_cipher | Permitted ciphers to use while encrypting data over the connection. |
tls_version | Secure communication will use this version and its protocols. |
这些选项是组配置所依赖的MySQL服务器配置选项。此外,还有以下特定于组复制的选项,用于在插件本身上配置SSL。
group_replication_ssl_mode
- 指定组复制成员之间的连接的安全状态
Value | Description |
DISABLED | Establish an unencrypted connection (default). |
REQUIRED | Establish a secure connection if the server supports secure connections. |
VERIFY_CA | Like REQUIRED, but additionally verify the server TLS certificate against the configured Certificate Authority (CA) certificates. |
VERIFY_IDENTITY | Like VERIFY_CA, but additionally verify that the server certificate matches the host to which the connection is attempted. |
以下示例显示了用于在服务器上配置SSL的示例my.cnf文件部分以及如何为组复制激活它。
[mysqld]
ssl_ca = "cacert.pem"
ssl_capath = "/.../ca_directory"
ssl_cert = "server-cert.pem"
ssl_cipher = "DHE-RSA-AEs256-SHA"
ssl_crl = "crl-server-revoked.crl"
ssl_crlpath = "/.../crl_directory"
ssl_key = "server-key.pem"
group_replication_ssl_mode= REQUIRED
唯一列出的特定于插件的配置选项为group_replication_ssl_mode。此选项通过使用提供给服务器的ssl_ *参数配置SSL框架来激活组成员之间的SSL通信。
Virtual Private Networks (VPN)
没有什么阻止组复制在虚拟专用网络上操作。在其核心,它只是依靠一个IPv4套接字在服务器之间建立连接,目的是在它们之间传播消息。