From edf25d3841cd6d400a45bcf70da707e09b17213d Mon Sep 17 00:00:00 2001 From: Rongfeng Fu Date: Tue, 10 Aug 2021 19:47:57 +0800 Subject: [PATCH] migrate check (#33) --- _cmd.py | 2 +- .../mysqltest/3.1.0/init_sql/init_tenant.sql | 7 --- .../mysqltest/3.1.0/init_sql/init_tpch.sql | 46 ------------------- .../3.1.0/init_sql/init_user_oracle.sql | 27 ----------- .../mysqltest/3.1.0/r/oracle/chinese.result | 16 ------- plugins/oceanbase/3.1.0/create_tenant.py | 19 ++++++++ 6 files changed, 20 insertions(+), 97 deletions(-) delete mode 100644 plugins/mysqltest/3.1.0/init_sql/init_tenant.sql delete mode 100644 plugins/mysqltest/3.1.0/init_sql/init_tpch.sql delete mode 100644 plugins/mysqltest/3.1.0/init_sql/init_user_oracle.sql delete mode 100644 plugins/mysqltest/3.1.0/r/oracle/chinese.result diff --git a/_cmd.py b/_cmd.py index b208c26..42f6f56 100644 --- a/_cmd.py +++ b/_cmd.py @@ -352,7 +352,7 @@ class ClusterDeployCommand(ClusterMirrorCommand): 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('-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('-F', '--fuzzymatch', action='store_true', help="enable fuzzy match when search package") def _do_command(self, obd): diff --git a/plugins/mysqltest/3.1.0/init_sql/init_tenant.sql b/plugins/mysqltest/3.1.0/init_sql/init_tenant.sql deleted file mode 100644 index 5935173..0000000 --- a/plugins/mysqltest/3.1.0/init_sql/init_tenant.sql +++ /dev/null @@ -1,7 +0,0 @@ -create resource unit box1 max_cpu 2, max_memory 1073741824, max_iops 128, max_disk_size '5G', max_session_num 64, MIN_CPU=1, MIN_MEMORY=1073741824, MIN_IOPS=128; -create resource pool pool1 unit = 'box1', unit_num = 1; -create tenant ora_tt replica_num = 1, resource_pool_list=('pool1') set ob_tcp_invited_nodes='%', ob_compatibility_mode='oracle'; -alter tenant ora_tt set variables autocommit='on'; -alter tenant ora_tt set variables nls_date_format='YYYY-MM-DD HH24:MI:SS'; -alter tenant ora_tt set variables nls_timestamp_format='YYYY-MM-DD HH24:MI:SS.FF'; -alter tenant ora_tt set variables nls_timestamp_tz_format='YYYY-MM-DD HH24:MI:SS.FF TZR TZD'; \ No newline at end of file diff --git a/plugins/mysqltest/3.1.0/init_sql/init_tpch.sql b/plugins/mysqltest/3.1.0/init_sql/init_tpch.sql deleted file mode 100644 index 2d203fe..0000000 --- a/plugins/mysqltest/3.1.0/init_sql/init_tpch.sql +++ /dev/null @@ -1,46 +0,0 @@ -system sleep 5; -alter system set balancer_idle_time = '60s'; -create user 'admin' IDENTIFIED BY 'admin'; -use oceanbase; -create database if not exists test; - -use test; -grant all on *.* to 'admin' WITH GRANT OPTION; - - -set global ob_enable_jit='OFF'; -alter system set large_query_threshold='1s'; -alter system set syslog_level='info'; -alter system set syslog_io_bandwidth_limit='30M'; -alter system set trx_try_wait_lock_timeout='0'; -alter system set zone_merge_concurrency=0; -alter system set merger_completion_percentage=100; -alter system set trace_log_slow_query_watermark='500ms'; -alter system set minor_freeze_times=30; -alter system set clog_sync_time_warn_threshold = '1000ms'; -alter system set trace_log_slow_query_watermark = '10s'; -alter system set enable_sql_operator_dump = 'false'; -alter system set rpc_timeout=1000000000; - - -create resource unit tpch_box1 min_memory '100g', max_memory '100g', max_disk_size '1000g', max_session_num 64, min_cpu=9, max_cpu=9, max_iops 128, min_iops=128; -create resource pool tpch_pool1 unit = 'tpch_box1', unit_num = 1, zone_list = ('z1', 'z2', 'z3'); -create tenant oracle replica_num = 3, resource_pool_list=('tpch_pool1') set ob_tcp_invited_nodes='%', ob_compatibility_mode='oracle'; - -alter tenant oracle set variables autocommit='on'; -alter tenant oracle set variables nls_date_format='yyyy-mm-dd hh24:mi:ss'; -alter tenant oracle set variables nls_timestamp_format='yyyy-mm-dd hh24:mi:ss.ff'; -alter tenant oracle set variables nls_timestamp_tz_format='yyyy-mm-dd hh24:mi:ss.ff tzr tzd'; -alter tenant oracle set variables ob_query_timeout=7200000000; -alter tenant oracle set variables ob_trx_timeout=7200000000; -alter tenant oracle set variables max_allowed_packet=67108864; -alter tenant oracle set variables ob_enable_jit='OFF'; -alter tenant oracle set variables ob_sql_work_area_percentage=80; -alter tenant oracle set variables parallel_max_servers=512; -alter tenant oracle set variables parallel_servers_target=512; - -select count(*) from oceanbase.__all_server group by zone limit 1 into @num; -set @sql_text = concat('alter resource pool tpch_pool1', ' unit_num = ', @num); -prepare stmt from @sql_text; -execute stmt; -deallocate prepare stmt; diff --git a/plugins/mysqltest/3.1.0/init_sql/init_user_oracle.sql b/plugins/mysqltest/3.1.0/init_sql/init_user_oracle.sql deleted file mode 100644 index c293bf2..0000000 --- a/plugins/mysqltest/3.1.0/init_sql/init_user_oracle.sql +++ /dev/null @@ -1,27 +0,0 @@ -alter session set current_schema = SYS; - -create user root IDENTIFIED BY root; -grant all on *.* to root WITH GRANT OPTION; -grant dba to root; - -create user test IDENTIFIED BY test; -grant all on *.* to test WITH GRANT OPTION; -grant dba to test; -grant all privileges to test; - -create user admin IDENTIFIED BY admin; -grant all on *.* to admin WITH GRANT OPTION; -grant dba to admin; -grant all privileges to admin; - -alter user LBACSYS account unlock; -grant all on *.* to LBACSYS WITH GRANT OPTION; -grant dba to LBACSYS; - -alter user ORAAUDITOR account unlock; -grant all on *.* to ORAAUDITOR WITH GRANT OPTION; -grant dba to ORAAUDITOR; -alter system set "_enable_split_partition" = 'true'; - -grant read on directory dd to TEST; -set global secure_file_priv = ''; diff --git a/plugins/mysqltest/3.1.0/r/oracle/chinese.result b/plugins/mysqltest/3.1.0/r/oracle/chinese.result deleted file mode 100644 index 648c47a..0000000 --- a/plugins/mysqltest/3.1.0/r/oracle/chinese.result +++ /dev/null @@ -1,16 +0,0 @@ -case 1: commit -show variables like 'autocommit'; -Variable_name Value -autocommit ON -drop table if exists t1; -create table t1 (c1 int primary key, c2 varchar(1024)); -set autocommit=0; -insert into t1 values (1, '中国'); -select * from t1 where c1 = 1 for update; -c1 c2 -1 中国 -commit; -set autocommit=1; -select * from t1; -c1 c2 -1 中国 diff --git a/plugins/oceanbase/3.1.0/create_tenant.py b/plugins/oceanbase/3.1.0/create_tenant.py index 13690b3..0c266dd 100644 --- a/plugins/oceanbase/3.1.0/create_tenant.py +++ b/plugins/oceanbase/3.1.0/create_tenant.py @@ -22,6 +22,7 @@ from __future__ import absolute_import, division, print_function import re +import time def parse_size(size): @@ -108,6 +109,24 @@ def create_tenant(plugin_context, cursor, *args, **kwargs): if unit_num > min_unit_num: return error('resource pool unit num is bigger than zone server count') + sql = "select count(*) num from oceanbase.__all_server where status = 'active' and start_service_time > 0" + try: + count = 30 + while count: + stdio.verbose('execute sql: %s' % sql) + cursor.execute(sql) + num = cursor.fetchone()['num'] + if num >= unit_num: + break + count -= 1 + time.sleep(1) + if count == 0: + stdio.error('server can not migrate in') + return + except: + exception('execute sql exception: %s' % sql) + return + cpu_total = 0 mem_total = 0 disk_total = 0 -- GitLab