1、安装环境需求
1.1-磁盘空间需求
/tmp 不能少于1GB
df –h /tmp
查看磁盘空间
df -h
1.2-RPM包需求
On Linux X86:
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
unixODBC-2.2.11(32 bit)
unixODBC-devel-2.2.11(32 bit)
pdksh-5.2.14
numactl-0.9.8
libXp-1.0.0
libXp-devel-1.0.0
libXau-devel-1.0.1
On Linux X86-64:
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
compat-libstdc++-33-3.2.3(32 bit)
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
expat-1.95.8
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-2.5-24(32 bit)
glibc-common-2.5
glibc-devel-2.5
glibc-headers-2.5
kernel-headers-2.6.18
ksh-20060214
libaio-0.3.106
libaio-0.3.106(32 bit)
libaio-devel-0.3.106
libaio-devel-0.3.106(32 bit)
libgcc-4.1.2
libgcc-4.1.2(32 bit)
libgomp-4.1.2
libstdc++-4.1.2
libstdc++-4.1.2(32 bit)
libstdc++-devel-4.1.2
make-3.81
sysstat-7.0.2
unixODBC-2.2.11(32 bit)
unixODBC-2.2.11(64 bit)
unixODBC-devel-2.2.11(64 bit)
pdksh-5.2.14
numactl-0.9.8(64 bit)
检测包是否安装
rpm –q package_name
在线下载安装包
yum –y install package_name
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh numactl libXp libXp-devel libXau-devel
1.3-Core文件编辑
修改/etc/profile文件,将
ulimit -s -c 0 > /dev/null 2>&1
修改为:
ulimit -s -c unlimited > /dev/null 2>&1
vi /etc/profile
按下i键进入编辑模式,修改之后,按ESC进入命令模式,输入”:wq”保存退出;
1.4-创建用户和用户组
创建用户组:oinstall,dba,oper,asmadmin,asmdba,asmoper
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/groupadd oper
/usr/sbin/groupadd asmdba
创建用户:oracle,
/usr/sbin/useradd -g oinstall -G dba,asmdba,oper oracle
passwd oracle
1.5-修改oracle用户资源限制
修改/etc/security/limits.conf
oracle soft nproc 65536
oracle hard nproc 65536
oracle soft nofile 65536
oracle hard nofile 65536
在/etc/pam.d/login增加下列参数
session required pam_limits.so
1.6-配置内核参数
修改/etc/sysctl.conf
kernel.core_uses_pid = 1
kernel.shmall = 2097152
kernel.shmmax = 536870912
fs.suid_dumpable = 1
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.aio-max-nr = 1048576
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 1024 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
以上参数为最小值需求,如果实际值大于最小值,则以实际值为准。
运行命令使参数生效
/sbin/sysctl –p
运行命令,确认参数已生效
/sbin/sysctl –a
1.7-创建目录及分配权限
mkdir -p /data/oracle
chown -R oracle:oinstall /data/oracle
chmod -R 775 /data/oracle
1.8-配置用户环境变量
修改系统版本信息:/etc/redhat-release
将CentOS release 5 (final)修改成
Red Hat Enterprise Linux AS release 3 (Taroon)
(oracle 10不支持5)
修改/etc/hosts参数,增加
192.168.56.101 localhost.localdomain localhost
192.168.56.101为机器的静态IP
关闭SELINUX模式
编辑/etc/selinux/config
修改SELINUX= disabled
切换到oracle用户
su – oracle
修改/home/oracle/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
ORACLE_BASE=/data/oracle
export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_HOME
ORACLE_SID=vbora10g
export ORACLE_SID
NLS_LANG=american_america.UTF8
export NLS_LANG
LANG=en_US
export LANG
TNS_ADMIN=$ORACLE_HOME/network/admin
export TNS_ADMIN
PATH=$ORACLE_HOME/bin:$ORACLE_BASE/common/oracle/bin:$PATH:$HOME/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jdk/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export CLASSPATH
umask 022
保存退出。
载入环境变量:
source .bash_profile
1.9、Oracle 安装
切换到root权限
su –
xhost +
进入oracle压缩包所在目录,解压缩安装包
gzip –d 10201_database_linux_x86_64.cpio.gz
cpio -idmv < 10201_database_linux_x86_64.cpio
切换到oracle用户,进入oracle安装文件目录,运行
./runInstaller
开始图形安装oracle
安装完毕后运行命令
/data/oracle/oraInventory/orainstRoot.sh
/data/oracle/product/10.2.0/db_1/root.sh
2.0、数据库配置
配置 /etc/oratab
修改为
ORCL:/data/oracle/product/10.2.0/db_1:Y
配置$ORACLE_HOME/network/admin/linstener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /data/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = vbora10g)
(ORACLE_HOME = /data/oracle/product/10.2.0/db_1)
(SID_NAME = vbora10g)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.220.247)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
配置$ORACLE_HOME/network/admin/tnsnames.ora
ORA10G =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.220.247)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = vbora10g)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
配置数据库和监听自动启动
切换到root权限
vi /etc/oratab
修改
vbora10g:/data/oracle/product/10.2.0/db_1:N
为
vbora10g:/data/oracle/product/10.2.0/db_1:Y
su - oracle
cd $ORACLE_HOME/bin
vi dbstart
修改
ORACLE_HOME_LISTNER=/ade/vikrkuma_new/oracle
为
ORACLE_HOME_LISTNER=$ORACLE_HOME
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/oradbstart
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1
export ORACLE_SID=vbora10g
export PATH=$PATH:$ORACLE_HOME/bin
case "$1" in
start)
su oracle -c $ORACLE_HOME/bin/dbstart
touch /var/lock/oracle
echo "OK"
;;
stop)
echo -n "Shutdown Oracle: "
su oracle -c $ORACLE_HOME/bin/dbshut
rm -f /var/lock/oracle
echo "OK"
;;
*)
echo "Usage: 'basename $0' start|stop"
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
启动数据库:
/etc/init.d/oradbstart start
新建库:
用oracle用户登录,在终端输入dbca命令,图形界面建数据库
通过sqlplus管理工具手工启动和关闭数据库,首先执行如下命令进入sqlplus并连接数据库。
$export ORACLE_SID= vbora10g //指定使用的数据库名称
$export NLS_LANG=anerican_america.zhs16gbk //指定sqlplus中使用的语言
$sqlplus /nolog
SQL> conn sys as sysdba //以sys用户登录数据库
Enter password: //输入sys用户的密码
Connected. //登录成功
如果要启动数据库,可在sqlplus中执行startup命令,
SQL> conn sys as sysdba
Enter password:
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 1224736768 bytes
Fixed Size 2020384 bytes
Variable Size 318770144 bytes
Database Buffers 889192448 bytes
Redo Buffers 14753792 bytes
Database mounted.
Database opened.
SQL>
如果要关闭数据库,执行如下命令:
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
数据库启动成功后,用户只能在本地服务器上对数据库访问,如果要通过网络访问数据库,还要启动网络监听程序。
[oracle@localhost ~]$ lsnrctl start
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-MAR-2012 00:17:44
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /data/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /data/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /data/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.20.220.247)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.20.220.247)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 12-MAR-2012 00:17:44
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /data/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /data/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.20.220.247)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "vbora10g" has 1 instance(s).
Instance "vbora10g", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
关闭网络监听程序:
[oracle@localhost ~]$ lsnrctl stop
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-MAR-2012 00:18:25
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.20.220.247)(PORT=1521)))
The command completed successfully