RHEL5下安装32位Oracle 10G

1389阅读 0评论2011-12-29 啦哆A梦
分类:

一、系统要求

1、至少1G物理内存;检查命令:# grep MemTotal /proc/meminfo

2、交换空间的设置;检查命令:# grep SwapTotal /proc/meminfo

实际内存 建议交换空间大小

-------------- -----------------------------

不超过1G 2倍于内存

1G-2G 1.5倍于内存

 

2G-8G 与内存相同

超过8G 0.75倍于内存

3/tmp目录至少400M空闲空间;检查命令:# df -k /tmp

4oracle软件所需空间至少3G;检查命令:# df -k

5、数据库文件所需空间1.2G左右;检查命令:# df -k

6确认系统架构(主要确认是装32bit还是64bit版本);检查命令:# grep "model name" /proc/cpuinfo

7确认Linux版本;检查命令:# more /etc/issue

8确认Linux内核;检查命令:# uname -r

 

二、准备工作

检查安装oracle10g的依赖包是否存在,如没有则安装

# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})n' binutils compat-db compat-libstdc++-296 control-center gcc gcc-c++ glibc glibc-common gnome-libs libstdc++ libstdc++-devel make pdksh sysstat xscreensaver setarch

应该包含下列的包:

---------------------------------------------------------------------------

binutils-2.15.92.0.2-13.EL4

compat-db-4.1.25-9

compat-libstdc++-296-2.96-132.7.2

control-center-2.8.0-12

gcc-3.4.3-22.1.EL4

gcc-c++-3.4.3-22.1.EL44

glibc-2.3.4-2.9

glibc-common-2.3.4-2.9

gnome-libs-1.4.1.2.90-44.1

libstdc++-3.4.3-22.1

libstdc++-devel-3.4.3-22.1

make-3.80-5

pdksh-5.2.14-30

sysstat-5.0.5-1

xscreensaver-4.18-5.rhel4.2

setarch-1.6-1

注意:RedHat AS4U2 x86默认安装的是binutils-2.15.92.0.2-15.x86_64.rpm,据称此版本会引起oracle安装失败!应另外下载binutils-2.15.92.0.2-13.0.0.0.2.x86_64.rpm

下载请到:http://rpm.pbone.net/index.php3/stat/4/idpl/2060541/com/binutils-2.15.92.0.2-13.i386.rpm.html

下载完成后执行下列命令安装:

#rpm -Uvh --force binutils-2.15.92.0.2-13.i386.rpm

compat-oracle-rhel4-1.0-5.i386.rpm网上也推荐安装,我想有总比没有强顺手也装上了。如果你安装不成功,可以下载这个包装上试试,安装这个包可能会关联到其它软件包,需要按照提示一并安装。

 

三、配置安装环境

1、配置核心参数。

1). # vi /etc/sysctl.conf ,将下列内容加入该文件。

kernel.shmall = 2097152

kernel.shmmax = 536870912

kernel.shmmni = 4096

kernel.sem = 250 32000 100 128

fs.file-max = 65536

net.ipv4.ip_local_port_range = 1024 65000

net.core.rmem_default = 1048576

net.core.rmem_max = 1048576

net.core.wmem_default = 262144

net.core.wmem_max = 262144

注:一般而言我们只需要修改kernel.shmmax这个值,该参数应该是物理内存的一半(字节)

 

 

编辑完之后存盘退出,然后运行下列命令重新加载并验证参数是否正确:

#sysctl -p

 

 

2). # vi /etc/security/limits.conf ,将下列内容加入该文件。

* soft nproc 2047

* hard nproc 16384

* soft nofile 1024

* hard nofile 65536

3). # vi /etc/pam.d/login ,将下列内容加入该文件

session required /lib/security/pam_limits.so

session required pam_limits.so

4). # vi /etc/selinux/config 确保存在以下内容。

SELINUX=disabled

2、创建相关目录,用户,组等

# groupadd dba

# groupadd oinstall

# useradd -g oinstall -G dba  oracle

# passwd oracle

## 创建用户和组完成,下面创建目录,目录位置你根据自己情况定吧,注意磁盘的空闲空间。

 

mkdir -p /u01/app/oracle/

chown -R oracle:oinstall /u01/app/oracle/

chmod -R 775 /u01/app/oracle/

 

mkdir -p /backup/bak/

mkdir -p /data/orash

chown oracle:oinstall /backup/ -R

chown oracle:oinstall /data -R

chmod 755 /data  -R

chmod 755 /backup/ -R

 

解压10201_database_linux32.zip

unzip 10201_database_linux32.zip

unzip p6810189_10204_Linux-x86.zip

修改database目录权限,用户和用户组

chown -R oracle:oinstall database/

chmod -R 775 database/

chown -R oracle:oinstall Disk1/

chmod -R 775 Disk1/

 

