How to configure database type, host and port for temporal CLI

Although I’ve specified DB related ENV variables during docker run, those values are not configured for tctl. By default, it is trying to connect How can I configure/override DB variables for CLI

Use --address flag to pass an alternative flag.

TEMPORAL_CLI_ADDRESS environment variable can be also used. Note that if you run tctl through docker then it is not going to see the environment variables from your shell.

$ tctl --help
   tctl - A command-line tool for Temporal users

   tctl [global options] command [command options] [arguments...]


   namespace, n   Operate Temporal namespace
   workflow, wf   Operate Temporal workflow
   activity, act  operate activities of workflow
   taskqueue, tq  Operate Temporal task queue
   batch          batch operation on a list of workflows from query.
   admin, adm     Run admin operation
   cluster, cl    Operate Temporal cluster
   help, h        Shows a list of commands or help for one command

   --address value, --ad value          host:port for Temporal frontend service [$TEMPORAL_CLI_ADDRESS]
   --namespace value, --ns value        Temporal workflow namespace (default: "default") [$TEMPORAL_CLI_NAMESPACE]
   --context_timeout value, --ct value  optional timeout for context of RPC call in seconds (default: 5) [$TEMPORAL_CONTEXT_TIMEOUT]
   --help, -h                           show help
   --version, -v                        print the version

I’ve configured --address flag properly. But, I’m getting below error while running below command. I’m using external mysql DB and it’s trying to connect to cassandra on localhost.

tctl admin membership list_db

2020/07/23 15:48:20 gocql: unable to dial control conn dial tcp connect: connection refused
Error: Failed to initialize cluster metadata manager
Error Details: gocql: unable to create session: control: unable to connect to initial hosts: dial tcp connect: connection refused

list_db command connects directly to the DB, so you have to specify the IP of the DB using db_address flag:

docker[master !*]$ tctl admin membership list_db --help
   tctl admin membership list_db - List cluster membership items

   tctl admin membership list_db [command options] [arguments...]

   --db_engine value               Type of the DB engine to use (cassandra, mysql..) (default: "cassandra")
   --db_address value              persistence address (right now only cassandra is fully supported) (default: "")
   --db_port value                 persistence port (default: 9042)
   --username value                cassandra username
   --password value                cassandra password
   --keyspace value                cassandra keyspace (default: "temporal")
   --tls                           enable TLS over cassandra connection
   --tls_cert_path value           cassandra tls client cert path (tls must be enabled)
   --tls_key_path value            cassandra tls client key path (tls must be enabled)
   --tls_ca_path value             cassandra tls client ca path (tls must be enabled)
   --tls_enable_host_verification  cassandra tls verify hostname and server cert (tls must be enabled)
   --heartbeated_within value      Filter by last heartbeat date time. Supported formats are '2006-01-02T15:04:05+07:00', raw UnixNano and time range (N<duration>), where 0 < N < 1000000 and duration (full-notation/short-notation) can be second/s, minute/m, hour/h, day/d, week/w, month/M or year/y. For example, '15minute' or '15m' implies last 15 minutes. (default: "15m")
   --role value                    Membership role filter: all (default), frontend, history, matching, worker (default: "all")
1 Like

Thanks @maxim. But it seems mysql is not fully supported. Will this be supported in V1 release ?

Error: CreatePersistenceFactory err
Error Details: DB type “mysql” is not supported by CLI

Hey @ganta,
All admin commands which directly connects to database are only supported for Cassandra at this point. This is something we plan to support in the future. Here is the github issue for it.

1 Like