【SHELL】Linux下安装Oracle Client

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

[[email protected]]# mkdir  -p /tmp/instance_oracle                    #新建存储目录

[[email protected] 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
[[email protected] install_oracle]#

二、安装脚本说明

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

1. repo_1.sh

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

[[email protected]172 install_oracle]# more repo_1.sh
#!/bin/bash

#The script is used to replace repo file

#1.create mount directory                          #判断/yum目录是否存在,如果不存在,则新建
if [ -d "/yum" ];then
    echo "Warning: The /yum directory is exitst!"
else
    mkdir /yum
fi

#2.mount iso                                       #判断/yum目录下是否已挂载文件,如果未挂载,则进行挂载
mountnum=`ls -lrt /yum|wc -l`
if [ $mountnum -gt 1 ];then
    echo "Warning:The directory is mounted!"
else
    mount -o loop /tmp/install_oracle/rhel-server-6.5-x86_64-dvd.iso  /yum
fi

#3.modify repofile                                #判断/etc/yum.repos.d目录下是否有扩展名为.repo的文件,如果有则进行重命名。重命名格式:原名称.当前日期
CurrentDate=`date +%Y-%m-%d`
repofile=`find /etc/yum.repos.d  -name "*.repo"|wc -l`
if [ $repofile == 0 ];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!"
[[email protected]172 install_oracle]# more rhel.repo
[rhel-source]
name=Red Hat Enterprise Linux $releasever - $basearch - Source
baseurl=file:///yum
enabled=1
gpgcheck=0

2. install_oracle_2.sh

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

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

[[email protected]172 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 0 ];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 0 ];then
    /usr/sbin/groupadd oinstall
else
    echo "Warning:The oinstall group is exists!"
fi

if [ $group2 -eq 0 ];then
    /usr/sbin/groupadd dba
else
    echo "Warning:The dba  group is exists!"
fi

if [ $user1 -eq 0 ];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 775 /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 1 ];then
su - oracle<<EOF
echo "umask 022
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\\\$ORACLE_BASE/product/11.2.0/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 = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
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">>/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++-33.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.0/client_1/root.sh

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

[[email protected]172 install_oracle]# more client_install.rsp
###############################################################################
## Copyright(c) Oracle Corporation 1998,2008. 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.0/client_1
ORACLE_HOME=/u01/app/oracle/product/11.2.0/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.0 -- "Oracle SQLJ"
# oracle.rdbms.util:11.2.0.1.0 -- "Oracle Database Utilities"
# oracle.javavm.client:11.2.0.1.0 -- "Oracle Java Client"
# oracle.sqlplus:11.2.0.1.0 -- "SQL*Plus"
# oracle.dbjava.jdbc:11.2.0.1.0 -- "Oracle JDBC/THIN Interfaces"
# oracle.ldap.client:11.2.0.1.0 -- "Oracle Internet Directory Client"
# oracle.rdbms.oci:11.2.0.1.0 -- "Oracle Call Interface (OCI)"
# oracle.precomp:11.2.0.1.0 -- "Oracle Programmer"
# oracle.xdk:11.2.0.1.0 -- "Oracle XML Development Kit"
# oracle.network.aso:11.2.0.1.0 -- "Oracle Advanced Security"
# oracle.assistants.oemlt:11.2.0.1.0 -- "Enterprise Manager Minimal Integration"
# oracle.oraolap.mgmt:11.2.0.1.0 -- "OLAP Analytic Workspace Manager and Worksheet"
# oracle.network.client:11.2.0.1.0 -- "Oracle Net"
# oracle.network.cman:11.2.0.1.0 -- "Oracle Connection Manager"
# oracle.network.listener:11.2.0.1.0 -- "Oracle Net Listener"
# oracle.ordim.client:11.2.0.1.0 -- "Oracle Multimedia Client Option"
# oracle.ons:11.2.0.0.0 -- "Oracle Notification Service"
# oracle.odbc:11.2.0.1.0 -- "Oracle ODBC Driver"
# oracle.has.client:11.2.0.1.0 -- "Oracle Clusterware High Availability API"
# oracle.dbdev:11.2.0.1.0 -- "Oracle SQL Developer"
# oracle.rdbms.scheduler:11.2.0.1.0 -- "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.0","oracle.ldap.client:11.2.0.1.0","oracle.rdbms.oci:11.2.0.1.0","oracle.precomp:11.2.0.1.0","oracle.xdk:11.2.0.1.0","oracle.network.aso:11.2.0.1.0"
,"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.0","oracle.ons:11.2.0.0.0","oracle.odbc:11.2.0.1.0","oracle.has.client:11.2.0.1.0","oracle.dbdev:11.2.0.1.0","oracle.rdbms.sched
uler:11.2.0.1.0"
#-------------------------------------------------------------------------------
#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 = 2030
#------------------------------------------------------------------------------
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 = 1500
#------------------------------------------------------------------------------
oracle.install.client.schedulerAgentPortNumber=

