今天是 2022 年的最后一个工作日了,很多人都在进行年终总结,很多 app 也都出现了年终总结,感觉年终总结这四个字最近比较火,可对于我来说,年终总结好像没什么可写的,这一年感觉都是在搞数据库升级的事,可到年底了最终核心库升级的事儿因为各种原因也没有进行,反而推迟到了二月份,那么就大概总结一下 oracle 11g 升级到 19c 需要关注的几个问题,如果您有其他不同问题欢迎补充。
好了,进入到今天的主题 oracle 11g 升级到 19c 需要关注的几个问题
1、oracle 19c 主要的新特性
- data guard 备库dml自动重定向
- varchar2 可以支持最大 32767 字节大小
- oracle的混合分区表支持
- 多实例并行重做日志应用增强
- multitenant environment 多租户系统
- in-memory option 内存列式存储
- 自动创建索引(仅一体机有此功能)
- 实时统计信息收集(仅一体机有此功能)
- sql隔离(仅一体机有此功能)
更多新特性请查看:
https://apex.oracle.com/database-features/
2、客户端连接问题
使用原有的 plsql、dbeaver 等去连接数据库时,由于软件驱动问题,可能会存在连接报错。
“登陆失败,登陆信息不正确”或“ora-28040:没有匹配的验证协议”
m6米乐安卓版下载的解决方案:使用新版本的客户端连接或者做如下调整
在 oracle 19c 服务器端 oracle 用户下:
cd $oracle_home/network/admin目录下 新建文件sqlnet.ora
vi sqlnet.ora
sqlnet.allowed_logon_version_server=8
sqlnet.allowed_logon_version_client=8
然后使用正确的 ip 和用户名密码连接 oracle 19c rac .
3、jdbc 驱动连接问题
原来的驱动程序有可能不支持 19c,建议使用新版本的驱动。
jdbc 下载链接:
https://www.oracle.com/database/technologies/appdev/jdbc-downloads.html
oracle jdbc faq
https://www.oracle.com/technetwork/database/enterprise-edition/jdbc-faq-090281.html
4、plsql、函数、存储过程问题
详细信息参考官方文档
https://docs.oracle.com/en/database/oracle/oracle-database/19/upgrd/loe.html
如下所示,可能有一些 sql 在原有 11g 环境运行正常,但在 19c 环境下会出错。
此类问题则为 plsql、函数、存储过程等的语法问题,需要开发人员重构代码解决。例如:listagg 聚合函数现在支持通过使用新的 distinct 关键字来消除重复项。listagg 聚合函数根据 order by 表达式对查询中每个组的行进行排序,然后将值连接成单个字符串。在串联成单个字符串之前,可以使用 new distinct 关键字从指定的表达式中删除重复值。这样就无需在使用聚合 listagg 函数之前创建复杂的查询处理来查找不同的值。使用“distinct”选项删除 listagg 函数中的重复值。
另外,如果在 11g 中使用了 wm_concat 函数,19c 中已经没有这个函数了,开发人员需要修改 sql 语法或者新建这个函数也可以。
wm_concat 函数创建
1.创建 type 头
create or replace type prod.wm_concat_impl as object
-- authid current_user as object
(
curr_str varchar2(32767),
static function odciaggregateinitialize(sctx in out wm_concat_impl) return number,
member function odciaggregateiterate(self in out wm_concat_impl,
p1 in varchar2) return number,
member function odciaggregateterminate(self in wm_concat_impl,
returnvalue out varchar2,
flags in number)
return number,
member function odciaggregatemerge(self in out wm_concat_impl,
sctx2 in wm_concat_impl) return number
);
/
2.创建 type 体
create or replace type body prod.wm_concat_impl
is
static function odciaggregateinitialize(sctx in out wm_concat_impl)
return number
is
begin
sctx := wm_concat_impl(null) ;
return odciconst.success;
end;
member function odciaggregateiterate(self in out wm_concat_impl,
p1 in varchar2)
return number
is
begin
if(curr_str is not null) then
curr_str := curr_str || ',' || p1;
else
curr_str := p1;
end if;
return odciconst.success;
end;
member function odciaggregateterminate(self in wm_concat_impl,
returnvalue out varchar2,
flags in number)
return number
is
begin
returnvalue := curr_str ;
return odciconst.success;
end;
member function odciaggregatemerge(self in out wm_concat_impl,
sctx2 in wm_concat_impl)
return number
is
begin
if(sctx2.curr_str is not null) then
self.curr_str := self.curr_str || ',' || sctx2.curr_str ;
end if;
return odciconst.success;
end;
end;
/
3.创建函数
create or replace function prod."wm_concat"(p1 varchar2)
return varchar2 aggregate using wm_concat_impl ;
/
4.授权及创建同义词
select 'grant execute on wm_concat to '|| username||';' from dba_users where account_status='open' and default_tablespace not in ('system','users');
grant execute on prod.wm_concat to prod;
grant execute on prod.wm_concat to prod_cc;
grant execute on prod.wm_concat to prod_cc;
create public synonym wm_concat for prod.wm_concat;
下图列出一些已知的常用函数,需要开发人员检查是否使用到如下对象是否使用,如使用需要寻找对应替代方案。
5、开发需要关注自建的存储过程、函数的兼容问题
统计用户对象的个数和类型
对象总数
select d.owner,count(1) from dba_objects d
where d.owner in ('prod','prod_cc','prod_op','prod_cb','prod_os')
and d.owner not in ('public')
and not exists (select 1 from dba_recyclebin b
where b.object_name=d.object_name
and d.owner = b.owner)
group by d.owner
order by count(1) desc;
查找使用自建函数的 sql
select distinct sql_id, sql_text, module
from v$sql,
(select object_name
from dba_objects o
where owner = 'prod'
and object_type in ('function', 'package'))
where (instr(upper(sql_text), object_name) > 0)
and plsql_exec_time > 0
and regexp_like(upper(sql_fulltext), '^[select]')
and parsing_schema_name = 'prod';
对象类型汇总
select d.owner,d.object_type,count(1) from dba_objects d where d.owner in ('prod','prod_cc','prod_op','prod_cb','prod_os') and d.owner not in ('public') and not exists (select 1 from dba_recyclebin b where b.object_name=d.object_name and d.owner = b.owner) group by d.owner,d.object_type order by count(1) desc;
owner object_type count(1)
------------------------------ ------------------- ----------
prod index 7352
prod_cc index 7125
prod_op index 4566
prod sequence 1151
prod table 1144
prod_cc sequence 1115
prod_cc table 1106
prod_op sequence 676
prod_op table 668
prod lob 126
prod_cc lob 118
prod_op lob 55
prod function 18
prod_cc function 17
prod_cb index 15
prod procedure 3
prod_cb table 3
prod_cc procedure 2
prod_cb sequence 2
prod trigger 1
prod type 1
prod_op function 1
22 rows selected.
检查业务用户自建对象
select owner,object_type,object_name from dba_objects d
where d.owner in ('prod','prod_cc','prod_op','prod_cb','prod_os')
and object_type not in ('index','sequence','lob','table')
order by 2,1;
检查无效索引
select owner,index_name,status from dba_indexes
where status='unusable' order by 1,2;
select i.owner,i.index_name,p.partition_name,p.status
from dba_ind_partitions p,dba_indexes i
where p.index_name=i.index_name and p.status='unusable' order by 1,2,3;
select i.owner,i.index_name,s.subpartition_name,s.status
from dba_ind_subpartitions s,dba_indexes i
where s.index_name=i.index_name and s.status='unusable'
order by 1,2,3;
确认系统用户是否包含业务对象
--检查sys和system的重复对象,返回如下行则正常。
set line 345
col object_name for a40
select owner,object_name,object_type from dba_objects
where (object_name,object_type) in
(select object_name,object_type from dba_objects where owner='sys')
and owner='system';
owner object_name object_type
------------------------------ ---------------------------------------- -------------------
system aq$_schedules table
system aq$_schedules_primary index
system dbms_repcat_auth package body
system dbms_repcat_auth package
select owner,segment_name,segment_type,tablespace_name
from dba_segments
where tablespace_name in('system','sysaux')
and owner in ('prod','prod_cc','prod_op','prod_cb','prod_os');
6、sql 执行计划变差问题
升级后可能会有些 sql 语句性能变差,这块需要 dba 介入,重新收集统计信息、固定执行计划或者使用 spa(sql 性能分析sqlperformance analyzer) 等技术检查,官方文档:oracle database testing guide 19c
https://docs.oracle.com/en/database/oracle/oracle-database/19/ratug/index.html
7、oracle19c 不再支持的功能
官方资料
8、oracle 19c 不再支持的参数
dba 需要关注的几个参数
9、最后,要说的一句话:测试、测试、测试,一定要测试验证。
10、如果还有其他问题欢迎补充,谢谢。
全文完,希望可以帮到正在阅读的你,如果觉得此文对你有帮助,可以分享给你身边的朋友,同事,你关心谁就分享给谁,一起学习共同进步~~~
欢迎关注我的公众号【jiekexu dba之路】,第一时间一起学习新知识!
————————————————————————————
公众号:jiekexu dba之路
csdn :https://blog.csdn.net/jiekexu
墨天轮:https://www.modb.pro/u/4347
腾讯云:https://cloud.tencent.com/developer/user/5645107
————————————————————————————