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>

至此 全部完成, 随笔记录

你可能感兴趣的:(oracle,centos,RHEL,11g)