super(ClusterAutoDeployCommand,self).__init__('autodeploy','Deploy a cluster automatically by using a simple configuration file.')
self.parser.add_option('-c','--config',type='string',help="Path to the configuration file.")
self.parser.add_option('-f','--force',action='store_true',help="Force autodeploy, overwrite the home_path.")
self.parser.add_option('-U','--unuselibrepo','--ulp',action='store_true',help="Disable OBD from installing the libs mirror automatically.")
self.parser.add_option('-A','--auto-create-tenant','--act',action='store_true',help="Disable OBD from creating a tenant named `test` by using all the available resource of the cluster.")
self.parser.add_option('--force-delete',action='store_true',help="Force delete, delete the registered cluster.")
self.parser.add_option('-s','--strict-check',action='store_true',help="Throw errors instead of warnings when check fails.")
self.parser.add_option('-f','--force',action='store_true',help="remove all when home_path is not empty",default=False)
self.parser.add_option('-U','--unuselibrepo','--ulp',action='store_true',help="obd will not install libs when library is not found")
super(ClusterDeployCommand,self).__init__('deploy','Deploy a cluster by using the current deploy configuration or a deploy yaml file.')
self.parser.add_option('-c','--config',type='string',help="Path to the configuration yaml file.")
self.parser.add_option('-f','--force',action='store_true',help="Force deploy, overwrite the home_path.",default=False)
self.parser.add_option('-U','--unuselibrepo','--ulp',action='store_true',help="Disable OBD from installing the libs mirror automatically.")
self.parser.add_option('-A','--auto-create-tenant','--act',action='store_false',help="Disable OBD from creating a tenant named `test` by using all the available resource of the cluster.")
# self.parser.add_option('-F', '--fuzzymatch', action='store_true', help="enable fuzzy match when search package")
def_do_command(self,obd):
...
...
@@ -312,9 +365,11 @@ class ClusterDeployCommand(ClusterMirrorCommand):
classClusterStartCommand(ClusterMirrorCommand):
def__init__(self):
super(ClusterStartCommand,self).__init__('start','start a cluster had deployed')
self.parser.add_option('-f','--force-delete',action='store_true',help="cleanup when cluster had registered")
self.parser.add_option('-s','--strict-check',action='store_true',help="prompt for errors instead of warnings when the check fails")
super(ClusterStartCommand,self).__init__('start','Start a deployed cluster.')
self.parser.add_option('-s','--servers',type='string',help="List the started servers. Multiple servers are separated with commas.")
self.parser.add_option('-c','--components',type='string',help="List the started components. Multiple components are separated with commas.")
self.parser.add_option('-f','--force-delete',action='store_true',help="Force delete, delete the registered cluster.")
self.parser.add_option('-S','--strict-check',action='store_true',help="Throw errors instead of warnings when check fails.")
def_do_command(self,obd):
ifself.cmds:
...
...
@@ -326,11 +381,13 @@ class ClusterStartCommand(ClusterMirrorCommand):
classClusterStopCommand(ClusterMirrorCommand):
def__init__(self):
super(ClusterStopCommand,self).__init__('stop','stop a cluster had started')
super(ClusterStopCommand,self).__init__('stop','Stop a started cluster.')
self.parser.add_option('-s','--servers',type='string',help="List the started servers. Multiple servers are separated with commas.")
self.parser.add_option('-c','--components',type='string',help="List the started components. Multiple components are separated with commas.")
def_do_command(self,obd):
ifself.cmds:
returnobd.stop_cluster(self.cmds[0])
returnobd.stop_cluster(self.cmds[0],self.opts)
else:
returnself._show_help()
...
...
@@ -338,8 +395,8 @@ class ClusterStopCommand(ClusterMirrorCommand):
classClusterDestroyCommand(ClusterMirrorCommand):
def__init__(self):
super(ClusterDestroyCommand,self).__init__('destroy','start a cluster had deployed')
self.parser.add_option('-f','--force-kill',action='store_true',help="force kill when observer is running")
super(ClusterDestroyCommand,self).__init__('destroy','Destroy a started cluster.')
self.parser.add_option('-f','--force-kill',action='store_true',help="Force kill the running observer process in the working directory.")
def_do_command(self,obd):
ifself.cmds:
...
...
@@ -351,7 +408,7 @@ class ClusterDestroyCommand(ClusterMirrorCommand):
classClusterDisplayCommand(ClusterMirrorCommand):
def__init__(self):
super(ClusterDisplayCommand,self).__init__('display','display a cluster info')
super(ClusterDisplayCommand,self).__init__('display','Display the information for a cluster.')
def_do_command(self,obd):
ifself.cmds:
...
...
@@ -363,11 +420,13 @@ class ClusterDisplayCommand(ClusterMirrorCommand):
classClusterRestartCommand(ClusterMirrorCommand):
def__init__(self):
super(ClusterRestartCommand,self).__init__('restart','restart a cluster had started')
super(ClusterRestartCommand,self).__init__('restart','Restart a started cluster.')
self.parser.add_option('-s','--servers',type='string',help="List the started servers. Multiple servers are separated with commas.")
self.parser.add_option('-c','--components',type='string',help="List the started components. Multiple components are separated with commas.")
def_do_command(self,obd):
ifself.cmds:
returnobd.restart_cluster(self.cmds[0])
returnobd.restart_cluster(self.cmds[0],self.opts)
else:
returnself._show_help()
...
...
@@ -375,8 +434,8 @@ class ClusterRestartCommand(ClusterMirrorCommand):
self.parser.add_option('-s','--variables',type='string',help="Set the variables for the system tenant. [ob_tcp_invited_nodes='%']",default="ob_tcp_invited_nodes='%'")
super(MySQLTestCommand,self).__init__('mysqltest','run mysqltest for a deploy')
self.parser.add_option('--component',type='string',help='the component for mysqltest')
self.parser.add_option('--test-server',type='string',help='the server for mysqltest, default the first root server in the component')
self.parser.add_option('--user',type='string',help='username for test',default='admin')
self.parser.add_option('--password',type='string',help='password for test',default='admin')
self.parser.add_option('--database',type='string',help='database for test',default='test')
self.parser.add_option('--mysqltest-bin',type='string',help='mysqltest bin path',default='/u01/obclient/bin/mysqltest')
self.parser.add_option('--obclient-bin',type='string',help='obclient bin path',default='obclient')
self.parser.add_option('--test-dir',type='string',help='test case file directory',default='./mysql_test/t')
self.parser.add_option('--result-dir',type='string',help='result case file directory',default='./mysql_test/r')
self.parser.add_option('--record-dir',type='string',help='the directory of the result file for mysqltest')
self.parser.add_option('--log-dir',type='string',help='the directory of the log file',default='./log')
self.parser.add_option('--tmp-dir',type='string',help='tmp dir to use when run mysqltest',default='./tmp')
self.parser.add_option('--var-dir',type='string',help='var dir to use when run mysqltest',default='./var')
super(MySQLTestCommand,self).__init__('mysqltest','Run mysqltest for a deployment.')
self.parser.add_option('--component',type='string',help='The component for mysqltest.')
self.parser.add_option('--test-server',type='string',help='The server for mysqltest. By default, the first root server in the component is the mysqltest server.')
self.parser.add_option('--user',type='string',help='Username for a test. [admin]',default='admin')
self.parser.add_option('--password',type='string',help='Password for a test. [admin]',default='admin')
self.parser.add_option('--database',type='string',help='Database for a test. [test]',default='test')
self.parser.add_option('--mysqltest-bin',type='string',help='Mysqltest bin path. [/u01/obclient/bin/mysqltest]',default='/u01/obclient/bin/mysqltest')
self.parser.add_option('--obclient-bin',type='string',help='OBClient bin path. [obclient]',default='obclient')
self.parser.add_option('--test-dir',type='string',help='Test case file directory. [./mysql_test/t]',default='./mysql_test/t')
self.parser.add_option('--result-dir',type='string',help='Result case file directory. [./mysql_test/r]',default='./mysql_test/r')
self.parser.add_option('--record-dir',type='string',help='The directory of the result file for mysqltest.')
@@ -495,11 +609,44 @@ class MySQLTestCommand(TestMirrorCommand):
returnself._show_help()
classSysBenchCommand(TestMirrorCommand):
def__init__(self):
super(SysBenchCommand,self).__init__('sysbench','Run sysbench for a deployment.')
self.parser.add_option('--component',type='string',help='The component for mysqltest.')
self.parser.add_option('--test-server',type='string',help='The server for mysqltest. By default, the first root server in the component is the mysqltest server.')
self.parser.add_option('--user',type='string',help='Username for a test. [root]',default='root')
self.parser.add_option('--password',type='string',help='Password for a test.')
self.parser.add_option('--tenant',type='string',help='Tenant for a test. [test]',default='test')
self.parser.add_option('--database',type='string',help='Database for a test. [test]',default='test')
self.parser.add_option('--obclient-bin',type='string',help='OBClient bin path. [obclient]',default='obclient')
self.parser.add_option('--sysbench-bin',type='string',help='Sysbench bin path. [sysbench]',default='sysbench')
self.parser.add_option('--sysbench-script-dir',type='string',help='The directory of the sysbench lua script file. [/usr/sysbench/share/sysbench]',default='/usr/sysbench/share/sysbench')
self.parser.add_option('--table-size',type='int',help='Number of data initialized per table. [20000]',default=20000)
self.parser.add_option('--tables',type='int',help='Number of initialization tables. [30]',default=30)
self.parser.add_option('--threads',type='int',help='Number of threads to use. [32]',default=16)
self.parser.add_option('--time',type='int',help='Limit for total execution time in seconds. [60]',default=60)
self.parser.add_option('--interval',type='int',help='Periodically report intermediate statistics with a specified time interval in seconds. 0 disables intermediate reports. [10]',default=10)
self.parser.add_option('--events',type='int',help='Limit for total number of events.')
self.parser.add_option('--rand-type',type='string',help='Random numbers distribution {uniform,gaussian,special,pareto}.')
self.parser.add_option('--percentile',type='int',help='Percentile to calculate in latency statistics. Available values are 1-100. 0 means to disable percentile calculations.')
self.parser.add_option('--skip-trx',dest='{on/off}',type='string',help='Open or close a transaction in a read-only test. ')
self._call_stdio('error','Deploy configuration is empty.\nIt may be caused by a failure to resolve the configuration.\nPlease check your configuration file.')
returnFalse
# Check the best suitable mirror for the components and installation plguins. Install locally
# Please don't use hostname, only IP can be supported
ip:192.168.1.2
-name:z2
ip:192.168.1.3
-name:z3
ip:192.168.1.4
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path:/root/observer
# The directory for data storage. The default value is $home_path/store.
# data_dir: /data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
# External port for OceanBase Database. The default value is 2881.
# mysql_port: 2881
# Internal port for OceanBase Database. The default value is 2882.
# rpc_port: 2882
# Defines the zone for an observer. The default value is zone1.
# zone: zone1
# The maximum running memory for an observer. When ignored, autodeploy calculates this value based on the current server available resource.
# memory_limit: 58G
# The percentage of the maximum available memory to the total memory. This value takes effect only when memory_limit is 0. The default value is 80.
# memory_limit_percentage: 80
# The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. Autodeploy calculates this value based on the current server available resource.
# system_memory: 22G
# The size of a data file. When ignored, autodeploy calculates this value based on the current server available resource.
# datafile_size: 200G
# The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
# datafile_disk_percentage: 90
# System log level. The default value is INFO.
# syslog_level: INFO
# Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. The default value for autodeploy mode is false.
# enable_syslog_wf: false
# Enable auto system log recycling or not. The default value is false. The default value for autodeploy mode is on.
# enable_syslog_recycle: true
# The maximum number of reserved log files before enabling auto recycling. When set to 0, no logs are deleted. The default value for autodeploy mode is 4.
# max_syslog_file_count: 4
# Cluster name for OceanBase Database. The default value is obcluster. When you deploy OceanBase Database and obproxy, this value must be the same as the cluster_name for obproxy.
# appname: obcluster
# Password for root. The default value is empty.
# root_password:
# Password for proxyro. proxyro_password must be the same as observer_sys_password. The default value is empty.
# proxyro_password:
z1:
zone:zone1
z2:
zone:zone2
z3:
zone:zone3
obproxy:
servers:
-192.168.1.5
global:
# The working directory for obproxy. Obproxy is started under this directory. This is a required field.
home_path:/root/obproxy
# External port. The default value is 2883.
# listen_port: 2883
# The Prometheus port. The default value is 2884.
# prometheus_listen_port: 2884
# rs_list is the root server list for observers. The default root server is the first server in the zone.
# The format for rs_list is observer_ip:observer_mysql_port;observer_ip:observer_mysql_port.
# Ignore this value in autodeploy mode.
# rs_list: 127.0.0.1:2881
# Cluster name for the proxy OceanBase Database. The default value is obcluster. This value must be set to the same with the appname for OceanBase Database.
# cluster_name: obcluster
# Password for obproxy system tenant. The default value is empty.
# obproxy_sys_password:
# Password for proxyro. proxyro_password must be the same with proxyro_password. The default value is empty.
# Please don't use hostname, only IP can be supported
-192.168.1.3
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path:/root/observer
# The directory for data storage. The default value is $home_path/store.
# data_dir: /data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
# External port for OceanBase Database. The default value is 2881.
# mysql_port: 2881
# Internal port for OceanBase Database. The default value is 2882.
# rpc_port: 2882
# Defines the zone for an observer. The default value is zone1.
# zone: zone1
# The maximum running memory for an observer. When ignored, autodeploy calculates this value based on the current server available resource.
# memory_limit: 58G
# The percentage of the maximum available memory to the total memory. This value takes effect only when memory_limit is 0. The default value is 80.
# memory_limit_percentage: 80
# The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. Autodeploy calculates this value based on the current server available resource.
# system_memory: 22G
# The size of a data file. When ignored, autodeploy calculates this value based on the current server available resource.
# datafile_size: 200G
# The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
# datafile_disk_percentage: 90
# System log level. The default value is INFO.
# syslog_level: INFO
# Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. The default value for autodeploy mode is false.
# enable_syslog_wf: false
# Enable auto system log recycling or not. The default value is false. The default value for autodeploy mode is on.
# enable_syslog_recycle: true
# The maximum number of reserved log files before enabling auto recycling. When set to 0, no logs are deleted. The default value for autodeploy mode is 4.
# max_syslog_file_count: 4
# Cluster name for OceanBase Database. The default value is obcluster. When you deploy OceanBase Database and obproxy, this value must be the same as the cluster_name for obproxy.
# appname: obcluster
# Password for root. The default value is empty.
# root_password:
# Password for proxyro. proxyro_password must be the same as observer_sys_password. The default value is empty.
# Please don't use hostname, only IP can be supported
-192.168.1.3
global:
# The working directory for OceanBase Database. OceanBase Database is started under this directory. This is a required field.
home_path:/root/observer
# The directory for data storage. The default value is $home_path/store.
# data_dir: /data
# The directory for clog, ilog, and slog. The default value is the same as the data_dir value.
# redo_dir: /redo
# External port for OceanBase Database. The default value is 2881.
# mysql_port: 2881
# Internal port for OceanBase Database. The default value is 2882.
# rpc_port: 2882
# Defines the zone for an observer. The default value is zone1.
# zone: zone1
# The maximum running memory for an observer. When ignored, autodeploy calculates this value based on the current server available resource.
# memory_limit: 58G
# The percentage of the maximum available memory to the total memory. This value takes effect only when memory_limit is 0. The default value is 80.
# memory_limit_percentage: 80
# The reserved system memory. system_memory is reserved for general tenants. The default value is 30G. Autodeploy calculates this value based on the current server available resource.
# system_memory: 22G
# The size of a data file. When ignored, autodeploy calculates this value based on the current server available resource.
# datafile_size: 200G
# The percentage of the data_dir space to the total disk space. This value takes effect only when datafile_size is 0. The default value is 90.
# datafile_disk_percentage: 90
# System log level. The default value is INFO.
# syslog_level: INFO
# Print system logs whose levels are higher than WARNING to a separate log file. The default value is true. The default value for autodeploy mode is false.
# enable_syslog_wf: false
# Enable auto system log recycling or not. The default value is false. The default value for autodeploy mode is on.
# enable_syslog_recycle: true
# The maximum number of reserved log files before enabling auto recycling. When set to 0, no logs are deleted. The default value for autodeploy mode is 4.
# max_syslog_file_count: 4
# Cluster name for OceanBase Database. The default value is obcluster. When you deploy OceanBase Database and obproxy, this value must be the same as the cluster_name for obproxy.
# appname: obcluster
# Password for root. The default value is empty.
# root_password:
# Password for proxyro. proxyro_password must be the same as observer_sys_password. The default value is empty.
# proxyro_password:
obproxy:
servers:
-192.168.1.2
global:
# The working directory for obproxy. Obproxy is started under this directory. This is a required field.
home_path:/root/obproxy
# External port. The default value is 2883.
# listen_port: 2883
# The Prometheus port. The default value is 2884.
# prometheus_listen_port: 2884
# rs_list is the root server list for observers. The default root server is the first server in the zone.
# The format for rs_list is observer_ip:observer_mysql_port;observer_ip:observer_mysql_port.
# Ignore this value in autodeploy mode.
# rs_list: 127.0.0.1:2881
# Cluster name for the proxy OceanBase Database. The default value is obcluster. This value must be set to the same with the appname for OceanBase Database.
# cluster_name: obcluster
# Password for obproxy system tenant. The default value is empty.
# obproxy_sys_password:
# Password for proxyro. proxyro_password must be the same with proxyro_password. The default value is empty.
description_en:the number of CPUs in the system. If this parameter is set to zero, the number will be set according to sysconf; otherwise, this parameter is used.