CentOS/RHEL/Oracle Linux   安裝oracle database 11g

測試環境:vmware workstation 9、CentOS Linux 5.4、Oracle database 11g

測試目的:學習筆記方便查閱

參考網站:http://www.oracle.com/pls/db112/homepage

說    明:Oracle Linux 和CentOS Linux是用RHEL的源碼重新編譯而成的,所以這三種系統一樣


1、新建虛擬機


根據官方文檔,oracle database 11g 安裝,內存最小爲1G,建議2G或者2G以上

2、安裝操作系統

安裝的時候把/tmp單獨分出一個分區,最小爲1G,安裝oracle的時候會檢查

安裝軟件的的時候選擇自定義,安裝x圖形、安裝開發工具、安裝x軟件開發


3、安裝vmtool工具

如果不安裝vmtool工具,linux的屏幕分辨率不能調整;

如果不安裝此工具,可以用Xmanager 遠程linux系統的桌面

然後以root身份進入linux系統進行安裝

3.1掛載vmtool盤

[root@localhost ~]# mount /dev/cdrom /mnt/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# mount
/dev/sda2 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda3 on /tmp type ext3 (rw)
/dev/sda1 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/hdc on /mnt type iso9660 (ro)

3.2解壓安裝包

[root@localhost ~]# tar -zxvf /mnt/VMwareTools-9.2.0-799703.tar.gz

3.3安裝程序包

[root@localhost ~]# ll vmware-tools-distrib/ -d
drwxr-xr-x 7 root root 4096 2012-08-02 vmware-tools-distrib/
[root@localhost ~]# cd vmware-tools-distrib/
[root@localhost vmware-tools-distrib]# ./vmware-install.pl

在安裝過程中,一路回車即可,在提示選擇屏幕分辨率的時候,選擇需要的屏幕分辨率即可

如下:

Please choose one of the following display sizes that X will start with:
[1]  "320x200"
[2]  "320x240"
[3]  "400x300"
[4]  "512x384"
[5]  "640x400"
[6]  "640x480"
[7]  "720x480"
[8]  "800x480"
[9]  "854x480"
[10]  "720x576"
[11]  "800x600"
[12]  "1024x768"
[13]  "1280x720"
[14]  "1280x768"
[15]  "1152x864"
[16]  "1280x800"
[17]  "1366x768"
[18]  "1280x960"
[19]  "1440x900"
[20]  "1280x1024"
[21]  "1400x1050"
[22]  "1680x1050"
[23]  "1600x1200"
[24]  "1920x1080"
[25]  "1920x1200"
[26]  "1920x1440"
[27]  "2048x1536"
[28]  "2560x1600"
[29]  "2560x1920"
Please enter a number between 1 and 29:
[3] 11


注意,這個11是我選擇的,然後回車

這個重啓纔會生效


4、關閉不相關的服務

方法一:

[root@localhost ~]# setup

方法二:

[root@localhost ~]# chkconfig --list
NetworkManager  0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉
acpid           0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉
anacron         0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉
apmd            0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉
atd             0:關閉  1:關閉  2:關閉  3:啓用  4:啓用  5:啓用  6:關閉
auditd          0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉
autofs          0:關閉  1:關閉  2:關閉  3:啓用  4:啓用  5:啓用  6:關閉
avahi-daemon    0:關閉  1:關閉  2:關閉  3:啓用  4:啓用  5:啓用  6:關閉
……(省略部分)

關閉iptables服務

[root@localhost ~]# chkconfig --list | grep iptables
iptables        0:關閉  1:關閉  2:啓用  3:啓用  4:啓用  5:啓用  6:關閉
[root@localhost ~]# chkconfig iptables off
[root@localhost ~]# chkconfig --list | grep iptables
iptables        0:關閉  1:關閉  2:關閉  3:關閉  4:關閉  5:關閉  6:關閉
[root@localhost ~]#

關閉SElinux(不關閉會有很多莫名其妙的錯誤)

[root@localhost ~]# vim /etc/sysconfig/selinux

修改成如下

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#       enforcing - SELinux security policy is enforced.
#       permissive - SELinux prints warnings instead of enforcing.
#       disabled - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted
~
"/etc/sysconfig/selinux" 10L, 447C                            6,1          全部

重啓生效


5、修改主機名,修改IP地址

5.1修改IP地址

