[TOC] # ALTER SYSTEM ALTER SYSTEM 语句用来对 OceanBase 发送命令,执行某项指定操作。 ## BOOTSTRAP #### 描述 该语句用于自举 OceanBase 集群。 #### 格式 ~~~ alter_system_bootstrap_stmt: ALTER SYSTEM BOOTSTRAP opt_cluster_type region_zone_server_list; opt_cluster_type: [CLUSTER cluster_role] cluster_role: PRIMARY | STANDBY region_zone_server_list: region_zone_server [, region_zone_server ...] region_zone_server: [region] zone server region: REGION [=] region_name zone: ZONE [=] zone_name server: SERVER [=] ip_port ip_port: 'STR_VALUE:INT_VALUE' ~~~ #### 参数解释 系统自举时,需要指定 RootService 信息,多台 RootService 通过逗号(,)分隔。 <table data-tag="table" id="table-x7r-lms-oqe" class="table"><colgroup width="240" span="1" data-tag="col" id="col-qw5-d0d-c9x" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="495" span="1" data-tag="col" id="col-a05-jdw-qhv" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-630-k6c-ejc" class="thead"><tr id="tr-3i2-d0o-9yu"><th id="td-1ia-gyb-bsj"><p id="p-llm-fhf-004"><b>参数</b></p></th><th id="td-5xs-8a5-rnh"><p id="p-v1t-882-x46"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-b7n-7cp-oyn" class="tbody"><tr data-tag="tr" id="tr-v23-mnj-5z8" class="tr"><td data-tag="td" id="td-9wh-gvt-u7r" class="td"><p data-tag="p" id="p-1af-c0j-em5" class="p">region_name</p></td><td data-tag="td" id="td-0zw-mtg-46b" class="td"><p data-tag="p" id="p-6mq-e7t-lcu" class="p">指定 RootService 所在的地域,通过在“多地多中心”部署时指定。</p></td></tr><tr data-tag="tr" id="tr-yca-fgy-65j" class="tr"><td data-tag="td" id="td-f74-zxc-ojq" class="td"><p data-tag="p" id="p-4j6-rzd-0jh" class="p">zone_name</p></td><td data-tag="td" id="td-7z4-lp7-wz3" class="td"><p data-tag="p" id="p-wu3-a6c-m22" class="p">指定 RootService 所属的 Zone。</p></td></tr><tr data-tag="tr" id="tr-p16-qn8-do1" class="tr"><td data-tag="td" id="td-5z6-at2-h3y" class="td"><p data-tag="p" id="p-d36-dz4-c5o" class="p">ip_port</p></td><td data-tag="td" id="td-ft9-8eg-hmo" class="td"><p data-tag="p" id="p-x0j-krp-p1d" class="p">指定 RootService 的 IP 和端口。</p></td></tr><tr data-tag="tr" id="tr-86a-z0f-67w" class="tr"><td data-tag="td" id="td-ruu-p2c-gg8" class="td"><p data-tag="p" id="p-4ab-tdr-x84" class="p">PRIMARY | STANDBY</p></td><td data-tag="td" id="td-uwc-g36-htw" class="td"><p data-tag="p" id="p-cf0-uv9-jco" class="p">指定主备库。系统启动时需要指定主备库,如果不指定,默认采用主库启动。</p></td></tr></tbody></table> #### 示例 * 指定一台 RootService: ~~~ ALTER SYSTEM BOOTSTRAP ZONE 'zone1' SERVER '10.218.248.178:55410'; ~~~ * 多台 RootService 通过逗号(,)分隔: ~~~ ALTER SYSTEM BOOTSTRAP ZONE 'zone1' SERVER '172.24.65.24:55410', ZONE 'zone2' SERVER '172.24.65.114:55410'; ~~~ * 启动备库 ~~~ ALTER SYSTEM BOOTSTRAP CLUSTER STANDBY ZONE 'zone1' SERVER '10.218.248.178:55410'; ~~~ ## JOB #### 描述 该语句触发参数指定的后台任务。 #### 格式 ~~~ alter_system_job_stmt: ALTER SYSTEM RUN JOB job_name [zone | server]; ~~~ #### 参数解释 <table data-tag="table" id="table-6t0-8r4-2cl" class="table"><colgroup width="240" span="1" data-tag="col" id="col-gek-e7q-vnu" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="487" span="1" data-tag="col" id="col-j4u-j4p-zj5" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-9z7-gt6-fxw" class="thead"><tr id="tr-hln-ybb-rnj"><th id="td-fva-7by-341"><p id="p-rxr-n99-3s3"><b>参数</b></p></th><th id="td-1am-lku-l9f"><p id="p-xbg-8r1-5h0"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-sjs-eld-lpk" class="tbody"><tr data-tag="tr" id="tr-b41-7bq-q54" class="tr"><td data-tag="td" id="td-5pp-snt-aei" class="td"><p data-tag="p" id="p-o5a-otb-6dd" class="p">JOB job_name</p></td><td data-tag="td" id="td-3v0-g02-qd7" class="td"><p data-tag="p" id="p-ukg-3zw-2ev" class="p">指定任务名称。有特殊字符时需要单引号,其它情况下单引号加与不加都支持,已支持的 JOB 有:</p><ul lake-indent="0" data-tag="ul" id="ul-38t-zl2-w8g" class="ul"><li data-tag="li" id="li-10r-5ez-4l2" class="li"><p id="p-lx3-mi6-5k4">check_partition_table:OBServer 执行 partition table 核对删除任务</p></li><li data-tag="li" id="li-oru-gmv-vvt" class="li"><p id="p-fa1-xcz-wq2">root_inspection:触发 RootService 自检</p></li></ul></td></tr><tr data-tag="tr" id="tr-ifl-er9-z0x" class="tr"><td data-tag="td" id="td-r4f-xfa-3tj" class="td"><p data-tag="p" id="p-w3n-3f3-ych" class="p">zone | server</p></td><td data-tag="td" id="td-8dw-3i6-987" class="td"><p data-tag="p" id="p-88o-zcx-vrp" class="p">该任务指定 Zone 或者 Server 执行。</p></td></tr></tbody></table> #### 示例 * 触发 RootService 自检任务。 ~~~ ALTER SYSTEM RUN JOB "root_inspection"; ~~~ ## MERGE #### 描述 该语句发起存储层合并。 #### 格式 ~~~ alter_system_merge_stmt: ALTER SYSTEM merge_action; merge_action: MAJOR FREEZE | MINOR FREEZE [tenant_list | replica] [server_list] [zone] | START MERGE zone | {SUSPEND | RESUME} MERGE [zone] | CLEAN MERGE ERROR tenant_list: TENANT [=] (tenant_name_list) tenant_name_list: tenant_name [, tenant_name ...] replica: PARTITION_ID [=] 'partition_id%partition_count@table_id' server_list: SERVER [=] ip_port_list ~~~ #### 参数解释 <table data-tag="table" id="table-o3q-dwt-jle" class="table"><colgroup width="240" span="1" data-tag="col" id="col-eqp-m46-l0h" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="486" span="1" data-tag="col" id="col-xcz-db2-bby" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-add-gz9-fah" class="thead"><tr id="tr-jea-l47-cum"><th id="td-shd-ebq-yhb"><p id="p-67e-rr9-8fv"><b>参数</b></p></th><th id="td-9hj-scf-19t"><p id="p-ldd-u77-4u5"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-je7-y2r-6gx" class="tbody"><tr data-tag="tr" id="tr-ckq-yho-z4c" class="tr"><td data-tag="td" id="td-fp3-j8j-1r3" class="td"><p data-tag="p" id="p-j7c-npg-olm" class="p">MAJOR FREEZE</p></td><td data-tag="td" id="td-fre-ws0-b62" class="td"><p data-tag="p" id="p-m2z-wwn-mcy" class="p">发起每日合并。</p></td></tr><tr data-tag="tr" id="tr-d1s-lxk-dn8" class="tr"><td data-tag="td" id="td-r9n-spb-48e" class="td"><p data-tag="p" id="p-50o-rl7-fuo" class="p">MINOR FREEZE</p></td><td data-tag="td" id="td-di3-m1x-7p9" class="td"><p data-tag="p" id="p-dkg-tx9-oci" class="p">发起转储。</p></td></tr><tr data-tag="tr" id="tr-iwo-igv-azh" class="tr"><td data-tag="td" id="td-q2a-yvd-sms" class="td"><p data-tag="p" id="p-zpt-aoq-iju" class="p">START MERGE</p></td><td data-tag="td" id="td-8k3-0pq-rlp" class="td"><p data-tag="p" id="p-64z-awx-abm" class="p">开始每日合并。</p></td></tr><tr data-tag="tr" id="tr-fx4-838-0jw" class="tr"><td data-tag="td" id="td-e7c-ci8-oq1" class="td"><p data-tag="p" id="p-uec-0f6-pqj" class="p">{SUSPEND | RESUME} MERGE</p></td><td data-tag="td" id="td-b4k-8tq-w48" class="td"><p data-tag="p" id="p-qfo-zkv-s5e" class="p">暂停或恢复每日合并。</p></td></tr><tr data-tag="tr" id="tr-8sz-bno-tqf" class="tr"><td data-tag="td" id="td-h32-txh-2o4" class="td"><p id="p-t83-fxc-tfd">CLEAN MERGE ERROR</p></td><td data-tag="td" id="td-j3l-ysq-7do" class="td"><p data-tag="p" id="p-362-qoq-m8b" class="p">清理合并出错的标记。</p></td></tr><tr data-tag="tr" id="tr-qc8-5uv-duz" class="tr"><td data-tag="td" id="td-no0-35x-lji" class="td"><p data-tag="p" id="p-3u2-tkw-b8t" class="p">tenant_name</p></td><td data-tag="td" id="td-8cv-gh6-dws" class="td"><p data-tag="p" id="p-j5u-e0n-ypf" class="p">指定租户转储。</p></td></tr><tr data-tag="tr" id="tr-rnt-6d7-r74" class="tr"><td data-tag="td" id="td-yfi-ba2-ihg" class="td"><p data-tag="p" id="p-chz-np3-emq" class="p">PARTITION_ID</p></td><td data-tag="td" id="td-v0e-6q0-grs" class="td"><p data-tag="p" id="p-q03-3xr-rpp" class="p">指定副本转储。</p></td></tr><tr data-tag="tr" id="tr-73z-mf9-275" class="tr"><td data-tag="td" id="td-srv-2y8-dp1" class="td"><p data-tag="p" id="p-si8-28y-367" class="p">SERVER</p></td><td data-tag="td" id="td-o8n-ni8-jsb" class="td"><p data-tag="p" id="p-85o-chl-zl7" class="p">指定机器转储。</p></td></tr><tr data-tag="tr" id="tr-dsg-lyp-408" class="tr"><td data-tag="td" id="td-xkv-5qj-epv" class="td"><p data-tag="p" id="p-tt5-9yc-rc6" class="p">zone</p></td><td data-tag="td" id="td-jtb-pjw-bie" class="td"><p data-tag="p" id="p-4mr-hx8-5o7" class="p">指定 Zone 开始合并。</p></td></tr></tbody></table> #### 示例 * 发起每日合并。 ~~~ OceanBase(root@oceanbase)>alter system major freeze; Query OK, 0 rows affected (0.06 sec) ~~~ ## PARAMETER #### 描述 该语句用来修改配置项信息。 #### 格式 ~~~ alter_system_parameter_stmt: ALTER SYSTEM [SET] parameter_name = expression [SCOPE = {MEMORY | SPFILE | BOTH}] [COMMENT [=} 'text'] {SERVER [=] ‘ip:port’ | ZONE [=] ‘zone’}; ~~~ #### 参数解释 <table data-tag="table" id="table-ip5-1th-5eg" class="table"><colgroup width="240" span="1" data-tag="col" id="col-ere-ehe-qdm" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="484" span="1" data-tag="col" id="col-g4x-94i-c1g" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-p0s-xyw-gyx" class="thead"><tr id="tr-hki-3fd-dhv"><th id="td-ayn-9n6-0a8"><p id="p-t7s-rn5-7gg"><b>参数</b></p></th><th id="td-s8y-z66-hvn"><p id="p-ffi-agc-bdy"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-1qo-gw6-74g" class="tbody"><tr data-tag="tr" id="tr-kag-h8x-1j6" class="tr"><td data-tag="td" id="td-na8-csr-u2n" class="td"><p data-tag="p" id="p-joc-ary-6j7" class="p">parameter_name</p></td><td data-tag="td" id="td-ivs-bon-kjy" class="td"><p data-tag="p" id="p-f9a-80q-agy" class="p">指定要修改的配置项名称。</p></td></tr><tr data-tag="tr" id="tr-fdz-l4y-7fi" class="tr"><td data-tag="td" id="td-fxa-9ly-oy8" class="td"><p data-tag="p" id="p-hfo-77y-yko" class="p">expression</p></td><td data-tag="td" id="td-hik-krs-t2e" class="td"><p data-tag="p" id="p-ezm-efl-fzn" class="p">指定修改后的配置项的值。</p></td></tr><tr data-tag="tr" id="tr-oli-5v3-g0z" class="tr"><td data-tag="td" id="td-bhp-ry6-qo4" class="td"><p data-tag="p" id="p-9b8-70e-z49" class="p">COMMENT 'text'</p></td><td data-tag="td" id="td-dao-mra-wu0" class="td"><p data-tag="p" id="p-8h4-pyr-irc" class="p">用于添加关于本次修改的注释。该参数为可选,建议不要省略。</p></td></tr><tr data-tag="tr" id="tr-7y0-sxh-en8" class="tr"><td data-tag="td" id="td-cd0-c6k-97m" class="td"><p id="p-x0c-2ja-22n">SCOPE</p></td><td data-tag="td" id="td-629-rfb-p50" class="td"><p data-tag="p" id="p-a73-83h-jzp" class="p">指定本次配置项修改的生效范围。它的值主要有以下三种:</p><ul lake-indent="0" data-tag="ul" id="ul-nl7-t5w-y7m" class="ul"><li data-tag="li" id="li-9vv-m39-di9" class="li"><p id="p-w97-x0y-f8e"> MEMORY:表明只修改内存中的配置项,修改立即生效,且本修改在 Server 重启以后会失效(目前暂时没有配置项支持这种方式)。</p></li><li data-tag="li" id="li-utr-kzl-6eo" class="li"><p id="p-21g-ggg-faz">SPFILE:表明只修改配置表中的配置项值,当 Server 重启以后才生效。</p></li><li data-tag="li" id="li-4sx-06k-pc5" class="li"><p id="p-ls7-swq-qyb">BOTH:表明既修改配置表,又修改内存值,修改立即生效,且 Server 重启以后配置值仍然生效。</p></li></ul><p data-tag="p" id="p-mlb-05r-cgp" class="p">SCOPE 默认值为 BOTH。对于不能立即生效的配置项,如果使用 BOTH 或 MEMORY,会报错 。</p></td></tr><tr data-tag="tr" id="tr-592-ywj-dlj" class="tr"><td data-tag="td" id="td-f2y-6cr-4fh" class="td"><p data-tag="p" id="p-afo-nfv-ck2" class="p">SERVER</p></td><td data-tag="td" id="td-6o0-u36-ov7" class="td"><p data-tag="p" id="p-ous-ud4-1ry" class="p">只修改指定 Server 实例的某个配置项。</p></td></tr><tr data-tag="tr" id="tr-479-gtn-8xn" class="tr"><td data-tag="td" id="td-826-o4k-835" class="td"><p data-tag="p" id="p-iuh-xku-lzq" class="p">ZONE</p></td><td data-tag="td" id="td-2p8-ons-izz" class="td"><p data-tag="p" id="p-8g7-0gd-ec4" class="p">表明本配置项的修改针对指定集群的特定 Server 类型,否则,针对所有集群的特定 Server 类型。</p></td></tr></tbody></table> **说明** 同时修改多个系统配置项时,用“,”隔开。 查看系统配置项的格式:`SHOW PARAMETERS [LIKE 'pattern' | WHERE expr];` #### 示例 * 修改配置项 enable\_sql\_audit 的信息。 ~~~ OceanBase(root@oceanbase)>show parameters like 'enable_sql_audit'; +------+----------+---------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | +------+----------+---------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | z1 | observer | 11.11.111.111 | 19510 | enable_sql_audit | NULL | True | specifies whether SQL audit is turned on. The default value is TRUE. Value: TRUE: turned on FALSE: turned off | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +------+----------+---------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ 1 rows in set (0.02 sec) OceanBase(root@oceanbase)>alter system set enable_sql_audit = false scope = BOTH; Query OK, 0 rows affected (0.05 sec) OceanBase(root@oceanbase)>show parameters like 'enable_sql_audit'; +------+----------+---------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | zone | svr_type | svr_ip | svr_port | name | data_type | value | info | section | scope | source | edit_level | +------+----------+---------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ | z1 | observer | 11.11.111.111 | 19510 | enable_sql_audit | NULL | False | specifies whether SQL audit is turned on. The default value is TRUE. Value: TRUE: turned on FALSE: turned off | OBSERVER | CLUSTER | DEFAULT | DYNAMIC_EFFECTIVE | +------+----------+---------------+----------+------------------+-----------+-------+---------------------------------------------------------------------------------------------------------------+----------+---------+---------+-------------------+ 1 rows in set (0.02 sec) ~~~ ## REFRESH #### 描述 该语句系列用来触发刷新操作,包括刷新 schema、时区信息、各类缓存等。 #### 格式 ~~~ alter_system_refresh_stmt: ALTER SYSTEM refresh_action; refresh_action: REFRESH SCHEMA [zone | server] | REFRESH TIME_ZONE_INFO | FLUSH cache_type CACHE [tenant_list] [GLOBAL] | FLUSH KVCACHE [tenant] [CACHE [=] cache_name] cache_type: ALL | LOCATION | CLOG | ILOG | COLUMN_STAT | BLOCK_INDEX | BLOCK | ROW | BLOOM_FILTER | SCHEMA | PLAN tenant: TENANT [=] tenant_name cache_name: ~~~ #### 参数解释 <table data-tag="table" id="table-l1x-j1q-9ch" class="table"><colgroup width="240" span="1" data-tag="col" id="col-ky0-oxc-yad" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="466" span="1" data-tag="col" id="col-vtl-ofe-tis" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-fg3-b2k-t0i" class="thead"><tr id="tr-dm8-15y-s85"><th id="td-97a-scd-hn7"><p id="p-4xh-zai-ail"><b>参数</b></p></th><th id="td-k40-rm4-a7v"><p id="p-n3a-kit-39m"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-cpg-c9h-x9i" class="tbody"><tr data-tag="tr" id="tr-2u7-qrq-5v7" class="tr"><td data-tag="td" id="td-h8g-syw-wev" class="td"><p data-tag="p" id="p-srx-egp-kl4" class="p">REFRESH SCHEMA</p></td><td data-tag="td" id="td-yn7-uf6-m9p" class="td"><p data-tag="p" id="p-lnj-sam-mut" class="p">刷新 Schema。正常情况下,当系统执行 DDL 操作, RootService 都会主动通知所有 OBServer 刷新 Schema。当某些 OBServer 发生异常,和 RootService 网络中断,此时需要手动刷新 Schema。刷新Schema 可以针对单独的机器,也可以针对某个集群。</p></td></tr><tr data-tag="tr" id="tr-h5x-vuj-fhq" class="tr"><td data-tag="td" id="td-7cj-ed8-4wj" class="td"><p data-tag="p" id="p-bz6-2ii-tp0" class="p">REFRESH TIME_ZONE_INFO</p></td><td data-tag="td" id="td-5rv-eoy-5mz" class="td"><p data-tag="p" id="p-mmy-h3d-bsf" class="p">通知集群中的所有 Server 更新本地的时区信息。</p></td></tr><tr data-tag="tr" id="tr-ahm-lyo-7bf" class="tr"><td data-tag="td" id="td-zsm-rt2-soo" class="td"><p data-tag="p" id="p-u50-2hl-d75" class="p">FLUSH cache_type CACHE</p></td><td data-tag="td" id="td-ptu-rpq-s2h" class="td"><p data-tag="p" id="p-c0x-vke-ok6" class="p">清空指定 Cache 指令。</p></td></tr><tr data-tag="tr" id="tr-9qv-tve-cf5" class="tr"><td data-tag="td" id="td-wlv-4d8-hc5" class="td"><p data-tag="p" id="p-uxr-yrt-0zy" class="p">FLUSH KVCACHE</p></td><td data-tag="td" id="td-ufa-8og-7s3" class="td"><p data-tag="p" id="p-8sd-3fe-0ae" class="p">清空 KV Cache 指令。</p><ul lake-indent="0" data-tag="ul" id="ul-4g7-79t-09p" class="ul"><li data-tag="li" id="li-dpy-sue-evl" class="li"><p id="p-3bi-kmn-x9s">如果指定 tenant 和 cache_name,则清除指定租户的指定 KV Cache</p></li><li data-tag="li" id="li-vxl-pyw-i47" class="li"><p id="p-83p-8yp-i6e">如果只指定 tenant,则清除指定租户的全部KV Cache</p></li><li data-tag="li" id="li-k63-8w1-kub" class="li"><p id="p-4i4-lqd-8se">如果不指定 tenant 和 cache_name,则清除所有租户的全部KV Cache</p></li></ul></td></tr></tbody></table> #### 示例 * 刷新单台 OBServer 的 Schema: ~~~ ALTER SYSTEM REFRESH SCHEMA SERVER='172.24.65.24:55410'; ~~~ * 刷新整个 Zone 的 Schema: ~~~ ALTER SYSTEM REFRESH SCHEMA ZONE='zone1'; ~~~ ## REPLICA #### 描述 该语句用来处理副本的迁移,复制,删除,副本类型转换,角色切换等行为。 #### 格式 ~~~ alter_system_replica_stmt: ALTER SYSTEM replica_action; replica_action: SWITCH REPLICA {LEADER | FOLLOWER} {replica server | server [tenant_name] | zone [tenant_name]} | DROP REPLICA partition_id_desc replica server [create_timestamp] [zone] [FORCE] | {MOVE | COPY} REPLICA replica source destination | REPORT REPLICA partition_id_desc     {zone | server}   | RECYCLE REPLICA partition_id_desc     {zone | server}   | {ALTER | CHANGE | MODIFY} REPLICA   replica server [set] REPLICA_TYPE = replica_type source: SOURCE [=] 'ip:port' destination: DESTINATION [=] 'ip:port' partition_id_desc PARTITION_ID partition_id%partition_count@table_id partition_idx | partition_count | table_id | task_id: INT_VALUE create_timestamp: CREATE_TIMESTAMP [=] INT_VALUE tenant_name_list: tenant_name [, tenant_name ...] replica_type: {FULL | F} | {READONLY | R} | {LOGONLY | L} ~~~ #### 参数解释 <table data-tag="table" id="table-v91-a76-4di" class="table"><colgroup width="240" span="1" data-tag="col" id="col-glu-bbl-bkq" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="464" span="1" data-tag="col" id="col-y3b-3gk-w6w" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-xss-pj5-sds" class="thead"><tr id="tr-iey-ld0-ohj"><th id="td-2uv-fbl-3lz"><p id="p-1t3-fku-vc8"><b>参数</b></p></th><th id="td-3le-fpm-d6y"><p id="p-oxq-r2j-zbf"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-qyd-4m0-3sf" class="tbody"><tr data-tag="tr" id="tr-mh4-cd3-6o8" class="tr"><td data-tag="td" id="td-g5j-egn-6gg" class="td"><p data-tag="p" id="p-mlb-tl8-jb4" class="p">SWITCH REPLICA</p></td><td data-tag="td" id="td-ex4-0qv-uwd" class="td"><p data-tag="p" id="p-dja-n32-pcn" class="p">Leader 改选。</p></td></tr><tr data-tag="tr" id="tr-1ta-l1x-y26" class="tr"><td data-tag="td" id="td-xi9-z5a-if8" class="td"><p data-tag="p" id="p-2jf-5se-kac" class="p">DROP REPLICA</p></td><td data-tag="td" id="td-4a9-mm4-3ao" class="td"><p data-tag="p" id="p-r8b-fuu-4nm" class="p">副本删除。删除指定 OBServer 上的 Replica,必须指定 partition_id,OBServer 地址以及 create_timestamp。</p></td></tr><tr data-tag="tr" id="tr-lqc-tih-3m1" class="tr"><td data-tag="td" id="td-ebb-1ho-aor" class="td"><p id="p-dz6-e57-dn6">{MOVE | COPY} REPLICA</p></td><td data-tag="td" id="td-c5s-2ba-s1l" class="td"><p data-tag="p" id="p-syl-krp-qbw" class="p">副本迁移/复制,需要指定源 OBServer 和目的 OBServer ,以及 partition_id。</p></td></tr><tr data-tag="tr" id="tr-m05-sxo-o0l" class="tr"><td data-tag="td" id="td-6p9-foh-5t8" class="td"><p data-tag="p" id="p-kxg-pz9-28z" class="p">REPORT REPLICA</p></td><td data-tag="td" id="td-mav-35o-oyd" class="td"><p id="p-r7c-25y-d7t">副本汇报,强制要求某个 OBServer 或者某个 Zone 内的所有 OBServer 进行 Replica 汇报。</p></td></tr><tr data-tag="tr" id="tr-axr-8bt-8t0" class="tr"><td data-tag="td" id="td-uc3-008-e8r" class="td"><p data-tag="p" id="p-8kg-ul9-8db" class="p">RECYCLE REPLICA</p></td><td data-tag="td" id="td-5pl-viz-4jr" class="td"><p data-tag="p" id="p-m53-d8b-fbl" class="p">回收无用副本。</p></td></tr><tr data-tag="tr" id="tr-8ud-2bc-cc2" class="tr"><td data-tag="td" id="td-2sw-t4d-yhc" class="td"><p data-tag="p" id="p-psg-rlm-f32" class="p">{ALTER | CHANGE | MODIFY} REPLICA</p></td><td data-tag="td" id="td-o62-vjg-ngs" class="td"><p data-tag="p" id="p-hk8-81f-1uk" class="p">修改副本属性,可以修改指定副本的副本类型。现在已经支持的副本类型包括:FULL/READONLY/LOGONLY。‘replica_type’的值可以是这三种副本类型的全称或者简写的首字符:’F/R/L’;大小写通用。</p></td></tr></tbody></table> #### 示例 * 副本迁移 ~~~ ALTER SYSTEM MOVE REPLICA PARTITION_ID '0%4@1100611139403777' SOURCE '172.24.65.24:55410' DESTINATION '172.24.65.26:55410'; ~~~ * 删除副本 ~~~ ALTER SYSTEM DROP REPLICA PARTITION_ID '0%4@1100611139403777' SERVER '172.24.65.26:55410'; ~~~ * 修改副本类型 ~~~ ALTER SYSTEM CHANGE REPLICA PARTITION_ID '0%4@1100611139403777' SERVER '172.24.65.26:55410'; CHANGE REPLICA_TYPE = 'L'; ~~~ * Leader改选 ~~~ ALTER SYSTEM SWITCH REPLICA LEADER PARTITION_ID '0%4@1100611139403777' SERVER '172.24.65.26:55410'; ~~~ ## ROOTSERVICE #### 描述 切换 RS 的角色。 #### 格式 ~~~ alter_system_rootservice_stmt: ALTER SYSTEM SWITCH ROOTSERVICE {LEADER | FOLLOWER} {zone | server}; ~~~ #### 参数解释 <table data-tag="table" id="table-fpg-wh5-2eo" class="table"><colgroup width="240" span="1" data-tag="col" id="col-1sw-q2x-1fk" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="480" span="1" data-tag="col" id="col-6dk-joc-ei2" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-9if-pk8-ddu" class="thead"><tr id="tr-fxt-d5l-gbe"><th id="td-gmh-40g-z8g"><p id="p-gwk-pks-31r"><b>参数</b></p></th><th id="td-lp9-ecg-k7g"><p id="p-s9n-gof-uq3"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-wg4-yah-v96" class="tbody"><tr data-tag="tr" id="tr-6ur-u4m-ngn" class="tr"><td data-tag="td" id="td-aca-iim-p5q" class="td"><p data-tag="p" id="p-4u0-ih5-ibz" class="p">LEADER | FOLLOWER</p></td><td data-tag="td" id="td-ukw-3mq-sju" class="td"><p data-tag="p" id="p-5ld-bmc-raq" class="p">把 RS 的角色设置为 Leader 或者 Follower。</p></td></tr><tr data-tag="tr" id="tr-c58-9xx-781" class="tr"><td data-tag="td" id="td-ue4-fju-e00" class="td"><p data-tag="p" id="p-3i7-0x6-5ah" class="p">zone | server</p></td><td data-tag="td" id="td-34t-o9h-wnj" class="td"><p data-tag="p" id="p-tnb-92t-5ee" class="p">修改指定 Zone 或 Server 的 RS 角色。</p></td></tr></tbody></table> #### 示例 * 把z1的 RS 切换为 Leader ~~~ ALTER SYSTEM SWITCH ROOTSERVICE LEADER ZONE 'z1'; ~~~ ## SERVER #### 描述 该语句维护系统中 OBServer 状态,控制 OBServer 的增、删、启、停等操作。 #### 格式 ~~~ alter_system_server_stmt: ALTER SYSTEM server_action SERVER ip_port_list [zone]; server_action: ADD | DELETE | CANCEL DELETE | START | STOP | FORCE STOP ip_port_list: ip_port [, ip_port ...] ~~~ #### 参数解释 服务器状态图如下: ![](https://img.kancloud.cn/a6/43/a643202daaa28a9376af6ad9d8c2d55d_294x359.png) <table data-tag="table" id="table-usp-r43-5l9" class="table"><colgroup width="240" span="1" data-tag="col" id="col-6d8-luv-moa" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="474" span="1" data-tag="col" id="col-fh0-bw5-vgm" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-8fb-vid-2nd" class="thead"><tr id="tr-iqh-cuq-n20"><th id="td-mb6-pls-t90"><p id="p-d5b-yik-5qk"><b>参数</b></p></th><th id="td-g24-pop-78d"><p id="p-pto-s0y-yo7"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-f6r-0tx-6oe" class="tbody"><tr data-tag="tr" id="tr-gvj-8bt-xp5" class="tr"><td data-tag="td" id="td-zed-o3d-ex1" class="td"><p data-tag="p" id="p-59o-rbs-zl4" class="p">ip_port</p></td><td data-tag="td" id="td-sgy-xlc-j3d" class="td"><p data-tag="p" id="p-vmt-43x-zth" class="p">指定 OBServer 的 IP 地址和端口</p></td></tr><tr data-tag="tr" id="tr-8tq-92u-psh" class="tr"><td data-tag="td" id="td-hjy-2av-vjm" class="td"><p data-tag="p" id="p-w9u-zlh-pel" class="p">zone</p></td><td data-tag="td" id="td-prm-8kb-kbv" class="td"><p id="p-kka-zwl-kyz">如果指定 Zone,将会对待维护 Server 执行 Zone 校验。</p></td></tr><tr data-tag="tr" id="tr-k6z-sgq-6pv" class="tr"><td data-tag="td" id="td-wk5-wxa-8jy" class="td"><p id="p-ro7-35w-qku">ADD</p></td><td data-tag="td" id="td-6t2-hy2-uxc" class="td"><p data-tag="p" id="p-rzg-gxt-o0w" class="p">新增服务器。</p></td></tr><tr data-tag="tr" id="tr-y9u-rj9-l0d" class="tr"><td data-tag="td" id="td-y3o-29v-kbm" class="td"><p data-tag="p" id="p-9pn-8pg-4sa" class="p">DELETE</p></td><td data-tag="td" id="td-ghz-gk3-5gy" class="td"><p data-tag="p" id="p-stm-v8f-ifz" class="p">删除服务器。</p></td></tr><tr data-tag="tr" id="tr-2ud-a30-zdj" class="tr"><td data-tag="td" id="td-33i-l2x-1yl" class="td"><p data-tag="p" id="p-okp-2p9-y9n" class="p">CANCEL DELETE</p></td><td data-tag="td" id="td-trg-fhx-4sn" class="td"><p data-tag="p" id="p-mb5-zut-x1s" class="p">取消删除服务器。</p></td></tr><tr data-tag="tr" id="tr-hhw-g3w-2rr" class="tr"><td data-tag="td" id="td-mo7-dlx-e1u" class="td"><p data-tag="p" id="p-les-5xi-xww" class="p">START</p></td><td data-tag="td" id="td-vhl-xya-fq6" class="td"><p data-tag="p" id="p-173-cc1-xmc" class="p">启动服务器。</p></td></tr><tr data-tag="tr" id="tr-f8q-7r3-7r3" class="tr"><td data-tag="td" id="td-mjh-jm2-92h" class="td"><p id="p-26h-1sw-8vo">STOP</p></td><td data-tag="td" id="td-vv3-oqq-05c" class="td"><p data-tag="p" id="p-dpq-o87-lvd" class="p">停止服务器。</p></td></tr><tr data-tag="tr" id="tr-r28-9r8-68f" class="tr"><td data-tag="td" id="td-pi9-7y9-j01" class="td"><p id="p-cd0-9cj-pk5">FORCE STOP</p></td><td data-tag="td" id="td-hks-hwl-lfo" class="td"><p data-tag="p" id="p-g85-sgi-z5e" class="p">强制停止服务器。</p></td></tr></tbody></table> #### 示例 * 新增服务器 ~~~ ALTER SYSTEM ADD SERVER '172.24.65.113:55410' ZONE 'zone1'; ~~~ **注意** * 通过 Add 和 Delete 命令将服务器加入到服务列表,只有服务列表中的服务器才可以提供服务。 * Delete 操作执行 leader 改选以及 replica 复制。 * Delete 操作执行时间很长,因此,允许通过 Cancel 命令取消该操作。 ## THROTTLE #### 描述 该语句用来设置特征限流。 #### 格式 ~~~ alter_system_throttle_stmt: ALTER SYSTEM throttle_action; throttle_action: ENABLE SQL THROTTLE [priority_option] [using_metric_option_list] | DISABLE SQL priority_option: FOR PRIORITY <= INT_VALUE using_metric_option_list: USING metric_option_list metric_option_list: metric_option [metric_option ...] metric_option: RT = {INT_VALUE | DECIMAL_VALUE} | CPU = {INT_VALUE | DECIMAL_VALUE} | IO = INT_VALUE | NETWORK = {INT_VALUE | DECIMAL_VALUE} | QUEUE_TIME = {INT_VALUE | DECIMAL_VALUE} | LOGICAL_READS = {INT_VALUE | DECIMAL_VALUE} ~~~ #### 参数解释 <table data-tag="table" id="table-yw4-xch-p5s" class="table"><colgroup width="240" span="1" data-tag="col" id="col-j08-0hp-zpw" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="476" span="1" data-tag="col" id="col-9to-dew-5n5" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-fmu-pbd-yap" class="thead"><tr id="tr-47g-4ho-36r"><th id="td-c63-z2e-2la"><p id="p-l3y-xsx-w5k"><b>参数</b></p></th><th id="td-gkp-rqp-3im"><p id="p-6jk-3wj-7as"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-pb1-svx-ayz" class="tbody"><tr data-tag="tr" id="tr-esn-ph3-yfk" class="tr"><td data-tag="td" id="td-zkw-hwh-6gp" class="td"><p data-tag="p" id="p-vbm-194-98o" class="p">ENABLE SQL</p></td><td data-tag="td" id="td-sk6-0xm-bxy" class="td"><p data-tag="p" id="p-9qi-yqn-fj8" class="p">开启限流,后接限流特征及特征值</p></td></tr><tr data-tag="tr" id="tr-xmh-bs8-7nq" class="tr"><td data-tag="td" id="td-0g0-55p-r8l" class="td"><p id="p-6hz-n9t-85g">FOR PRIORITY</p></td><td data-tag="td" id="td-o7d-4v9-wwg" class="td"><p data-tag="p" id="p-95r-55b-9av" class="p">设定优先级,目的是只在部分 session 生效</p></td></tr><tr data-tag="tr" id="tr-n0b-mpl-lc4" class="tr"><td data-tag="td" id="td-udi-lxd-il6" class="td"><p id="p-jlr-ryq-z0e">RT</p></td><td data-tag="td" id="td-6i0-u7h-ao6" class="td"><p data-tag="p" id="p-qyc-etj-5jw" class="p">按请求执行时间限流</p></td></tr><tr data-tag="tr" id="tr-wzy-ojp-dd4" class="tr"><td data-tag="td" id="td-y3b-p2y-18q" class="td"><p data-tag="p" id="p-tad-7pi-nsc" class="p">CPU</p></td><td data-tag="td" id="td-3t4-scq-2kv" class="td"><p data-tag="p" id="p-h25-bng-kbz" class="p">按 CPU 占用限流,暂未支持</p></td></tr><tr data-tag="tr" id="tr-wiv-e7o-uq1" class="tr"><td data-tag="td" id="td-ywl-xpu-mcf" class="td"><p id="p-9w3-w0o-r7r">IO</p></td><td data-tag="td" id="td-k5f-e2d-dx7" class="td"><p data-tag="p" id="p-vdk-o85-ebm" class="p">按 IO 次数限流,暂未支持</p></td></tr><tr data-tag="tr" id="tr-lq4-rh1-4au" class="tr"><td data-tag="td" id="td-jft-wxp-cqb" class="td"><p id="p-24c-2fe-ogl">NETWORK</p></td><td data-tag="td" id="td-ib8-wfs-83d" class="td"><p data-tag="p" id="p-luk-07w-rcw" class="p">按传输的网络流量大小限流,暂未支持</p></td></tr><tr data-tag="tr" id="tr-stn-xj0-u55" class="tr"><td data-tag="td" id="td-lrx-d4v-p66" class="td"><p data-tag="p" id="p-lke-bxb-3tq" class="p">QUEUE_TIME</p></td><td data-tag="td" id="td-7xx-2ew-3jp" class="td"><p data-tag="p" id="p-672-coz-xxa" class="p">按队列等待时间限流</p></td></tr><tr data-tag="tr" id="tr-cr7-bhy-j3m" class="tr"><td data-tag="td" id="td-qet-bv6-d53" class="td"><p id="p-xrw-orv-y4r">LOGICAL_READS</p></td><td data-tag="td" id="td-nre-k7h-1z7" class="td"><p data-tag="p" id="p-xvk-jca-473" class="p">按逻辑读次数限流,暂未支持</p></td></tr><tr data-tag="tr" id="tr-4be-5vm-vvc" class="tr"><td data-tag="td" id="td-g2w-jyx-361" class="td"><p data-tag="p" id="p-dx6-csm-t1l" class="p">DISABLE SQL</p></td><td data-tag="td" id="td-fg5-kcw-xa1" class="td"><p data-tag="p" id="p-3j2-me8-c89" class="p">关闭限流</p></td></tr></tbody></table> #### 示例 * 对 prioriy<=100 的 session 上队列等待时间超过 0.1s 的请求限流。 ~~~ alter system enable sql throttle for priority <= 100 using queue_time=0.1 ~~~ ## UNIT #### 描述 该语句负责 UNIT 资源迁移。 #### 格式 ~~~ alter_system_unit_stmt: ALTER SYSTEM MIGRATE UNIT [=] unit_id DESTINATION [=] ip_port unit_id: INT_VALUE ~~~ #### 参数解释 <table data-tag="table" id="table-tdk-42c-nlk" class="table"><colgroup width="240" span="1" data-tag="col" id="col-1f5-r4j-pjs" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="480" span="1" data-tag="col" id="col-l9h-hg6-4bq" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-8bx-3dn-54r" class="thead"><tr id="tr-nil-b98-uaj"><th id="td-y06-xhz-qc9"><p id="p-2zp-3yo-rks"><b>参数</b></p></th><th id="td-q9b-2kj-nbr"><p id="p-l8x-2u1-i4z"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-8h1-1xx-8o3" class="tbody"><tr data-tag="tr" id="tr-yun-4je-xtd" class="tr"><td data-tag="td" id="td-3oq-r7b-bjl" class="td"><p data-tag="p" id="p-q26-aul-hqe" class="p">unit_id</p></td><td data-tag="td" id="td-sen-h1x-q1b" class="td"><p data-tag="p" id="p-njr-pvg-taa" class="p">UNIT 编号。</p></td></tr><tr data-tag="tr" id="tr-gzu-s9g-zby" class="tr"><td data-tag="td" id="td-u4i-763-hv2" class="td"><p data-tag="p" id="p-qqe-sio-lyq" class="p">ip_port</p></td><td data-tag="td" id="td-ypc-dm2-nr6" class="td"><p data-tag="p" id="p-xh0-mfy-ogu" class="p">将 UNIT 迁移到的目标 Server 地址。</p></td></tr></tbody></table> #### 示例 * 将 UNIT 1001 的资源迁移到 11.11.111.111:19510。 ~~~ OceanBase(root@oceanbase)>alter system migrate unit = 1001 destination = '11.11.111.111:19510'; Query OK, 0 rows affected (0.05 sec) ~~~ ## ZONE #### 描述 该语句负责维护 Zone 的状态,如 Zone 的增、删、启、停等操作。 #### 格式 ~~~ alter_system_zone_stmt: ADD ZONE zone_name [zone_option_list] | {ALTER | CHANGE | MODIFY} ZONE zone_name [SET] zone_option_list | {DELETE | START | STOP | FORCE STOP} ZONE zone_name zone_option_list: zone_option [, zone_option ...] zone_option: region | idc | ZONE_TYPE {READONLY | READWRITE} idc: STR_VALUE ~~~ #### 参数解释 <table data-tag="table" id="table-un8-g94-n1s" class="table"><colgroup width="240" span="1" data-tag="col" id="col-bbz-vb0-3ms" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="470" span="1" data-tag="col" id="col-cxf-8t5-ebd" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-znx-65o-rjc" class="thead"><tr id="tr-11n-kvw-05x"><th id="td-c05-nfn-5p6"><p id="p-acc-2kn-ejc"><b>参数</b></p></th><th id="td-3tp-ky0-v30"><p id="p-smn-d21-k9k"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-2u1-95y-r06" class="tbody"><tr data-tag="tr" id="tr-8dn-ale-ho0" class="tr"><td data-tag="td" id="td-veq-p53-anx" class="td"><p id="p-mjq-r0v-rc7">ADD ZONE</p></td><td data-tag="td" id="td-mke-95o-6it" class="td"><p id="p-fdq-8st-g8i">新增 Zone</p></td></tr><tr data-tag="tr" id="tr-vdt-tj7-6n2" class="tr"><td data-tag="td" id="td-jub-bgu-rl1" class="td"><p id="p-141-27x-vtc">{ALTER | CHANGE | MODIFY} ZONE</p></td><td data-tag="td" id="td-9qm-bsl-5dw" class="td"><p id="p-8c6-kjm-0up">修改 Zone 的 Region 属性</p><div type="note" id="note-yrp-kru-x0q" class="note note-note"><div class="note-icon-wrapper"><i class="icon-note note note"></i></div><div class="noteContentSpan"><strong>说明 </strong><p id="p-hoi-x4c-w92"></p><p id="p-5fh-etz-ps3">ALTER、CHANGE、MODIFY 三者功能相同,可以使用任意命令来修改 Zone 的 Region 属性。</p></div></div></td></tr><tr data-tag="tr" id="tr-lrh-wlk-4i4" class="tr"><td data-tag="td" id="td-mux-5yx-6nl" class="td"><p id="p-a84-8nf-qo3">DELETE ZONE</p></td><td data-tag="td" id="td-x98-htd-r0f" class="td"><p id="p-6u5-5cw-7sl">删除 Zone,删除前需要保证 Zone 中没有可用的 Server</p></td></tr><tr data-tag="tr" id="tr-57v-7f1-fut" class="tr"><td data-tag="td" id="td-t22-taw-l05" class="td"><p id="p-3e6-4nf-7oc">START | STOP</p></td><td data-tag="td" id="td-myb-k5g-m5v" class="td"><p id="p-1gx-8ho-14o">主动上下线 Zone</p></td></tr></tbody></table> #### 示例 * 删除 Zone。 ~~~ OceanBase(root@oceanbase)>alter system delete zone 'z1'; ERROR 4668 (HY000): The zone is not empty and can not be deleted. You should delete the servers of the zone. There are 1 servers alive and 0 not alive. ~~~ ## CLUSTER #### 描述 集群管理相关操作,可以新增、删除、修改集群级相关属性。 #### 格式 ~~~ ALTER SYSTEM cluster_action cluster_name CLUSTER_ID INTNUM; cluster_action: ADD CLUSTER | REMOVE CLUSTER | ENABLE CLUSTER SYNCHRONIZATION | DISABLE CLUSTER SYNCHRONIZATION | MODIFY CLUSTER REDO_TRANSPORT_OPTIONS = 'SYNC|ASYNC' ~~~ #### 参数解释 <table data-tag="table" id="table-8tn-tpa-ct9" class="table"><colgroup width="291" span="1" data-tag="col" id="col-fcy-xk6-cfb" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="442" span="1" data-tag="col" id="col-exm-2jv-1cv" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-uwe-0hx-0d8" class="thead"><tr id="tr-e2a-mud-f77"><th id="td-130-vbh-lgx"><p id="p-z84-pfo-9p9"><b>参数</b></p></th><th id="td-i66-ioz-l0l"><p id="p-btp-9kh-590"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-hk4-plc-k98" class="tbody"><tr data-tag="tr" id="tr-yxe-twr-w7n" class="tr"><td data-tag="td" id="td-eaj-57z-rtd" class="td"><p id="p-o89-lk0-mui">ADD CLUSTER</p></td><td data-tag="td" id="td-4ul-jsl-8uw" class="td"><p id="p-2mf-9zz-zp7">新增一个备库。</p></td></tr><tr data-tag="tr" id="tr-w77-c9d-kug" class="tr"><td data-tag="td" id="td-y3k-yq8-w0t" class="td"><p id="p-4kp-ixy-l9v">REMOVE CLUSTER</p></td><td data-tag="td" id="td-0xn-daw-53a" class="td"><p id="p-b28-ckv-8ne">删除一个已经存在的备库。</p></td></tr><tr data-tag="tr" id="tr-fru-57g-fre" class="tr"><td data-tag="td" id="td-0cr-945-31n" class="td"><p id="p-tml-g9q-5ht">ENABLE CLUSTER SYNCHRONIZATION</p></td><td data-tag="td" id="td-wnz-qxi-r5g" class="td"><p id="p-rbz-j58-poy">允许一个备库的同步。</p></td></tr><tr data-tag="tr" id="tr-zrs-qu0-r4p" class="tr"><td data-tag="td" id="td-9qk-49s-dd3" class="td"><p id="p-s9p-rnc-9y9">DISABLE CLUSTER SYNCHRONIZATION</p></td><td data-tag="td" id="td-ta6-45w-r4b" class="td"><p data-tag="p" id="p-oor-667-aw0" class="p">禁掉一个备库的同步。</p></td></tr><tr data-tag="tr" id="tr-h4s-tsf-83a" class="tr"><td id="td-ryi-a2b-06b"><p id="p-0g6-3og-53p">MODIFY CLUSTER REDO_TRANSPORT_OPTIONS</p></td><td id="td-x3t-tks-i08"><p id="p-8vc-yzn-iys">在主库上修改备库的日志同步方式:</p><ul id="ul-th1-bmk-0hd"><li id="li-hft-114-g2c"><p id="p-q0g-vu6-vtt">SYNC:强同步</p></li><li id="li-qfp-s0b-gei"><p id="p-2bd-wnl-qtl">ASYNC:异步同步</p></li></ul><p id="p-uam-og6-c9w">默认为 ASYCN 方式。</p></td></tr></tbody></table> #### 示例 * 新增备库 ~~~ ALTER SYSTEM ADD CLUSTER 'ob1.test' cluster_id = 1; ~~~ ## SWITCHOVER #### 描述 集群无损、有损切换语法,包括主库切成备库,备库切成主库。 #### 格式 ~~~ ALTER SYSTEM commit_switchover_clause; commit_switchover_clause: COMMIT TO SWITCHOVER TO PRIMARY | COMMIT TO SWITCHOVER TO PHYSICAL STANDBY | ACTIVATE PHYSICAL STANDBY CLUSTER | CONVERT TO PHYSICAL STANDBY ~~~ #### 参数解释 <table data-tag="table" id="table-4s9-z1r-rdi" class="table"><colgroup width="337" span="1" data-tag="col" id="col-1vc-ay6-inz" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="380" span="1" data-tag="col" id="col-1wy-h1v-uzy" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-uxl-ntz-htj" class="thead"><tr id="tr-7vy-pas-jdn"><th id="td-b8b-w0v-x5q"><p id="p-idb-8n3-mtj"><b>参数</b></p></th><th id="td-k89-pte-m0r"><p id="p-mi1-8c7-i2h"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-zpy-dgf-4qy" class="tbody"><tr data-tag="tr" id="tr-hie-yln-jt7" class="tr"><td data-tag="td" id="td-1ab-0xv-4re" class="td"><p id="p-v6l-2yv-4yl">COMMIT TO SWITCHOVER TO PRIMARY</p></td><td data-tag="td" id="td-i2z-1ao-x8l" class="td"><p id="p-50u-606-4jw">备库切成主库,在备库上执行,并且旧主库已经切换成主库,集群中没有其他的备库先切换成主库。</p></td></tr><tr data-tag="tr" id="tr-0ey-3m9-c1x" class="tr"><td data-tag="td" id="td-4xw-hms-esh" class="td"><p id="p-6cv-nnl-je3">COMMIT TO SWITCHOVER TO PHYSICAL STANDBY</p></td><td data-tag="td" id="td-iuu-j6k-zyz" class="td"><p id="p-0f2-r6h-sko">主库无损切换成备库,在主库上执行,并且备库已经同步成功。</p></td></tr><tr data-tag="tr" id="tr-aqt-o36-0tu" class="tr"><td data-tag="td" id="td-eij-lwi-ajt" class="td"><p id="p-pq1-6rs-k89">ACTIVATE PHYSICAL STANDBY CLUSTER</p></td><td data-tag="td" id="td-sai-gto-m7l" class="td"><p id="p-p4f-tge-vdh">在主库宕机的情况下,把一个集群拉成主库。</p></td></tr><tr data-tag="tr" id="tr-e5h-o97-xr0" class="tr"><td data-tag="td" id="td-3ms-8t7-zr7" class="td"><p id="p-o9d-spq-6t3">CONVERT TO PHYSICAL STANDBY</p></td><td data-tag="td" id="td-eu2-kp8-y3k" class="td"><p id="p-8cp-0v3-n67">把一个主库切换成备库。</p></td></tr></tbody></table> #### 示例 * 主库切换成备库 ~~~ ALTER SYSTEM COMMIT TO SWITCHOVER TO PHYSICAL STANDBY; ~~~ * 备库切换成主库 ~~~ ALTER SYSTEM COMMIT TO SWITCHOVER TO PRIMARY; ~~~ * 主库宕机,备库切换成主库 ~~~ ALTER SYSTEM ACTIVATE PHYSICAL STANDBY CLUSTER; ~~~ * 旧主库重启,切成备库 ~~~ ALTER SYSTEM CONVERT TO PHYSICAL STANDBY; ~~~ ## BALANCE TASK #### 描述 该语句用来清除没有正在调度的负载均衡任务。 #### 格式 ~~~ ALTER SYSTEM REMOVE BALANCE TASK opt_tenant_list opt_zone_list opt_balance_task_type; opt_tenant_list TENANT [=] name,name_list opt_zone_list ZONE [=] zone_name, zone_list opt_balance_task_type ALL | MANUAL | AUTO ~~~ #### 参数解释 <table data-tag="table" id="table-3c7-02t-hee" class="table"><colgroup width="248" span="1" data-tag="col" id="col-06k-pn9-n2g" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="441" span="1" data-tag="col" id="col-cuz-wlb-iqa" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-rwa-pd4-nft" class="thead"><tr id="tr-dzr-75z-ts4"><th id="td-sfr-716-0w4"><p id="p-fcl-8qh-5uo"><b>参数</b></p></th><th id="td-v5e-4sk-hfs"><p id="p-ny6-34k-xcq"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-yfe-w9l-0tq" class="tbody"><tr data-tag="tr" id="tr-5zu-19a-h6u" class="tr"><td data-tag="td" id="td-f3r-zz4-4i4" class="td"><p id="p-xbe-im2-4jp">opt_tenant_list</p></td><td data-tag="td" id="td-hah-jwd-2k9" class="td"><p id="p-koz-3nh-2on">租户列表,如果不指定,就会清除所有租户的任务。</p></td></tr><tr data-tag="tr" id="tr-m3e-tmk-z6p" class="tr"><td data-tag="td" id="td-x8v-txl-jf3" class="td"><p id="p-ai0-65n-lde">opt_zone_list</p></td><td data-tag="td" id="td-bxf-t98-ic1" class="td"><p id="p-d72-kyt-dm4">Zone 的列表,可不指定。</p></td></tr><tr data-tag="tr" id="tr-xpn-wzw-avt" class="tr"><td data-tag="td" id="td-y9o-2ad-bbs" class="td"><p id="p-9zv-mp6-72m">opt_balance_task_type</p></td><td data-tag="td" id="td-hlr-q9y-kpb" class="td"><p data-tag="p" id="p-bk6-95o-b36" class="p">待清除的任务类型:</p><ul lake-indent="0" data-tag="ul" id="ul-2mn-d9n-i75" class="ul"><li data-tag="li" id="li-x80-t7e-11w" class="li"><p id="p-f4y-1qk-7l9">ALL:所有的任务;</p></li><li data-tag="li" id="li-bx1-k4l-h32" class="li"><p id="p-9gw-mlm-e4u">AUTO:自动生成的任务;</p></li><li data-tag="li" id="li-f3r-gyu-lo5" class="li"><p id="p-h5q-5r8-t1t">MANUAL:用户手动发起的任务。</p></li></ul></td></tr></tbody></table> #### 示例 * 清除所有租户所有没有在调度的任务。 ~~~ ALTER SYSTEM REMOVE BALANCE TASK; ~~~ ## CANCEL MIGRATE UNIT #### 描述 该语句用来取消 UNIT 的迁移。 #### 格式 ~~~ ALTER SYSTEM CANCEL MIGRATE UNIT unit_id; ~~~ #### 参数解释 <table data-tag="table" id="table-9tb-qf9-2lq" class="table"><colgroup width="276" span="1" data-tag="col" id="col-mep-03x-y38" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="422" span="1" data-tag="col" id="col-i1d-a8d-9dd" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-zgo-zrb-9wz" class="thead"><tr id="tr-rz7-0yp-7fj"><th id="td-7xz-z0u-v79"><p id="p-y6r-385-5i6"><b>参数</b></p></th><th id="td-6en-97q-ndw"><p id="p-q2h-hmz-wkm"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-j93-z9x-kxf" class="tbody"><tr data-tag="tr" id="tr-bbj-13n-z05" class="tr"><td data-tag="td" id="td-h6v-nn0-3wl" class="td"><p id="p-xts-8n9-mvo">unit_id</p></td><td data-tag="td" id="td-fhi-leu-kvw" class="td"><p data-tag="p" id="p-j6t-8r2-47v" class="p">指定迁移的 UNIT 的 ID。</p></td></tr></tbody></table> #### 示例 * 取消 UNIT 1001 的迁移。 ~~~ ALTER SYSTEM CANCEL MIGRATE UNIT 1001; ~~~ ## RESTORE #### 描述 该语句用来恢复租户的数据。 #### 格式 ~~~ alter system restore dest_tenant from source_tenant at 'uri' until 'timestamp' with 'restore_option'; ~~~ #### 参数解释 <table data-tag="table" id="table-su2-9i6-vg3" class="table"><colgroup width="195" span="1" data-tag="col" id="col-eeb-5ob-0g8" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="528" span="1" data-tag="col" id="col-lin-il7-ckx" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-v1g-qml-2q9" class="thead"><tr id="tr-gq3-0av-evx"><th id="td-lu2-t78-7hp"><p id="p-5t2-obl-4l6"><b>参数</b></p></th><th id="td-v3a-y14-60b"><p id="p-tm4-4j7-avr"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-tv6-9ho-yd0" class="tbody"><tr data-tag="tr" id="tr-czz-x8t-i97" class="tr"><td data-tag="td" id="td-gj4-ane-p3o" class="td"><p data-tag="p" id="p-k5s-dlu-rz0" class="p">dest_tenant</p></td><td data-tag="td" id="td-lvl-bc7-rpf" class="td"><p data-tag="p" id="p-17z-6ts-65s" class="p">指恢复的新租户的名字。</p></td></tr><tr data-tag="tr" id="tr-mp1-8ew-7f7" class="tr"><td data-tag="td" id="td-81y-3oh-2fx" class="td"><p data-tag="p" id="p-wy5-zzo-e3b" class="p"> source_tenant</p></td><td data-tag="td" id="td-ly3-q10-8ax" class="td"><p data-tag="p" id="p-a5x-kzy-dvp" class="p">指原集群的租户。</p></td></tr><tr data-tag="tr" id="tr-446-8hh-mn9" class="tr"><td data-tag="td" id="td-w0m-wvq-618" class="td"><p data-tag="p" id="p-tzd-d0v-85o" class="p">uri</p></td><td data-tag="td" id="td-ruc-j6x-cqx" class="td"><p data-tag="p" id="p-tgv-p22-1cs" class="p">指备份的时候设置的 backup_dest。</p></td></tr><tr data-tag="tr" id="tr-mlq-49v-0z0" class="tr"><td data-tag="td" id="td-b24-mzf-f2w" class="td"><p data-tag="p" id="p-a2v-052-bmh" class="p">timestamp</p></td><td data-tag="td" id="td-vx1-nxe-h71" class="td"><p id="p-8lp-50k-isz">恢复的时间戳,需要大于等于最早备份的基线备份的 CDB_OB_BACKUP_SET_DETAILS 的START_TIME,小于等于日志备份 CDB_OB_BACKUP_ARCHIVELOG_SUMMARY 的 MAX_NEXT_TIME。</p></td></tr><tr data-tag="tr" id="tr-ua8-f80-36h" class="tr"><td data-tag="td" id="td-c73-o5t-ykx" class="td"><p id="p-6r7-9j0-ayl">restore_option</p></td><td data-tag="td" id="td-s14-qpl-39q" class="td"><p data-tag="p" id="p-vr6-stu-wri" class="p">恢复选项,支持以下几种:</p><ul lake-indent="0" data-tag="ul" id="ul-esi-c10-hrt" class="ul"><li data-tag="li" id="li-jk4-9a3-hod" class="li"><p id="p-1s3-uww-axw">backup_cluster_name:源集群的名字,必选项</p></li><li data-tag="li" id="li-6dn-tvb-0wi" class="li"><p id="p-gm6-w3s-bsu">backup_cluster_id:源集群的 cluster_id,必选项</p></li><li data-tag="li" id="li-inx-l15-3wt" class="li"><p id="p-50n-rx9-evv">pool_list:用户的资源池,必选项</p></li><li data-tag="li" id="li-wwn-qsd-1qy" class="li"><p id="p-bj3-iz2-1e5">locality:租户的 locality 信息,可选项</p></li><li data-tag="li" id="li-qu8-64n-w0m" class="li"><p id="p-ijt-uy6-wbr">kms_encrypt:为 true 表示需要恢复的时候指定kms_encrypt_info,可选项</p></li></ul></td></tr></tbody></table> #### 示例 * 恢复租户的数据。 ~~~ alter system restore restored_trade from trade at 'oss://antsys-oceanbasebackup/backup_rd/20200323?host=cn-hangzhou-alipay-b.oss-cdn.aliyun-inc.com&access_id=xxx&access_key=xxx' until ' 2020-03-23 08:59:45' with 'backup_cluster_name=ob20daily.backup&backup_cluster_id=1&pool_list=restore_pool'; alter system restore restored_trade from trade at 'file:///data/nfs/physical_backup_test/20200520' until '2020-05-21 09:39:54.071670' with 'backup_cluster_name=ob20daily.backup&backup_cluster_id=1&pool_list=restore_pool&locality=F@z1,F@z2,F@z3'; ~~~ ## CHANGE TENANT #### 描述 该语句用来切换租户。 #### 格式 ~~~ ALTER SYSTEM CHANGE TENANT tenant_name; ALTER SYSTEM CHANGE TENANT TENANT_ID [=] INTNUM; ~~~ #### 参数解释 <table data-tag="table" id="table-76d-lrk-lv9" class="table"><colgroup width="360" span="1" data-tag="col" id="col-iuf-bv4-ej3" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="360" span="1" data-tag="col" id="col-cb5-gyn-6w8" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-9wj-m6i-2q8" class="thead"><tr id="tr-i9f-c9z-t7q"><th id="td-zgu-k5x-kqb"><p id="p-s5w-7g1-54k"><b>参数</b></p></th><th id="td-ft7-rkm-1aa"><p id="p-3fc-ia2-xgv"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-qof-4ny-jpe" class="tbody"><tr data-tag="tr" id="tr-d8a-x32-eu8" class="tr"><td data-tag="td" id="td-zjt-q3t-4ta" class="td"><p data-tag="p" id="p-24e-wkk-1o5" class="p">tenant_name</p></td><td data-tag="td" id="td-k7l-eyq-jqz" class="td"><p data-tag="p" id="p-2rr-kg7-tfg" class="p">指定要切换到的租户名称。</p></td></tr><tr data-tag="tr" id="tr-l8o-2i0-k1p" class="tr"><td data-tag="td" id="td-v2z-4rj-26k" class="td"><p data-tag="p" id="p-6ge-yib-dn8" class="p">TENANT_ID</p></td><td data-tag="td" id="td-0a8-yvu-ulx" class="td"><p data-tag="p" id="p-tkw-3uc-vw7" class="p">指定要切换到的租户 ID。</p></td></tr></tbody></table> #### 示例 * 切换至 ID 为 1001 的租户。 ~~~ ALTER SYSTEM CHANGE TENANT TENANT_ID = 1001; ~~~ #### 注意事项 1. 需以系统租户身份登陆,普通租户无法执行该命令。 2. 需直连 OBServer 执行,断连接后需重新执行。 3. 不能在事务执行过程中执行该命令。 4. 切换到非系统租户后,无法执行 DDL 操作。 ## BACKUP #### 描述 该语句用来触发备份。 #### 格式 ~~~ 设置备份的介质路径 : alter system set backup_dest = <backup_uri> 开启 logarchive 的 SQL: alter system archivelog 关闭 logarchive 的 SQL: alter system noarchivelog 触发基线备份(只支持集群级别): alter system backup database; 取消当前备份: alter system cancel backup ~~~ #### 参数解释 <table data-tag="table" id="table-yn5-rif-38a" class="table"><colgroup width="172" span="1" data-tag="col" id="col-0cy-izv-5w4" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="557" span="1" data-tag="col" id="col-v3s-xmo-yte" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-8wl-u3r-s71" class="thead"><tr id="tr-x2q-qtt-1q6"><th id="td-ogq-3dp-kla"><p id="p-6f5-c1x-7gd"><b>参数</b></p></th><th id="td-emp-su8-207"><p id="p-9fe-zs2-rhh"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-x3b-gso-9um" class="tbody"><tr data-tag="tr" id="tr-8w5-4e6-rpu" class="tr"><td data-tag="td" id="td-00l-g80-pyn" class="td"><p data-tag="p" id="p-zj6-n40-eky" class="p">backup_uri</p></td><td data-tag="td" id="td-8q1-i9t-trc" class="td"><p data-tag="p" id="p-99z-k7u-vcw" class="p">指定备份的路径,目前支持 oss 和 file 两种,具体格式参考示例。</p></td></tr></tbody></table> #### 示例 * 设置备份的路径。 ~~~ alter system set backup_dest='oss://antsys-oceanbasebackup/backup_dir?host=xxx&access_id=xxx&access_key=xxx'; alter system set backup_dest='file:///data/nfs/physical_backup_dir'; ~~~ #### 注意事项 需以系统租户身份登陆,普通租户无法执行该命令。 ## MAXIMIZE 描述 该语句用来设置主备库的保护模式,只能在主库上执行。 #### 格式 ~~~ ALTER SYSTEM SET STANDBY CLUSTER TO MAXIMIZE {AVAILABILITY | PERFORMANCE | PROTECTION}; ~~~ #### 参数解释 <table data-tag="table" id="table-x0x-6e9-7vs" class="table"><colgroup width="172" span="1" data-tag="col" id="col-1zz-tom-6pl" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="557" span="1" data-tag="col" id="col-gg6-qay-7wc" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-ikh-av5-wai" class="thead"><tr id="tr-xmn-pk3-apn"><th id="td-gqq-5op-qvg"><p id="p-tw0-2jy-s0f"><b>参数</b></p></th><th id="td-h3b-uwc-uwk"><p id="p-l0f-712-q8y"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-cw6-uyc-das" class="tbody"><tr data-tag="tr" id="tr-fti-1y2-ioj" class="tr"><td data-tag="td" id="td-fig-uoi-01m" class="td"><p data-tag="p" id="p-cob-hyz-m26" class="p">AVAILABILITY</p></td><td data-tag="td" id="td-0er-bdi-sti" class="td"><p data-tag="p" id="p-xyv-nhi-086" class="p">设置为最大可用模式。</p></td></tr><tr data-tag="tr" id="tr-sgw-x6h-omp" class="tr"><td id="td-nt6-qwe-chg"><p id="p-gkv-x3i-dat">PERFORMANCE</p></td><td id="td-mgj-0qa-elu"><p id="p-3ck-ovd-yvv">设置为最大性能模式,为默认配置。</p></td></tr><tr data-tag="tr" id="tr-3po-has-cox" class="tr"><td id="td-ng5-60f-kpp"><p id="p-ifl-k7n-a6b">PROTECTION</p></td><td id="td-s6o-kt1-025"><p id="p-dpq-38x-e7e">设置为最大保护模式。</p></td></tr></tbody></table> #### 示例 * 设置主备库的保护模式为最大可用模式。 ~~~ ALTER SYSTEM SET STANDBY CLUSTER TO MAXIMIZE AVAILABILITY; ~~~ ## DELETE BACKUPSET 描述 该语句用来清理一个备份。 #### 格式 ~~~ ALTER SYSTEM DELETE BACKUPSET backup_set_id ~~~ #### 参数解释 <table data-tag="table" id="table-08q-ogq-x2z" class="table"><colgroup width="172" span="1" data-tag="col" id="col-v1f-qgt-csi" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="557" span="1" data-tag="col" id="col-j3b-fl1-6wr" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-b7b-i3e-cib" class="thead"><tr id="tr-grt-nw2-83p"><th id="td-x3g-vrx-crl"><p id="p-4kv-wnl-9p7"><b>参数</b></p></th><th id="td-d60-wxv-h2n"><p id="p-1np-3gf-t4o"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-w5s-3zw-3xi" class="tbody"><tr data-tag="tr" id="tr-v9q-tc1-18s" class="tr"><td data-tag="td" id="td-hru-2qb-3t6" class="td"><p data-tag="p" id="p-llg-in7-nmd" class="p">backup_set_id</p></td><td data-tag="td" id="td-hhs-y8s-jox" class="td"><p data-tag="p" id="p-wzm-6jm-yat" class="p">指定要清理的备份对应的 backup_set 的编号。用户发起一次备份时会有对应的 id,在 CDB_OB_BACKUP_SET_DETAILS 视图中可以查到。</p></td></tr></tbody></table> #### 示例 * 清理 backup\_set\_id 为 1 的备份数据。 ~~~ ALTER SYSTEM DELETE BACKUPSET 1; ~~~ ## DELETE OBSOLETE BACKUP 描述 该语句用来清理过期的备份数据。 **说明** 使用该语句清理过期的备份数据之前,需要先配置过期时间。 #### 格式 ~~~ ALTER SYSTEM SET backup_recovery_window = <过期时间>; ALTER SYSTEM DELETE OBSOLETE BACKUP; ~~~ #### 参数解释 <table data-tag="table" id="table-6lm-8zc-t3e" class="table"><colgroup width="172" span="1" data-tag="col" id="col-2h6-i3n-3x0" colwidth="1*" colnum="1" colname="col1" style="width:50%" class="col"></colgroup><colgroup width="557" span="1" data-tag="col" id="col-zd5-5x8-6y5" colwidth="1*" colnum="2" colname="col2" style="width:50%" class="col"></colgroup><thead id="thead-u06-xkw-2t3" class="thead"><tr id="tr-82u-uxn-bha"><th id="td-qjy-v7k-ltb"><p id="p-wcw-ogd-x1p"><b>参数</b></p></th><th id="td-wxe-31f-r4g"><p id="p-90n-vz2-cj6"><b>描述</b></p></th></tr></thead><tbody data-tag="tbody" id="tbody-m5m-0q3-yaa" class="tbody"><tr data-tag="tr" id="tr-gga-9oh-iym" class="tr"><td data-tag="td" id="td-29z-pyc-bbe" class="td"><p data-tag="p" id="p-wa6-p6z-p52" class="p">backup_recovery_window</p></td><td data-tag="td" id="td-04m-hym-pk8" class="td"><p data-tag="p" id="p-in5-78d-c3b" class="p">该配置项用于表示成功备份的数据可以提供恢复的时间窗口,默认值为 0,表示永久保留;建议设置为'7d',表示备份数据保留一周,一周之后备份数据会被清理掉。</p></td></tr></tbody></table> #### 示例 * 设置备份数据的过期时间为一周,一周后备份数据被清理。 ~~~ ALTER SYSTEM SET backup_recovery_window = '7d'; ALTER SYSTEM DELETE OBSOLETE BACKUP; ~~~