The rotate_certs Command
Available in 7.2.0 and later.
The rotate_certs command allows a seamless upgrade of MySQL certificates (on the MySQL server side).
rotate_certs [options]
Where:
| Option | Description | Product | Version |
|---|---|---|---|
--aliasAliases: -a | Specify the new alias. | CT | 7.2.0 |
--all | Do import, restart, update and reconfig. | CT | 7.2.0 |
--copyAliases: -c | Copy the new MySQL Certs to the other nodes, requires root ssh via sudo. | CT | 7.2.0 |
--dirAliases: -d | Specify the directory of the certs. | CT | 7.2.0 |
--dryrunAliases: -n | Do not execute, only display what would be run. | CT | 7.2.0 |
--endAliases: -e | Specify the ending db number for --copy | CT | 7.2.0 |
--generate | Create the MySQL Certs in the directory provided. | CT | 7.2.0 |
--importAliases: -i | Import the new MySQL certs into the four Tungsten files. | CT | 7.2.0 |
--one | Do generate and copy. | CT | 7.2.0 |
--pattern | Specify the hostname pattern. Default: db | CT | 7.2.0 |
--reconfig | Execute connector reconfig to deploy the new certs. | CT | 7.2.0 |
--removeAliases: --rm | Remove the certs dir first, used only with --generate. | CT | 7.2.0 |
--restart | Restart mysqld via sudo service mysqld restart. | CT | 7.2.0 |
--runningAliases: -r | Specify --running --force to tpm cert commands, used only with --import | CT | 7.2.0 |
--startAliases: -s | Specify the starting db number for --copyDefault: 2 | CT | 7.2.0 |
--systemd | When issuing --restart, use the systemctl syntax instead. | CT | 7.2.0 |
--update | Change the alias in security.properties for Client <> Connector communication | CT | 7.2.0 |
The update should be made one node at a time, starting with a Replica, switching to it, and then doing the other Replicas.
Examples
On a single node:
shell> rotate_certs --one --dir /etc/mysql/certs2 --alias mysql_new -rm -n
or:
shell> rotate_certs --generate --dir /etc/mysql/certs2 --alias mysql_new --rm -n
shell> rotate_certs --copy --dir /etc/mysql/certs2 -n
On all nodes:
shell> rotate_certs --all --dir /etc/mysql/certs2 --alias mysql_new --running -n
or:
shell> rotate_certs --import --dir /etc/mysql/certs2 --alias mysql_new --running -n
shell> rotate_certs --restart --systemd -n
shell> rotate_certs --update --alias mysql_new -n
shell> rotate_certs --reconfig -n
Standard Workflow Summary
On a Single Node:
shell> rotate_certs --generateshell> rotate_certs --copyOn all nodes, Starting with a replica:
shell> rotate_certs --importEdit
my.cnfmanuallyshell> rotate_certs --restartshell> rotate_certs --updateshell> rotate_certs --reconfig
Standard Workflow Details
Database Nodes:
Generate the new mysql certs (
rotate_certs --generate)Copy the new mysql certs to all database and Connector nodes (
rotate_certs --copy)Add the new cert to four keystores/truststores (
rotate_certs --import)Update
my.cnfwith the new cert location (manual)Restart mysqld on the first Replica when ready and only after the keystores have been updated on that node (
rotate_certs --restart)Switch to the above Replica, and repeat Steps 3-6 on the rest of the nodes (manual via
cctrl)
Connector Nodes:
Before using the new certs on the client application side:
- Update security.properties:
connector.security.keystore.alias.client.to.connector=[new_alias](rotate_certs --update) - Run
connector reconfigure(rotate_certs --reconfig) - If applications rely on the [client] stanza in my.cnf, make sure this section is updated with the new cert locations only after the Connectors have been reconfigured (see above two steps)
Standard Workflow Notes
- This procedure to be done in AUTOMATIC policy mode
- After mysqld restart, the Replica being updated will briefly show as failed; this is expected and the node will be brought online automatically by the Manager. Similarly, the Replicator will briefly show suspect, then come back online.
- Once all nodes have been updated:
- Update all
/etc/tungsten/tungsten.inifiles with the new aliases to be used by default viajava-mysql-alias, then runtpm update - A best practice is to remove the old alias from the keystores and truststores as this will avoid Tungsten trying too many
aliases next time certs are updated. i.e.
tpm cert rm ke,ts,ck,ct [OLD_ALIAS_HERE]
- Update all