一、新建Oracle脚本存储目录并上传文件

[root@A04-Test-172]# mkdir  -p /tmp/instance_oracle                    #新建存储目录

[root@A04-Test-172 install_oracle]# ll
total 4452872
-rw-r--r-- 1 root root 8752 Apr 26 08:24 client_install.rsp
-rwxr-xr-x 1 root root 3880 Apr 26 09:16 install_oracle_2.sh
-rw-r--r-- 1 root root 706187979 Apr 25 14:54 linux.x64_11gR2_client.zip
-rwxr-xr-x 1 root root 803 Apr 25 14:52 repo_1.sh
-rw-r--r-- 1 root root 118 Apr 23 13:51 rhel.repo
-rw-r--r-- 1 root root 3853516800 Apr 25 14:29 rhel-server-6.5-x86_64-dvd.iso
[root@A04-Test-172 install_oracle]#

二、安装脚本说明

执行脚本时需依照脚本后的尾号顺序进行执行!

1. repo_1.sh

说明:该脚本用来挂载ISO镜像,为Oracle安装依赖包做准备!

[root@A04-Test- install_oracle]# more repo_1.sh
#!/bin/bash #The script is used to replace repo file #.create mount directory #判断/yum目录是否存在,如果不存在,则新建
if [ -d "/yum" ];then
echo "Warning: The /yum directory is exitst!"
else
mkdir /yum
fi #.mount iso #判断/yum目录下是否已挂载文件,如果未挂载,则进行挂载
mountnum=`ls -lrt /yum|wc -l`
if [ $mountnum -gt ];then
echo "Warning:The directory is mounted!"
else
mount -o loop /tmp/install_oracle/rhel-server-6.5-x86_64-dvd.iso /yum
fi #.modify repofile #判断/etc/yum.repos.d目录下是否有扩展名为.repo的文件,如果有则进行重命名。重命名格式:原名称.当前日期
CurrentDate=`date +%Y-%m-%d`
repofile=`find /etc/yum.repos.d -name "*.repo"|wc -l`
if [ $repofile == ];then
echo "Warning: The repo file is no exsits! Now starting copy repo file to destination directory!"
else
for i in `find /etc/yum.repos.d -name "*.repo"`
do
mv $i $i.$CurrentDate
done
fi
cp /tmp/install_oracle/rhel.repo /etc/yum.repos.d #复制/tmp/instance_oracle目录下的文件到/etc/yum.repos.d目录
echo "The directory mount over!"
[root@A04-Test- install_oracle]# more rhel.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///yum
enabled=
gpgcheck=

2. install_oracle_2.sh

说明:该脚本主要完成Oracle Client的安装工作,主要包括新建oracle用户、新建Oracle安装目录,修改环境变量,安装Oracle Client.

Oracle安装时的一些选项通过文件client_install.rsp来配置,该文件默认在Oracle解压后的response目录下。

