Execute a Command or Script on Grid Instances (instanceExec)
The instanceExec
command executes a command (such as a system command or TimesTen command) or a script on instances in the grid, as specified.
ttGridAdmin instanceExec [-only hostname[.instancename]] [-exclude hostname[.instancename]] [-parallel n] [-type all|management|data] [-up] command | -script filepath
Options
The instanceExec
command has the options:
Option | Description |
---|---|
|
The command or script is run only on the specified instances. Specify just one instance with Use host names and instance names as defined in the model. You do not have to include the instance name if it is the only instance on the host. |
|
The command or script is run on all instances in the grid except for those specified. Specify just one instance with Use host names and instance names as defined in the model. You do not have to include the instance name if it is the only instance on the host. |
|
Specifies that the command or script runs on no more than |
|
Specifies whether the command or script is run on all instances (the default), only management instances, or only data instances. This can be used in combination with |
|
Specifies that the command or script is run only on instances that are part of the current membership. The default is to run commands on all instances (whether they are running or not). |
|
Or:
|
Examples
On each data instance, this example creates directories databases
and logs
under /data
(with no error if the directories already exist).
% ttGridAdmin instanceExec -type data mkdir -p /data/{databases,logs} Overall return code: 0 Commands executed on: mysys6host.griddata4 rc 0 mysys5host.griddata3 rc 0 mysys3host.griddata1 rc 0 mysys4host.griddata2 rc 0 Return code from mysys6host.griddata4: 0 Output from mysys6host.griddata4: Return code from mysys5host.griddata3: 0 Output from mysys5host.griddata3: Return code from mysys3host.griddata1: 0 Output from mysys3host.griddata1: Return code from mysys4host.griddata2: 0 Output from mysys4host.griddata2:
This example starts the TimesTen daemon on mysys5host.griddata3
(useful, for example, if the element on that instance went down).
% ttGridAdmin instanceExec -only mysys5host.griddata3 ttDaemonAdmin -start Overall return code: 0 Commands executed on: mysys5host.griddata3 rc 0 Return code from mysys5host.griddata3: 0 Output from mysys5host.griddata3: TimesTen Daemon (PID: 7586, port: 6624) startup OK.
For each data instance, this example runs the ttIsql monitor
command then exits ttIsql
. (Only selected portions of the ttIsql
connection output and monitoring output are shown.)
% ttGridAdmin instanceExec -type data 'ttIsql -e "monitor;quit" -dsn database1' Overall return code: 0 Commands executed on: mysys4host.griddata2 rc 0 mysys5host.griddata3 rc 0 mysys6host.griddata4 rc 0 mysys3host.griddata1 rc 0 Return code from mysys4host.griddata2: 0 Output from mysys4host.griddata2: Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=database1"; Connection successful: DSN=database1;... monitor; TIME_OF_1ST_CONNECT: Fri Aug 3 13:47:42 2018 ... PERM_ALLOCATED_SIZE: 262144 PERM_IN_USE_SIZE: 29997 PERM_IN_USE_HIGH_WATER: 29997 TEMP_ALLOCATED_SIZE: 131072 TEMP_IN_USE_SIZE: 19146 TEMP_IN_USE_HIGH_WATER: 22352 ... quit; Disconnecting... Done. Return code from mysys5host.griddata3: 0 Output from mysys5host.griddata3: Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=database1"; Connection successful: DSN=database1;... monitor; TIME_OF_1ST_CONNECT: Fri Aug 3 13:47:41 2018 ... PERM_ALLOCATED_SIZE: 262144 PERM_IN_USE_SIZE: 29916 PERM_IN_USE_HIGH_WATER: 29932 TEMP_ALLOCATED_SIZE: 131072 TEMP_IN_USE_SIZE: 19613 TEMP_IN_USE_HIGH_WATER: 22819 ... quit; Disconnecting... Done. Return code from mysys6host.griddata4: 0 Output from mysys6host.griddata4: Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=database1"; Connection successful: DSN=database1;... monitor; TIME_OF_1ST_CONNECT: Fri Aug 3 13:47:41 2018 ... PERM_ALLOCATED_SIZE: 262144 PERM_IN_USE_SIZE: 29981 PERM_IN_USE_HIGH_WATER: 29981 TEMP_ALLOCATED_SIZE: 131072 TEMP_IN_USE_SIZE: 19344 TEMP_IN_USE_HIGH_WATER: 22550 ... quit; Disconnecting... Done. Return code from mysys3host.griddata1: 0 Output from mysys3host.griddata1: Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. Type ? or "help" for help, type "exit" to quit ttIsql. connect "DSN=database1"; Connection successful: DSN=database1;... monitor; TIME_OF_1ST_CONNECT: Fri Aug 3 13:47:40 2018 ... PERM_ALLOCATED_SIZE: 262144 PERM_IN_USE_SIZE: 29965 PERM_IN_USE_HIGH_WATER: 29965 TEMP_ALLOCATED_SIZE: 131072 TEMP_IN_USE_SIZE: 19281 TEMP_IN_USE_HIGH_WATER: 22486 ... quit; Disconnecting... Done.
Notes
-
The command or script is run as the instance administrator on each instance, through passwordless SSH.
-
Environment variables (such as
TIMESTEN_HOME
,CLASSPATH
,PATH
, andLD_LIBRARY_PATH
) are set appropriately for each instance. -
The command returns 2000 if execution did not complete prior to the timeout.
-
During execution,
stdout
andstderr
output is displayed as part of thestdout
andstderr
output from theinstanceExec
command. Because output is buffered, the output from different commands is not intermingled.