Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

ports management

Giuseppe Maxia edited this page Nov 6, 2020 · 2 revisions

Ports management

[HOME]

dbdeployer will try using the default port for each sandbox whenever possible. For single sandboxes, the port will be the version number without dots: 5.7.22 will deploy on port 5722. For multiple sandboxes, the port number is defined by using a prefix number (visible in the defaults: dbdeployer defaults list) + the port number + the revision number (for some topologies multiplied by 100.) For example, single-primary group replication with MySQL 8.0.11 will compute the ports like this:

base port = 8011 (version number) + 13000 (prefix) + 11 (revision) * 100  = 22111
node1 port = base port + 1 = 22112
node2 port = base port + 2 = 22113
node3 port = base port + 2 = 22114

For group replication we need to calculate the group port, and we use the group-port-delta (= 125) to obtain it from the regular port:

node1 group port = 22112 + 125 = 22237
node2 group port = 22113 + 125 = 22238
node3 group port = 22114 + 125 = 22239

For MySQL 8.0.11+, we also need to assign a port for the XPlugin, and we compute that using the regular port + the mysqlx-port-delta (=10000).

Thus, for MySQL 8.0.11 group replication deployments, you would see this listing:

$ dbdeployer sandboxes --header
name                   type                  version  ports
----------------       -------               -------  -----
group_msb_8_0_11     : group-multi-primary    8.0.11 [20023 20148 30023 20024 20149 30024 20025 20150 30025]
group_sp_msb_8_0_11  : group-single-primary   8.0.11 [22112 22237 32112 22113 22238 32113 22114 22239 32114]

This method makes port clashes unlikely when using the same version in different deployments, but there is a risk of port clashes when deploying many multiple sandboxes of close-by versions. Furthermore, dbdeployer doesn't let the clash happen. Thanks to its central catalog of sandboxes, it knows which ports were already used, and will search for free ones whenever a potential clash is detected. Bear in mind that the concept of "used" is only related to sandboxes. dbdeployer does not know if ports may be used by other applications. You can minimize risks by telling dbdeployer which ports may be occupied. The defaults have a field reserved-ports, containing the ports that should not be used. You can add to that list by modifying the defaults. For example, if you want to exclude port 7001, 10000, and 15000 from being used, you can run

dbdeployer defaults update reserved-ports '7001,10000,15000'

or, if you want to preserve the ones that are reserved by default:

dbdeployer defaults update reserved-ports '1186,3306,33060,7001,10000,15000'
Clone this wiki locally