[root@A04-Test- install_oracle]# more install_oracle_2.sh
#!/bin/bash echo "#####################1.add ip and hostname to /etc/hosts###########"
ip=`ifconfig|grep "inet addr"|grep "Bcast"|awk -F: '{print$2 }'|awk '{print$1}'`
hostname1=`hostname`
checkhosts=`cat /etc/hosts|grep $ip|wc -l`
if [ $checkhosts -eq ];then
echo "$ip $hostname1">>/etc/hosts
else
echo "Warning: the hostname added to the /etc/hosts!"
fi echo "#####################2.create user and group######################" group1=`cat /etc/group|grep oinstall|wc -l`
group2=`cat /etc/group|grep dba|wc -l`
user1=`cat /etc/passwd|grep oracle|wc -l` if [ $group1 -eq ];then
/usr/sbin/groupadd oinstall
else
echo "Warning:The oinstall group is exists!"
fi if [ $group2 -eq ];then
/usr/sbin/groupadd dba
else
echo "Warning:The dba group is exists!"
fi if [ $user1 -eq ];then
/usr/sbin/useradd -m -g oinstall -G dba oracle
echo "a4oracle"|passwd --stdin oracle
else
echo "Warning:The user oracle is exists!"
fi echo "The user and group created finish!" echo "######################4.create directory##############################" if [ ! -d "/u01/app/oracle" ];then
mkdir -p /u01/app/oracle
chown -R oracle:oinstall /u01/app/oracle
chmod -R /u01/app/oracle
else
echo "Warning: /u01/app/oracle is exists!"
fi if [ ! -d "/u01/app/oraInventory" ];then
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oraInventory
else
echo "Warning: /u01/app/oraInventory is exists!"
fi cp /etc/skel/.bashrc /home/oracle
cp /etc/skel/.bash_logout /home/oracle
cp /etc/skel/.bash_profile /home/oracle echo "The Oracle install directory created finish" echo "#####################5.add env variable on oracle user###############" user1=`cat /etc/passwd|grep oracle|wc -l`
if [ $user1 -eq ];then
su - oracle<<EOF
echo "umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\\\$ORACLE_BASE/product/11.2./client_1
export PATH=\\\$ORACLE_HOME/bin:\\\$PATH" >> ~/.bash_profile; source ~/.bash_profile;
EOF else
echo "The oracle user is non exists!"
exit;
fi echo "######################6.add content in /etc/sysctl.conf###############"
echo "fs.aio-max-nr = 1048576
fs.file-max =
kernel.shmall =
kernel.shmmax =
kernel.shmmni =
kernel.sem =
net.ipv4.ip_local_port_range =
net.core.rmem_default =
net.core.rmem_max =
net.core.wmem_default =
net.core.wmem_max = ">>/etc/sysctl.conf /sbin/sysctl -p echo "The /etc/sysctl.conf modified finish!" echo "####################7.install depend on package#######################"
yum -y install libaio.i686 libaio-devel.i686
yum -y install libstdc++.i686 libstdc++-devel.i686 compat-libstdc++-.i686 elfutils-libs.i686 glibc.i686 unixODBC.i686 unixODBC-devel.i686
yum -y install gcc gcc-c++ libaio libaio-devel libstdc++ libstdc++-devel elfutils-libelf-devel unixODBC unixODBC-devel compat-libstdc++ echo "The oracle depend package installed finish!" echo "####################8.install oracle client###########################"
su - oracle<<EOF
mkdir -p /home/oracle/client;
cp /tmp/install_oracle/linux.x64_11gR2_client.zip /home/oracle/client;
unzip /home/oracle/client/linux.x64_11gR2_client.zip;
mv /home/oracle/client/linux.x64_11gR2_client.zip /home/oracle;
mv /home/oracle/client/response/client_install.rsp /home/oracle/client/response/client_install.rsp.bak;
cp /tmp/install_oracle/client_install.rsp /home/oracle/client/response;
chown -R oracle:oinstall /home/oracle/client; cd /home/oracle/client;
./runInstaller -silent -responseFile /home/oracle/client/response/client_install.rsp
EOF echo "#####################9.execute root script#############################"
sleep 180s #Oracle安装时需要一定时间,在安装完成时,需要执行如下两个脚本,这里给一个休眠时间,避免Oracle未安装完成就执行脚本,也可以手动执行脚本
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2./client_1/root.sh

client_install.rsp内容如下,主要修改标记红色部分,当然也可根据自己实际要求进行配置:

