{question}
How to change default memsql user on the fully installed cluster?
{question}
{answer}
SingleStore should be installed as a user ‘memsql’ and group ‘memsql’.
For some business reason, if you would like to change the default User to something like 'memsql2', this article includes the steps to do it.
NOTE: this install only shows 1 node; the steps will be the same on a SingleStore cluster with an N number of nodes.
1) If the new user does not already exist, create that user first (in our example ‘memsql2’)
and make sure it has the same or higher privileges than the current owner, ‘memsql’. For more information, click here.
2) It is important to find all the SingleStore related directories locations. Executing the below tools command from MA Provides those required details for every node. Click here to learn more about the command.
The following output lists the base directory as /var/lib/memsql:
sdb-admin describe-node
$ sdb-admin describe-node
Enter the MemSQL ID of the target node, or 'all' to describe all nodes: all
+--------------------+---------------------------------------------------------------------------------+
| memsqlId | 94B02965BF36EB26F96EF64652807D37A9C74E8C |
| host | ec2-54-85-3-209.compute-1.amazonaws.com |
| role | Leaf |
| port | 3307 |
| bindAddress | 0.0.0.0 |
| processState | Running |
| version | 7.3.6 |
| memsqlConfig | /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/memsql.cnf |
| datadir | /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/data |
| plancachedir | /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/plancache |
| tracelogsdir | /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/tracelogs |
| auditlogsdir | /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/auditlogs |
| memsqld | /opt/memsql-server-7.3.6-ae5d1857b8/memsqld |
| nodeID | 2 |
| pid | 23835 |
| dpid | 23842 |
| autoRestartEnabled | true |
| isConnectable | true |
| recoveryState | Online |
| availabilityGroup | 1 |
| config | Omitted from table view. Use 'sdb-admin describe-node ... --property config' |
| variables | Omitted from table view. Use 'sdb-admin describe-node ... --property variables' |
+--------------------+----------------------------------------------------------
3) Start with the process of changing the default user from memsql to memsql2,
Stop all nodes from MA:
sdb-admin stop-node --all
$ sdb-admin stop-node --all
Continue to stop the node(s) without taking a database snapshot?
Select 'Y' to stop the node(s) without taking a database snapshot.
Select 'N' to take a snapshot of all databases and then stop the node(s).
Taking a database snapshot will reduce the time it takes for the node(s) to recover after being restarted, but may increase the time it takes for the node(s) to stop. [Y/n]: n
✓ Snapshots completed
✓ Successfully connected to host ec2-54-85-3-209.compute-1.amazonaws.com
Toolbox is about to perform the following actions:
· Stop all nodes in the cluster
Would you like to continue? [y/N]: y
✓ Stopped Master node on ec2-54-85-3-209.compute-1.amazonaws.com (1/1)
✓ Successfully stopped Master node on 1 host
✓ Stopped Master node
✓ Stopped Leaf nodes on ec2-54-85-3-209.compute-1.amazonaws.com (1/1)
✓ Successfully stopped Leaf nodes on 1 host
✓ Stopped Leaf node
Operation completed successfully
4) Next, we need to edit the configuration files of the toolbox,
Files which are needed to be updated are memsqlctl.hcl and toolbox.hcl files:
Modify the configuration file from memsql to memsql2 (Desired User)
# cat /etc/memsql/memsqlctl.hcl
version = 1
nodeMetadataFile = "/var/lib/memsql/nodes.hcl"
defaultInstallDir = "/var/lib/memsql"
user = "memsql2"
# cat /etc/memsql/toolbox.hcl
version = 1
state = "/root/.local/share/singlestoredb-toolbox/toolbox-state.hcl"
cache = "/root/.local/share/singlestoredb-toolbox/toolbox-cache.hcl"
runtimeDir = "/run/user/1000"
user = "memsql2"
parallelism = 4
With the new Toolbox management system, the memsqlctl
the package is node-specific to manage local operations, and the Toolbox package is to manage the whole cluster (by calling memsqlctl
on each host).
5) Next, we need to change the owner of the SingleStore binaries. This should be executed with a privileged user, either as sudo or root. Do this at the base MemSQL install directory:
# ls -ld memsql
drwxr-xr-x 5 memsql memsql 4096 Mar 23 13:55 memsql
# chown -R memsql2:memsql2 memsql
# ls -ld memsql
drwxr-xr-x 5 memsql2 memsql2 4096 Mar 23 14:01 memsql
Perform Step 5) on all leaf nodes.
6) Now that the changes have been completed, start the nodes.
sdb-admin start-node --all
$ sdb-admin start-node --all
Toolbox is about to perform the following actions:
· Start all nodes in the cluster
Would you like to continue? [y/N]: y
✓ Successfully connected to host ec2-54-85-3-209.compute-1.amazonaws.com
✓ Started Leaf nodes on ec2-54-85-3-209.compute-1.amazonaws.com (1/1)
✓ Successfully started Leaf nodes on 1 host
✓ Successfully connected to Leaf node
✓ Started Master node on ec2-54-85-3-209.compute-1.amazonaws.com (1/1)
✓ Successfully started Master node on 1 host
✓ Successfully connected to Master node
Operation completed successfully
7) Confirm that MemSQL processes are running as the new user, in this example
‘memsql2’:
$ ps -ef|grep [m]emsqld
memsql2 29680 1 0 16:47 ? 00:00:00 /opt/memsql-server-7.3.6-ae5d1857b8/memsqld_safe --defaults-file /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/memsql.cnf --user 1001 --auto-restart StagedEnable
memsql2 29688 29680 6 16:47 ? 00:00:06 /opt/memsql-server-7.3.6-ae5d1857b8/memsqld --defaults-file /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/memsql.cnf --user 1001
memsql2 29690 29688 0 16:47 ? 00:00:00 /opt/memsql-server-7.3.6-ae5d1857b8/memsqld --defaults-file /var/lib/memsql/27e6ec70-8426-4966-819d-2503a42bb316/memsql.cnf --user 1001
memsql2 29940 1 0 16:47 ? 00:00:00 /opt/memsql-server-7.3.6-ae5d1857b8/memsqld_safe --defaults-file /var/lib/memsql/a8ec19a7-381a-400a-8cd6-74278eb42416/memsql.cnf --user 1001 --auto-restart StagedEnable
memsql2 29947 29940 6 16:47 ? 00:00:05 /opt/memsql-server-7.3.6-ae5d1857b8/memsqld --defaults-file /var/lib/memsql/a8ec19a7-381a-400a-8cd6-74278eb42416/memsql.cnf --user 1001
memsql2 29949 29947 0 16:47 ? 00:00:00 /opt/memsql-server-7.3.6-ae5d1857b8/memsqld --defaults-file /var/lib/memsql/a8ec19a7-381a-400a-8cd6-74278eb42416/memsql.cnf --user 1001
At this point, the Default user has been changed to the new user. Please
connect to the databases, and run the tests like CREATE DATABASE and TABLES to validate the results.
{answer}