3、配置oracle用户的环境变量

# su - oracle

$ vi .bash_profile

 

PATH=$PATH:$HOME/bin

 

export PATH

 

unset ORACLE_SID  ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH TNS_ADMIN ORA_NLS33 ORACLE_OWNER ORACLE_TERM PATH NLS_LANG LANG

ORACLE_BASE=/u01/app/oracle

export ORACLE_BASE

ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1

export ORACLE_HOME

ORACLE_SID=orcl

export ORACLE_SID

ORA_NLS10=$ORACLE_HOME/nls/data

export ORA_NLS10

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:usr/lib:$LD_LIBRARY_PATH

export LD_LIBRARY_PATH

#export LANG=AMERICAN_AMERICA.ZHS16GBK

export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin::$HOME/bin:$ORACLE_HOME/bin:/usr/bin:/usr/ucb:/etc:/usr/openwin/bin:/usr/ccs/bin:/usr/local/bin

#export PATH=$ORACLE_HOME/bin:${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin

export PATH

 

if [ $USER = "oracle" ]; then

  if [ $SHELL = "/bin/ksh" ]; then

    ulimit -p 16384

    ulimit -n 65536

  else

    ulimit -u 16384 -n 65536

  fi

fi

 

让刚才编辑的环境变量生效:

 

                            . .bash_profile

 

 

 

四、安装ORACLE10GR2

 

终于要开始安装了,以oracle用户启动到视窗状态,打开一个终端。

$ cd /opt/database

su - root

xhost +

export LANG=C

 

su - oracle

 

rpm -Uvh libXp-1.0.0-8.1.el5.i386.rpm

 

 

增加swap分区

 

dd if=/dev/zero of=/tmp/swap bs=1M count=00 500M swap文件

mkswap /tmp/swap

swapon /tmp/swap

free

vi /etc/fstab

/tmp/swap swap swap defaults 0 0

 

$ ./runInstaller

 

选择只安装软件

 

按照提示:

su - root

 

cd /u01/app/oracle/product/10.2.0/db_1/

 

 ./root.sh

 

 

 

升级数据库到10.2.0.4

 

cd /Disk1

 

./runInstall

 

如果提示非空目录,则选择确定

 

next

 

root身份运行两个.sh文件  y

 

 

 

        

 

建立数据库

 

su - oracle

 

dbca

 

next

 

create a database

 

next

 

transaction processing

 

next

 

sid  环境变量 sid 一致

 

next

 

next

 

输入密码

 

next

 

file system

 

next

 

next

 

next

 

sample schemas

 

next

 

memory

70

 

character sets

 

use unicode (AL32UTF8)

 

一般选zhs16gbk

 

next

 

next

 

finish

 

OK

 

 

 

 

打开归档

 

sqlplus / as sysdba

 

shutdown immediate

 

startup mount

 

alter database archivelog;

archive log list

 

看到:Automatic archival             Enabled

 

alter database open;

alter system switch logfile;    --执行5

 

exit

 

 ls /u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_12_15/

 

看到到里面有日期目录,即可

 

 

 

创建表空间

sqlplus / as sysdba

 

 

CREATE TABLESPACE OTA_DATA01 DATAFILE

  '/data/ota_data01_01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED

LOGGING

ONLINE

EXTENT MANAGEMENT LOCAL AUTOALLOCATE

BLOCKSIZE 8K

SEGMENT SPACE MANAGEMENT MANUAL

FLASHBACK ON;

 

CREATE TABLESPACE OTA_DATA04 DATAFILE

  '/data/ota_data04_01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED

LOGGING

ONLINE

EXTENT MANAGEMENT LOCAL AUTOALLOCATE

BLOCKSIZE 8K

SEGMENT SPACE MANAGEMENT MANUAL

FLASHBACK ON;

 

 

CREATE TABLESPACE OTA_DATA02 DATAFILE

  '/data/ota_data02_01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED

LOGGING

ONLINE

EXTENT MANAGEMENT LOCAL AUTOALLOCATE

BLOCKSIZE 8K

SEGMENT SPACE MANAGEMENT MANUAL

FLASHBACK ON;

 

 

CREATE TABLESPACE OTA_DATA03 DATAFILE

  '/data/ota_data03_01.dbf' SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE UNLIMITED

LOGGING

ONLINE

EXTENT MANAGEMENT LOCAL AUTOALLOCATE

BLOCKSIZE 8K

SEGMENT SPACE MANAGEMENT MANUAL

FLASHBACK ON;

 

 

 

创建用户

 

