一、新建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. 一、Spring-Data-Jpa 初体验(基于SpringBoot)

    闲话少说,首先动起来(基于springboot+gradle): 1.引入依赖 dependencies { compile 'org.springframework.boot:spring-boot ...

  2. Vue-watch选项

    Vue ----watch 选项 用于 监听数据变化: <!DOCTYPE html> <html lang="en"> <head> < ...

  3. axios使用配置

    axios 配置 下载cnpm install axios vue-axios --save-dev main.js文件中配置 import axios from 'axios' import Vue ...

  4. This is your path and you will pursue it with excellence.

    This is your path and you will pursue it with excellence.自己选的路就要走出精彩.

  5. iQuery stop()

    jQuery stop() 方法 jQuery stop() 方法用于停止动画或效果,在它们完成之前. stop() 方法适用于所有 jQuery 效果函数,包括滑动.淡入淡出和自定义动画. 语法 $ ...

  6. #include< >和#include“ ”的区别

    < >引用的是编译器的类库路径里面的头文件 " "引用的是你程序目录的相对路径中的头文件 假如你编译器定义的自带头文件引用在C:\Keil\c51\INC\下面 则#i ...

  7. LeetCode Number of 1 Bits 计算1的个数

    题意: 提供一个无符号32位整型uint32_t变量n,返回其二进制形式的1的个数. 思路: 考察二进制的特性,设有k个1,则复杂度为O(k).考虑将当前的数n和n-1做按位与,就会将n的最后一个1去 ...

  8. HDU 2191 悼念汶川地震(多重背包)

    思路: 多重背包转成01背包,怎么转?把一种大米看成一堆单个的物品,每件物品要么装入,要么不装.复杂度比01背包要大.时间复杂度为O(vns)(这里S是所有物品的数量s之和).这个做法太粗糙了,但就是 ...

  9. ubuntu 自动启动程序

    首先打开终端ctrl + alt + t sudo  -i 输入密码:ubuntu chmod 777 /etc/rc.local 打开  vi   /etc/rc.local 按  i  键进入输入 ...

  10. win10搜索不到蓝牙设备

    多半是驱动不兼容的问题. 解决方法: 此电脑右键,设备管理器,然后将蓝牙下的驱动,右键.卸载设备. 安装驱动精灵,会自动检测到缺少蓝牙驱动,安装即可.