您的位置:首页 > 数据库 > Oracle

oracle 第01章 安装

2015-09-29 10:47 429 查看
2015-09-29

[root@mdb ~]# vim /etc/hosts
10.10.2.87      mdb

#下载安装包 http://www.oracle.com/technetwork/database/enterprise-edition/downloads/ mkdir -p /usr/local/src/oracle
mv linux.x64_11gR2_client.zip /usr/local/src/oracle
mv linux.x64_11gR2_database_1of2.zip /usr/local/src/oracle
mv linux.x64_11gR2_database_2of2.zip /usr/local/src/oracle
#解压安装包
cd /usr/local/src/oracle
unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
#安装基础包
yum -y install  gcc gcc-c++ make binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static glibc glibc-common glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel numactl-devel sysstat unixODBC unixODBC-devel kernel-headers pdksh pcre-devel
#创建组、用户
groupadd oinstall && groupadd dba && useradd -g oinstall -G dba oracle
echo "oracle" | passwd --stdin oracle && id oracle
#修改内核参数
vim /etc/sysctl.conf
#添加以下内容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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
#使内核新配置生效
sysctl -p
#修改用户限制
vim /etc/security/limits.conf
#添加以下内容
oracle           soft    nproc           2047
oracle           hard    nproc           16384
oracle           soft    nofile          1024
oracle           hard    nofile          65536
oracle           soft    stack           10240
#修改/etc/pam.d/login文件
vim /etc/pam.d/login
#添加以下内容
session  required   /lib64/security/pam_limits.so
session  required   pam_limits.so
#修改/etc/profile文件
vim /etc/profile
#添加以下内容
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
#创建目录
mkdir -p /u01/app/oracle/product/11.2.0
mkdir /u01/app/oracle/{oradata,inventory,fast_recovery_area}
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
#设置oracle用户环境变量
su - oracle
vim .bash_profile
#添加以下内容
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
#编辑静默安装响应文件
cp -R /usr/local/src/oracle/database/response/ .
cd response/
vim db_install.rsp
#设置以下内容
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=mdb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
#根据响应文件静默安装Oracle 11g
cd /usr/local/src/oracle/database/
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
#打开终端,以root身份登录,执行脚本:
ctrl +d
sh /u01/app/oracle/inventory/orainstRoot.sh
sh /u01/app/oracle/product/11.2.0/root.sh
#以静默方式配置监听
su - oracle
netca /silent /responsefile /home/oracle/response/netca.rsp
netstat -tnulp | grep 1521
#以静默方式建立新库,和实例
vim /home/oracle/response/dbca.rsp
#设置以下参数
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/u01/app/oracle/oradata
RECOVERYAREADESTINATION=/u01/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
#启用配置
dbca -silent -responseFile /home/oracle/response/dbca.rsp
#检查实例进程
ps -ef | grep ora_ | grep -v grep
#查看监听状态
lsnrctl status
#登录查看实例状态
sqlplus / as sysdba
SQL> select status from v$instance;
#开机自启动设置,可以用dbstart、dbshut启动、关闭oracle服务
vim /u01/app/oracle/product/11.2.0/bin/dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /u01/app/oracle/product/11.2.0/bin/dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME
vim /etc/oratab
orcl:/u01/app/oracle/product/11.2.0:Y
#切换到root,建立启动脚本,可以用service命令启动、关闭、重启oracle服务
ctrl+d
vim /etc/rc.d/init.d/oracle
#-----------------------------------------------------------------------------------
#!/bin/bash

# oracle: Start/Stop Oracle Database 11g R2
# chkconfig: 345 90 10
# description: The Oracle Database is an Object-Relational Database Management System.
#
. /etc/rc.d/init.d/functions
LOCKFILE=/var/lock/subsys/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0
ORACLE_USER=oracle
case "$1" in
'start')
if [  -f $LOCKFILE ]; then
echo $0 already running.
exit 1
fi
echo -n $"Starting Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
touch $LOCKFILE
;;
'stop')
if [ ! -f $LOCKFILE ]; then
echo $0 already stopping.
exit 1
fi
echo -n $"Stopping Oracle Database:"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
rm -f $LOCKFILE
;;
'restart')
$0 stop
$0 start
;;
'status')
if [ -f $LOCKFILE ]; then
echo $0 started.
else
echo $0 stopped.
fi
;;
*)
echo "Usage: $0 [start|stop|status]"
exit 1
esac
exit 0
#-------------------------------------------------------------------
#修改/etc/init.d/oracle服务文件权限
chmod 755 /etc/init.d/oracle
#设置启动级别
chkconfig oracle on
#进行service oracle start/stop/restart测试
service oracle start/stop/restart


参考资料

[1] 林树泽.Oracle 11g R2 DBA操作指南[M].北京:清华大学出版社,2013

[2] 自己动手 CentOS-6.5 安装Oracle11g R2

[3] Oracle11gR2 for Linux 静默安装

[4] RHEL6(CentOS6)安装 Oracle 11g R2 手记(完整详细可用版)

[5] Linux系统(X64)安装Oracle11g完整安装图文教程另附基本操作


[6] Oracle 11g R2+RAC+ASM+OracleLinux6.4安装详解(图)

[7] CentOS 6.4上安装 Oracle 11g R2图文教程

[8] Oracle RAC -安装图解

[9] CentOs 6.3_64静默安装oracle11g_r2

[10] Oracle 11g R2静默安装

[11] oracle 11g R2静默安装

[12] CentOS-6.4-x64上静默安装Oracle 11g R2 (11.2.0.3)

[13] Oracle Database 11g R2 RAC 静默安装文档

[14] Oracle Database 11g Release 2 (11.2.0.1.0)

[15] SQL Developer 4.1.2

[16] Oracle Linux 6 Repositories
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: