Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
oceanbase
oceanbase
提交
6b675a2a
O
oceanbase
项目概览
oceanbase
/
oceanbase
2 年多 前同步成功
通知
263
Star
6084
Fork
1301
代码
文件
提交
分支
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看板
未验证
提交
6b675a2a
编写于
11月 21, 2022
作者:
羽飞
提交者:
GitHub
11月 21, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix obd (#1136)
上级
b27c6c97
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
443 addition
and
137 deletion
+443
-137
deps/init/oceanbase.el7.aarch64.deps
deps/init/oceanbase.el7.aarch64.deps
+2
-6
deps/init/oceanbase.el7.x86_64.deps
deps/init/oceanbase.el7.x86_64.deps
+3
-1
deps/init/oceanbase.el8.aarch64.deps
deps/init/oceanbase.el8.aarch64.deps
+2
-1
deps/init/oceanbase.el8.x86_64.deps
deps/init/oceanbase.el8.x86_64.deps
+2
-1
src/sql/engine/expr/ob_expr_to_outfile_row.cpp
src/sql/engine/expr/ob_expr_to_outfile_row.cpp
+126
-126
tools/deploy/init_create_tenant_routines.sql
tools/deploy/init_create_tenant_routines.sql
+308
-0
tools/deploy/obd.sh
tools/deploy/obd.sh
+0
-2
未找到文件。
deps/init/oceanbase.el7.aarch64.deps
浏览文件 @
6b675a2a
...
...
@@ -8,11 +8,6 @@ os=7
arch=aarch64
repo=http://mirrors.aliyun.com/oceanbase/community/stable/el/7/aarch64/
[target-tbsite]
os=7
arch=aarch64
repo=http://yum.tbsite.net/taobao/7/aarch64/test/ob-deploy/
[deps]
devdeps-gtest-1.8.0-132022101316.el7.aarch64.rpm
devdeps-isa-l-static-2.22.0-22022092915.el7.aarch64.rpm
...
...
@@ -44,4 +39,5 @@ devdeps-oblogmsg-1.0-42022101823.el7.aarch64.rpm
devdeps-rocksdb-6.22.1.1-52022100420.el7.aarch64.rpm
[test-utils]
#ob-deploy-1.5.0-12.el7.aarch64.rpm target=community
ob-deploy-1.6.0-41.el7.aarch64.rpm target=community
obclient-2.0.2-3.el7.aarch64.rpm target=community
deps/init/oceanbase.el7.x86_64.deps
浏览文件 @
6b675a2a
...
...
@@ -3,6 +3,7 @@ os=7
arch=x86_64
repo=http://mirrors.aliyun.com/oceanbase/development-kit/el/7/x86_64/
[target-community]
os=7
arch=x86_64
...
...
@@ -40,4 +41,5 @@ devdeps-oblogmsg-1.0-42022101823.el7.x86_64.rpm
devdeps-rocksdb-6.22.1.1-52022100420.el7.x86_64.rpm
[test-utils]
ob-deploy-1.6.0-41.el7.x86_64.rpm target=community
obclient-2.0.2-3.el7.x86_64.rpm target=community
deps/init/oceanbase.el8.aarch64.deps
浏览文件 @
6b675a2a
...
...
@@ -39,4 +39,5 @@ devdeps-oblogmsg-1.0-42022101823.el8.aarch64.rpm
devdeps-rocksdb-6.22.1.1-52022100420.el8.aarch64.rpm
[test-utils]
#ob-deploy-1.5.0-12.el8.aarch64.rpm target=community
ob-deploy-1.6.0-41.el8.aarch64.rpm target=community
obclient-2.0.2-3.el8.aarch64.rpm target=community
deps/init/oceanbase.el8.x86_64.deps
浏览文件 @
6b675a2a
...
...
@@ -40,4 +40,5 @@ devdeps-oblogmsg-1.0-42022101823.el8.x86_64.rpm
devdeps-rocksdb-6.22.1.1-52022100420.el8.x86_64.rpm
[test-utils]
#ob-deploy-1.5.0-12.el8.x86_64.rpm target=community
ob-deploy-1.6.0-41.el8.x86_64.rpm target=community
obclient-2.0.2-3.el8.x86_64.rpm target=community
src/sql/engine/expr/ob_expr_to_outfile_row.cpp
浏览文件 @
6b675a2a
...
...
@@ -10,48 +10,48 @@
* See the Mulan PubL v2 for more details.
*/
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/expr/ob_expr_to_outfile_row.h"
#include <string.h>
#include "lib/oblog/ob_log.h"
#include "objit/common/ob_item_type.h"
#include "sql/session/ob_sql_session_info.h"
#include "sql/engine/ob_exec_context.h"
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
sql
{
ObExprToOutfileRow
::
ObExprToOutfileRow
(
ObIAllocator
&
alloc
)
:
ObStringExprOperator
(
alloc
,
T_OP_TO_OUTFILE_ROW
,
N_TO_OUTFILE_ROW
,
MORE_THAN_ZERO
,
INTERNAL_IN_MYSQL_MODE
)
{
need_charset_convert_
=
false
;
}
ObExprToOutfileRow
::~
ObExprToOutfileRow
()
{
}
int
ObExprToOutfileRow
::
calc_result_typeN
(
ObExprResType
&
type
,
ObExprResType
*
types
,
int64_t
param_num
,
ObExprTypeCtx
&
type_ctx
)
const
{
//objs[0] field_str varchar
//objs[1] line_str varchar
//objs[2] closed_cht char
//objs[3] is_optional bool
//objs[4] escaped_cht char
//objs[5:] params
int
ret
=
OB_SUCCESS
;
UNUSED
(
type_ctx
);
if
(
OB_UNLIKELY
(
param_num
<=
PARAM_SELECT_ITEM
))
{
ret
=
OB_INVALID_ARGUMENT_NUM
;
LOG_WARN
(
"invalid argument number"
,
K
(
ret
),
K
(
param_num
));
#define USING_LOG_PREFIX SQL_ENG
#include "sql/engine/expr/ob_expr_to_outfile_row.h"
#include <string.h>
#include "lib/oblog/ob_log.h"
#include "objit/common/ob_item_type.h"
#include "sql/session/ob_sql_session_info.h"
#include "sql/engine/ob_exec_context.h"
using
namespace
oceanbase
::
common
;
namespace
oceanbase
{
namespace
sql
{
ObExprToOutfileRow
::
ObExprToOutfileRow
(
ObIAllocator
&
alloc
)
:
ObStringExprOperator
(
alloc
,
T_OP_TO_OUTFILE_ROW
,
N_TO_OUTFILE_ROW
,
MORE_THAN_ZERO
,
INTERNAL_IN_MYSQL_MODE
)
{
need_charset_convert_
=
false
;
}
ObExprToOutfileRow
::~
ObExprToOutfileRow
()
{
}
int
ObExprToOutfileRow
::
calc_result_typeN
(
ObExprResType
&
type
,
ObExprResType
*
types
,
int64_t
param_num
,
ObExprTypeCtx
&
type_ctx
)
const
{
//objs[0] field_str varchar
//objs[1] line_str varchar
//objs[2] closed_cht char
//objs[3] is_optional bool
//objs[4] escaped_cht char
//objs[5:] params
int
ret
=
OB_SUCCESS
;
UNUSED
(
type_ctx
);
if
(
OB_UNLIKELY
(
param_num
<=
PARAM_SELECT_ITEM
))
{
ret
=
OB_INVALID_ARGUMENT_NUM
;
LOG_WARN
(
"invalid argument number"
,
K
(
ret
),
K
(
param_num
));
}
else
{
// deduce type and length
type
.
set_varbinary
();
...
...
@@ -84,90 +84,90 @@ int ObExprToOutfileRow::cg_expr(ObExprCGCtx &, const ObRawExpr &, ObExpr &expr)
if
(
!
expr
.
args_
[
i
]
->
is_static_const_
)
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"non-const format not supported"
,
K
(
ret
));
}
}
expr
.
eval_func_
=
&
to_outfile_str
;
}
return
ret
;
}
int
ObExprToOutfileRow
::
extend_buffer
(
ObExprOutFileInfo
&
out_info
,
ObIAllocator
&
allocator
)
{
int
ret
=
OB_SUCCESS
;
int64_t
old_len
=
out_info
.
buf_len_
;
int64_t
new_len
=
(
old_len
==
0
)
?
OB_MALLOC_MIDDLE_BLOCK_SIZE
:
old_len
*
2
;
if
(
OB_ISNULL
(
out_info
.
buf_
=
static_cast
<
char
*>
(
allocator
.
alloc
(
new_len
))))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
LOG_WARN
(
"fail to allocate memory"
,
K
(
ret
),
K
(
old_len
),
K
(
new_len
));
}
else
if
(
OB_ISNULL
(
out_info
.
tmp_buf_
=
static_cast
<
char
*>
(
allocator
.
alloc
(
new_len
))))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
LOG_WARN
(
"fail to allocate memory"
,
K
(
ret
),
K
(
old_len
),
K
(
new_len
));
}
else
{
out_info
.
buf_len_
=
new_len
;
out_info
.
tmp_buf_len_
=
new_len
;
}
return
ret
;
}
int
ObExprToOutfileRow
::
calc_outfile_info
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObIAllocator
&
allocator
,
ObExprOutFileInfo
&
out_info
)
{
int
ret
=
OB_SUCCESS
;
ObObj
objs_array
[
PARAM_SELECT_ITEM
];
ObSQLSessionInfo
*
session
=
ctx
.
exec_ctx_
.
get_my_session
();
if
(
OB_ISNULL
(
session
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"session is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
out_info
.
print_params_
.
tz_info_
=
session
->
get_timezone_info
()))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to get timezone info"
,
K
(
ret
));
}
else
{
out_info
.
print_params_
.
use_memcpy_
=
true
;
out_info
.
is_optional_
=
expr
.
locate_param_datum
(
ctx
,
PARAM_OPTIONAL
).
get_bool
();
}
for
(
int
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
PARAM_SELECT_ITEM
;
++
i
)
{
OZ
(
expr
.
locate_param_datum
(
ctx
,
i
).
to_obj
(
objs_array
[
i
],
expr
.
args_
[
i
]
->
obj_meta_
,
expr
.
args_
[
i
]
->
obj_datum_map_
));
}
if
(
OB_SUCC
(
ret
))
{
out_info
.
field_
=
objs_array
[
PARAM_FIELD
];
out_info
.
line_
=
objs_array
[
PARAM_LINE
];
out_info
.
enclose_
=
objs_array
[
PARAM_ENCLOSED
];
out_info
.
escape_
=
objs_array
[
PARAM_ESCAPED
];
out_info
.
print_params_
.
cs_type_
=
static_cast
<
ObCollationType
>
(
objs_array
[
PARAM_CHARSET
].
get_int
());
}
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
field_
,
out_info
.
wchar_field_
));
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
line_
,
out_info
.
wchar_line_
));
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
enclose_
,
out_info
.
wchar_enclose_
));
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
escape_
,
out_info
.
wchar_escape_
));
OZ
(
extend_buffer
(
out_info
,
allocator
));
return
ret
;
}
int
ObExprToOutfileRow
::
to_outfile_str
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
)
{
int
ret
=
OB_SUCCESS
;
if
(
OB_UNLIKELY
(
expr
.
arg_cnt_
<=
PARAM_SELECT_ITEM
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"Invalid argument"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
expr
.
eval_param_value
(
ctx
)))
{
LOG_WARN
(
"evaluate parameters values failed"
,
K
(
ret
));
}
else
{
ObExprOutFileInfo
*
out_info
=
NULL
;
auto
rt_ctx_id
=
static_cast
<
uint64_t
>
(
expr
.
expr_ctx_id_
);
if
(
NULL
==
(
out_info
=
static_cast
<
ObExprOutFileInfo
*>
(
ctx
.
exec_ctx_
.
get_expr_op_ctx
(
rt_ctx_id
))))
{
if
(
OB_FAIL
(
ctx
.
exec_ctx_
.
create_expr_op_ctx
(
rt_ctx_id
,
out_info
)))
{
LOG_WARN
(
"failed to create operator ctx"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
calc_outfile_info
(
expr
,
ctx
,
ctx
.
exec_ctx_
.
get_allocator
(),
*
out_info
)))
{
LOG_WARN
(
"fail calc outfile info"
,
K
(
ret
));
}
}
}
expr
.
eval_func_
=
&
to_outfile_str
;
}
return
ret
;
}
int
ObExprToOutfileRow
::
extend_buffer
(
ObExprOutFileInfo
&
out_info
,
ObIAllocator
&
allocator
)
{
int
ret
=
OB_SUCCESS
;
int64_t
old_len
=
out_info
.
buf_len_
;
int64_t
new_len
=
(
old_len
==
0
)
?
OB_MALLOC_MIDDLE_BLOCK_SIZE
:
old_len
*
2
;
if
(
OB_ISNULL
(
out_info
.
buf_
=
static_cast
<
char
*>
(
allocator
.
alloc
(
new_len
))))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
LOG_WARN
(
"fail to allocate memory"
,
K
(
ret
),
K
(
old_len
),
K
(
new_len
));
}
else
if
(
OB_ISNULL
(
out_info
.
tmp_buf_
=
static_cast
<
char
*>
(
allocator
.
alloc
(
new_len
))))
{
ret
=
OB_ALLOCATE_MEMORY_FAILED
;
LOG_WARN
(
"fail to allocate memory"
,
K
(
ret
),
K
(
old_len
),
K
(
new_len
));
}
else
{
out_info
.
buf_len_
=
new_len
;
out_info
.
tmp_buf_len_
=
new_len
;
}
return
ret
;
}
int
ObExprToOutfileRow
::
calc_outfile_info
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObIAllocator
&
allocator
,
ObExprOutFileInfo
&
out_info
)
{
int
ret
=
OB_SUCCESS
;
ObObj
objs_array
[
PARAM_SELECT_ITEM
];
ObSQLSessionInfo
*
session
=
ctx
.
exec_ctx_
.
get_my_session
();
if
(
OB_ISNULL
(
session
))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"session is null"
,
K
(
ret
));
}
else
if
(
OB_ISNULL
(
out_info
.
print_params_
.
tz_info_
=
session
->
get_timezone_info
()))
{
ret
=
OB_ERR_UNEXPECTED
;
LOG_WARN
(
"fail to get timezone info"
,
K
(
ret
));
}
else
{
out_info
.
print_params_
.
use_memcpy_
=
true
;
out_info
.
is_optional_
=
expr
.
locate_param_datum
(
ctx
,
PARAM_OPTIONAL
).
get_bool
();
}
for
(
int
i
=
0
;
OB_SUCC
(
ret
)
&&
i
<
PARAM_SELECT_ITEM
;
++
i
)
{
OZ
(
expr
.
locate_param_datum
(
ctx
,
i
).
to_obj
(
objs_array
[
i
],
expr
.
args_
[
i
]
->
obj_meta_
,
expr
.
args_
[
i
]
->
obj_datum_map_
));
}
if
(
OB_SUCC
(
ret
))
{
out_info
.
field_
=
objs_array
[
PARAM_FIELD
];
out_info
.
line_
=
objs_array
[
PARAM_LINE
];
out_info
.
enclose_
=
objs_array
[
PARAM_ENCLOSED
];
out_info
.
escape_
=
objs_array
[
PARAM_ESCAPED
];
out_info
.
print_params_
.
cs_type_
=
static_cast
<
ObCollationType
>
(
objs_array
[
PARAM_CHARSET
].
get_int
());
}
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
field_
,
out_info
.
wchar_field_
));
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
line_
,
out_info
.
wchar_line_
));
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
enclose_
,
out_info
.
wchar_enclose_
));
OZ
(
extract_fisrt_wchar_from_varhcar
(
out_info
.
escape_
,
out_info
.
wchar_escape_
));
OZ
(
extend_buffer
(
out_info
,
allocator
));
return
ret
;
}
int
ObExprToOutfileRow
::
to_outfile_str
(
const
ObExpr
&
expr
,
ObEvalCtx
&
ctx
,
ObDatum
&
expr_datum
)
{
int
ret
=
OB_SUCCESS
;
if
(
OB_UNLIKELY
(
expr
.
arg_cnt_
<=
PARAM_SELECT_ITEM
))
{
ret
=
OB_INVALID_ARGUMENT
;
LOG_WARN
(
"Invalid argument"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
expr
.
eval_param_value
(
ctx
)))
{
LOG_WARN
(
"evaluate parameters values failed"
,
K
(
ret
));
}
else
{
ObExprOutFileInfo
*
out_info
=
NULL
;
auto
rt_ctx_id
=
static_cast
<
uint64_t
>
(
expr
.
expr_ctx_id_
);
if
(
NULL
==
(
out_info
=
static_cast
<
ObExprOutFileInfo
*>
(
ctx
.
exec_ctx_
.
get_expr_op_ctx
(
rt_ctx_id
))))
{
if
(
OB_FAIL
(
ctx
.
exec_ctx_
.
create_expr_op_ctx
(
rt_ctx_id
,
out_info
)))
{
LOG_WARN
(
"failed to create operator ctx"
,
K
(
ret
));
}
else
if
(
OB_FAIL
(
calc_outfile_info
(
expr
,
ctx
,
ctx
.
exec_ctx_
.
get_allocator
(),
*
out_info
)))
{
LOG_WARN
(
"fail calc outfile info"
,
K
(
ret
));
}
}
if
(
OB_SUCC
(
ret
))
{
do
{
...
...
tools/deploy/init_create_tenant_routines.sql
0 → 100644
浏览文件 @
6b675a2a
-- =========================================================================================
-- author: wanhong.wwh
-- 本文件提供了创建和删除租户相关的procedure,简化操作流程,不再需要了解租户资源规格、资源池概念,提供集成化的接口
-- * 创建租户: 集成创建租户规格、创建资源池、创建租户
-- * 删除租户: 删除租户、删除资源池、删除资源规格
-- 使用方法示例:
-- call oceanbase.create_mysql_tenant('租户名称');
-- call oceanbase.drop_tenant();
-- 注意事项:
-- * create_xx_tenant()和drop_tenant()需要成对调用,保证删除所有资源
-- * procedure创建在oceanbase库下,需要增加oceanbase前缀
-- * 如果放在mysqltest中使用,建议增加 --disable_query_log和--enable_query_log,避免输出影响结果,例如:
-- --disable_query_log
-- call oceanbase.create_mysql_tenant('test');
-- --enable_query_log
-- * mysql租户系列procedure
-- - create_mysql_tenant:创建一个默认配置的mysql租户,目前是2c4g
-- - create_mysql_tenant_mini:创建一个默认配置的mysql租户
set
@@
session
.
ob_query_timeout
=
200000000
;
alter
system
set
__min_full_resource_pool_memory
=
1073741824
;
use
oceanbase
;
-- 1C1G 规格
create
resource
unit
if
not
exists
1
c1g
max_cpu
1
,
memory_size
'1G'
;
-- 1C2G 规格
create
resource
unit
if
not
exists
1
c2g
max_cpu
1
,
memory_size
'2G'
;
-- 2C2G 规格
create
resource
unit
if
not
exists
2
c2g
max_cpu
2
,
memory_size
'2G'
;
-- 2C4G 规格
create
resource
unit
if
not
exists
2
c4g
max_cpu
2
,
memory_size
'4G'
;
-- =================================== create_tenant 模板 ===================================
-- create_tenant: 指定规格创建租户
-- @param tenant_name 租户名
-- @param compat_mode 兼容模式,'mysql' or 'oracle'
-- @param unit_config unit规格名,要求规格名已存在,例如:我们预创建了一批规格:1c1g, 1c2g, 2c2g, 2c4g
delimiter
/
drop
procedure
if
exists
create_tenant
;
/
create
procedure
create_tenant
(
tenant_name
varchar
(
64
),
compat_mode
varchar
(
10
),
unit_config
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
compat_mode
,
unit_config
,
''
);
end
/
-- create_tenant_with_arg: 指定规格、以及参数列表创建租户
-- @param arg_list 创建租户的参数列表,例如: charset=gb18030
drop
procedure
if
exists
create_tenant_with_arg
;
/
create
procedure
create_tenant_with_arg
(
tenant_name
varchar
(
64
),
compat_mode
varchar
(
10
),
unit_config
varchar
(
64
),
arg_list
varchar
(
64
))
begin
declare
num
int
;
declare
zone_name
varchar
(
20
);
select
count
(
*
)
from
oceanbase
.
DBA_OB_SERVERS
group
by
zone
limit
1
into
num
;
select
zone
from
(
select
zone
,
count
(
*
)
as
a
from
oceanbase
.
DBA_OB_ZONES
group
by
region
order
by
a
desc
limit
1
)
into
zone_name
;
-- resource pool名称默认为:pool_for_tenant_xxx
set
@
pool_name
=
concat
(
"pool_for_tenant_"
,
tenant_name
);
set
@
sql_text
=
concat
(
"create resource pool if not exists "
,
@
pool_name
,
" unit = '"
,
unit_config
,
"', unit_num = "
,
num
,
";"
);
prepare
stmt
from
@
sql_text
;
execute
stmt
;
if
(
arg_list
=
''
)
then
set
@
str
=
''
;
else
set
@
str
=
','
;
end
if
;
set
@
sql_text
=
concat
(
"create tenant "
,
tenant_name
,
" primary_zone='"
,
zone_name
,
"', resource_pool_list=('"
,
@
pool_name
,
"') "
,
@
str
,
arg_list
,
" set ob_compatibility_mode='"
,
compat_mode
,
"', ob_tcp_invited_nodes='%', parallel_servers_target=10, secure_file_priv = '';"
);
prepare
stmt
from
@
sql_text
;
execute
stmt
;
deallocate
prepare
stmt
;
end
/
-- =================================== drop_tenant ===================================
-- 保证删除掉租户,清理资源
drop
procedure
if
exists
drop_tenant
;
/
create
procedure
drop_tenant
(
tenant_name
varchar
(
64
))
begin
declare
recyclebin_value
int
;
select
value
from
oceanbase
.
CDB_OB_SYS_VARIABLES
where
name
=
'recyclebin'
and
tenant_id
=
1
into
recyclebin_value
;
set
recyclebin
=
off
;
-- 首先删除租户
set
@
sql_text
=
concat
(
"drop tenant if exists "
,
tenant_name
,
";"
);
prepare
stmt
from
@
sql_text
;
execute
stmt
;
-- 清理resource pool
set
@
pool_name
=
concat
(
"pool_for_tenant_"
,
tenant_name
);
set
@
sql_text
=
concat
(
"drop resource pool if exists "
,
@
pool_name
,
";"
);
prepare
stmt
from
@
sql_text
;
execute
stmt
;
deallocate
prepare
stmt
;
set
recyclebin
=
recyclebin_value
;
end
/
-- =================================== drop_tenant_force ===================================
-- 快速删除租户,资源可能还保留
drop
procedure
if
exists
drop_tenant_force
;
/
create
procedure
drop_tenant_force
(
tenant_name
varchar
(
64
))
begin
declare
recyclebin_value
int
;
select
value
from
oceanbase
.
CDB_OB_SYS_VARIABLES
where
name
=
'recyclebin'
and
tenant_id
=
1
into
recyclebin_value
;
set
recyclebin
=
off
;
-- 首先删除租户
set
@
sql_text
=
concat
(
"drop tenant if exists "
,
tenant_name
,
" force;"
);
prepare
stmt
from
@
sql_text
;
execute
stmt
;
-- 清理resource pool
set
@
pool_name
=
concat
(
"pool_for_tenant_"
,
tenant_name
);
set
@
sql_text
=
concat
(
"drop resource pool if exists "
,
@
pool_name
,
";"
);
prepare
stmt
from
@
sql_text
;
execute
stmt
;
deallocate
prepare
stmt
;
set
recyclebin
=
recyclebin_value
;
end
/
-- =================================== create_mysql_tenant ===================================
-- create_mysql_tenant / create_mysql_tenant_with_arg: 默认创建一个2c4g的mysql租户
drop
procedure
if
exists
create_mysql_tenant
;
/
create
procedure
create_mysql_tenant
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_mysql_tenant_with_arg
(
tenant_name
,
''
);
end
/
drop
procedure
if
exists
create_mysql_tenant_with_arg
;
/
create
procedure
create_mysql_tenant_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_mysql_tenant_2c4g
(
tenant_name
);
end
/
-- create_mysql_tenant_mini / create_mysql_tenant_mini_with_arg: 默认创建一个1c1g的mysql租户
drop
procedure
if
exists
create_mysql_tenant_mini
;
/
create
procedure
create_mysql_tenant_mini
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_mysql_tenant_1c1g
(
tenant_name
);
end
/
drop
procedure
if
exists
create_mysql_tenant_mini_with_arg
;
/
create
procedure
create_mysql_tenant_mini_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_mysql_tenant_1c1g_with_arg
(
tenant_name
,
arg_list
);
end
/
-- create_mysql_tenant_1c1g / create_mysql_tenant_1c1g_with_arg: 创建一个1c1g的mysql租户
drop
procedure
if
exists
create_mysql_tenant_1c1g
;
/
create
procedure
create_mysql_tenant_1c1g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'mysql'
,
'1c1g'
);
end
/
drop
procedure
if
exists
create_mysql_tenant_1c1g_with_arg
;
/
create
procedure
create_mysql_tenant_1c1g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'mysql'
,
'1c1g'
,
arg_list
);
end
/
-- create_mysql_tenant_1c2g / create_mysql_tenant_1c2g_with_arg: 创建一个1c2g的mysql租户
drop
procedure
if
exists
create_mysql_tenant_1c2g
;
/
create
procedure
create_mysql_tenant_1c2g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'mysql'
,
'1c2g'
);
end
/
drop
procedure
if
exists
create_mysql_tenant_1c2g_with_arg
;
/
create
procedure
create_mysql_tenant_1c2g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'mysql'
,
'1c2g'
,
arg_list
);
end
/
-- create_mysql_tenant_2c2g / create_mysql_tenant_2c2g_with_arg: 创建一个2c2g的mysql租户
drop
procedure
if
exists
create_mysql_tenant_2c2g
;
/
create
procedure
create_mysql_tenant_2c2g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'mysql'
,
'2c2g'
);
end
/
drop
procedure
if
exists
create_mysql_tenant_2c2g_with_arg
;
/
create
procedure
create_mysql_tenant_2c2g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'mysql'
,
'2c2g'
,
arg_list
);
end
/
-- create_mysql_tenant_2c4g / create_mysql_tenant_2c4g_with_arg: 创建一个2c4g的mysql租户
drop
procedure
if
exists
create_mysql_tenant_2c4g
;
/
create
procedure
create_mysql_tenant_2c4g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'mysql'
,
'2c4g'
);
end
/
drop
procedure
if
exists
create_mysql_tenant_2c4g_with_arg
;
/
create
procedure
create_mysql_tenant_2c4g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'mysql'
,
'2c4g'
,
arg_list
);
end
/
-- =================================== create_oracle_tenant ===================================
-- create_oracle_tenant / create_oracle_tenant_with_arg: 默认创建一个2c4g的oracle租户
drop
procedure
if
exists
create_oracle_tenant
;
/
create
procedure
create_oracle_tenant
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_oracle_tenant_2c4g
(
tenant_name
);
end
/
drop
procedure
if
exists
create_oracle_tenant_with_arg
;
/
create
procedure
create_oracle_tenant_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_oracle_tenant_2c4g_with_arg
(
tenant_name
,
arg_list
);
end
/
-- create_oracle_tenant_mini / create_oracle_tenant_mini_with_arg: 默认创建一个1c1g的oracle租户
drop
procedure
if
exists
create_oracle_tenant_mini
;
/
create
procedure
create_oracle_tenant_mini
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_oracle_tenant_1c1g
(
tenant_name
);
end
/
drop
procedure
if
exists
create_oracle_tenant_mini_with_arg
;
/
create
procedure
create_oracle_tenant_mini_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_oracle_tenant_1c1g_with_arg
(
tenant_name
,
arg_list
);
end
/
-- create_oracle_tenant_1c1g / create_oracle_tenant_1c1g_with_arg: 创建一个1c1g的oracle租户
drop
procedure
if
exists
create_oracle_tenant_1c1g
;
/
create
procedure
create_oracle_tenant_1c1g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'oracle'
,
'1c1g'
);
end
/
drop
procedure
if
exists
create_oracle_tenant_1c1g_with_arg
;
/
create
procedure
create_oracle_tenant_1c1g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'oracle'
,
'1c1g'
,
arg_list
);
end
/
-- create_oracle_tenant_1c2g / create_oracle_tenant_1c2g_with_arg: 创建一个1c2g的oracle租户
drop
procedure
if
exists
create_oracle_tenant_1c2g
;
/
create
procedure
create_oracle_tenant_1c2g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'oracle'
,
'1c2g'
);
end
/
drop
procedure
if
exists
create_oracle_tenant_1c2g_with_arg
;
/
create
procedure
create_oracle_tenant_1c2g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'oracle'
,
'1c2g'
,
arg_list
);
end
/
-- create_oracle_tenant_2c2g / create_oracle_tenant_2c2g_with_arg: 创建一个2c2g的oracle租户
drop
procedure
if
exists
create_oracle_tenant_2c2g
;
/
create
procedure
create_oracle_tenant_2c2g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'oracle'
,
'2c2g'
);
end
/
drop
procedure
if
exists
create_oracle_tenant_2c2g_with_arg
;
/
create
procedure
create_oracle_tenant_2c2g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'oracle'
,
'2c2g'
,
arg_list
);
end
/
-- create_oracle_tenant_2c4g: 创建一个2c4g的oracle租户
drop
procedure
if
exists
create_oracle_tenant_2c4g
;
/
create
procedure
create_oracle_tenant_2c4g
(
tenant_name
varchar
(
64
))
begin
call
oceanbase
.
create_tenant
(
tenant_name
,
'oracle'
,
'2c4g'
);
end
/
drop
procedure
if
exists
create_oracle_tenant_2c4g_with_arg
;
/
create
procedure
create_oracle_tenant_2c4g_with_arg
(
tenant_name
varchar
(
64
),
arg_list
varchar
(
64
))
begin
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
'oracle'
,
'2c4g'
,
arg_list
);
end
/
-- create_tenant_by_memory_limit: 根据memory_limit创建租户
drop
procedure
if
exists
create_tenant_by_memory_resource
;
/
create
procedure
create_tenant_by_memory_resource
(
tenant_name
varchar
(
64
),
compat_mode
varchar
(
10
))
begin
declare
mem
bigint
;
select
memory_limit
from
GV
$
OB_SERVERS
limit
1
into
mem
;
if
(
mem
<
8589934592
)
then
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
compat_mode
,
'1c1g'
,
''
);
elseif
(
mem
<
17179869184
)
then
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
compat_mode
,
'2c2g'
,
''
);
else
call
oceanbase
.
create_tenant_with_arg
(
tenant_name
,
compat_mode
,
'2c4g'
,
''
);
end
if
;
end
/
-- adjust_sys_resource: 根据memory_limit调整sys租户规格
drop
procedure
if
exists
adjust_sys_resource
;
/
create
procedure
adjust_sys_resource
()
begin
declare
mem
bigint
;
select
memory_limit
from
GV
$
OB_SERVERS
limit
1
into
mem
;
set
@
sql_text
=
"alter resource unit sys_unit_config memory_size = 1073741824;"
;
if
(
mem
<
17179869184
)
then
prepare
stmt
from
@
sql_text
;
execute
stmt
;
deallocate
prepare
stmt
;
end
if
;
end
/
-- end of procedure
delimiter
;
tools/deploy/obd.sh
浏览文件 @
6b675a2a
...
...
@@ -333,8 +333,6 @@ function deploy_cluster {
esac
done
fi
get_init_sql
obd
test
mysqltest
"
$deploy_name
"
$INIT_FLIES
--init-only
$CLIENT_BIN_ARGS
}
function
get_init_sql
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录