Administering servers in the grid with the SQL administration API
You can run SQL administration API commands in grid routines to perform administrative tasks on all servers in the grid.
About this task
The grid must exist and you must run the grid routines as an authorized user from an authorized server and while connected to the sysadmin database.
Procedure
- Run the ifx_grid_function() function with the SQL administration API command as the second argument.
- Check the return code of the SQL administration API command
to determine if it succeeded by running the cdr list grid command.The cdr list grid command shows the return code. The status of the ifx_grid_function() function can be ACK, which indicates success, even if the SQL administration API command failed.
Results
Examples
The following examples must be run in the sysadmin database.
Example 1: Change a configuration parameter setting
The following example sets the maximum size of the log staging directory to 100 KB on all the servers in the grid:
EXECUTE FUNCTION ifx_grid_function('grid1',
'admin("set onconfig permanent",
"CDR_LOG_STAGING_MAXSIZE","100")');
The output of the cdr list grid command shows that the admin() function succeeded because the return codes are positive numbers:
Grid Node User
------------------ ------------------ ----------------
grid1 cdr1* bill
cdr2
cdr3
Details for grid grid1
Node:cdr1 Stmtid:1 User:dba1 Database:tstdb 2010-05-27 15:21:57
Tag:test
admin("set onconfig permanent",
"CDR_LOG_STAGING_MAXSIZE","100")
ACK cdr1 2010-05-27 15:21:57
'110'
ACK cdr2 2010-05-27 15:21:58
'111'
ACK cdr3 2010-05-27 15:21:58
'112'
Example 2: Create a new dbspace
The following example creates a new dbspace on all the servers in the grid1 grid:
EXECUTE FUNCTION ifx_grid_function('grid1',
'task("create dbspace","dbsp2",
"/db/chunks/dbsp2","2G","0")');
The output of the cdr list grid command shows that the task() function failed:
Grid Node User
------------------ ------------------ ----------------
grid1 cdr1* bill
cdr2
cdr3
Details for grid grid1
Node:cdr1 Stmtid:1 User:dba1 Database:tstdb 2010-05-27 15:21:57
Tag:test
task("create dbspace","dbsp2",
"/db/chunks/dbsp2","2G","0"
ACK cdr1 2010-05-27 15:21:57
'Unable to create file /db/chunks/dbsp2'
ACK cdr2 2010-05-27 15:21:58
'Unable to create file /db/chunks/dbsp2'
ACK cdr3 2010-05-27 15:21:58
'Unable to create file /db/chunks/dbsp2'