CREATE USER SOTPMS_TEST

  IDENTIFIED BY "123456"

  DEFAULT TABLESPACE USERS

  TEMPORARY TABLESPACE TEMP

  PROFILE DEFAULT

  ACCOUNT UNLOCK;

  #-- 2 Roles for SOTPMS_TEST

  GRANT CONNECT TO SOTPMS_TEST;

  GRANT RESOURCE TO SOTPMS_TEST;

  ALTER USER SOTPMS_TEST DEFAULT ROLE ALL;

  #-- 6 System Privileges for SOTPMS_TEST

  GRANT DEBUG ANY PROCEDURE TO SOTPMS_TEST;

  GRANT DROP ANY DIRECTORY TO SOTPMS_TEST;

  GRANT CREATE ANY DIRECTORY TO SOTPMS_TEST;

  GRANT DEBUG CONNECT SESSION TO SOTPMS_TEST;

  GRANT CREATE VIEW TO SOTPMS_TEST;

  GRANT UNLIMITED TABLESPACE TO SOTPMS_TEST;

 

CREATE USER SOTPAS_TEST

  IDENTIFIED BY "123456"

  DEFAULT TABLESPACE USERS

  TEMPORARY TABLESPACE TEMP

  PROFILE DEFAULT

  ACCOUNT UNLOCK;

  #-- 2 Roles for SOTPAS_TEST

  GRANT CONNECT TO SOTPAS_TEST;

  GRANT RESOURCE TO SOTPAS_TEST;

  ALTER USER SOTPAS_TEST DEFAULT ROLE ALL;

  -- 6 System Privileges for SOTPAS_TEST

  GRANT DROP ANY DIRECTORY TO SOTPAS_TEST;

  GRANT CREATE ANY DIRECTORY TO SOTPAS_TEST;

  GRANT UNLIMITED TABLESPACE TO SOTPAS_TEST;

  GRANT CREATE VIEW TO SOTPAS_TEST;

  GRANT DEBUG CONNECT SESSION TO SOTPAS_TEST;

  GRANT DEBUG ANY PROCEDURE TO SOTPAS_TEST;

 

CREATE USER sotpcms_demo

  IDENTIFIED BY "123456"

  DEFAULT TABLESPACE USERS

  TEMPORARY TABLESPACE TEMP

  PROFILE DEFAULT

  ACCOUNT UNLOCK;

  #-- 2 Roles for sotpcms_demo

  GRANT CONNECT TO sotpcms_demo;

  GRANT RESOURCE TO sotpcms_demo;

  ALTER USER sotpcms_demo DEFAULT ROLE ALL;

  #-- 6 System Privileges for sotpcms_demo

  GRANT DEBUG ANY PROCEDURE TO sotpcms_demo;

  GRANT DROP ANY DIRECTORY TO sotpcms_demo;

  GRANT CREATE ANY DIRECTORY TO sotpcms_demo;

  GRANT DEBUG CONNECT SESSION TO sotpcms_demo;

  GRANT CREATE VIEW TO sotpcms_demo;

  GRANT UNLIMITED TABLESPACE TO sotpcms_demo;

 

Exit

 

 

创建用户错误后清理用户

drop user sotpcms_demo cascade;

drop user SOTPAS_TEST cascade;

drop user SOTPMS_TEST cascade;

 

 

 

 

导入数据

gunzip sotpas_test.dmp.gz

gunzip sotpms_test.dmp.gz

 

Imp sotpms_test/123456 file=/tmp/sotpms_test.dmp log=/tmp/sotpms_test.log fromuser=sotpms_test touser=sotpms_test

 

 

Imp sotpas_test/123456 file=/tmp/sotpas_test.dmp log=/tmp/sotpas_test.log fromuser=sotpas_test touser=sotpas_test

 

imp sotpcms_demo/123456 file=/tmp/sotpcms_demo.dmp log=/tmp/sotpcms_demo.log fromuser= sotpcms_demo  touser= sotpcms_demo

 

 

 

备份脚本

 

su – oracle

 

crontab -e

 

 

加入以下内容:

 

 

 

0 4 * * 3 /data/orash/incremental1.sh > /data/orash/incremental1.log

0 4 * * 1,2,4,5,6 /data/orash/incremental2.sh > /data/orash/incremental2.log

0 4 * * 0 /data/orash/incremental0.sh > /data/orash/incremental0.log

 

 

 

 

vi /data/orash/incremental0.sh

 

#!/bin/sh

export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin

dt=`date +%Y%m%d`

$ORACLE_HOME/bin/rman <

connect target /;

run

{

  allocate channel d1 type disk;

  backup

    incremental level=0

    format '/backup/bak/%d_incre0_$dt_%U.bak'

  database;

  backup format  '/backup/bak/%d_control_$dt_%U.bak'

   current controlfile;

backup archivelog all

format '/backup/bak/arch_bk1_$_dt_%U.bak'

delete input;

  release channel d1;

}

quit;

 

vi /data/orash/incremental1.sh

 

#!/bin/sh

export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin

dt=`date +%Y%m%d`

$ORACLE_HOME/bin/rman <

connect target /;

