2015年9月15日 星期二

Redhat 6.4 install Oracle 11G

環境:REDHAT 6.4 + GUI

依參考網址的步驟安裝
http://techblog.forink.net/2014/01/centos-6-5-oracle-database-11gr2-apex-%E5%AE%89%E8%A3%9D%E8%A8%98%E9%8C%84/

至23步止便安裝完成無須後面設定

只要添加防火牆規則開放1521PORT即可連線


以下皆可不需觀看
=====================================

1.安裝設置JAVA

詳情請見:
Redhat/CentOS java環境設置
看不懂沒關係看結論!
不用做任何事
Redhat 已預設安裝JAVA

2. 安裝相關套件

yum -y install compat-libstdc++* gcc-c++* glibc* libaio* libstdc++* unixODBC* elfutils-libelf-devel*

YUM詳情請見REDHAT yum offline

3. 預先建立oracle帳號,並建立oinstall、dba、oper群組,並指定給oracle (主群組設定為oinstall)

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

mkdir -p /opt/oracle/product/11.2.0/dbhome_1
chown -R oracle:oinstall /opt

5. 設定系統參數,編輯/etc/profile,新增以下段落,
vim /etc/profile

# 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

以Oracle
在  Oracle帳號的PATH變數中新增$ORACLE_HOME/bin

cd ~
vim .bash_profile
PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin

6. 修改 /etc/security/limits.conf,在最下方加入下列內容 ( 若跟原有資料重複的話,請記得刪除舊值 ):
vim /etc/security/limits.conf

#oracle
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
oracle              soft    stack   10240






8.  解壓縮
unzip -oq "linux.x64_11gR2_database*.zip"




Inventory
資料夾擁有者需要與安裝帳號相同



9. 設定環境變數,若CentOS為非英文版,沒做這一步,安裝畫面會出現方框亂碼

[oracle@localhost database]$ export LANG=en_US.UTF-8
[oracle@localhost database]$ export LC_ALL=en_US.UTF-8


10.用oracle 帳號登入桌面執行安裝
終端機
sh /tmp/Oracle_install/database/runInsraller

至這一步起若前面設定皆有成功

若有出現

./runInstaller

Checking Temp space: must be greater than 120 MB. Actual 6820 MB Passed
Checking swap space: must be greater than 150 MB. Actual 1965 MB Passed
Checking monitor: must be configured to display at least 256 colors
Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set. Failed <<<<

則為登入的桌面使用者非Oracle帳號
請更換為Oracle帳號登入



就可以操作畫面安裝點選下一步

直至檢查畫面
接下來依指示以ROOT權限執行SH檔修正即可

※沒意外的話是執行以下兩行
sh /opt/oraInventory/orainstRoot.sh
sh /opt/oracle/product/11.2.0/dbhome_1/root.sh


11. 檢查相依的Library,可以先點選中間的 "Fix & Check Again" 按鈕查看驗證結果,
並依其指示進行修正。

※錯誤訊息 ins-20802

vi /etc/sysconfig/ntpd

添加 -x

OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
OPTIONS="-x -u ntp:ntp -p /var/run/ntpd.pid -g"


12.
防火牆開啟 1521

iptables-save > /root/iptables
vim /root/iptables

添加

-A INPUT -p tcp -m state --state NEW -m tcp --dport 1521 -j ACCEPT

13.設定
$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
# 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


14.
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

====================================
14.Oracle Enterprise Manager

至此可以透過網頁工具操作

Web版的管理工具 Oracle Enterprise Manager 的網址預設為 https://localhost:1158/em
不過在啟動前還需要做一些設定,不然是看不到的


連接資料庫
sqlplus / as sysdba






=========
參考資料

https://oracle-base.com/articles/11g/oracle-db-11gr2-installation-on-oracle-linux-7
https://oracle-base.com/articles/11g/oracle-db-11gr2-installation-on-oracle-linux-6
http://techblog.forink.net/2014/01/centos-6-5-oracle-database-11gr2-apex-%E5%AE%89%E8%A3%9D%E8%A8%98%E9%8C%84/
http://figaro.neo-info.net/?cat=243

Inventory
資料夾擁有者需要與安裝帳號相同
oracle create database script