[新手教程]命令行模式部署ORACLE客户端-详细篇

ronpris
ronpris
ronpris
253
文章
1
评论
2020年3月25日14:29:40 评论 148 8084字阅读26分56秒

由于工作环境限制,无法登录图形化界面进行安装部署ORACLE客户端情况,在网络上进行资料收集,并亲自测试,总结了一下命令行模式安装部署ORACLE环境的操作命令

准备工作

(1)oracle客户端安装包,可以到官网去下载;

(2)oracle客户端安装依赖包,如yum已经部署可进行yum安装;

yum install -y elfutils libaio1 libaio-dev libstdc++6-4.4-dev numactl pdksh sysstat unixODBC-dev unixODBC build-essential libaio1 gawk ksh libmotif3 alien libtool

(一)创建用户及组

groupadd -g 500 oinstall
groupadd -g 501 dba
groupadd -g 502 oper
useradd -u 601 -g oinstall -G dba,oper -d /home/oracle -s /bin/bash oracle

(二)创建文件目录及权限

mkdir -p /u01/app/oracle
mkdir -p /u01/app/oraInventory
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/product/12.0.1.2/db_1
chown -R oracle:oinstall /u01
chmod -R 775 /u01

(三)修改对应访问oracle用户的环境变量

su - oracle
vi ~/.bash_profile
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/12.0.1.2/db_1
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export EDITOR=vi
export LANG=en_US
export NLS_LANG=american_america.AL32UTF8
export NLS_DATE_FORMAT='yyyy/mm/dd hh24:mi:ss'
umask 022
source ~/.bash_profile

(四)上传客户端及修改对应客户端目录所属

这个要根据需要去官网下载符合oracle服务端版本的oracle

unzip linuxamd64_12102_client.zip
chown -R oracle:oinstall /opt/client

(五)编辑配置文件

文件目录为:/opt/client/response/client_install.rsp

需要修改的地方用颜色注释

###############################################################################

## Copyright(c) Oracle Corporation 1998,2014. 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_v12.1.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=orcl

#-------------------------------------------------------------------------------

# Unix group to be set for the inventory directory.

#-------------------------------------------------------------------------------

UNIX_GROUP_NAME=oinstall

#-------------------------------------------------------------------------------

# Inventory location.

#-------------------------------------------------------------------------------

INVENTORY_LOCATION=/u01/app/oraInventory

#-------------------------------------------------------------------------------

# Specify the 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

#

# all_langs : All languages

#

# Specify value as the following to select any of the languages.

# Example : SELECTED_LANGUAGES=en,fr,ja

#

# Specify value as the following to select all the languages.

# Example : SELECTED_LANGUAGES=all_langs

#-------------------------------------------------------------------------------

SELECTED_LANGUAGES=en,zh_CN

#-------------------------------------------------------------------------------

# Complete path of the Oracle Home

#-------------------------------------------------------------------------------

ORACLE_HOME=/u01/app/oracle/product/12.0.1.2/db_1

#-------------------------------------------------------------------------------

# Complete path of the Oracle Base.

#-------------------------------------------------------------------------------

ORACLE_BASE=/u01/app/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

# - Administrator

# - Runtime

# - Custom

#

#Example : INSTALL_TYPE = Administrator

#------------------------------------------------------------------------------

oracle.install.client.installType=Administrator

#-------------------------------------------------------------------------------

# 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:12.1.0.2.0 -- "Oracle SQLJ"

# oracle.rdbms.util:12.1.0.2.0 -- "Oracle Database Utilities"

# oracle.javavm.client:12.1.0.2.0 -- "Oracle Java Client"

# oracle.sqlplus:12.1.0.2.0 -- "SQL*Plus"

# oracle.dbjava.jdbc:12.1.0.2.0 -- "Oracle JDBC/THIN Interfaces"

# oracle.ldap.client:12.1.0.2.0 -- "Oracle Internet Directory Client"

# oracle.rdbms.oci:12.1.0.2.0 -- "Oracle Call Interface (OCI)"

# oracle.precomp:12.1.0.2.0 -- "Oracle Programmer"

# oracle.xdk:12.1.0.2.0 -- "Oracle XML Development Kit"

# oracle.network.aso:12.1.0.2.0 -- "Oracle Advanced Security"

# oracle.oraolap.mgmt:12.1.0.2.0 -- "OLAP Analytic Workspace Manager and Worksheet"

# oracle.network.client:12.1.0.2.0 -- "Oracle Net"

# oracle.network.cman:12.1.0.2.0 -- "Oracle Connection Manager"

# oracle.network.listener:12.1.0.2.0 -- "Oracle Net Listener"

# oracle.ordim.client:12.1.0.2.0 -- "Oracle Multimedia Client Option"

# oracle.odbc:12.1.0.2.0 -- "Oracle ODBC Driver"

# oracle.has.client:12.1.0.2.0 -- "Oracle Clusterware High Availability API"

# oracle.dbdev:12.1.0.2.0 -- "Oracle SQL Developer"

# oracle.rdbms.scheduler:12.1.0.2.0 -- "Oracle Scheduler Agent"

#

# Example : oracle.install.client.customComponents="oracle.precomp:12.1.0.2.0","oracle.oraolap.mgmt:12.1.0.2.0","oracle.rdbms.scheduler:12.1.0.2.0"

#-------------------------------------------------------------------------------

oracle.install.client.customComponents="oracle.precomp:12.1.0.2.0","oracle.oraolap.mgmt:12.1.0.2.0","oracle.rdbms.scheduler:12.1.0.2.0"

#-------------------------------------------------------------------------------

# 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=1500

(六)进行客户端安装部署

使用oracle用户

cd /opt/client
./runInstaller -silent -responseFile /opt/client/response/client_install.rsp

最后需要以root运行个脚本
以 root 用户的身份执行以下脚本:

sh /u01/app/oraInventory/orainstRoot.sh

(七)创建并添加tns

安装完成后需要添加tnsnames.ora配置需要连接的数据库
配置tns的目录:

/u01/app/oracle/product/12.0.1.2/db_1/network/admin

在ORACLE_HOME/network/admin目录下新建tnsnames.ora文件

并添加需要连接的数据库的信息

例:

# /u01/app/oracle/product/12.0.1.2/db_1/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

orcl =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))

)

(CONNECT_DATA =

(SERVICE_NAME = orcl )

)

)
继续阅读
[基础教程]Mysql单表查询优先级实例讲解 原创推荐

[基础教程]Mysql单表查询优先级实例讲解

这篇文章主要介绍了MySQL单表查询操作,结合实例形式详细分析了mysql单表查询的语法、约束、分组、聚合、过滤、排序等相关原理、操作技巧与注意事项,需要的朋友可以参考下 本文实例讲述了MySQL单表...
[基础教程]Linux系统常用文件管理命令 原创推荐

[基础教程]Linux系统常用文件管理命令

这篇文章主要介绍了linux文件管理命令,结合实例形式分析Linux文件管理的显示、查看、统计等相关操作命令使用技巧,需要的朋友可以参考下 本文实例讲述了linux文件管理命令。分享给大家供大家参考,...