oracle 19C操作常用命令
Posted San6653
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 19C操作常用命令相关的知识,希望对你有一定的参考价值。
oracle19c基本操作命令
进入cdb:
su - oracle
ps -ef|grep pmon
export ORACLE_SID=H01U08PF2 (非单节点PDB的sid不同)
sqlplus / as sysdba
export ORACLE_SID=H01U10PF1
sqlplus / as sysdba
exit 退出,查看监听状态
lsnrctl status 显示监听状态
alter session set container=PDB;设置连接到指定的PDB 进入数据库
alter session set container=WCMMNG00;
alter session set container=CDB$ROOT;设置连接到指定的CDB
show pdbs 查看数据库是否创建成功
创建pdb:
create pluggable database tyu1db admin user pdbuser identified by pdbuser file_name_convert = ('+datadg','+datadg');
第一次创建注意数据库的名称与用户的名称
create pluggable database tyu1db admin user pdbuser identified by pdbuser file_name_convert = ('+datadg','+datadg');
create pluggable database STDFTC00 admin user STDFTC00 identified by STDFTC00 file_name_convert = ('+datadg','+datadg');
打开和关闭CDB
在CDB下操作
alter session set container=CDB$ROOT;
关闭CDB
shutdown immediate;
srvctl stop database -d bd
打开CDB
startup //直接启动
alter session set container=WCMMNG00;
alter session set container=WCMEAC00;
打开和关闭PDB WCMMNG00 WCMEAC00 //为PDB H01U10PF2
在PDB下操作
1、alter session set container=ODPDBHK2;
2、alter pluggable database close immediate; //关闭PDB
3、alter pluggable database ODPDBHK2 open read write; //打开PDB
4、exit, srvctl start service -d H01U10PF2 -s ODPDBHK2_S1; // 启动服务WCMMNG00_S2,这里有两个服务都给开启。
5、srvctl status service -d H01U10PF2 -pdb ODPDBHK2; //查看服务是否启动
1、alter session set container=WCMEAC00;
2、alter pluggable database close immediate; //关闭PDB
3、alter pluggable database WCMEAC00 open read write; //打开PDB
4、exit, srvctl start service -d H01U08PF -s WCMEAC00_R1_S1; // 启动服务WCMEAC00_R1_S2;这里有两个服务都给开启。
5、srvctl status service -d H01U08PF -pdb WCMEAC00; //查看服务是否启动
other close:alter pluggable database all close; //一次性关闭所有PDB
删除PDB,首先关闭PDB,
alter pluggable database pmsdta01 close immediate insrances=all; //关闭PDB
alter pluggable database dw17 unplug into '/home/oracle/unplugged_pdbs/dw17.xml'; //拨出pdb
drop pluggable database dw17 including datafiles; //关闭并且拨出pdb后才可以进行删除,删除时一起删除数据文件
drop pluggable database dw17 keep datafiles; // 保留数据文件
其他管理操作,需要在CDB执行
alter pluggable database pdb1,pdb2 open read only force;
alter pluggable database pdb1,pdb2 close immediate;
alter pluggable database all open;
alter pluggable database all close immediate;
alter pluggable database all except pdb1 open;
alter pluggable database all except pdb1 close immediate;
创建用户:
create user apphigh1 identified by apphigh1;创建用户;
grant dba to apphigh1;赋权
create user apphigh1 identified by apphigh1;
克隆PDB
create pluggable database pdb2 from pdb1;
克隆pdb不带数据
create pluggable database pdb2 from pdb1 no data;
建Oracle的应用隔离服务
SRVCTL ADD SERVICE -D PERGBK -S AYN1DB01_R1_S1 -R PERGBK1 -A PERGBK2 -PDB AYN1DB01;
SRVCTL ADD SERVICE -D PERGBK -S AYN1DB01_R1_S2 -R PERGBK1 -A PERGBK2 -PDB AYN1DB01;
负载均衡模式
srvctl add service -d H01U08PF -s WCMMNG00_S2 -r H01U08PF1,H01U08PF2 -pdb WCMMNG00;注意大小写
srvctl add service -db DBNAME -pdb pdbName -s pdbName_s1 -netnum 1 -preferred Instance_pre1,Instance_pre2 -role primary
删除服务:srvctl remove service -d DEVUTF -s PMSDTA01_R1_S1 -r DEVUTF1,DEVUTF2 -pdb PMSDTA01
srvctl remove service -d H01U08PF -s WCMMNG00_R1_S1 -r H01U08PF1,H01U08PF2 -pdb WCMMNG00
查看参数
show parameter;
修改参数;
alter system set cpu_count=2;
alter system set sessions=300;
alter system set sga_target=8000m;
alter system set shared_pool_size=2000m;
alter system set db_cache_size=2000m;
alter system set pga_aggregate_limit=4000m;
alter system set pga_aggregate_target=2000m;
alter system set job_queue_processes=20;
alter system set db_performance_profile=middleplan;
启动监听:
srvctl start service -d uatu14db -pdb CMBPAY;
srvctl start service -d PERFUTF -s PMSDTA01_S1 启动服务
srvctl start service -d H01U08PF -s WCMMNG00_S1
查看监听状态:
srvctl status service -d uatu14db -pdb CMBPAY;
srvctl status service -d H01U08PF2 -pdb WCMMNG00;
H01U08PF2
ODPDBHK2
pdb 打快照
alter session set container=ntmshis1;
EXEC DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();
EXEC DBMS_WORKLOAD_REPOSITORY.CREATE_SNAPSHOT();
@?/rdbms/admin/awrrpt.sql
AWR_PDB
修改密码:alter user apphigh identified by Qzmp%123;
1、执行数据迁移 源库IP 数据库名
源库dblink用戶名/密码 不动
2、目标库IP 目标库用户名/密码/目标库CDB查看ps -ef|grep pm cdb是否正确
3、服务模式需手动选择负载均衡或其他
4、一键迁移,完成 招呼获取 用户名密码
导库已经结束并可以正常使用了,且成功重置了APP1/APPBATCH/APPHIGH 的密码:Cmb#2021
5、查看是否服务创建成功:
srvctl status service -d C19U25PF -pdb IMGCTRA
6、进入pdb下,lter session set container=IMGCTRA;进行赋权语句执行,grant dba to apphigh;
7、占用平台数据库()
更换服务模式:
1、停掉之前的监听
srvctl stop service -d H01U10PF -s ODPDBHK2_S2 //ODPDBHK2_S1 2个都要重复操作
2、删除之前的服务
删除服务:srvctl remove service -d H01U10PF -s ODPDBHK2_S2 //ODPDBHK2_S1 2个都要重复操作
3、查看服务
srvctl status service -d H01U10PF -s ODPDBHK2_S1 //ODPDBHK2_S2 2个都要重复操作
4、创建新的服务
srvctl add service -db H01U10PF -pdb ODPDBHK2 -s ODPDBHK2_R1_S2 -netnum 1 -preferred H01U10PF1 -available H01U10PF2 -failback yes -role primary
5、启动监听
srvctl start service -d H01U10PF -s ODPDBHK2_R1_S2 启动服务 //ODPDBHK2_S1 2个都要重复操作
使用新用户连接吸入数据库场景/用户赋权操作::
1、进入cdb:
su - oracle
ps -ef|grep pmon
export ORACLE_SID=H01U08PF2 (非单节点PDB的sid不同)
sqlplus / as sysdba
2、进入数据库设置连接到指定的PDB
alter session set container=ODPDBHK2;
3、创建用户:
create user ODP_APP identified by ODP_APP;创建用户;
grant dba to ODP_APP;赋权
grant dba to apphigh;赋权
以上是关于oracle 19C操作常用命令的主要内容,如果未能解决你的问题,请参考以下文章