Versions available for this page: CUBRID 8.4.3 | CUBRID 9.0.0 |
By using the CUBRID SHARD utility, CUBRID SHARD can be started or stopped and various status information can be retrieved.
To start the CUBRID SHARD, enter the following:
% cubrid shard start
@ cubrid shard start
++ cubrid shard start: success
If the CUBRID SHARD has already been started, the following message will appear:
% cubrid shard start
@ cubrid shard start
++ cubrid shard is running.
While executing cubrid shard start, the information of the CUBRID SHARD configuration file (shard.conf) are read to start all components of the configuration. All metadata DBs and shard DBs should be started before starting the CUBRID SHARD because it accesses them.
Enter the following to stop the CUBRID SHARD.
% cubrid shard stop
@ cubrid shard stop
++ cubrid shard stop: success
If the CUBRID SHARD has already been stopped, the following message will appear:
$ cubrid shard stop
@ cubrid shard stop
++ cubrid shard is not running.
You can configure the parameters related to running CUBRID SHARD in the environment configuration file (shard.conf). Additionally, you can some CUBRID SHARD parameters while it is running by using the shard_broker_changer utility. For details about configuration of CUBRID SHARD parameters and dynamically changeable parameters see CUBRID SHARD > Configuration.
The shard_broker_changer syntax used to change parameter while CUBRID SHARD is running is as follows: Enter the name of CUBRID SHARD running in shard-name and enter dynamically changeable parameters in parameter. value must be specified based on the parameter to be modified. You can apply changes in a specific CUBRID SHARD by specifying an identifier of CUBRID SHARD. proxy-number represents PROXY-ID displayed in the cubrid shard status command.
shard_broker_changer shard-name [proxy-number] parameter value
Even though SQL logs are recorded in CUBRID SHARD which is running, you need to enter as follows to configure the SQL_LOG parameter to ON so that SQL logs are recorded in CUBRID SHARD running. Such dynamic parameter change is effective only while CUBRID SHARD is running.
% shard_broker_changer shard1 sql_log on
OK
cubrid shard status provides a variety of options to check the status information of each shard broker, shard proxy, and shard cas. In addition, it is possible to check the metadata information and the information on the client who has accessed the shard proxy.
<When expr> is given, the status monitoring is performed for the corresponding CUBRID SHARD. When it is omitted, status monitoring is performed for all CUBRID SHARDs registered to the CUBRID SHARD configuration file (shard.conf).
cubrid shard status options [<expr>]
options : [-b | -f [-l sec] | -t | -c | -m | -s <sec>]
The following table shows options that can be used together with cubrid broker status.
|
Option |
Description |
|---|---|
|
<expr> |
Displays the status information for the CUBRID SHARD whose name includes <expr>. If the name is not specified, displays the status information for all CUBRID SHARDs. |
|
-b |
Displays the status information for the CUBRID broker excluding the information on the CUBRID proxy or the CUBRID CAS. |
|
-c |
Displays the information on the client which has accessed the CUBRID proxy. |
|
-m |
Displays the metadata information. |
|
-t |
Displays in tty mode. The output content can be redirected to a file. |
|
-f [-l secs] |
Displays more detailed information on the CUBRID SHARD. |
|
-s secs |
Periodically displays the status information for the CUBRID SHARD at a specified time. Returns to the command prompt if q is entered. |
If no options or parameters are given to check the status of all CUBRID SHARDs, the following will be displayed as a result:
@ cubrid shard status
% test_shard - shard_cas [2576,45000] /home/CUBRID/log/broker/test_shard.err
JOB QUEUE:0, AUTO_ADD_APPL_SERVER:ON, SQL_LOG_MODE:ALL:100000
LONG_TRANSACTION_TIME:60.00, LONG_QUERY_TIME:60.00, SESSION_TIMEOUT:10
KEEP_CONNECTION:AUTO, ACCESS_MODE:RW
----------------------------------------------------------------
PROXY_ID SHARD_ID CAS_ID PID QPS LQS PSIZE STATUS
----------------------------------------------------------------
1 1 1 2580 100 3 55968 IDLE
1 2 1 2581 200 4 55968 IDLE
To check the status of the shard broker, enter the following:
$ cubrid shard status -b
@ cubrid shard status
NAME PID PORT Active-P Active-C REQ TPS QPS K-QPS NK-QPS LONG-T LONG-Q ERR-Q
==========================================================================================================
* test_shard 3548 45000 1 2 0 0 0 0 0 0/60.0 0/60.0 0
To check details on the status of the shard broker, enter as follows:
$ cubrid shard status -b -f
@ cubrid shard status
NAME PID PSIZE PORT Active-P Active-C REQ TPS QPS K-QPS (H-KEY H-ID H-ALL) NK-QPS LONG-T LONG-Q ERR-Q CANCELED ACCESS_MODE SQL_LOG
======================================================================================================================================================================
* test_shard 3548 100644 45000 1 2 0 0 0 0 0 0 0 0 0/60.0 0/60.0 0 0 RW ALL
By using the -s option, enter the monitoring interval of the shard broker which includes test_shard, and then enter the following to monitor the shard broker status periodically. If test_shard is not entered as a parameter,the status monitoring is periodically made for all shard brokers. If q is entered, the monitoring screen returns to the command prompt.
$ cubrid shard status -b test_shard -s 1 -t
@ cubrid shard status
NAME PID PORT Active-P Active-C REQ TPS QPS K-QPS NK-QPS LONG-T LONG-Q ERR-Q
==========================================================================================================
* test_shard 3548 45000 1 2 0 0 0 0 0 0/60.0 0/60.0 0
Output TPS and QPS information to a file by using the -t option. To stop the output as a file, press <Ctrl+C> to stop the program.
% cubrid shard status -b -s 1 -t > log_file
Output the metadata information by using the -m option. For details on the parameter of shard.conf, see Default Configuration File shard.conf.
$ cubrid shard status -m
@ cubrid shard status
% test_shard [299009]
MODULAR : 256, LIBRARY_NAME : NOT DEFINED, FUNCTION_NAME : NOT DEFINED
SHARD STATISTICS
ID NUM-KEY-Q NUM-ID-Q NUM-NO-HINT-Q SUM
-----------------------------------------------------
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
Use the -m -f option to display more detailed metadata information. For details on the parameter of shard.conf, see Default Configuration File shard.conf.
$ cubrid shard status –m -f
@ cubrid shard status
% test_shard [299009]
MODULAR : 256, LIBRARY_NAME : NOT DEFINED, FUNCTION_NAME : NOT DEFINED
SHARD : 0 [HostA] [shard1], 1 [HostB] [shard1], 2 [HostC] [shard1], 3 [HostD] [shard1]
SHARD STATISTICS
ID NUM-KEY-Q NUM-ID-Q NUM-NO-HINT-Q SUM
-----------------------------------------------------
0 0 0 0 0
1 0 0 0 0
2 0 0 0 0
3 0 0 0 0
RANGE STATISTICS : user_no
MIN ~ MAX : SHARD NUM-Q
------------------------------------
0 ~ 31 : 0 0
32 ~ 63 : 1 0
64 ~ 95 : 2 0
96 ~ 127 : 3 0
128 ~ 159 : 0 0
160 ~ 191 : 1 0
192 ~ 223 : 2 0
224 ~ 255 : 3 0
DB Alias : shard1 [USER : shard, PASSWD : shard123]
Displays the information on the client that has accessed the shard proxy by using the -c option.
$ cubrid shard status -c
@ cubrid shard status
% test_shard(0), MAX-CLIENT : 10000
------------------------------------------------------------------------------------------------
CLIENT-ID CLIENT-IP CONN-TIME L-REQ-TIME L-RES-TIME
------------------------------------------------------------------------------------------------
0 10.24.18.68 2011/12/15 16:33:31 2011/12/15 16:33:31 2011/12/15 16:33:31
To limit the applications to access shard proxy, the ACCESS_CONTROL of the cubrid_shard.conf should set to ON and enter a file name where the list of users, databases, and IPs of which access is access is permitted ot the ACCESS_CONTROL_FILE parameter is stored. The default value of ACCESS_CONTROL parameter is OFF.
The ACCESS_CONTROL and ACCESS_CONTROL_FILE parameters should be written under [shard] which are located in common parameters.
The format of ACCESS_CONTROL_FILE is as follows:
[%<shard_name>]
<db_name>:<db_user>:<ip_list_file>
…
You can additionally specify [%<broker_name>] and <db_name>:<db_user>:<ip_list_file> for each shard proxy and separate line can be added for the same <db_name> and <db_user>.
The format of writing ip_list_file is as follows:
<ip_addr>
…
While the value of ACCESS_CONTROL is ON and ACCESS_CONTROL_FILE is not specified, shard proxy allows access request from localhost. When running shard proxy and if it analysis of ACCESS_CONTROL_FILE and ip_list_file is faled, shard proxy allows access request only from localhost.
When running shard proxy and if it analysis of ACCESS_CONTROL_FILE and ip_list_file is faled, shard proxy does not run.
# cubrid_broker.conf
[broker]
MASTER_SHM_ID =30001
ADMIN_LOG_FILE =log/broker/cubrid_broker.log
ACCESS_CONTROL =ON
ACCESS_CONTROL_FILE =/home1/cubrid/access_file.txt
[%QUERY_EDITOR]
SERVICE =ON
BROKER_PORT =30000
......
The following is an example of ACCESS_CONTROL_FILE. * means everything; it can be used when you specifying the database name, database user ID, and the list of IP list file.
[%QUERY_EDITOR]
dbname1:dbuser1:READIP.txt
dbname1:dbuser2:WRITEIP1.txt,WRITEIP2.txt
*:dba:READIP.txt
*:dba:WRITEIP1.txt
*:dba:WRITEIP2.txt
[%SHARD2]
dbname:dbuser:iplist2.txt
[%SHARD3]
dbname:dbuser:iplist2.txt
[%SHARD4]
dbname:dbuser:iplist2.txt
The shard proxy specified above is QUERY_EDITOR, SHARD2, and SHARD3, SHARD4.
The QUERY_EDITOR shard proxy allows only access of the same applications.
The following shows how to configure IPs accessible in ip_list_file.
192.168.1.25
192.168.*
10.*
*
The IPs specified above are as follows:
For shard proxy which has been running, you can re-apply configuration by using the following command or check the current status.
To apply changes to server after database, database user ID, and IP allowed in shard proxy is configured, use the following command.
cubrid shard acl reload [<SP_NAME>]
To output IP configuration of which database, database user ID, and IP allowed in shard proxy to screen, use the following command.
cubrid shard acl status [<SP_NAME>]
Note For details, see Limiting Database Server Access.
Enter the following to run shard1.
$ cubrid shard on shard1
If shard1 is not configured in shared memory, the following message will output.
% cubrid shard on shard1
Cannot open shared memory
To exit shard1, enter the following.
$ cubrid shard off shard1
To restart shard1, enter the following.
$ cubrhd shard restart shard1
The shard proxy reset feature disconnects exiting connection and makes new connection when shard proxy is connected unwanted database server due to failover in HA. If SHARD_DB_NAME, SHARD_DB_USER, SHARD_DB_PASSWORD is changed dynamically, it will try to connect with the changed value.
% cubrid shard reset shard1