Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
soremi
oceanbase
提交
2b5dd977
O
oceanbase
项目概览
soremi
/
oceanbase
与 Fork 源项目一致
Fork自
oceanbase / oceanbase
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
oceanbase
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2b5dd977
编写于
10月 27, 2022
作者:
O
obdev
提交者:
wangzelin.wzl
10月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
modify upgrade script
上级
a589195f
变更
3
展开全部
隐藏空白更改
内联
并排
Showing
3 changed file
with
180 addition
and
783 deletion
+180
-783
tools/upgrade/upgrade_checker.py
tools/upgrade/upgrade_checker.py
+54
-19
tools/upgrade/upgrade_post.py
tools/upgrade/upgrade_post.py
+63
-382
tools/upgrade/upgrade_pre.py
tools/upgrade/upgrade_pre.py
+63
-382
未找到文件。
tools/upgrade/upgrade_checker.py
浏览文件 @
2b5dd977
...
...
@@ -285,16 +285,16 @@ def config_logging_module(log_filenamme):
#### ---------------end----------------------
fail_list
=
[]
#### START ####
# 1. 检查前置版本
def
check_observer_version
(
query_cur
,
upgrade_params
):
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select distinct value from GV$OB_PARAMETERS where name='min_observer_version'"""
)
if
len
(
results
)
!=
1
:
raise
MyError
(
'query results count is not 1'
)
fail_list
.
append
(
'query results count is not 1'
)
elif
cmp
(
results
[
0
][
0
],
upgrade_params
.
old_version
)
<
0
:
raise
MyError
(
'old observer version is expected equal or higher then: {0}, actual version:{1}'
.
format
(
upgrade_params
.
old_version
,
results
[
0
][
0
]))
fail_list
.
append
(
'old observer version is expected equal or higher then: {0}, actual version:{1}'
.
format
(
upgrade_params
.
old_version
,
results
[
0
][
0
]))
logging
.
info
(
'check observer version success, version = {0}'
.
format
(
results
[
0
][
0
]))
# 2. 检查paxos副本是否同步, paxos副本是否缺失
...
...
@@ -302,7 +302,7 @@ def check_paxos_replica(query_cur):
# 2.1 检查paxos副本是否同步
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select count(1) as unsync_cnt from GV$OB_LOG_STAT where in_sync = 'NO'"""
)
if
results
[
0
][
0
]
>
0
:
raise
MyError
(
'{0} replicas unsync, please check'
.
format
(
results
[
0
][
0
]))
fail_list
.
append
(
'{0} replicas unsync, please check'
.
format
(
results
[
0
][
0
]))
# 2.2 检查paxos副本是否有缺失 TODO
logging
.
info
(
'check paxos replica success'
)
...
...
@@ -311,11 +311,11 @@ def check_rebalance_task(query_cur):
# 3.1 检查是否有做locality变更
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select count(1) as cnt from DBA_OB_TENANT_JOBS where job_status='INPROGRESS' and result_code is null"""
)
if
results
[
0
][
0
]
>
0
:
raise
MyError
(
'{0} locality tasks is doing, please check'
.
format
(
results
[
0
][
0
]))
fail_list
.
append
(
'{0} locality tasks is doing, please check'
.
format
(
results
[
0
][
0
]))
# 3.2 检查是否有做balance
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select count(1) as rebalance_task_cnt from CDB_OB_LS_REPLICA_TASKS"""
)
if
results
[
0
][
0
]
>
0
:
raise
MyError
(
'{0} rebalance tasks is doing, please check'
.
format
(
results
[
0
][
0
]))
fail_list
.
append
(
'{0} rebalance tasks is doing, please check'
.
format
(
results
[
0
][
0
]))
logging
.
info
(
'check rebalance task success'
)
# 4. 检查集群状态
...
...
@@ -323,33 +323,65 @@ def check_cluster_status(query_cur):
# 4.1 检查是否非合并状态
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select count(1) from CDB_OB_MAJOR_COMPACTION where STATUS != 'IDLE'"""
)
if
results
[
0
][
0
]
>
0
:
raise
MyError
(
'{0} tenant is merging, please check'
.
format
(
results
[
0
][
0
]))
fail_list
.
append
(
'{0} tenant is merging, please check'
.
format
(
results
[
0
][
0
]))
logging
.
info
(
'check cluster status success'
)
# 16. 修改永久下线的时间,避免升级过程中缺副本
def
modify_server_permanent_offline_time
(
cur
):
set_parameter
(
cur
,
'server_permanent_offline_time'
,
'72h'
)
# 23. 检查是否有异常租户(creating,延迟删除,恢复中)
# 5. 检查是否有异常租户(creating,延迟删除,恢复中)
def
check_tenant_status
(
query_cur
):
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select count(*) as count from DBA_OB_TENANTS where status != 'NORMAL'"""
)
if
len
(
results
)
!=
1
or
len
(
results
[
0
])
!=
1
:
raise
MyError
(
'results len not match'
)
fail_list
.
append
(
'results len not match'
)
elif
0
!=
results
[
0
][
0
]:
raise
MyError
(
'has abnormal tenant, should stop'
)
fail_list
.
append
(
'has abnormal tenant, should stop'
)
else
:
logging
.
info
(
'check tenant status success'
)
#
27
. 检查无恢复任务
#
6
. 检查无恢复任务
def
check_restore_job_exist
(
query_cur
):
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select count(1) from CDB_OB_RESTORE_PROGRESS"""
)
if
len
(
results
)
!=
1
or
len
(
results
[
0
])
!=
1
:
raise
MyError
(
'failed to restore job cnt'
)
fail_list
.
append
(
'failed to restore job cnt'
)
elif
results
[
0
][
0
]
!=
0
:
raise
MyError
(
"""still has restore job, upgrade is not allowed temporarily"""
)
fail_list
.
append
(
"""still has restore job, upgrade is not allowed temporarily"""
)
logging
.
info
(
'check restore job success'
)
def
check_is_primary_zone_distributed
(
primary_zone_str
):
semicolon_pos
=
len
(
primary_zone_str
)
for
i
in
range
(
len
(
primary_zone_str
)):
if
primary_zone_str
[
i
]
==
';'
:
semicolon_pos
=
i
break
comma_pos
=
len
(
primary_zone_str
)
for
j
in
range
(
len
(
primary_zone_str
)):
if
primary_zone_str
[
j
]
==
','
:
comma_pos
=
j
break
if
comma_pos
<
semicolon_pos
:
return
True
else
:
return
False
# 7. 升级前需要primary zone只有一个
def
check_tenant_primary_zone
(
query_cur
):
(
desc
,
results
)
=
query_cur
.
exec_query
(
"""select tenant_name,primary_zone from DBA_OB_TENANTS where tenant_id != 1"""
);
for
item
in
results
:
if
cmp
(
item
[
1
],
"RANDOM"
)
==
0
:
fail_list
.
append
(
'{0} tenant primary zone random before update not allowed'
.
format
(
item
[
0
]))
elif
check_is_primary_zone_distributed
(
item
[
1
]):
fail_list
.
append
(
'{0} tenant primary zone distributed before update not allowed'
.
format
(
item
[
0
]))
logging
.
info
(
'check tenant primary zone success'
)
# 8. 修改永久下线的时间,避免升级过程中缺副本
def
modify_server_permanent_offline_time
(
cur
):
set_parameter
(
cur
,
'server_permanent_offline_time'
,
'72h'
)
# last check of do_check, make sure no function execute after check_fail_list
def
check_fail_list
():
if
len
(
fail_list
)
!=
0
:
error_msg
=
"upgrade checker failed with "
+
str
(
len
(
fail_list
))
+
" reasons: "
+
", "
.
join
([
'['
+
x
+
"] "
for
x
in
fail_list
])
raise
MyError
(
error_msg
)
# 开始升级前的检查
def
do_check
(
my_host
,
my_port
,
my_user
,
my_passwd
,
upgrade_params
):
try
:
...
...
@@ -368,8 +400,11 @@ def do_check(my_host, my_port, my_user, my_passwd, upgrade_params):
check_rebalance_task
(
query_cur
)
check_cluster_status
(
query_cur
)
check_tenant_status
(
query_cur
)
modify_server_permanent_offline_time
(
cur
)
check_restore_job_exist
(
query_cur
)
check_tenant_primary_zone
(
query_cur
)
# all check func should execute before check_fail_list
check_fail_list
()
#modify_server_permanent_offline_time(cur)
except
Exception
,
e
:
logging
.
exception
(
'run error'
)
raise
e
...
...
tools/upgrade/upgrade_post.py
浏览文件 @
2b5dd977
此差异已折叠。
点击以展开。
tools/upgrade/upgrade_pre.py
浏览文件 @
2b5dd977
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录