一、 前置条件准备
1、系统及配置要求
[root@db1 ~]# cat /etc/redhat-release
CentOS release 6.2 (Final)
[root@db1 ~]# uname -a
Linux db1.dong.com 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux
[root@db1 ~]# grep "MemTotal" /proc/meminfo
MemTotal: 2051164 kB //物理内存大于1G
[root@db1 ~]# grep "SwapTotal" /proc/meminfo
SwapTotal: 4194296 kB //交换分区大于2G
[root@db1 ~]# df -h /tmp/
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 9.7G 851M 8.3G 10% / //至少8G的硬盘空间
[root@db1 ~]# df -h | grep /opt
/dev/sdb1 15G 166M 14G 2% /opt
[root@db1 ~]# hostname
db1.dong.com
[root@db1 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.253 db1 db1.dong.com
2、软件环境要求
[root@db1 ~]# yum install binutils compat-libstdc++-33 compat-libstdc++ elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
[root@db1 ~]# rpm -e ksh
[root@db1 ~]# rpm -ivh pdksh-5.2.14-36.el5.x86_64.rpm #安装CentOS5上面的这个软件包
[root@db1 ~]# yum -y install java
3、用户环境要求
[root@db1 ~]# groupadd oinstall
[root@db1 ~]# groupadd dba
[root@db1 ~]# useradd -g oinstall -G dba oracle
[root@db1 ~]# passwd oracle
[root@db1 ~]# mkdir /opt/oracle
[root@db1 ~]# chown -R oracle.oinstall /opt/oracle/
[root@db1 ~]# chown -R 775 /opt/oracle/
[root@db1 ~]# vim ~oracle/.bash_profile
umask 022
export ORACLE_BASE=/opt/oracle
export ORACLE_SID=orcl
export DISPLAY=:0.0
export LANG=en_US.UTF-8
[root@db1 ~]# vim /etc/sysctl.conf #最后添加如下内容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
[root@db1 ~]# sysctl –p
[root@db1 ~]# vim /etc/pam.d/login #文件中添加
session required pam_limits.so
[root@db1 ~]# vim /etc/security/limits.conf #最后添加
oracle soft nproc 8192
oracle hard nproc 16384
oracle soft nofile 32768
oracle hard nofile 65536
4、安装图形环境
[root@db1 ~]# yum -y groupinstall "X Window System"
[root@db1 ~]# yum -y groupinstall "Desktop"
[root@db1 ~]# yum -y groupinstall "Chinese Support"
[root@db1 ~]# init 5
二、 Oracle 11g安装过程
[root@db1 ~]# cd /opt/
[root@db1 opt]# unzip linux.x64_11gR2_database_1of2.zip
[root@db1 opt]# unzip linux.x64_11gR2_database_2of2.zip
[oracle@db1 ~]$ cd /opt/database/
[oracle@db1 database]$ ./runInstaller
图形安装过程省略……
切换root执行脚本
/opt/oracle/oraInventory/orainstRoot.sh
/opt/oracle/product/11.2.0/dbhome_1/root.sh
[root@db1 ~]# vim /etc/profile #在最后添加
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_OWNER=oracle
export ORACLE_SID=orcl
export ORACLE_TERM=xterm
export PATH=$PATH:$ORACLE_HOME/bin
[root@db1 ~]# source /etc/profile
[root@db1 ~]# vim /etc/oratab
orcl:/opt/oracle/product/11.2.0/dbhome_1:Y
[root@db1 ~]# sqlplus sys AS SYSDBA
SQL*Plus: Release 11.2.0.1.0 Production on Sun Jun 24 01:14:04 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> help index;
Enter Help [topic] for help.
@ COPY PAUSE SHUTDOWN
@@ DEFINE PRINT SPOOL
/ DEL PROMPT SQLPLUS
ACCEPT DESCRIBE QUIT START
APPEND DISCONNECT RECOVER STARTUP
ARCHIVE LOG EDIT REMARK STORE
ATTRIBUTE EXECUTE REPFOOTER TIMING
BREAK EXIT REPHEADER TTITLE
BTITLE GET RESERVED WORDS (SQL) UNDEFINE
CHANGE HELP RESERVED WORDS (PL/SQL) VARIABLE
CLEAR HOST RUN WHENEVER OSERROR
COLUMN INPUT SAVE WHENEVER SQLERROR
COMPUTE LIST SET XQUERY
CONNECT PASSWORD SHOW
SQL> show user;
USER is "SYS"
三、 Oracle基本管理
1、 编写启动脚本
[root@db1 ~]# vim /etc/init.d/oracle
[root@db1 ~]# cat /etc/init.d/oracle #!/bin/bash #### 2011.10.10 by TsengYia #### # chkconfig: 35 90 10 # description: Oracle Database Service Daemon. ORCL_BASE="/opt/oracle" ORACLE_HOME=$ORCL_BASE/product/11.2.0/dbhome_1 ORACLE_OWNER=oracle case "$1" in start) su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl start" #//启用监听器 su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME" #//启用数据库 su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl start dbconsole" #//启用OEM ;; stop) su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/emctl stop dbconsole" #//停止OEM su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME" #//停止数据库 su - $ORACLE_OWNER -c "$ORACLE_HOME/bin/lsnrctl stop" #//停止监听器 ;; status) if(pgrep "tnslsnr" && netstat -anpt | grep ":1521") &> /dev/null then echo "Oracle 11g Net Listener is running." else echo "Oracle 11g Net Listener is not running." fi if(netstat -anpt | grep ":1158" && netstat -anpt | grep ":5520") &> /dev/null then echo "Oracle 11g Enterprise Manager is running." else echo "Oracle 11g Enterprise Manager is not running." fi ;; restart) $0 stop $0 start ;; *) echo "Usage: $0 {start|stop|restart|status}" exit 1 ;; esac exit 0
|
[root@db1 ~]# chmod +x /etc/init.d/oracle
[root@db1 ~]# chkconfig --add oracle
[root@db1 ~]# service oracle status