[root@A04-Test- install_oracle]# more client_install.rsp
###############################################################################
## Copyright(c) Oracle Corporation ,. All rights reserved. ##
## ##
## Specify values for the variables listed below to customize ##
## your installation. ##
## ##
## Each variable is associated with a comment. The comment ##
## can help to populate the variables with the appropriate ##
## values. ##
## ##
############################################################################### #-------------------------------------------------------------------------------
# Do not change the following system generated value.
#-------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_clientinstall_response_schema_v11_2_0 #-------------------------------------------------------------------------------
# This variable holds the hostname of the system as set by the user.
# It can be used to force the installation to use an alternative
# hostname rather than using the first hostname found on the system
# (e.g., for systems with multiple hostnames and network interfaces).
ORACLE_HOSTNAME=Oracle_Client #Oracle主机名,这里可通过hostname查询到
#-------------------------------------------------------------------------------
# Unix group to be set for the inventory directory.
UNIX_GROUP_NAME=oinstall #Oracle安装时所属组
#-------------------------------------------------------------------------------
# Inventory location.
INVENTORY_LOCATION=/u01/app/oraInventory #Oracle清单安装目录
#-------------------------------------------------------------------------------
# Languages in which the components will be installed.
#
# en : English ja : Japanese
# fr : French ko : Korean
# ar : Arabic es : Latin American Spanish
# bn : Bengali lv : Latvian
# pt_BR: Brazilian Portuguese lt : Lithuanian
# bg : Bulgarian ms : Malay
# fr_CA: Canadian French es_MX: Mexican Spanish
# ca : Catalan no : Norwegian
# hr : Croatian pl : Polish
# cs : Czech pt : Portuguese
# da : Danish ro : Romanian
# nl : Dutch ru : Russian
# ar_EG: Egyptian zh_CN: Simplified Chinese
# en_GB: English (Great Britain) sk : Slovak
# et : Estonian sl : Slovenian
# fi : Finnish es_ES: Spanish
# de : German sv : Swedish
# el : Greek th : Thai
# iw : Hebrew zh_TW: Traditional Chinese
# hu : Hungarian tr : Turkish
# is : Icelandic uk : Ukrainian
# in : Indonesian vi : Vietnamese
# it : Italian
#
# Example : SELECTED_LANGUAGES=en,fr,ja
#-------------------------------------------------------------------------------
SELECTED_LANGUAGES=en #默认的语言,这里选择英文
#-------------------------------------------------------------------------------
# Complete path of the Oracle Home
#ORACLE_HOME=$ORACLE_BASE/product/11.2./client_1
ORACLE_HOME=/u01/app/oracle/product/11.2./client_1
#-------------------------------------------------------------------------------
# Complete path of the Oracle Base.
ORACLE_BASE=/u01/app/oracle #Oracle安装基目录
#-------------------------------------------------------------------------------
#Name : INSTALL_TYPE
#Datatype : String
#Description: Installation type of the component.
#
# The following choices are available. The value should contain
# only one of these choices.
# InstantClient : InstantClient
# Administrator : Administrator
# Runtime : Runtime
# Custom : Custom
#
#Example : INSTALL_TYPE = "Administrator"
#------------------------------------------------------------------------------
oracle.install.client.installType=Administrator #oracle安装时使用的用户类型
#-------------------------------------------------------------------------------
# Name : oracle.install.client.customComponents
# Datatype : StringList
#
# This property is considered only if INSTALL_TYPE is set to "Custom"
#
# Description: List of Client Components you would like to install
#
# The following choices are available. You may specify any
# combination of these choices. The components you choose should
# be specified in the form "internal-component-name:version"
# Below is a list of components you may specify to install.
#
# oracle.sqlj:11.2.0.1. -- "Oracle SQLJ"
# oracle.rdbms.util:11.2.0.1. -- "Oracle Database Utilities"
# oracle.javavm.client:11.2.0.1. -- "Oracle Java Client"
# oracle.sqlplus:11.2.0.1. -- "SQL*Plus"
# oracle.dbjava.jdbc:11.2.0.1. -- "Oracle JDBC/THIN Interfaces"
# oracle.ldap.client:11.2.0.1. -- "Oracle Internet Directory Client"
# oracle.rdbms.oci:11.2.0.1. -- "Oracle Call Interface (OCI)"
# oracle.precomp:11.2.0.1. -- "Oracle Programmer"
# oracle.xdk:11.2.0.1. -- "Oracle XML Development Kit"
# oracle.network.aso:11.2.0.1. -- "Oracle Advanced Security"
# oracle.assistants.oemlt:11.2.0.1. -- "Enterprise Manager Minimal Integration"
# oracle.oraolap.mgmt:11.2.0.1. -- "OLAP Analytic Workspace Manager and Worksheet"
# oracle.network.client:11.2.0.1. -- "Oracle Net"
# oracle.network.cman:11.2.0.1. -- "Oracle Connection Manager"
# oracle.network.listener:11.2.0.1. -- "Oracle Net Listener"
# oracle.ordim.client:11.2.0.1. -- "Oracle Multimedia Client Option"
# oracle.ons:11.2.0.0. -- "Oracle Notification Service"
# oracle.odbc:11.2.0.1. -- "Oracle ODBC Driver"
# oracle.has.client:11.2.0.1. -- "Oracle Clusterware High Availability API"
# oracle.dbdev:11.2.0.1. -- "Oracle SQL Developer"
# oracle.rdbms.scheduler:11.2.0.1. -- "Oracle Scheduler Agent"
#
#-------------------------------------------------------------------------------
oracle.install.client.customComponents="oracle.sqlj:11.2.0.1.0","oracle.rdbms.util:11.2.0.1.0","oracle.javavm.client:11.2.0.1.0","oracle.sqlplus:11.2.0.1.0","oracle.db
java.jdbc:11.2.0.1.","oracle.ldap.client:11.2.0.1.","oracle.rdbms.oci:11.2.0.1.","oracle.precomp:11.2.0.1.","oracle.xdk:11.2.0.1.","oracle.network.aso:11.2.0.1."
,"oracle.assistants.oemlt:11.2.0.1.0","oracle.oraolap.mgmt:11.2.0.1.0","oracle.network.client:11.2.0.1.0","oracle.network.cman:11.2.0.1.0","oracle.network.listener:11.
2.0.1.0","oracle.ordim.client:11.2.0.1.","oracle.ons:11.2.0.0.","oracle.odbc:11.2.0.1.","oracle.has.client:11.2.0.1.","oracle.dbdev:11.2.0.1.","oracle.rdbms.sched
uler:11.2.0.1."
#-------------------------------------------------------------------------------
#Name : MTS_PORT
#Datatype : int
#Description: Port number to be used for by the Oracle MTS Recovery Service to listen
# for requests. This needs to be entered in case oracle.ntoramts is
# selected in the list of custom components in custom install
#
#
#Example : MTS_PORT =
#------------------------------------------------------------------------------
oracle.install.client.oramtsPortNumber= #------------------------------------------------------------------------------
# Host name to be used for by the Oracle Scheduler Agent.
# This needs to be entered in case oracle.rdbms.scheduler is selected in the
# list of custom components during custom install
#
# Example : oracle.install.client.schedulerAgentHostName = acme.domain.com
#------------------------------------------------------------------------------
oracle.install.client.schedulerAgentHostName= #------------------------------------------------------------------------------
# Port number to be used for by the Oracle Scheduler Agent.
# This needs to be entered in case oracle.rdbms.scheduler is selected in the
# list of custom components during custom install
#
# Example: oracle.install.client.schedulerAgentPortNumber =
#------------------------------------------------------------------------------
oracle.install.client.schedulerAgentPortNumber=

