Oracle Database 11gR2 on CentOS 6.5安裝記錄
1.先設定CentOS上的JAVA環境,可參閱 管理CentOS上的JAVA環境建置與管理
2. 安裝相關套件
1 |
yum -y install compat-libstdc++* gcc-c++* glibc* libaio* libstdc++* unixODBC* elfutils-libelf-devel* |
3. 預先建立oracle帳號,並建立oinstall、dba、oper群組,並指定給oracle (主群組設定為oinstall)
1 2 3 4 5 6 7 8 |
groupadd oinstall groupadd dba groupadd oper groupadd asmdba groupadd asmoper groupadd asmadmin useradd --gid oinstall --groups dba,oper,asmdba,asmoper,asmadmin oracle passwd oracle |
4. 預先建立Oracle安裝路徑,並設定所在路徑的擁有者為oracle
1 2 |
[root@localhost /]# mkdir -p /opt/oracle/product/11.2.0/dbhome_1 [root@localhost opt]# chown -R oracle:oinstall /opt |
5. 設定系統參數,編輯/etc/profile,新增以下段落,並在 PATH變數中新增$ORACLE_HOME/bin
1 2 3 4 5 6 7 |
# Oracle TMP=/tmp TMPDIR=$TMP ORACLE_BASE=/opt/oracle ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 ORACLE_SID=orcl export TMP TMPDIR ORACLE_BASE ORACLE_HOME ORACLE_SID |
6. 修改 /etc/security/limits.conf,在最下方加入下列內容 ( 若跟原有資料重複的話,請記得刪除舊值 ):
1 2 3 4 5 |
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240 |
7. 下載 Oracle Database 11g Release 2 Linux x86-64版本
1 2 3 4 |
[oracle@localhost Downloads]$ ll 總計 2295600 -rwxrwxr-x. 1 oracle oracle 1239269270 2014-01-06 16:22 linux.x64_11gR2_database_1of2.zip -rwxrwxr-x. 1 oracle oracle 1111416131 2014-01-06 16:23 linux.x64_11gR2_database_2of2.zip |
8. 解壓縮
1 2 3 4 5 6 7 8 |
[oracle@localhost Downloads]$ unzip -oq "linux.x64_11gR2_database*.zip" 2 archives were successfully processed. [oracle@localhost Downloads]$ ls database linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip [oracle@localhost Downloads]$ cd database/ [oracle@localhost database]$ ls doc install response rpm runInstaller sshsetup stage welcome.html |
9. 設定環境變數,若CentOS為非英文版,沒做這一步,安裝畫面會出現方框亂碼
1 2 |
[oracle@localhost database]$ export LANG=en_US.UTF-8 [oracle@localhost database]$ export LC_ALL=en_US.UTF-8 |
10. 執行安裝,若出現 “Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.” 的錯誤,請見解決方法
1 2 3 4 5 6 7 |
[oracle@localhost database]$ sh runInstaller Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 43899 MB Passed Checking swap space: must be greater than 150 MB. Actual 3023 MB Passed Checking monitor: must be configured to display at least 256 colors. Actual 16777216 Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2014-01-06_05-03-34PM. Please wait ... |
11. 安裝畫面,沒輸入Email會出現錯誤,但不影響安裝作業
14. 設定安裝位置,本例中設定為剛剛設定的ORACLE_HOME位置
16. 檢查相依的Library,可以先點選中間的 “Fix & Check Again” 按鈕查看驗證結果,
並依其指示進行修正。
17. 依其指示進行修正。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
[root@localhost ~]# sh /tmp/CVU_11.2.0.1.0_oracle/runfixup.sh Response file being used is :/tmp/CVU_11.2.0.1.0_oracle/fixup.response Enable file being used is :/tmp/CVU_11.2.0.1.0_oracle/fixup.enable Log file location: /tmp/CVU_11.2.0.1.0_oracle/orarun.log Setting Kernel Parameters... kernel.sem = 250 32000 100 128 fs.file-max = 6815744 net.ipv4.ip_local_port_range = 9000 65500 net.core.rmem_default = 262144 net.core.wmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 uid=500(oracle) gid=503(oinstall) groups=503(oinstall),500(oracle),502(dba),504(oper) |
18. 參照 此篇 所示,部分packages 產生的錯誤是可以略過不處理的:
libaio-0.3.105 (i386)
compat-libstdc++-33-3.2.3 (i386)
libaio-devel-0.3.105 (i386)
libgcc-3.4.6 (i386)
libstdc++-3.4.6 (i386)
unixODBC-2.2.11 (i386)
unixODBC-devel-2.2.11 (i386)
pdksh-5.2.14
19. 最後確認,點選完成後開始進行安裝
21. 安裝完成後,跳出Configuration Assistant,
Web版的管理工具 Oracle Enterprise Manager 的網址預設為 https://localhost:1158/em,
不過在啟動前還需要做一些設定,不然是看不到的
22. 執行設定Scripts進行環境配置
1 2 3 4 5 6 7 |
[root@localhost ~]# sh /opt/oraInventory/orainstRoot.sh Changing permissions of /opt/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /opt/oraInventory to oinstall. The execution of the script is complete. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
[root@localhost ~]# sh /opt/oracle/product/11.2.0/dbhome_1/root.sh Running Oracle 11g root.sh script... The following environment variables are set as: ORACLE_OWNER= oracle ORACLE_HOME= /opt/oracle/product/11.2.0/dbhome_1 Enter the full pathname of the local bin directory: [/usr/local/bin]: Copying dbhome to /usr/local/bin ... Copying oraenv to /usr/local/bin ... Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root.sh script. Now product-specific root actions will be performed. Finished product-specific root actions. |
23. 設定$ORACLE_HOME/network/admin/listener.ora
修改以下內容,若HOST設定為127.0.0.1,記得要改成localhost或固定IP,
避免無法監聽Client端的連線的問題。
1 2 3 4 5 6 7 8 9 10 11 12 |
# listener.ora Network Configuration File: /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora # Generated by Oracle configuration tools. LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) ) ) ADR_BASE_LISTENER = /opt/oracle |
24. 切換至oracle帳號,啟動Oracle監聽器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
[root@localhost ~]# su oracle - [oracle@localhost root]$ lsnrctl start LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-JAN-2014 17:03:33 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /opt/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 07-JAN-2014 17:03:35 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/localhost/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) The listener supports no services The command completed successfully |
1 2 |
[oracle@localhost ~]# tnslsnr start [oracle@localhost ~]# |
25. 連接資料庫
1 2 3 4 5 6 7 |
[oracle@localhost ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.1.0 Production on Tue Jan 7 17:09:18 2014 Copyright (c) 1982, 2009, Oracle. All rights reserved. Connected to an idle instance. |
26. 直接以startup啟動資料庫(關閉資料庫則使用 shutdown immediate)
1 2 3 4 5 6 7 8 9 10 |
SQL> startup ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2212856 bytes Variable Size 754977800 bytes Database Buffers 452984832 bytes Redo Buffers 9084928 bytes Database mounted. Database opened. |
或逐步啟動資料庫以進行偵錯
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
SQL> startup nomount ORACLE instance started. Total System Global Area 1219260416 bytes Fixed Size 2212856 bytes Variable Size 754977800 bytes Database Buffers 452984832 bytes Redo Buffers 9084928 bytes SQL> alter database mount; Database altered. SQL> alter database open; Database altered. |
27. 設定EM之配置 (Oracle Enterprise Manager)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
[oracle@localhost ~]$ emca -config dbcontrol db 啟動 EMCA 的時間 2014/1/7 下午 05:30:43 EM 組態輔助程式, 版本 11.2.0.0.2 Production 版 版權所有 (c) 2003, 2005, Oracle. 保留一切權利. 請輸入下列資訊: 資料庫 SID: orcl 監聽器連接埠號碼: 1521 監聽器 ORACLE_HOME [ /opt/oracle/product/11.2.0/dbhome_1 ]: SYS 使用者密碼: DBSNMP 使用者密碼: SYSMAN 使用者密碼: 通知的電子郵件地址 (選擇性): 通知的外送郵件 (SMTP) 伺服器 (選擇性): ----------------------------------------------------------------- 您已指定下列設定值 資料庫 ORACLE_HOME ................ /opt/oracle/product/11.2.0/dbhome_1 本機主機名稱 ................ 127.0.0.1 監聽器 ORACLE_HOME ................ /opt/oracle/product/11.2.0/dbhome_1 監聽器連接埠號碼 ................ 1521 資料庫 SID ................ orcl 通知的電子郵件地址 ............... 通知的外送郵件 (SMTP) 伺服器 ............... ----------------------------------------------------------------- 要繼續? [yes(Y)/no(N)]: y 2014/1/7 下午 05:31:33 oracle.sysman.emcp.EMConfig perform 資訊: 已將這項作業記錄於 /opt/oracle/cfgtoollogs/emca/orcl/emca_2014_01_07_17_30_42.log. 2014/1/7 下午 05:31:35 oracle.sysman.emcp.EMReposConfig uploadConfigDataToRepository 資訊: 正在將組態資料上傳至 EM 儲存區域 (可能需要一些時間) ... 2014/1/7 下午 05:32:31 oracle.sysman.emcp.EMReposConfig invoke 資訊: 已順利上傳組態資料 2014/1/7 下午 05:32:33 oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib 資訊: 已經設定軟體程式庫. 2014/1/7 下午 05:32:33 oracle.sysman.emcp.util.DBControlUtil configureSoftwareLib 資訊: EM_SWLIB_STAGE_LOC (值) 將被忽略. 2014/1/7 下午 05:32:33 oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary 資訊: 正在建置啟動設定存檔 ... 2014/1/7 下午 05:33:04 oracle.sysman.emcp.EMDBPostConfig configureSoftwareLibrary 資訊: 已順利建置啟動設定存檔. 2014/1/7 下午 05:33:04 oracle.sysman.emcp.util.DBControlUtil secureDBConsole 資訊: 正在保護 Database Control (可能需要一些時間) ... 2014/1/7 下午 05:33:14 oracle.sysman.emcp.util.PlatformInterface executeCommand 警告: 執行 /opt/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -repos 時發生錯誤 2014/1/7 下午 05:33:14 oracle.sysman.emcp.util.DBControlUtil secureDBConsole 警告: 設定 EM 金鑰失敗. 2014/1/7 下午 05:33:14 oracle.sysman.emcp.EMDBPostConfig performConfiguration 警告: 保護 Database Control 時發生錯誤. 2014/1/7 下午 05:33:14 oracle.sysman.emcp.EMDBPostConfig setWarnMsg 資訊: 保護 Database Control 時發生錯誤, Database Control 在非安全模式啟動. 若要保護 Database Control, 請執行下列命令: 1) 將環境變數 ORACLE_SID 設成 orcl 2) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl stop dbconsole 3) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -repos -sysman_pwd < SYSMAN 使用者密碼 > 4) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl secure dbconsole -sysman_pwd < SYSMAN 使用者密碼 > 5) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl start dbconsole 若要保護「EM 金鑰」, 請執行 /opt/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -remove_from_repos -sysman_pwd < SYSMAN 使用者密碼 > 2014/1/7 下午 05:33:14 oracle.sysman.emcp.util.DBControlUtil startOMS 資訊: 正在啟動 Database Control (可能需要一些時間) ... 2014/1/7 下午 05:33:47 oracle.sysman.emcp.EMDBPostConfig performConfiguration 資訊: 已順利啟動 Database Control 2014/1/7 下午 05:33:47 oracle.sysman.emcp.EMDBPostConfig performConfiguration 資訊: >>>>>>>>>>> Database Control URL 是 http://127.0.0.1:5500/em <<<<<<<<<<< 保護 Database Control 時發生錯誤, Database Control 在非安全模式啟動. 若要保護 Database Control, 請執行下列命令: 1) 將環境變數 ORACLE_SID 設成 orcl 2) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl stop dbconsole 3) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -repos -sysman_pwd < SYSMAN 使用者密碼 > 4) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl secure dbconsole -sysman_pwd < SYSMAN 使用者密碼 > 5) /opt/oracle/product/11.2.0/dbhome_1/bin/emctl start dbconsole 若要保護「EM 金鑰」, 請執行 /opt/oracle/product/11.2.0/dbhome_1/bin/emctl config emkey -remove_from_repos -sysman_pwd < SYSMAN 使用者密碼 > [oracle@localhost ~]$ |
28. 執行 “emctl start dbconsole” 啟動EM (關閉指令為 “emctl stop dbconsole” )
1 2 3 4 5 |
[root@localhost ~]# emctl start dbconsole Oracle Enterprise Manager 11g Database Control Release 11.2.0.1.0 Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved. Copyright (c) 1996, 2009 Oracle Corporation. All rights reserved. https://127.0.0.1:5500/em/console/aboutApplication https://127.0.0.1:5500/em/console/aboutApplication - An instance of Oracle Enterprise Manager 11g Database Control is already running. |
29. 開啟瀏覽器,連結https://localhost:1158/em,輸入剛才設定的帳號和密碼,
即可進入Oracle Enterprise Manager的Web管理畫面
30. 若要使用SQL Developer連線,( SQL Developer可至Oracle官網進行下載 )
可在選單 “檔案” > “新建…” > “資料庫連線”,填入以下的連線資料,測試、儲存並連線