三、验证是否安装完成

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

原文地址:https://www.cnblogs.com/xialiaoliao0911/p/8966447.html

时间: 2024-10-07 16:28:05

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

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

linux单独安装oracle client(oracle客户端) 更新:2013-10-17 18:30 | 标签:linux oracle 1.要远程使用oracle,先下载下面三个文件,注意版本最好一致. oracle-instantclient-basic-10.2.0.4-1.i386.ziporacle-instantclient-devel-10.2.0.4-1.i386.zip     //这个是sdk 的,文件名上没有说明,特此说明oracle-instantclient-sq

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

摘:linux下安装Oracle时交换空间不足的解决方法 linux上安装Oracle时交换空间不足的解决办法 增加交换空间有两种方法: 严格的说,在系统安装完后只有一种方法可以增加swap,那就是本文的第二种方法, 至于第一种方法应该是安装系统时设置交换区. 1.使用分区: 在安装OS时划分出专门的交换分区,空间大小要事先规划好,启动系统时自动进行mount. 这种方法只能在安装OS时设定,一旦设定好不容易改变,除非重装系统. 2.使用swapfile:(或者是整个空闲分区) 新建临时swap

linux下安装oracle需要的配置

1.检查系统包安装情况 rpm -qa|grep binutils rpm -ivh sysstat-7.0.2.rpm 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 gcc-4.1.2 gcc-c++-4.1.2 glibc-2.5-24 glibc-2.5-24 (32 bit

Linux下安装Oracle的过程和涉及的知识点-系列5

12.命令行启动 由于我是用VM进行安装的,所以首先需要修改默认启动为命令行的方式. 使用root登录,编辑/etc/inittab文件,将d:5:initdefault:改为d:3:initdefault: 知识点6:Linux的运行级别 # 0 - 停机(千万不能把initdefault 设置为0) # 1 - 单用户模式 # s init s = init 1 # 2 - 多用户,没有 NFS # 3 - 完全多用户模式(标准的运行级) # 4 - 没有用到 # 5 - X11 多用户图形

Ubuntu Linux下安装Oracle JDK

Ubuntu Linux下安装Oracle JDK Dennis Hu 2014-4-22 说明:因为非常多系统不支持使用OpenJDK,因此在ubuntu下会须要安装Oracle JDK.而Oracle JDK的安装貌似没有提供apt方式,因此安装Oracle JDK的方式相对麻烦一些,我常常安装,为了方便别人同一时候方便自己查看,把它记下来. 第一步:区分32位还是64位操作系统 先确定你的ubuntu linux是32位还是64位的,方法非常多,这里介绍一种就可以. $uname -a 第

Linux下安装oracle 11g数据库(一)

Linux下安装oracle 11g数据库(一) 1 内存的要求 最低配置: 1 GB of RAM 推荐配置: 2 GB of RAM or more 确定内存大小,输入下面的命令:grep MemTotal /proc/meminfo 确定系统版本,输入下面的命令:uname –m 确定交换空间的大小,输入下面的命令:grep SwapTotal /proc/meminfo 确定可用的内存和交换空间,输入下面的命令:free 2 磁盘空间要求 数据库软件 数据库软件需要的大小 企业版 4.7

Linux下安装Oracle 11g

1.环境 VMware 10 CentOS-6.3-x86_64 Oracle:linux.x64_11gR2 硬件上我分了2.5G的内存,30G硬盘(应该不需要这么大)2个U 2. 2.1 先把系统装上,root登陆之后需要改掉系统设置: setup命令关掉防火墙 vi /etc/selinux/config 把SELINUX的值改成disabled,然后wq存盘退出 2.2 查阅了我下载的11G的文档里面linux下Oracle需要的软件(E11882_01,貌似解压了有2.22G)列表如下

Linux下安装Oracle的过程和涉及的知识点-系列6

16.一路安装后,会提示以下界面,此时需要用root登录以下目录,然后执行这两个脚本. 至此,Oracle软件的安装就已经完成了,接下来就可以创建数据库了. 17.选择自定义数据库: 输入数据库名称和SID,一般两者相同: 不配置EM工具: 输入数据库文件所在路径(这里的名称可能有些歧义,路径下是所有数据库文件,不是仅指数据文件): 此处选择归档日志的路径和文件名:(从提示可以知道闪回区默认存放路径是{ORACLE_BASE}/flash_recovery_area,但如果定义了归档日志路径则会

Linux下安装Oracle 12c数据库

(1)Linux下安装Oracle 安装前注意:1.确保/etc/hosts中有系统主机名的记录 2.Linux系统安装图形化界面 3.OFA(最佳灵活体系结构):/字母数字/标准名字/用户名,如/u01/app/oracle 步骤:1.创建Oracle用户和/u01目录,并将/u01的所有者和所属组修改为此用户: 2.将软件复制到/u01,之后unzip解压,使用创建的用户运行runInstaller安装: (注:(1)如果报DISPLAY未定义执行:export DISPLAY=:0.0和x