[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

內容如下

# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0
BOOTPROTO=static
BROADCAST=192.168.100.255
HWADDR=00:0C:29:B0:29:09
IPADDR=192.168.100.200
NETMASK=255.255.255.0
NETWORK=192.168.100.0
ONBOOT=yes
~

重新啓動服務

[root@localhost ~]# service network restart
正在關閉接口 eth0:                                        [確定]
關閉環回接口:                                             [確定]
彈出環回接口:                                             [確定]
彈出界面 eth0:                                            [確定]
[root@localhost ~]#

查看IP

[root@localhost ~]# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:0C:29:B0:29:09
          inet addr:192.168.100.200  Bcast:192.168.100.255  Mask:255.255.255.0
          inet6 addr: fe80::20c:29ff:feb0:2909/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:2973 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4874 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:213076 (208.0 KiB)  TX bytes:864952 (844.6 KiB)
          Interrupt:67 Base address:0x2000
[root@localhost ~]#

5.2修改主機名,修改網關

[root@localhost ~]# vim /etc/sysconfig/network

內容如下

NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=night
GATEWAY=192.168.100.254
~

重新登錄shell 就會生效

5.3修改hosts文件(這個非常重要)

[root@night ~]# vim /etc/hosts

內容如下

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1               localhost.localdomain localhost
#::1            localhost6.localdomain6 localhost6
192.168.100.200         night
~
~

將原來的IPv6的那一行註釋掉

添加一行,讓本機的IP和hostname解析


6、用root用戶登錄檢查硬件環境

[root@night ~]# uname -m
i686
[root@night ~]# free -m
             total       used       free     shared    buffers     cached
Mem:          1189       1169         20          0         84        882
-/+ buffers/cache:        202        987
Swap:         2392          0       2392
[root@night ~]# df -Th /tmp/
文件系統      類型    容量  已用 可用 已用% 掛載點
/dev/sda3     ext3    1.4G   35M  1.3G   3% /tmp
[root@night ~]#
[root@night ~]# df -Th
文件系統      類型    容量  已用 可用 已用% 掛載點
/dev/sda2     ext3     16G  3.5G   12G  24% /
/dev/sda3     ext3    1.4G   35M  1.3G   3% /tmp
/dev/sda1     ext3     99M   12M   83M  13% /boot
tmpfs        tmpfs    595M     0  595M   0% /dev/shm
[root@night ~]#

我的硬件架構、內存、swap、磁盤分區都符合最小要求

7、檢查軟件環境,並安裝依賴的軟件包

7.1檢查系統內核,系統發佈版本

[root@night ~]# cat /proc/version
Linux version 2.6.18-164.el5 ([email protected]) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Thu Sep 3 03:33:56 EDT 2009
[root@night ~]# uname -r
2.6.18-164.el5
[root@night ~]# cat /etc/redhat-release
CentOS release 5.4 (Final)
[root@night ~]#

以下是Oracle Database 11g 對系統內核的要求

  • For Oracle Linux 4 and Red Hat Enterprise Linux 4:

    2.6.9 or later

  • For Asianux Server 3, Oracle Linux 5, and Red Hat Enterprise Linux 5:

    2.6.18 or later

  • For Oracle Linux 6:

    2.6.32.100 or later

  • For Red Hat Enterprise Linux 6:

    2.6.32-71 or later

  • For SUSE Linux Enterprise Server 10:

    2.6.16.21 or later

  • On SUSE Linux Enterprise Server 11:

    2.6.27.19 or later

7.2安裝依賴的軟件包

Asianux Server 3, Oracle Linux 5,CentOS Linux and Red Hat Enterprise Linux 5 should be installed:

binutils-2.17.50.0.6、compat-libstdc++-33-3.2.3、elfutils-libelf-0.125、elfutils-libelf-devel-0.125、

elfutils-libelf-devel-static-0.125、gcc-4.1.2、gcc-c++-4.1.2、glibc-2.5-24、glibc-common-2.5、

glibc-devel-2.5、glibc-headers-2.5、kernel-headers-2.6.18、ksh-20060214、libaio-0.3.106、

libaio-devel-0.3.106 、libgcc-4.1.2、libgomp-4.1.2、libstdc++-4.1.2、 libstdc++-devel-4.1.2、

make-3.81、sysstat-7.0.2、libXp-1.0、pdksh、numactl-devel、cpp、nscd、unixODBC、unixODBC-devel



Oracle Linux 6, and Red Hat Enterprise Linux 6 should be installed:

binutils-2.20.51.0.2-5.11.el6.i686、compat-libcap1-1.10-1.i686、compat-libstdc++-33-3.2.3-69.el6.i686、

gcc-4.4.4-13.el6.i686、gcc-c++-4.4.4-13.el6.i686、glibc-2.12-1.7.el6.i686、

glibc-devel-2.12-1.7.el6.i686、ksh、libgcc-4.4.4-13.el6.i686、libstdc++-4.4.4-13.el6.i686、

libstdc++-devel-4.4.4-13.el6.i686、libaio-0.3.107-10.el6.i686、libaio-devel-0.3.107-10.el6.i686、

make-3.81-19.el6.i686、sysstat-9.0.4-11.el6.i686、unixODBC、unixODBC-devel

如果安裝ksh 不能通過的話,可以從版本5的盤上拷貝pdksh進行安裝


8、創建用戶和組

[root@night ~]# groupadd oinstall
[root@night ~]# groupadd dba
[root@night ~]# useradd -g oinstall -G dba oracle
[root@night ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@night ~]# id oracle
uid=500(oracle) gid=500(oinstall) groups=500(oinstall),501(dba) context=root:system_r:unconfined_t:SystemLow-SystemHigh

9、創建Oracle的安裝目錄,並且修改權限

[root@night ~]# mkdir -p /u01/app
[root@night ~]# mkdir -p /u01/install
[root@night ~]# chown -R oracle:oinstall /u01/
[root@night ~]# chmod -R 775 /u01/
[root@night ~]# ll -d /u01/
drwxrwxr-x 4 oracle oinstall 4096 07-23 16:41 /u01/
[root@night ~]# ll  /u01/
總計 16
drwxrwxr-x 2 oracle oinstall 4096 07-23 16:40 app
drwxrwxr-x 2 oracle oinstall 4096 07-23 16:41 install
[root@night ~]#

10、配置Oracle用戶的環境變量

[root@night ~]# vim /home/oracle/.bash_profile

內容如下

# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
####for oracle install
export TMPDIR=/tmp
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product
export ORACLE_SID=thinkdba
export ORACLE_TERM=xterm
export PATH=$PATH:$ORACLE_BASE:$ORACLE_HOME/bin
~

切換Oracle用戶,使環境變量生效

[root@night ~]# su - oracle
[oracle@night ~]$ source .bash_profile
[oracle@night ~]$ env | grep ORACLE
ORACLE_SID=thinkdba
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/u01/app/oracle/product
[oracle@night ~]$

查看PATH

[oracle@night ~]$ echo $PATH
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin:/u01/app/oracle:/u01/app/oracle/product/bin:/home/oracle/bin:/u01/app/oracle:/u01/app/oracle/product/bin
[oracle@night ~]$

11、配置內核參數

[oracle@night ~]$ su -
口令:
[root@night ~]#
[root@night ~]# vim /etc/sysctl.conf

內容如下

……(省略部分)
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 268435456
#######for oracle install
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
"/etc/sysctl.conf" 47L, 1328C

設置生效

[root@night ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 4294967295
kernel.shmall = 268435456
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
[root@night ~]#

12、修改資源限制


[root@night ~]# vim /etc/security/limits.conf

內容如下

……(省略部分)
#@student        -       maxlogins       4
# End of file
##########for oracle install
oracle              soft    nproc   2047
oracle              hard    nproc   16384
oracle              soft    nofile  1024
oracle              hard    nofile  65536
oracle              soft    stack   10240

13、修改pam認證

[root@night ~]# vim /etc/pam.d/login

內容如下

……(省略部分)
session    optional     pam_keyinit.so force revoke
########for oracle install
session    required     /lib/security/pam_limits.so
session    required     pam_limits.so

14、僞裝系統

Oracle Linux和RHEL系統不需要,此操作針對CentOS Linux系統

[root@night ~]# vim /etc/redhat-release

內容如下

Red Hat Enterprise Linux AS release 5(Final)

Oracl果是e Database 10g  則需要僞裝爲版本4

15、上傳Oracle Database 11g軟件包到Linux系統

上傳工具很多,只要支持sftp就可以,我個人喜好filezilla,最好使用Oracle賬戶上傳

16、用Oracle用戶登錄桌面系統,解壓Linux,並安裝

[oracle@night ~]$ cd /u01/install/
[oracle@night install]$ ls
linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip
[oracle@night install]$
[oracle@night install]$ unzip linux_11gR2_database_1of2.zip
……(解壓過程省略)
[oracle@night install]$ unzip linux_11gR2_database_2of2.zip
……(解壓過程省略)
[oracle@night install]$ ls
database  linux_11gR2_database_1of2.zip  linux_11gR2_database_2of2.zip
[oracle@night install]$
[oracle@night install]$ du -sh ./
4.4G    ./
[oracle@night install]$ cd database/
[oracle@night database]$ ls
doc  install  response  rpm  runInstaller  sshsetup  stage  welcome.html
[oracle@night database]$ pwd
/u01/install/database
[oracle@night database]$

確認一切都正常後,開始執行安裝

17、安裝圖解

18、手動啓動Oracle數據庫

首先用Oracle用戶登錄

[root@night ~]# su - oracle
[oracle@night ~]$ clear
[oracle@night ~]$ env | grep ORACLE
ORACLE_SID=thinkdba
ORACLE_BASE=/u01/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/u01/app/oracle/product
[oracle@night ~]$
[oracle@night ~]$ clear
[oracle@night ~]$ ps -ef | grep oracle
root      3949  3900  0 15:54 pts/1    00:00:00 su - oracle
oracle    3950  3949  0 15:54 pts/1    00:00:00 -bash
oracle    3983  3950  0 15:54 pts/1    00:00:00 ps -ef
oracle    3984  3950  0 15:54 pts/1    00:00:00 grep oracle
[oracle@night ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 24 15:54:49 2013
Copyright (c) 1982, 2009, Oracle.  All rights reserved.
SQL> conn sys/ as sysdba
Enter password:
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area  481259520 bytes
Fixed Size                  1337352 bytes
Variable Size             301991928 bytes
Database Buffers          171966464 bytes
Redo Buffers                5963776 bytes
Database mounted.
Database opened.
SQL> !ps -ef | grep thinkdba
oracle    4030     1  0 15:56 ?        00:00:00 ora_pmon_thinkdba
oracle    4032     1  0 15:56 ?        00:00:00 ora_vktm_thinkdba
oracle    4036     1  0 15:56 ?        00:00:00 ora_gen0_thinkdba
oracle    4038     1  0 15:56 ?        00:00:00 ora_diag_thinkdba
oracle    4040     1  0 15:56 ?        00:00:00 ora_dbrm_thinkdba
oracle    4042     1  0 15:56 ?        00:00:00 ora_psp0_thinkdba
oracle    4044     1  0 15:56 ?        00:00:00 ora_dia0_thinkdba
oracle    4046     1  4 15:56 ?        00:00:03 ora_mman_thinkdba
oracle    4048     1  0 15:56 ?        00:00:00 ora_dbw0_thinkdba
oracle    4050     1  0 15:56 ?        00:00:00 ora_lgwr_thinkdba
oracle    4052     1  0 15:56 ?        00:00:00 ora_ckpt_thinkdba
oracle    4054     1  0 15:56 ?        00:00:00 ora_smon_thinkdba
oracle    4056     1  0 15:56 ?        00:00:00 ora_reco_thinkdba
oracle    4058     1  0 15:56 ?        00:00:00 ora_mmon_thinkdba
oracle    4060     1  0 15:56 ?        00:00:00 ora_mmnl_thinkdba
oracle    4062     1  0 15:56 ?        00:00:00 ora_d000_thinkdba
oracle    4064     1  0 15:56 ?        00:00:00 ora_s000_thinkdba
oracle    4111  3986  2 15:56 ?        00:00:01 oraclethinkdba (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))
oracle    4114     1  0 15:56 ?        00:00:00 ora_qmnc_thinkdba
oracle    4117     1  0 15:57 ?        00:00:00 ora_q000_thinkdba
oracle    4119     1  0 15:57 ?        00:00:00 ora_q001_thinkdba
oracle    4130     1  3 15:57 ?        00:00:00 ora_m003_thinkdba
oracle    4136     1  0 15:57 ?        00:00:00 ora_cjq0_thinkdba
oracle    4138  3986  0 15:57 pts/1    00:00:00 /bin/bash -c ps -ef | grep thinkdba
SQL>

可以看到後臺進程已經啓動

19、手動啓動監聽

SQL> !lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 24-JUL-2013 16:02:20
Copyright (c) 1991, 2009, Oracle.  All rights reserved.
Starting /u01/app/oracle/product/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/night/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=night)(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                24-JUL-2013 16:02:22
Uptime                    0 days 0 hr. 0 min. 11 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/night/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=night)(PORT=1521)))
The listener supports no services
The command completed successfully
SQL>

至此 全部完成, 隨筆記錄

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章