run

{

  allocate channel d1 type disk;

  backup

    incremental level=1

    format '/backup/bak/%d_incre1_$dt_%U.bak'

  database;

  backup format  '/backup/bak/%d_control_$dt_%U.bak'

   current controlfile;

backup archivelog all

format '/backup/bak/arch_bk1_$_dt_%U.bak'

delete input;

  release channel d1;

}

quit;

 

vi /data/orash/incremental2.sh

 

#!/bin/sh

export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin

dt=`date +%Y%m%d`

$ORACLE_HOME/bin/rman <

 connect target /;

 

run

{

  allocate channel d1 type disk;

  backup

    incremental level=2

    format '/backup/bak/%d_incre2_$dt_%U.bak'

  database;

  backup format  '/backup/bak/%d_control_$dt_%U.bak'

   current controlfile;

backup archivelog all

format '/backup/bak/arch_bk1_$_dt_%U.bak'

delete input;

  release channel d1;

}

quit;

 

 

 

chmod +x /data/orash/incremental0.sh

chmod +x /data/orash/incremental1.sh

chmod +x /data/orash/incremental2.sh

 

 

 

 

 

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

 

 

------------------------------------------------------------

 

 

 

 

 

 

 

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

 

 

startup     --开启数据库

 

 

shutdown immediate  --关闭数据库

 

 

 

 

字符集选择  GB2312

 

 

select open_mode from v$database;  --查看数据库启动状态。

 

read write                         --正常

 

 

 

 

 

 

 

 

Vi $ORACLE_HOME/network/admin/listener.ora

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcl)

      (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1)

      (SID_NAME = orcl)

    )

 

 

   )

LISTENER =

  (DESCRIPTION_LIST =

    (DESCRIPTION =

      (ADDRESS = (PROTOCOL = TCP)(HOST = ip)(PORT = 1521))

    )

  )

 

 

Vi $ORACLE_HOME/network/admin/tnsnames.ora

 

orcl =

  (DESCRIPTION =

    (ADDRESS_LIST =

      (ADDRESS = (PROTOCOL = TCP)(HOST = ip)(PORT = 1521))

    )

    (CONNECT_DATA =

      (SERVICE_NAME = orcl)

    )

  )

开启监听

 

$ lsnrctl start

 

查看监听状态

 

$ lsnrctl status

 

停止监听

 

$ lsnrctl stop

 

 

启动脚本:

 

 

 

$ vi /etc/oratab

 

orcl:/ORACLE/app/product/10.2.0/db_1:N

 

改为:

 

orcl:/ORACLE/app/product/10.2.0/db_1:Y

 

也就是将最后的N改为Y

 

 

 

 

Su – root

# cd /etc/rc.d/init.d/

 

# vi oradbstart

 

#!/bin/bash

# chkconfig: 345 99 10

# description: Startup Script for Oracle Databases

# /etc/rc.d/init.d/dbstart

export LANG=C

export ORACLE_BASE=/u01/app/oracle/

export ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1

export ORACLE_SID=orcl

export PATH=$PATH:$ORACLE_HOME/bin

ORA_OWNR="oracle"

# if the executables do not exist -- display error

if [  -f $ORACLE_HOME/bin/dbstart  ]

then

echo "OK!"

else

echo "Oracle startup: cannot start"

exit 1

fi

# depending on parameter -- startup, shutdown, restart

# of the instance and listener or usage display

case "$1" in

start)

# Oracle listener and instance startup

 

echo -n "Starting Oracle: "

su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbstart"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"

touch /var/lock/ORACLE

su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl start dbconsole"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl start"

echo "OK"

;;

stop)

# Oracle listener and instance shutdown

echo -n "Shutdown Oracle: "

su - $ORA_OWNR -c "$ORACLE_HOME/bin/emctl stop dbconsole"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/isqlplusctrl stop"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/dbshut"

su - $ORA_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"

rm -f /var/lock/ORACLE

echo "OK"

;;

reload|restart)

$0 stop

$0 start

;;

*)

echo "Usage: `basename $0` start|stop|restart|reload"

exit 1

esac

exit 0

 

 

 

 

$su - root

 

#chown oracle.oinstall /etc/rc.d/init.d/oradbstart

 

#chmod 775 /etc/rc.d/init.d/oradbstart

 

然后执行:

 

chkconfig --add oradbstart

 

chkconfig --list oradbstart

 

chkconfig --list oradbstart

 

运行结果:

 

oradbstart 0:off 1:off 2:off 3:on 4:on 5:on 6:off

 

 

检验:

Su – oracle

 

$file /etc/rc.d/rc5.d/S99oradbstart

 

S99oradbstart:symbolic link to '../init.d/oradbstart

 

 

[oracle@filesvr2 init.d]$ rman target /

 

configure retention policy to recovery window of 14 days;

 

exit