您好,登錄后才能下訂單哦!
由于oracle 12c使用了CDB-PDB架構(gòu),類似于docker,在container-db內(nèi)可以加載多個(gè)pluggable-db,因此安裝后需要額外配置才能使用。
一、修改listener.ora , tnsnames.ora
###listener.ora###
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = orcl))
)
#sid list列舉cdb和所有pdb的數(shù)據(jù)庫名,所有sid與oracle環(huán)境變量保持一致#
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl) #cdb db_name
(SID_NAME = orcl)
)
(SID_DESC =
(GLOBAL_DBNAME = pdborcl) #pdb db_name
(SID_NAME = orcl)
)
)
###listener.ora###
##tnsnames.ora###
#cdb
orcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) )
(CONNECT_DATA =
(SERVICE_NAME = orcl) #cdb的db_name
)
)
#pdb
pdborcl =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = pdborcl) #pdb的db_name
)
)
##tnsnames.ora###
在客戶端連接時(shí)使用“service_name+domain_name”連接。如果出現(xiàn)ora-01017,很有可能是
二、創(chuàng)建pdb
cdb相當(dāng)于操作系統(tǒng),調(diào)用并管理各個(gè)pdb。pdb相當(dāng)于真正提供業(yè)務(wù)需求的數(shù)據(jù)庫實(shí)例。oracle 12c安裝后只創(chuàng)建了cdb,需要自己生成相應(yīng)的pdb。
1、創(chuàng)建pdb
在sqlplus下:
create pluggable database pdborcl
admin user pdbadmin identified by pdbadmin
role=(resource)
file_name_convert=( 'PDB$SEED's directory' , 'PDBOrcl's directory' );
2、同步文件
select pdb_name,status from cdb_pdbs
若pdb狀態(tài)為need sync,則需要:
alter sesseion set container=pdborcl
shutdown immediate或者alter pluggable database pdborcl close immediate ;
alter pluggable database pdborcl open restricted ;
exec dbms_pdb.sync_pdb ; #調(diào)用dbms_pdb進(jìn)行pdb
3、新增用戶
create user scott account unlock identified by tiger ;
grant resource to scott ;
按照上述方法創(chuàng)建用戶,如果出現(xiàn)ora-01017,很有可能是1、沒有指定連接的service_name到具體pdb,或者oracle對密碼大小寫敏感。前者檢查listener.ora中sid_list是否已經(jīng)列出該pdb,并檢查連接字符串是否在tnsnames.ora指定。后者如果無法修改前端程序,可以使用
alter system set SEC_CASE_SENSITIVE_LOGON = false ;
強(qiáng)制關(guān)閉oracle的大小寫檢查進(jìn)行確認(rèn)。
三、常用命令
show pdbs:查看當(dāng)前數(shù)據(jù)庫container中包含有多少個(gè)pdb。如果session在某個(gè)pdb中,可以查看當(dāng)前的pdb。
alter session set container=PDBNAME
切換當(dāng)前會(huì)話到某個(gè)pdb中。切換后才可使用當(dāng)前pdb的私有用戶進(jìn)行操作
startup/shutdown immediate
關(guān)閉當(dāng)前會(huì)話所在的cdb/pdb
alter pluggable database PDBNAME open ;
打開指定pdb
alter pluggable database PDBNAME close immediate ;
關(guān)閉指定pdb
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。