這裡介紹在Red Hat Enterprise Linux Server release 5.7 (Tikanga)下安裝ORACLE 11.2.0.1.0的過程,本文僅僅是為了寫這樣安裝指導文檔而整理在此。僅供參考!
1:下載對應平台的ORACLE 11g安裝介質
安裝ORACLE,首先要獲取安裝介質,大部分情況手頭都有相關版本的安裝介質。如果你手頭沒有安裝介質,那麼可以從下面鏈接獲取對應平台的ORACLE安裝介質。
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
強烈建議在安裝ORACLE之前,先看一遍Linux Installation Guides 文檔,畢竟這是最權威、最全面的資料。這樣可以避免你在安裝過程中遇到各類奇奇怪怪的問題,下載鏈接如下所示:
http://docs.oracle.com/cd/E11882_01/nav/portal_11.htm
2:檢查硬件配置是否滿足要求
2.1:內存大小要求
官方文檔中,要求物理內存至少需要1G,推薦2G或以上配置,如果是服務器的話,配置肯定比這個高。查看系統內存配置,可以使用下面命令:
檢查物理內存
[root@DB-Server ~]# grep MemTotal /proc/meminfo
MemTotal: 3968144 kB
[root@DB-Server ~]# free -m
total used free shared buffers cached
Mem: 3875 710 3164 0 85 317
-/+ buffers/cache: 307 3567
Swap: 5887 0 5887
[root@DB-Server ~]#
Note: On Linux, the HugePages feature allocates non-swappable memory for large page tables using memory-mapped files. If you enable HugePages, then you should deduct the memory allocated to HugePages from the available RAM before calculating swap space
Linux Swap大小要求(這是一個指導值,最好根據Linux版本供應商的文檔設置。如果不太清楚這些,盡量按照下面要求設置)
檢查交換空間(Swap)大小(free命令亦可)
[root@DB-Server ~]# grep SwapTotal /proc/meminfo
SwapTotal: 6029304 kB
Automatic Memory Management
從Oracle Database 11g開始,自動內存管理(Automatic Memory Management)要求更多的共享內存(/dev/shm)和文件描述符(file descriptors),共享內存的大小應該只是比MEMROY_MAX_TARGET 和MEMROY_TARGET大。
查看共享內存大小
[root@DB-Server ~]# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
tmpfs 1.9G 927M 1012M 48% /dev/shm
[root@DB-Server ~]#
Starting with Oracle Database 11g, the Automatic Memory Management feature requires more shared memory (/dev/shm)and file descriptors. The size of the shared memory must be at least the greater of the MEMORY_MAX_TARGET and MEMORY_TARGET parameters for each Oracle instance on the computer. If the MEMORY_MAX_TARGET parameter or the MEMORY_TARGET parameter is set to a nonzero value, and an incorrect size is assigned to the shared memory, it results in an ORA-00845 error at startup. On Linux systems, if the operating system /dev/shm mount size is too small for the Oracle system global area (SGA) and program global area (PGA), it results in an ORA-00845 error.
The number of file descriptors for each Oracle instance must be at least 512*PROCESSES. The limit of descriptors for each process must be at least 512. If file descriptors are not sized correctly, you see an ORA-27123 error from various Oracle processes and potentially Linux Error EMFILE (Too many open files)in non-Oracle processes.
注意:MEMORY_MAX_TARGET and MEMORY_TARGET cannot be used when LOCK_SGA is enabled or with HugePages on Linux.
2.2:系統架構要求
檢查系統架構是否符合軟件安裝要求。如果是x86的架構,肯定不能運行64位的ORACLE軟件。檢查系統架構使用下面命令:
[root@DB-Server ~]# uname -m
x86_64
2.3:磁盤空間要求
At least 1 GB of disk space in the /tmp directory
檢查/tmp目錄大小
#df -h /tmp
檢查磁盤空間:
#df –h
3:Checking the Software Requirements
Red Hat Enterprise Linux 5 and Oracle Linux 5 on Linux x86 and Linux x86-64 require Update 2.
3.1:操作系統要求
Oracle Database 11g Release 1 (11.1) 要求安裝在下面版本的操作系統或後續版本中。安裝Oracle數據庫是必須檢查目前操作系統版本是否支持。
■ Asianux Server 3 SP2
■ Asianux Server 4 SP3
■ Oracle Linux 4 Update 7
■ Oracle Linux 5 Update 2 (with Red Hat Compatible Kernel)
■ Oracle Linux 5 Update 5
■ Oracle Linux 6
■ Oracle Linux 6 (with Red Hat Compatible Kernel)
■ Oracle Linux 7
■ Oracle Linux 7 (with the Red Hat Compatible Kernel)
■ Red Hat Enterprise Linux 4 Update 7
■ Red Hat Enterprise Linux 5 Update 2
■ Red Hat Enterprise Linux 6
■ Red Hat Enterprise Linux 7
■ SUSE Linux Enterprise Server 10 SP2
■ SUSE Linux Enterprise Server 11
■ SUSE Linux Enterprise Server 12 SP1
■ NeoKylin Linux Advanced Server 6
3.2 操作系統內核要求
下面僅僅列舉了部分內容,更多請見官方文檔
■On Oracle Linux 4 and Red Hat Enterprise Linux 4
2.6.9 or later
■ On Oracle Linux 5 Update 2 with Red Hat Compatible Kernel
2.6.18 or later
■ On Oracle Linux 5 Update 5 with Red Hat Compatible Kernel
2.6.18 or later
■ On Oracle Linux 5 Update 5 with Unbreakable Enterprise Kernel
2.6.32-100.0.19 or later
■ On Oracle Linux 6
2.6.32-100.28.5.el6.x86_64 or later
■ On Oracle Linux 6 with Red Hat Compatible Kernel
2.6.32-71.el6.x86_64 or later
■ On Oracle Linux 7
3.8.13-33.el7uek.x86_64 or later
■ On Oracle Linux 7 with Red Hat Compatible Kernel
3.10.0-54.0.1.el7.x86_64 or later
■ On Red Hat Enterprise Linux 5 Update 2
2.6.18 or later
■ On Red Hat Enterprise Linux 5 Update 5
2.6.18 or later
■ On Red Hat Enterprise Linux 6
2.6.32-71.el6.x86_64 or later
■ On Red Hat Enterprise Linux 7
3.10.0-54.0.1.el7.x86_64 or later
■ On Asianux Server 3
2.6.18 or later
■ On Asianux Server 4
2.6.32-71.el6.x86_64 or later
查看操作系統內部版本,可以使用下面命令,如下所示,內部版本滿足要求。
[root@DB-Server ~]# cat /proc/version
Linux version 2.6.18-274.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-51)) #1 SMP Fri Jul 8 17:36:59 EDT 2011
[root@DB-Server ~]# uname -r
2.6.18-274.el5
3.3:ORACLE軟件所要求或依賴的一些包
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \
compat-libstdc++-33 \
elfutils-libelf \
elfutils-libelf-devel \
gcc \
gcc-c++ \
glibc \
glibc-common \
glibc-devel \
glibc-headers \
ksh \
libaio \
libaio \
libaio-devel \
libgcc \
libstdc++ \
libstdc++-devel \
make \
sysstat
[root@DB-Server ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \
> compat-libstdc++-33 \
> elfutils-libelf \
> elfutils-libelf-devel \
> gcc \
> gcc-c++ \
> glibc \
> glibc-common \
> glibc-devel \
> glibc-headers \
> ksh \
> libaio \
> libaio \
> libaio-devel \
> libgcc \
> libstdc++ \
> libstdc++-devel \
> make \
> sysstat
binutils-2.17.50.0.6-14.el5 (x86_64)
compat-libstdc++-33-3.2.3-61 (x86_64)
compat-libstdc++-33-3.2.3-61 (i386)
elfutils-libelf-0.137-3.el5 (x86_64)
elfutils-libelf-0.137-3.el5 (i386)
elfutils-libelf-devel-0.137-3.el5 (x86_64)
gcc-4.1.2-51.el5 (x86_64)
gcc-c++-4.1.2-51.el5 (x86_64)
glibc-2.5-65 (x86_64)
glibc-2.5-65 (i686)
glibc-common-2.5-65 (x86_64)
glibc-devel-2.5-65 (x86_64)
glibc-devel-2.5-65 (i386)
glibc-headers-2.5-65 (x86_64)
ksh-20100202-1.el5_6.6 (x86_64)
libaio-0.3.106-5 (x86_64)
libaio-0.3.106-5 (i386)
libaio-0.3.106-5 (x86_64)
libaio-0.3.106-5 (i386)
package libaio-devel is not installed
libgcc-4.1.2-51.el5 (x86_64)
libgcc-4.1.2-51.el5 (i386)
libstdc++-4.1.2-51.el5 (x86_64)
libstdc++-4.1.2-51.el5 (i386)
libstdc++-devel-4.1.2-51.el5 (x86_64)
make-3.81-3.el5 (x86_64)
package sysstat is not installed
如上檢測所示,我們需要安裝這些缺少的包:
[root@DB-Server Server]# rpm -ivh libaio-devel*
warning: libaio-devel-0.3.106-5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:libaio-devel ########################################### [ 50%]
2:libaio-devel ########################################### [100%]
[root@DB-Server Server]# rpm -ivh sysstat*
warning: sysstat-7.0.2-11.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:sysstat ########################################### [100%]
[root@DB-Server Server]#
3.4 Compiler Requirements
Intel C++ Compiler 10.1 or later and the version of GNU C and C++ compilers listed under "Package Requirements" are supported with these products
3.5 其它軟件要求(Additional Software Requirements)
這部分建立參考安裝文檔(裡面內容較詳細,有些是特殊要求),這裡僅僅涉及Oracle ODBC相關驅動。
在 Oracle Linux 5, Red Hat Enterprise Linux 5, and Asianux Server 3中,需要下面3個包的版本
- unixODBC-2.2.11 (32-bit) or later
- unixODBC-devel-2.2.11 (64-bit) or later
- unixODBC-2.2.11 (64-bit) or later
[root@DB-Server Server]# rpm -ivh unixODBC-2.2.11-7.1.i386.rpm
warning: unixODBC-2.2.11-7.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:unixODBC ########################################### [100%]
[root@DB-Server Server]# rpm -ivh unixODBC-2.2.11-7.1.x86_64.rpm
warning: unixODBC-2.2.11-7.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:unixODBC ########################################### [100%]
[root@DB-Server Server]# rpm -ivh unixODBC-devel-2.2.11-7.1.i386.rpm
warning: unixODBC-devel-2.2.11-7.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:unixODBC-devel ########################################### [100%]
[root@DB-Server Server]# rpm -ivh unixODBC-devel-2.2.11-7.1.x86_64.rpm
warning: unixODBC-devel-2.2.11-7.1.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:unixODBC-devel ########################################### [100%]
[root@DB-Server Server]#
4 Configuring Kernel Parameters and Resource Limits
在修改內核參數前,我們先檢查、查看這些內核參數的配置值
[root@DB-Server ~]# /sbin/sysctl -a | grep sem
kernel.sem = 250 32000 32 128
[root@DB-Server ~]# /sbin/sysctl -a | grep shm
vm.hugetlb_shm_group = 0
kernel.shmmni = 4096
kernel.shmall = 4294967296
kernel.shmmax = 68719476736
[root@DB-Server ~]# /sbin/sysctl -a | grep file-max
fs.file-max = 358778
[root@DB-Server ~]# /sbin/sysctl -a | grep ip_local_port_range
net.ipv4.ip_local_port_range = 32768 61000
[root@DB-Server ~]# /sbin/sysctl -a | grep rmem_default
net.core.rmem_default = 129024
[root@DB-Server ~]# /sbin/sysctl -a | grep rmem_max
net.core.rmem_max = 131071
[root@DB-Server ~]# /sbin/sysctl -a | grep wmem_default
net.core.wmem_default = 129024
[root@DB-Server ~]# /sbin/sysctl -a | grep wmem_max
net.core.wmem_max = 131071
[root@DB-Server ~]#
官方文檔關於內核參數的推薦值如下截圖所示,如果系統裡面的配置大於這個值,那麼就使用默認的值,不需要修改該參數值。
注意:If the current value of any parameter is higher than the value listed in this table, then do not change the value of that parameter.
在 /etc/sysctl.conf中添加如下參數的設置值,如果這一步設置有誤,也沒有關系,後面安裝過程會檢測系統參數,提示參數設置有誤,不能通過。需要你重新配置。
fs.file-max = 6815744
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
kernel.sem = 250 32000 100 128
設置完成後執行/sbin/sysctl -p 使之理解生效,從而不用重啟系統。Oracle 11g新增了fixup腳本,在安裝過程中,安裝程序將會檢查推薦的操作系統內核參數設置以及必須的軟件包,對於不符合要求的部分將會自動生成runfixup.sh,只需要手動以root用戶執行該腳本即可,不需要手動調整配置了。所以這一塊即使一些內核參數配置不正確,也可以在後面環境快速處理、驗證。
5:創建系統賬號和用戶組
一般要檢查是否存在oracle以及dba、oinstall用戶組,如果是新環境,可以直接跳過,如果以前安裝過Oracle數據庫,那麼就必須檢查一下。
[root@DB-Server ~]# more /etc/oraInst.loc
/etc/oraInst.loc: No such file or directory
[root@DB-Server ~]# grep oinstall /etc/group
[root@DB-Server ~]# grep dba /etc/group
[root@DB-Server ~]#
創建用戶組dba、oinstall
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
創建用戶oracle
[root@DB-Server ~]# id oracle
id: oracle: No such user
[root@DB-Server ~]# /usr/sbin/useradd -g oinstall -G dba oracle
[root@DB-Server ~]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba) context=root:system_r:unconfined_t:SystemLow-SystemHigh
[root@DB-Server ~]#
設置賬號密碼:
[root@DB-Server ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is too simplistic/systematic
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@DB-Server ~]#
6:修改用戶資源限制
[root@DB-Server ~]# ulimit -Sn
1024
[root@DB-Server ~]# ulimit -Hn
1024
[root@DB-Server ~]# ulimit -Su
36848
[root@DB-Server ~]# ulimit -Hu
36848
[root@DB-Server ~]# ulimit -Ss
10240
[root@DB-Server ~]# ulimit -Hs
unlimited
[root@DB-Server ~]#
在配置文件/etc/security/limits.conf 裡面設置
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
修改用戶驗證選項
在/etc/pam.d/login配置文件裡面加上下面配置,如果已經存在的,就忽略這些。
session required pam_selinux.so
session required /lib/security/pam_limits.so
7:修改用戶配置文件
root用戶下:修改/etc/profile文件加入如下參數
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
或是在oracle用戶下,修改.bash_profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
8:安裝目錄配置
[root@DB-Server ~]# mkdir -p /u01/app/oracle
[root@DB-Server ~]# chown -R oracle:oinstall /u01/app/oracle
[root@DB-Server ~]# chmod -R 775 /u01/app/oracle
[root@DB-Server ~]# mkdir -p /u01/app/oraInventory
[root@DB-Server ~]# chown -R oracle:oinstall /u01/app/oraInventory/
[root@DB-Server ~]# chmod -R 775 /u01/app/oraInventory/
[root@DB-Server ~]#
9:修改用戶bash shell
以oracle賬號登錄,修改.bash_profile參數文件
[oracle@DB-Server ~]$ vi .bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.1.0/dbhome_1
export ORACLE_SID=gsp
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
10:配置VNC
[root@DB-Server ~]# rpm -qa | grep vnc
vnc-server-4.1.2-14.el5_6.6
[root@DB-Server ~]# vi /etc/sysconfig/vncservers
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
VNCSERVERS="2:oracle"
VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
[root@DB-Server ~]# su - oracle
[oracle@DB-Server ~]$ vncserver :2
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /home/oracle/.Xauthority
xauth: (stdin):1: bad display name "DB-Server.localdomain:2" in "add" command
New 'DB-Server.localdomain:2 (oracle)' desktop is DB-Server.localdomain:2
Creating default startup script /home/oracle/.vnc/xstartup
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/DB-Server.localdomain:2.log
在root用戶下,設置iptables,添加
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 5902 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT
ORACLE 11g圖形化安裝步驟
將安裝介質解壓到/tmp/database下,然後按照下面步驟安裝
$ ./runInstaller
如果沒有Oracle Support賬號或不想設置,取消勾選選項。
勾選Server Class
我們勾選“Advanced install”
此處設置字符集,SGA Target等。
Qwe123456
[root@DB-Server Server]# /u01/oraInventory/orainstRoot.sh
Changing permissions of /u01/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/oraInventory to oinstall.
The execution of the script is complete.
[root@DB-Server Server]# /u01/app/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app
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.
[root@DB-Server Server]#
至此安裝完成,然後測試驗證,必要的話,關閉VNC服務,修改iptables設置。