{question}
How can I change the SingleStoreDB port for the entire cluster?
{question}
{answer}
You may want to change the default ports for the entire cluster after its deployment. In this example, we will be changing the ports of the entire cluster, including the Master Aggregator.
We will be changing the nodes from port {OLDPORT} to {NEWPORT}
The cluster needs at least two Aggregators since we have to remove the Master Aggregator from the cluster and add it.
Variable in examples |
Description |
{MASTERIP} |
The IP address of the Master Aggregator |
{NEWMASTERIP} |
The new IP of the Temporary Master Aggregator ({AGGREGATORIP} ) |
{MASTERMEMSQLID} |
The memsql-id from the Master Aggregator. You can retrieve this by running >sdb-admin list-nodes |
{AGGREGATORIP} |
The IP address of the aggregator of the cluster, if you have more than one, repeat the steps. |
{AGGREGATORMEMSQLID} |
the memsql-id of the aggregator of the cluster. |
{LEAFIP} |
The IP address of the Leaf |
{OLDPORT} |
The port that we want to change from. |
{NEWPORT} |
The port that we want to set the cluster in. |
{PASSWORD} |
The password for the root user. |
Warnings
If the password contains some bash special characters you need to escape them during the usage of the commands.
Master and Child Aggregator Configuration
Remove, Change Port, and define as Master one aggregator that will be temporary assume the master role during this procedure
a) Remove the aggregator from the cluster
singlestore -hlocalhost -uroot -p -P{OLDPORT} -e "REMOVE AGGREGATOR {AGGREGATORIP}:{OLDPORT};"
b) Change the port for the aggregator
sdb-admin update-config --key port --value {NEWPORT} --memsql-id {AGGREGATORMEMSQLID} --yes
c) Restart the aggregator to assume the new port
sdb-admin restart-node --memsql-id {AGGREGATORMEMSQLID} --yes
d) Add the aggregator to the cluster with the new port
singlestore -hlocalhost -uroot -p -P{OLDPORT}
At the database prompt :
ADD AGGREGATOR root:'{PASSWORD}'@'{AGGREGATORIP}':{NEWPORT};"
e) Promote the changed aggregator to be the Master of the cluster
singlestore -hlocalhost -uroot -p -P{OLDPORT} -e "PROMOTE AGGREGATOR '{AGGREGATORIP}':{NEWPORT} TO MASTER;"
Perform this operation for the remaining aggregators in the cluster, including the previous Master Aggregator
a) Remove the aggregator from the cluster
singlestore -h{NEWMASTERIP} -uroot -p -P{NEWPORT} -e "REMOVE AGGREGATOR '{AGGREGATORIP}':{OLDPORT};"
b) Change the port for the aggregator
sdb-admin update-config --key port --value {NEWPORT} --memsql-id {AGGREGATORMEMSQLID} --yes
c) Restart the aggregator to assume the new port
sdb-admin restart-node --memsql-id {AGGREGATORMEMSQLID} --yes
d) Add the aggregator to the cluster with the new port
singlestore -h{NEWMASTERIP} -uroot -p -P{NEWPORT}
At the DB Prompt
singlestore> ADD AGGREGATOR root:'{PASSWORD}'@'{AGGREGATORIP}':{NEWPORT};"
e) Configure the old master back to be master
singlestore -h{NEWMASTERIP} -uroot -p -P{NEWPORT} -e "PROMOTE AGGREGATOR {AGGREGATORIP}:{NEWPORT} TO MASTER;"
At this time you should have all the aggregators using the new port and the master properly set.
Leaves Configuration:
Configure the leaves to use a new port, this manual will change all the leaf ports to the same one, if you need custom actions you need to perform the operation, leaf by leaf. Only perform one of the bellow operations, depending if you have High Availability enabled on your cluster.
Non-High Availability enabled.
NB*** This will cause downtime in the databases since all the leaves will be removed from the cluster and re-added.
a) Remove all leaves from the cluster.
sdb-admin list-nodes -q -r leaf | xargs -I{} sdb-admin remove-leaf --yes --memsql-id {}
b) Change the port for all the leaves, at this stage, the leaves are marked as unknown in the list of nodes.
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin update-config --key port --value {NEWPORT} --yes --memsql-id {}
c) Restart all the leaves.
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin restart-node --yes --memsql-id {}
d) Add the leaves back to the cluster
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin add-leaf --yes --memsql-id {}
High Availability enabled
NB***This will not cause downtime, since we will be performing the operation per each availability group.
We need to perform the same operation for each availability group
Availability Group 1
a) Remove all leaves from the cluster
sdb-admin list-nodes --availability-group 1 -q -r leaf | xargs -I{} sdb-admin remove-leaf --yes --memsql-id {}
b) Change the port for the leaves that were in the AG1, they are now defined as unknown in the list of nodes
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin update-config --key port --value {NEWPORT} --yes --memsql-id {}
c) Restart the leaves
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin restart-node --yes --memsql-id {}
d) Add the leaves back to the cluster in the availability group 1
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin add-leaf --availability-group 1 --yes --memsql-id {}
Wait for the recovery to complete before changing the leaves in the availability group 2, it may take some time depending on the size of the databases.
Availability Group 2
a) Remove all leaves from the cluster
sdb-admin list-nodes --availability-group 2 -q -r leaf | xargs -I{} sdb-admin remove-leaf --yes --memsql-id {}
b) Change the port for the leaves that were in the AG1, they are now defined as unknown in the list of nodes
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin update-config --key port --value {NEWPORT} --yes --memsql-id {}
c) Restart the leaves
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin restart-node --yes --memsql-id {}
d) Add the leaves back to the cluster in the availability group 2
sdb-admin list-nodes -q -r unknown | xargs -I{} sdb-admin add-leaf --availability-group 2 --yes --memsql-id {}
Important Note: Leaf nodes might take some time to recover (Depending on the database size).
Please reach out to SingleStore support in case of any questions with respect to this runbook.
{answer}