三、验证是否安装完成

Oracle安装成功后,可以切换至Oracle用户时,使用sqlplus登录数据库,看是否可以登录上。如果可以,说明安装成功。

【SHELL】Linux下安装Oracle Client的更多相关文章

  1. 百度文库,linux下安装oracle客户端

    linux单独安装oracle client(oracle客户端) 更新:2013-10-17 18:30 | 标签:linux oracle   1.要远程使用oracle,先下载下面三个文件,注意 ...

  2. 解决在Linux下安装Oracle时的中文乱码问题

    本帖最后由 TsengYia 于 2012-2-22 17:06 编辑 解决在Linux下安装Oracle时的中文乱码问题 操作系统:Red Hat Enterprise Linux 6.1数据库:O ...

  3. linux下安装Oracle时交换空间不足的解决方法

    摘:linux下安装Oracle时交换空间不足的解决方法 linux上安装Oracle时交换空间不足的解决办法 增加交换空间有两种方法: 严格的说,在系统安装完后只有一种方法可以增加swap,那就是本 ...

  4. Ubuntu Linux下安装Oracle JDK

    from://http://blog.csdn.net/gobitan/article/details/24322561 Ubuntu Linux下安装Oracle JDK Dennis Hu 201 ...

  5. Redhat Linux 下安装Oracle 11g R2

    能够下载:http://download.csdn.net/detail/ykh554541184/8086647文档方便查阅 官方文档:http://docs.oracle.com/cd/E1188 ...

  6. Linux 下安装oracle数据库

    原文出处       http://www.linuxidc.com/Linux/2015-02/113222.html 需要安装Oracle DataGuard,所以先要安装单台Oracle11g, ...

  7. linux下安装oracle及weblogic

    安装weblogic 下载weblogic http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-for-dev-17 ...

  8. Linux下安装Oracle后重启无法登录数据库ORA-01034:ORACLE not available

    Linux下安装了数据库,安装完成后可以用,今天启动就不能用了,提示Oracle not available,后来查找资料,据说是oracle服务没有打开.如下方式可以解决问题. [root@root ...

  9. linux下安装oracle

    一>1.关闭防火墙,禁用selinux vi /etc/selinux/config  修改SELINUX=disabled,然后重启,如果不想重启使用命令setenforce 0 2.安装依赖 ...

随机推荐

  1. JeeSite 工作流Activiti的应用实例

    新建流程模型 在线办公-流程管理-模型管理-新建模型  点击“提交”后会立即跳转到“流程在线设计器”页面,请看下一章节 在线流程设计器 在线办公流程管理模型管理模型管理编辑 整体流程图 mat ...

  2. 腾讯云服务器手动和自动安装WordPress网站程序

    如果我们需要建站的话,对于基础个人网站.博客建站选择基础的1Mbps带宽配置的1GB内存的腾讯云服务器还是够用的,且如果我们需要用来建网站的话可以手工添加程序,以及有些面板,比如宝塔面板是自带CMS程 ...

  3. HDU 2602 Bone Collector骨头收藏者(01背包)

    题意:收藏骨头. 思路: 常规的01背包. #include <iostream> #define N 1005 using namespace std; int volume[N]; / ...

  4. iphone开发笔记

    1.uiimage图片拉伸 - (void)stretchBackgroundImage { //UIImage *originalImage = [[self backgroundImageForS ...

  5. linux 命令——5 rm(转)

    昨天学习了创建文件和目录的命令mkdir ,今天学习一下linux中删除文件和目录的命令: rm命令.rm是常用的命令,该命令的功能为删除一个目录中的一个或多个文件或目录,它也可以将某个目录及其下的所 ...

  6. Android(java)学习笔记93:为什么局部内部类只能访问外部类中的 final型的常量

    为什么匿名内部类参数必须为final类型: 1)  从程序设计语言的理论上:局部内部类(即:定义在方法中的内部类),由于本身就是在方法内部(可出现在形式参数定义处或者方法体处),因而访问方法中的局部变 ...

  7. GC Root总结

    为什么80%的码农都做不了架构师?>>> JVM根据GC Roots算法判定一个对象需要被回收,GC Roots一般在JVM的栈区域里产生. GC Roots原理 GC Roots基 ...

  8. JS中的async/await的执行顺序详解

    虽然大家知道async/await,但是很多人对这个方法中内部怎么执行的还不是很了解,本文是我看了一遍技术博客理解 JavaScript 的 async/await(如果对async/await不熟悉 ...

  9. detection in video and image

    video中的detection,背景更加复杂,目标更加不聚焦,同时由于图片分辨率低于图像,因此更加难做. image中的Detection,背景相对简单些,目标更加聚焦,同时图片分辨率高,因此更加容 ...

  10. 微信小程序的开发——01小程序的执行流程是怎样的?

    作者:叶小钗 转载至:https://www.cnblogs.com/yexiaochai/p/9346043.html 我们这边最近一直在做基础服务,这一切都是为了完善技术体系,这里对于前端来说便是 ...