Oracle 12c创建pdb

一. 创建pdb

1. 查看主机存储情况(asm/文件系统/裸设备),确定pdb数据文件存放路径

查看存储情况:df -h

查看seed pdb:cdb下查询dba_data_files

查看pdb数据文件存放路径:可以切换到其他pdb结合存储情况确认新建的pdb存放路径

2. create pluggable database

SQL> create pluggable database pdb_test
  2  admin user test identified by oracle
  3  FILE_NAME_CONVERT =('/oradata/sys/pdbseed','/oradata/data01/pdb_test/')
  4  default tablespace TBS_DATA  datafile '/oradata/data01/pdb_test/TEST_DATA_01.dbf' size 30G autoextend off;

Pluggable database created.

二. 开启PDB

统计各节点的连接数,可以只开启部分节点(连接数较少的)的pdb

查看rac节点数:gv$instance

统计连接数:

a.

# 连接数使用率
select resource_name, trunc(current_utilization * 100 / limit_value) Result_Number
  from v$resource_limit
 where resource_name in ('processes');

b. ps -ef|grep LOCAL=NO wc=l  #查看外部连接

--3号节点
SQL> select instance_number,instance_name from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
              3 prod3

SQL> alter pluggable database pdb_test open;
--4号节点
SQL>  select instance_number,instance_name from v$instance;

INSTANCE_NUMBER INSTANCE_NAME
--------------- ----------------
              4 prod4

SQL> alter pluggable database pdb_test open;

三. 数据文件调整

1. 切换到新建的pdb

SQL> alter session set container=pdb_cxrh;

Session altered.

2. 根据要求,添加数据文件(生产环境一般关闭数据文件自动扩展)

SQL> alter tablespace TBS_DATA add datafile '/oradata/data01/pdb_test/TEST_DATA_02.dbf' size 30G autoextend off;

Tablespace altered.

SQL> alter tablespace TBS_DATA add datafile '/oradata/data01/pdb_test/TEST_DATA_03.dbf' size 30G autoextend off;

Tablespace altered.

3. 根据需要调整SYSTEM表空间大小,关闭自动扩展(dba_data_files)

SQL> alter database datafile '/oradata/data01/pdb_test/system01.dbf' resize 2G;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/system02.dbf' resize 2G;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/system03.dbf' resize 2G;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/system01.dbf' autoextend off;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/system02.dbf' autoextend off;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/system03.dbf' autoextend off;

Database altered.

4. 调整SYSAUX辅助表空间大小

SQL> alter database datafile '/oradata/data01/pdb_test/sysaux01.dbf' resize 2G;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/sysaux02.dbf' resize 2G;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/sysaux03.dbf' resize 2G;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/sysaux01.dbf' autoextend off;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/sysaux01.dbf' autoextend off;

Database altered.

SQL> alter database datafile '/oradata/data01/pdb_test/sysaux03.dbf' autoextend off;

Database altered.

5. 调整临时表空间(根据需要,这里临时表空间本身就比较大就不再调整,DBA_TEMP_FILES)

SQL> alter database tempfile '/oradata/data53/pdb_cxrh/temp01.dbf' autoextend off;

Database altered.

SQL> alter database tempfile '/oradata/data53/pdb_cxrh/temp02.dbf' autoextend off;

Database altered.

SQL> alter database tempfile '/oradata/data53/pdb_cxrh/temp03.dbf' autoextend off;

Database altered.

四. 创建用户

SQL> create user test identified by oracle default tablespace TBS_DATA;

User created.

SQL> grant connect,resource to test;

Grant succeeded.
注意:oracle12c resource角色已不包括unlimited on tablespace的权限,需要额外授予

SQL> ALTER USER test quota unlimited on tbs_data;

User altered.

五. 根据监听配置提供TNS

# 应用使用
pdb_test =
(DESCRIPTION_LIST =
     (LOAD_BALANCE = off)
     (FAILOVER = on)
        (DESCRIPTION =
           (ADDRESS_LIST =
              (LOAD_BALANCE=OFF)
              (FAILOVER=ON)
              (ADDRESS = (PROTOCOL = TCP)(HOST = 10.78.237.56)(PORT = 1521)) #VIP
           )
           (CONNECT_DATA =
             (SERVICE_NAME = pdb_test)
           
             (FAILOVER_MODE=(TYPE=session)(METHOD=basic)(RETRIES=4)(DELAY=1))
           )
        )
        (DESCRIPTION =
           (ADDRESS_LIST =
              (LOAD_BALANCE=OFF)
              (FAILOVER=ON)
              (ADDRESS = (PROTOCOL = TCP)(HOST = 10.78.237.58)(PORT = 1521)) #VIP
           )
           (CONNECT_DATA =
              (SERVICE_NAME = pdb_test)
              (FAILOVER_MODE=(TYPE=session)(METHOD=basic)(RETRIES=4)(DELAY=1))
           )
        )
  )
# 个人使用
pdb_test_inst1 =
        (DESCRIPTION =
           (ADDRESS_LIST =
              (ADDRESS = (PROTOCOL = TCP)(HOST =10.70.98.44)(PORT = 1521)) #VIP
           )
           (CONNECT_DATA =
             (SERVICE_NAME = pdb_test)
           )
        )
pdb_test_inst2 =
        (DESCRIPTION =
           (ADDRESS_LIST =
              (ADDRESS = (PROTOCOL = TCP)(HOST =10.70.98.50)(PORT = 1521))
           )
           (CONNECT_DATA =
             (SERVICE_NAME = pdb_test)
           )
        )

附:

# 删除PDB
drop pluggable database test including datafiles 
# 关闭PDB
alter pluggable database pdb_pub close;
# 开启PDB
alter pluggable database pdb_pub open;
# 切换到指定PDB
alter session set container=pdb_test;




你可能感兴趣的:(Oracle-12c)