9.17. The rotate_certs Command

The rotate_certs allows a seamless upgrade of MySQL certificates (on the MySQL server side).

Table 9.36. rotate_certs Options

OptionDescription
--alias, -aSpecify the new alias
--allDo import, restart, update and reconfig
--copy, -cCopy the new MySQL Certs to the other nodes, requires root ssh via sudo
--dir, -dSpecify the directory of the certs
--dryrun, -nDo not execute, only display what would be run
--end, -eSpecify the ending db number for --copy (default: 6)
--generate, --gen, -gCreate the MySQL Certs in the directory provided
--import, -iImport the new MySQL certs into the four Tungsten files.
--oneDo generate and copy
--patternSpecify the hostname pattern (default: db)
--reconfig
--remove, --rmRemove the certs dir first, used only with --generate
--restartRestart mysqld via `sudo service mysqld restart`
--running, -rSpecify --running --force to tpm cert commands, used only with --import
--start, -sSpecify the starting db number for --copy (default: 2)
--systemdWHen issuing --restart, use the systemctl syntax instead
--update

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

  1. On a Single Node:

    shell> rotate_certs --generate
    shell> rotate_certs --copy
  2. On all nodes, Starting with a replica:

    shell> rotate_certs --import

    Edit my.cnf manually

    shell> rotate_certs --restart
    shell> rotate_certs --update
    shell> rotate_certs --reconfig

Standard Workflow Details

Database Nodes:

  1. Generate the new mysql certs (rotate_certs --generate)

  2. Copy the new mysql certs to all database and Connector nodes (rotate_certs --copy)

  3. Add the new cert to four keystores/truststores (rotate_certs --import)

  4. Update my.cnf with the new cert location (manual)

  5. Restart mysqld on the first Replica when ready and only after the keystores have been updated on that node (rotate_certs --restart)

  6. 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 tungsten.ini files with the new aliases to be used by default via java_mysql_alias={NEW_ALIAS_HERE}, then run tpm 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}