Oracle 12C中引入了PDB(可插拔數據庫)的概念,雖然大家都說這是在模擬Mysql、Sqlserver的架構,還沒有深入了解過Mysql以及Sqlserver,暫時還不能妄下結論。但是引入PDB之后,那些接觸11G時間長的老DBA初次接觸12C還是很不適應的。
從我個人目前已經了解到的情況而言,使用PDB這種架構的企業還是很少的,及時使用也是從壓力測試這個層面使用。對於那些金融行業的公司而言,雖然使用了12C,但是還沒有使用PDB這種方式。不管是從成本角度還是穩定性角度考慮,PDB的使用還是處於低頻的這種狀態,其優點暫時還是沒有體現。個人覺得,Oracle開發12C的PDB是為了方便中小企業,畢竟兩台性能不錯的Linux服務器上部署幾套庫,在壓力不大的情況下,使用是完全完全沒問題的。
閑言少敘,下面來說下12C數據庫的用戶如何連接到數據庫:
******************
當前數據庫的/etc/hosts配置
******************
[oracle@12c1 ~]$ cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.8.100 12c1
192.168.8.101 12c1-vip
10.168.8.100 12c1-priv
192.168.8.103 12c2
192.168.8.104 12c2-vip
10.168.8.103 12c2-priv
192.168.8.105 r12c-scan
******************
當前數據庫下只有一個pdb
******************
[oracle@12c1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Sat Aug 18 22:18:04 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 DAYUPDB1 READ WRITE NO
為pdb指定雙節點的service,關於如何為pdb添加service見(https://www.cnblogs.com/dayu-liu/p/9501732.html)
**************************************************************************************************************
查看監聽狀態
**************************************************************************************************************
[oracle@12c1 ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.1.0.2.0 - Production on 18-AUG-2018 22:02:26
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.1.0.2.0 - Production
Start Date 18-AUG-2018 19:35:40
Uptime 0 days 2 hr. 26 min. 46 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/12.1.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/12c1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.100)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.8.101)(PORT=1521)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "-MGMTDBXDB" has 1 instance(s).
Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "_mgmtdb" has 1 instance(s).
Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "dayupdb1" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "r12c_cluster" has 1 instance(s).
Instance "-MGMTDB", status READY, has 1 handler(s) for this service...
Service "racdb" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "racdbXDB" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "racdb_test" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
Service "racdb_test1" has 1 instance(s).
Instance "racdb1", status READY, has 1 handler(s) for this service...
The command completed successfully
**************************************************************************************************************
通過IP地址直接連接到PDB
**************************************************************************************************************
[oracle@12c1 ~]$ sqlplus dayupdb1/dayupdb1@192.168.8.101:1521/racdb_test --這里注意是service name
SQL*Plus: Release 12.1.0.2.0 Production on Sun Aug 19 19:24:08 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Sun Aug 19 2018 18:30:36 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> set line 300
SQL> set line 300
SQL> show parameter name;
NAME TYPE VALUE
------------------------------------ --------------------------------- ------------------------------
cell_offloadgroup_name string
db_file_name_convert string
db_name string racdb
db_unique_name string racdb
global_names boolean FALSE
instance_name string racdb1
lock_name_space string
log_file_name_convert string
pdb_file_name_convert string
processor_group_name string
service_names string racdb
**************************************************************************************************************
通過net service name連接到數據庫(即通過配置tnsnames連接到數據庫)
**************************************************************************************************************
[oracle@12c1 admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.1.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
RACDB =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST =192.168.8.101 )(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = racdb_test)
)
)
[oracle@12c1 admin]$ sqlplus dayupdb1/dayupdb1@racdb
SQL*Plus: Release 12.1.0.2.0 Production on Sun Aug 19 19:33:30 2018
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Sun Aug 19 2018 19:24:59 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Advanced Analytics and Real Application Testing options
SQL> show user;
USER is "DAYUPDB1"
注:一般在配置HOST的時候配置為vip,因為如果一旦配置的VIP對應的節點發生了問題,此VIP可以漂移到另一個節點上,如果使用public ip,一但連接的節點出現了問題,連接就會中斷。
**************************************************************************************************************
在plsql里,如果tnsnames沒有配置的話,可以采用IP:PORT/service name的方式連接到數據庫
**************************************************************************************************************

