1、在oracle用户,添加如下内容
vim /opt/oracle/app/oracle/product/19c/dbhome_1/network/admin/tnsnames.ora
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan80)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)pdb1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan80)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdb1)
)XPDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = scan80)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XPDB)
2、监听在grid用户,添加如下内容
vim /opt/oracle/app/19c/grid/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /opt/oracle/app/oracle/product/19c/dbhome_1)
(SID_NAME = orcl1)
)(SID_DESC =
(GLOBAL_DBNAME = PDB1)
(SID_NAME = PDB1)
)(SID_DESC =
(GLOBAL_DBNAME = XPDB)
(SID_NAME = XPDB)
)
)
3、重启监听
lsnrctl stop
lsnrctl start
4、远程连接
sqlplus pdb1admin/pdb1admin@192.168.1.80:1521/pdb1
无法创建PDB,cdb这一项查到为NO,应该为YES(界面选择创建一个空的容器数据库).
select cdb from v$database; CDB — YES
创建PDB:
create pluggable database pdb1 admin user pdb1admin identified by pdb1admin;
CREATE PLUGGABLE DATABASE pdb1 ADMIN USER pdb1_admin IDENTIFIED BY pdb1_admin
file_name_convert=(’/opt/oracle/oradata/ORA19C/pdbseed/’,’/opt/oracle/oradata/ORA19C/pdb1/’);
连接:
sqlplus pdb1_admin/pdb1_admin@192.168.1.123:1521/pdb1
sqlplus /nolog
conn / as sysdba
CREATE PLUGGABLE DATABASE pdb1 ADMIN USER pdb1_admin IDENTIFIED BY pdb1_admin ROLES=(DBA) \
DEFAULT TABLESPACE USERS DATAFILE '/opt/oracle/oradata/ORA19C/pdb1/users01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M LOGGING \
FILE_NAME_CONVERT=('/opt/oracle/oradata/ORA19C/pdbseed/sysaux01.dbf','/opt/oracle/oradata/ORA19C/pdbseed/sysaux01.dbf', \
'/opt/oracle/oradata/ORA19C/pdbseed/system01.dbf','/opt/oracle/oradata/ORA19C/pdb1/system01.dbf',\
'/opt/oracle/oradata/ORA19C/pdbseed/undotbs01.dbf','/opt/oracle/oradata/ORA19C/pdb1/undotbs01.dbf',\
'/opt/oracle/oradata/ORA19C/pdbseed/temp012020-06-22_15-50-04-339-PM.dbf','/opt/oracle/oradata/ORA19C/pdb1/temp01.dbf');
ALTER PLUGGABLE DATABASE pdb1 OPEN;
exit;
oracle pdb其他命令
查看容器:
show con_name
select name from v$containers ;
SELECT SYS_CONTEXT(‘USERENV’,‘CON_NAME’) FROM dual;
show pdbs ;
SQL> show pdbs;CON_ID CON_NAME OPEN MODE RESTRICTED
/---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 MOUNTED
4 XPDB READ WRITE NO
5 PDB0 MOUNTED
打开pdb:
SQL> alter pluggable database pdb1 open;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
/---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 XPDB READ WRITE NO
5 PDB0 MOUNTED
关闭pdb:
SQL> alter pluggable database XPDB close;
Pluggable database altered.
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
/---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB1 READ WRITE NO
4 XPDB MOUNTED
5 PDB0 MOUNTED
切换容器:
SQL>alter session set container=XPDB;
SQL>startup