Outdated Version

You are viewing an older version of this section. View current production version.


Create a MemSQL node on the local machine.


Create a MemSQL node on the local machine

memsqlctl create-node will create a MemSQL node on the local machine by creating
its config file and various data directories on the local filesystem.
It will also start the node by default.

Example usages:

    memsqlctl create-node --password TEST_PASSWORD

This will create a node with its files in the default install directory.
The node will also be started and the MemSQL root password will be set to

If you do not want to use the --password flag to pass in the MemSQL
root password you may also set the environment variable "MEMSQL_PASSWORD".

The --password must be specified if the node will be started, but it may be set
to the empty string (equivalent to no password) for convenience in demo or
testing situations:

    memsqlctl create-node --password ""

If you only want to lay out the node's data and directories on the filesystem
but do not want to start the process, set --no-start:

    memsqlctl create-node --no-start

Note that you must NOT specify a password when you use --no-start and thus when
the node is eventually started, its MemSQL root password will not be set. You
will have to run 'memsqlctl change-root-password' to set it.

To configure the port (default 3306):

    memsqlctl create-node ... --port 3307

By default the node's data and directories will be rooted in a base install
directory (named a randomly generated UUID) which is in the default install dir.
To find out where the default install dir is, run "memsqlctl env".
Note that the memsql-server rpm and deb packages configure the default install
dir to be /var/lib/memsql.

If you want to change the location of the node's base install dir:

    memsqlctl create-node ... --base-install-dir /memsql_node_1

This will lay out all of the node's data and directories in /memsql_node_1
The filesystem will resemble:

If you want to change the location of only one directory and leave the rest
in a directory rooted in the default install dir:

    memsqlctl create-node ... --datadir /data/memsql_node_1/data

The filesystem will resemble:
{default install dir}
  {base dir}


  memsqlctl create-node [flags]

      --auditlogsdir ABSOLUTE_PATH       Absolute path to the auditlogs directory
      --base-install-dir ABSOLUTE_PATH   Absolute path to the base install directory
      --bind-address IPv4                The bind address
      --datadir ABSOLUTE_PATH            Absolute path to the data directory
      --disable-auto-restart             Disable automatic restart of memsqld on error
  -h, --help                             Help for create-node
      --memsql-config ABSOLUTE_PATH      Absolute path to the MemSQL config file
      --no-start                         Do not start the node
  -p, --password STRING                  The password
      --plancachedir ABSOLUTE_PATH       Absolute path to the plancache directory
  -P, --port PORT                        The port
      --tracelogsdir ABSOLUTE_PATH       Absolute path to the tracelogs directory

Global Flags:
  -c, --config FILE_PATH                     Path to the memsqctl config file
      --default-install-dir DIRECTORY_PATH   Path to the default install directory
  -j, --json                                 Print output in JSON format
      --node-metadata-file FILE_PATH         Path to the node metadata file
      --parallelism POSITIVE_INTEGER         Maximum amount of operations to be run in parallel
      --ssl-ca FILE_PATH                     Path to the CA certificate file in PEM format to authenticate the MemSQL server certificate
      --timeout duration                     Maximum time for operation to complete (e.g., 30s, 10m, 1.5h)
  -v, --verbosity count                      Increase logging verbosity
  -y, --yes                                  Enable non-interactive mode and assume the user would like to move forward with the proposed actions by default


memsqlctl will create (if one does not already exist) a new memsql.cnf file for the node and populate it with paths for the data directory (datadir), plancache directory (plancachedir), temporary directory (tmpdir), trace log directory (tracelogsdir), and audit log directory (auditlogsdir). For each of these directory paths, if the directory does not exist, memsqlctl will create the directory. The owner for each directory is the current user with the permissions set to 755.

Next, memsqlctl will add a record of the node (its path to memsql.cnf) to the node metadata file, nodes.hcl.

If --base-install-dir is specified, all of the other directories (data, tracelogs, etc) will be placed in that directory by default. So to install a node into a particular directory, run create-node --base-install-dir /my/dir. Specifying values for --datadir, --tracelogsdir, etc. allow you to put those particular directory somewhere else, but all directories you don’t specify will go into the directory specified by --base-install-dir.

If --base-install-dir is not specified, memsqlctl sets the base install directory to a subdirectory of --default-install-dir. The --default-install-dir flag can be specified as a global flag, but would more likely be specified in the global memsqlctl configuration file which is at /etc/memsql/memsqlctl.hcl by default. If you set --default-install-dir, then by default, all created nodes will go into that directory. When creating a node in the --default-install-dir, memsqlctl will create a subdirectory with a random UUID name to differentiate it from other nodes on the same machine. So the default base directory of a new node will be something like /var/lib/memsql/2de7ec03-93c3-4f90-837b-65aaa769034d. /var/lib/memsql is the default value of --default-install-dir.

If --password is specified by the user, memsqlctl will connect to the node and run the necessary GRANT… SQL commands to set a password for the root user. The encrypted password will be added to nodes.hcl.

This command is interactive unless you use either the --yes or --json flags to override interactive behavior.

The memsqlctl create-node command is equivalent to the memsql-admin create-node command.


The following is the standard output for the create-node command. Also, if you want to create more than one node per machine, you must set --port to a unique value for each new subsequent node.

$ sudo memsqlctl create-node
memsqlctl will perform the following actions:
  · Create node on port 3307
    - Base directory = /var/lib/memsql/e3f3bceb-a714-421d-8451-905e1d35684a
    - Config file = /var/lib/memsql/e3f3bceb-a714-421d-8451-905e1d35684a/memsql.cnf

  · Set up runtime environment

  · Start node

Would you like to continue? [y/N]: y
✓ Created node with MemSQL ID 994274A024996ADAD6B1B780352C0EDBC0E7328F
✓ Set up runtime environment
✓ Started node with MemSQL ID 994274A024996ADAD6B1B780352C0EDBC0E7328F