1. 程式人生 > >ORACLE 11g在linux上建立第二個例項

ORACLE 11g在linux上建立第二個例項

linux伺服器主機不夠,而測試人員需要新的一臺oracle環境做測試,,所以準備在已經有的oracle的linux主機上上面建立第二個例項。這臺oracle伺服器的資源足夠用,所以就直接在上面搭建多例項來滿足測試人員的需求。

1,使用vnc 遠端工具進去,dbca報錯如下:

[[email protected] ~]$ dbca
No protocol specified
[[email protected] ~]$ exit

2,需要設定display視窗:

[[email protected] ~]# export DISPLAY=localhost:1
[

[email protected] ~]#
[[email protected] ~]# xhost +
access control disabled, clients can connect from any host
[[email protected] ~]# su - oracle
[[email protected] ~]$ dbca
如下圖所示:
這裡寫圖片描述

3,建立步驟

3.1 Database Configuration Assistant

圖形介面啟動。標題同時指明瞭步驟的編號和步驟的名稱。在步驟名稱為Welcome的歡迎視窗,直接點選next。

選擇Custom Database,然後下一步

Global Database Name框:輸入前面確定的資料庫名
SID框:自動出現和資料庫名相同的內容作為資料庫例項名,單例項情況下不作改動

3.2繼續預設

3.3 atabase Credentials

Use Different Administrative Passwords
表格的Password和Confirm Password列中分別為User Name列SYS、SYSTEM、DBSNMP和SYSMAN使用者輸入口令並重復一次輸入(如密碼設定過於簡單,下一步前會有彈出視窗提示確認接受安全風險)。
sys和system密碼設定可以在資料庫建立後修改。

3.4 Database File Locations

Storage Locations:選擇Use Common Location for All Database Files
Database File Location框:輸入/oracle/pddev1

3.5 Recovery Configuration

Specify Fast Recovery Area
如果前面Management Options步驟選擇了自動備份,則保留勾選,並在下方:
Fast Recovery Area框:修改為快速恢復區的目錄名
Fast Recovery Area Size框:調整快速恢復區的大小

3.6 Enable Archiving

根據是否歸檔日誌的實際需求決定是否選擇(重要的生產系統必須開啟歸檔,測試系統一般關閉歸檔節省伺服器空間)
點選旁邊的Edit Archive Mode Parameters…,在彈出視窗中:
Automatic Archiving:保持預設勾選
Archive Log File Format框:修改為%t_%s_%r.arc
Archive Log Destinations表格:第一行中輸入/oracle/pddev1/archivelog
點選OK返回主視窗
Database Content
Database Components頁面

3.7 然後繼續下一步

3.8 Initialization Parameters

記憶體分配20%(測試庫所以分小一些,生產庫可以分配較大的比如40%60%等),字符集選擇相容utf8的選項

3.9 然後下一步

點選File Location Variables,裡面可以看到一些基礎引數資訊,返回,然後直接下一步,

3.10 然後下一步, 選擇Generate Database Creation Scripts

預設為 /oracle/app/oracle/admin/powerdes/scripts,然後選擇點選 Finish按鈕,之後再彈出的介面上點選OK按鈕,有報錯說/etc/oratab讀取錯誤,可以不理會。

等待等待55分鐘後,資料庫建立完畢,之後點選,如下3.1png所示
這裡寫圖片描述

4,驗證2個oracle例項

[[email protected] admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 22 17:02:07 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$database;

NAME
---------
POWERDES

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] admin]$ sqlplus sys/[email protected] as sysdba;

SQL*Plus: Release 11.2.0.1.0 Production on Fri May 22 17:02:21 2015

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$database;

NAME
------------------
PDDEV1

SQL>

預設sqlplus / as sysdba是登入第一個啟動的例項,如果想登入第二個例項,就需要指定tnsping的名字,sqlplus sys/[email protected] as sysdba;

5,關於多例項的自動隨機啟動

--假設一個例項是itsm、另外一個是test
export ORACLE_SID=itsm
sqlplus / as sysdba
startup
quit
export ORACLE_SID=test
sqlplus / as sysdba
startup
quit

PS:自動啟動,可以在/etc/rc.local中設定,增加如下的內容
–啟動預設的第一個資料庫例項
su - oracle < lsnrctl start
sqlplus / as sysdba
startup
quit
EOF
–啟動第二個資料庫例項
su - oracle < export ORACLE_SID=test
sqlplus / as sysdba
startup
quit
EOF