基于Linux系统静默安装Oracle数据库
a. 安装环境准备
步骤1:环境准备
- 安装依赖
如果服务器能连接网络,直接安装所需的依赖库:
yum install libnsl libnsl2-devel libaio-devel libcap-devel xorg-x11-utils xauth gcc make libstdc++-devel sysstat smartmontools glibc-compat-2.17 unzip vim net-tools
如果服务器无法连接网络,可以先在一个有网络连接的服务器上下载依赖包:
yum -y install yum-utils
yumdownloader --destdir=/root/rpm --resolve libnsl libnsl2-devel libaio-devel libcap-devel xorg-x11-utils xauth gcc make libstdc++-devel sysstat smartmontools glibc-compat-2.17 unzip vim net-tools
步骤2:查看libaio版本
检查当前libaio的版本号:
rpm -qa libaio
如果版本号大于0.3.109,需要下载指定版本并替换当前版本:
wget http://mirrors.ustc.edu.cn/centos/7.9.2009/os/x86_64/Packages/libaio-0.3.109-13.el7.x86_64.rpm
mv /usr/lib64/libaio.so.1 /usr/lib64/libaio.so.1-bak # 备份原有的libaio.so.1
rpm2cpio libaio-0.3.109-13.el7.x86_64.rpm | cpio -idmv # 解压rpm包
cp -r /lib64/libaio.so.1 /usr/lib64 # 将解压后的文件拷贝到/usr/lib64下
cp -r /lib64/libaio.so.1.0.1 /usr/lib64
rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm --force --nodeps # 强制安装新版本
- 修改host文件,绑定主机名
编辑/etc/hosts文件,添加主机名绑定:
vim /etc/hosts
添加:
192.168.159.100 db // 添加IP地址和主机名
设置主机名:
hostnamectl set-hostname db
查看主机名:
hostname
步骤3:关闭SELinux
修改SELinux模式为disabled:
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
重启服务器并确认SELinux是否已关闭:
setenforce 0
b. 安装配置
步骤1:创建组和用户
创建oinstall组、dba子组和oracle用户:
groupadd oinstall # 创建oinstall组
groupadd dba # 创建dba组
useradd -g oinstall -G dba oracle # 创建oracle用户并将其加入到两个组中
passwd oracle # 设置oracle用户的密码
步骤2:修改内核参数
编辑/etc/sysctl.conf文件,添加必要的内核参数:
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
使参数生效:
/sbin/sysctl -p
步骤3:配置Oracle用户参数
编辑/etc/security/limits.conf文件,添加Oracle用户的软限制和硬限制:
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
步骤4:修改/etc/pam.d/login文件
编辑/etc/pam.d/login
文件,确保Oracle用户能够使用密码认证:
vim /etc/pam.d/login
添加:
session required /lib64/security/pam_limits.so
session required pam_limits.so
步骤5:修改/etc/profile文件
编辑/etc/profile
文件,设置Oracle用户的环境变量:
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
重新加载配置:
source /etc/profile
步骤6:创建数据库相关目录
创建安装Oracle所需的目录结构:
mkdir -p /apps/oracle/app/
mkdir -p /apps/oracle/etc/
chown -R oracle:oinstall /apps/oracle
chmod 775 /apps/oracle
步骤7: 上传并解压安装包
上传Oracle安装包到/apps/oracle/app/
目录下,并解压,将生成一个database
目录:
cd /apps/oracle/app/
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
c. 部署
步骤1:修改db_install.rsp
创建或修改响应文件以适应静默安装:
cd /apps/oracle/etc/
vim db_install.rsp
示例内容:
####################################################################
## Copyright(c) Oracle Corporation1998,2008. All rights reserved. ##
## Specify values for the variables listedbelow to customize your installation. ##
## Each variable is associated with acomment. The comment ##
## can help to populate the variables withthe appropriate values. ##
## IMPORTANT NOTE: This file contains plaintext passwords and ##
## should be secured to have readpermission only by oracle user ##
## or db administrator who owns thisinstallation. ##
##对整个文件的说明,该文件包含参数说明,静默文件中密码信息的保密 ##
####################################################################
#------------------------------------------------------------------------------
# Do not change the following system generatedvalue. 标注响应文件版本,这个版本必须和要#安装的数据库版本相同,安装检验无法通过,不能更改
#------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# 1. INSTALL_DB_SWONLY
# 2. INSTALL_DB_AND_CONFIG
# 3. UPGRADE_DB
#选择安装类型:1.只装数据库软件 2.安装数据库软件并建库 3.升级数据库
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_AND_CONFIG
#-------------------------------------------------------------------------------
# Specify the hostname of the system as setduring the install. It can be used
# to force the installation to use analternative hostname rather than using the
# first hostname found on the system.(e.g., for systems with multiple hostnames
# and network interfaces)指定操作系统主机名,通过hostname命令获得
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=vm-ctos-tes-his-web01
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for theinventory directory.
#指定oracle inventory目录的所有者,通常会是oinstall或者dba
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall
#-------------------------------------------------------------------------------
# Specify the location which holds theinventory files.
#指定产品清单oracle inventory目录的路径,如果是Win平台下可以省略
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/apps/oracle/app/oraInventory
#-------------------------------------------------------------------------------
# Specify the languages in which thecomponents 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
#指定数据库语言,可以选择多个,用逗号隔开。选择en, zh_CN(英文和简体中文)
#------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN
#------------------------------------------------------------------------------
# Specify the complete path of the OracleHome.设置ORALCE_HOME的路径
#------------------------------------------------------------------------------
ORACLE_HOME=/apps/oracle/app/product/11.2.0/db_1
#------------------------------------------------------------------------------
# Specify the complete path of the OracleBase. 设置ORALCE_BASE的路径
#------------------------------------------------------------------------------
ORACLE_BASE=/apps/oracle/app
#------------------------------------------------------------------------------
# Specify the installation edition of thecomponent.
# The value should contain only one ofthese choices.
# EE : EnterpriseEdition
# SE : Standard Edition
# SEONE Standard Edition One
# PE : Personal Edition (WINDOWS ONLY)
#选择Oracle安装数据库软件的版本(企业版,标准版,标准版1),不同的版本功能不同
#详细的版本区别参考附录D
#------------------------------------------------------------------------------
oracle.install.db.InstallEdition=EE
#------------------------------------------------------------------------------
# This variable is used to enable ordisable custom install.
# true : Components mentioned as part of 'customComponents' property
#are considered for install.
# false : Value for 'customComponents' isnot considered.
#是否自定义Oracle的组件,如果选择false,则会使用默认的组件
#如果选择true否则需要自己在下面一条参数将要安装的组件一一列出。
#安装相应版权后会安装所有的组件,后期如果缺乏某个组件,再次安装会非常的麻烦。
#------------------------------------------------------------------------------
#oracle.install.db.isCustomInstall=false
#------------------------------------------------------------------------------
# This variable is considered only if'IsCustomInstall' is set to true.
# Description: List of Enterprise EditionOptions you would like to install.
# The following choices areavailable. You may specify any
# combination of thesechoices. The components you chooseshould
# be specified in the form"internal-component-name:version"
# Below is a list of components youmay specify to install.
# oracle.rdbms.partitioning:11.2.0.1.0- Oracle Partitioning
# oracle.rdbms.dm:11.2.0.1.0- Oracle Data Mining
# oracle.rdbms.dv:11.2.0.1.0- Oracle Database Vault
# oracle.rdbms.lbac:11.2.0.1.0- Oracle Label Security
# oracle.rdbms.rat:11.2.0.1.0- Oracle Real Application Testing
# oracle.oraolap:11.2.0.1.0- Oracle OLAP
# oracle.install.db.isCustomInstall=true的话必须手工选择需要安装组件的话
#------------------------------------------------------------------------------
#oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
###############################################################################
# PRIVILEGED OPERATING SYSTEM GROUPS
# Provide values for the OS groups to whichOSDBA and OSOPER privileges #
# needs to be granted. If the install isbeing performed as a member of the #
# group "dba", then that will beused unless specified otherwise below. #
#指定拥有OSDBA、OSOPER权限的用户组,通常会是dba组
###############################################################################
#------------------------------------------------------------------------------
# The DBA_GROUP is the OS group which is tobe granted OSDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.DBA_GROUP=dba
#------------------------------------------------------------------------------
# The OPER_GROUP is the OS group which isto be granted OSOPER privileges.
#------------------------------------------------------------------------------
oracle.install.db.OPER_GROUP=oinstall
#------------------------------------------------------------------------------
# Specify the cluster node names selectedduring the installation.
#如果是RAC的安装,在这里指定所有的节点
#------------------------------------------------------------------------------
#oracle.install.db.CLUSTER_NODES=
#------------------------------------------------------------------------------
# Specify the type of database to create.
# It can be one of the following:
# - GENERAL_PURPOSE/TRANSACTION_PROCESSING
# - DATA_WAREHOUSE
#选择数据库的用途,一般用途/事物处理,数据仓库
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
#------------------------------------------------------------------------------
# Specify the Starter Database GlobalDatabase Name. 指定GlobalName
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.globalDBName=orcl
#------------------------------------------------------------------------------
# Specify the Starter Database SID.指定SID
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.SID=orcl
#------------------------------------------------------------------------------
# Specify the Starter Database characterset.
# It can be one of the following:
# AL32UTF8, WE8ISO8859P15, WE8MSWIN1252,EE8ISO8859P2,
# EE8MSWIN1250, NE8ISO8859P10,NEE8ISO8859P4, BLT8MSWIN1257,
# BLT8ISO8859P13, CL8ISO8859P5,CL8MSWIN1251, AR8ISO8859P6,
# AR8MSWIN1256, EL8ISO8859P7, EL8MSWIN1253,IW8ISO8859P8,
# IW8MSWIN1255, JA16EUC, JA16EUCTILDE,JA16SJIS, JA16SJISTILDE,
# KO16MSWIN949, ZHS16GBK, TH8TISASCII,ZHT32EUC, ZHT16MSWIN950,
# ZHT16HKSCS, WE8ISO8859P9, TR8MSWIN1254,VN8MSWIN1258
#选择字符集。不正确的字符集会给数据显示和存储带来麻烦无数。
#通常中文选择的有ZHS16GBK简体中文库,建议选择unicode的AL32UTF8国际字符集
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.characterSet=AL32UTF8
#------------------------------------------------------------------------------
# This variable should be set to true ifAutomatic Memory Management
# in Database is desired.
# If Automatic Memory Management is notdesired, and memory allocation
# is to be done manually, then set it tofalse.
#11g的新特性自动内存管理,也就是SGA_TARGET和PAG_AGGREGATE_TARGET都#不用设置了,Oracle会自动调配两部分大小。
#------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.memoryOption=true
#------------------------------------------------------------------------------
# Specify the total memory allocation forthe database. Value(in MB) should be
# at least 256 MB, and should not exceedthe total physical memory available on the system.
# Example:oracle.install.db.config.starterdb.memoryLimit=512
#指定Oracle自动管理内存的大小,最小是256MB
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.memoryLimit=2048
#------------------------------------------------------------------------------
# This variable controls whether to loadExample Schemas onto the starter
# database or not.是否载入模板示例
#------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.installExampleSchemas=true
#------------------------------------------------------------------------------
# This variable includes enabling auditsettings, configuring password profiles
# and revoking some grants to public. Thesesettings are provided by default.
# These settings may also be disabled. 是否启用安全设置
#------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.enableSecuritySettings=true
###############################################################################
# Passwords can be supplied for thefollowing four schemas in the #
# starter database: #
# SYS #
# SYSTEM #
# SYSMAN (used by Enterprise Manager) #
# DBSNMP (used by Enterprise Manager) #
# Same password can be used for allaccounts (not recommended) #
# or different passwords for each accountcan be provided (recommended) #
#设置数据库用户密码
###############################################################################
#------------------------------------------------------------------------------
# This variable holds the password that isto be used for all schemas in the
# starter database.
#设定所有数据库用户使用同一个密码,其它数据库用户就不用单独设置了。
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.password.ALL=123456
#-------------------------------------------------------------------------------
# Specify the SYS password for the starterdatabase.
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.password.SYS=oracle
#-------------------------------------------------------------------------------
# Specify the SYSTEM password for thestarter database.
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.password.SYSTEM=oracle
#-------------------------------------------------------------------------------
# Specify the SYSMAN password for thestarter database.
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.password.SYSMAN=oracle
#-------------------------------------------------------------------------------
# Specify the DBSNMP password for thestarter database.
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.password.DBSNMP=oracle
#-------------------------------------------------------------------------------
# Specify the management option to beselected for the starter database.
# It can be one of the following:
# 1. GRID_CONTROL
# 2. DB_CONTROL
#数据库本地管理工具DB_CONTROL,远程集中管理工具GRID_CONTROL
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.control=DB_CONTROL
#-------------------------------------------------------------------------------
# Specify the Management Service to use ifGrid Control is selected to manage
# the database. GRID_CONTROL需要设定grid control的远程路径URL
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
#-------------------------------------------------------------------------------
# This variable indicates whether toreceive email notification for critical
# alerts when using DB control.是否启用Email通知, 启用后会将告警等信息发送到指定邮箱
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
#-------------------------------------------------------------------------------
# Specify the email address to which thenotifications are to be sent.设置通知EMAIL地址
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.dbcontrol.emailAddress=
#-------------------------------------------------------------------------------
# Specify the SMTP server used for emailnotifications.设置EMAIL邮件服务器
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
###############################################################################
# SPECIFY BACKUP AND RECOVERY OPTIONS #
# Out-of-box backup and recovery optionsfor the database can be mentioned #
# using the entries below. #
#安全及恢复设置(默认值即可)out-of-box(out-of-box experience)缩写为OOBE
#产品给用产品给用户良好第一印象和使用感受
###############################################################################
#------------------------------------------------------------------------------
# This variable is to be set to false ifautomated backup is not required. Else
# this can be set to true.设置自动备份,和OUI里的自动备份一样。
#------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.automatedBackup.enable=false
#------------------------------------------------------------------------------
# Regardless of the type of storage that ischosen for backup and recovery, if
# automated backups are enabled, a job willbe scheduled to run daily at
# 2:00 AM to backup the database. This jobwill run as the operating system
# user that is specified in this variable.自动备份会启动一个job,指定启动JOB的系统用户ID
#------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.automatedBackup.osuid=
#-------------------------------------------------------------------------------
# Regardless of the type of storage that ischosen for backup and recovery, if
# automated backups are enabled, a job willbe scheduled to run daily at
# 2:00 AM to backup the database. This jobwill run as the operating system user
# specified by the above entry. Thefollowing entry stores the password for the
# above operating system user.自动备份会开启一个job,需要指定OSUser的密码
#-------------------------------------------------------------------------------
#oracle.install.db.config.starterdb.automatedBackup.ospwd=
#-------------------------------------------------------------------------------
# Specify the type of storage to use forthe database.
# It can be one of the following:
# - FILE_SYSTEM_STORAGE
# - ASM_STORAGE
#自动备份,要求指定使用的文件系统存放数据库文件还是ASM
#------------------------------------------------------------------------------
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
#-------------------------------------------------------------------------------
# Specify the database file location whichis a directory for datafiles, control
# files, redo logs.
# Applicable only when oracle.install.db.config.starterdb.storage=FILE_SYSTEM
#使用文件系统存放数据库文件才需要指定数据文件、控制文件、Redo log的存放目录
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/apps/oracle/app/fast_recovery_area
#-------------------------------------------------------------------------------
# Specify the backup and recovery location.
# Applicable only whenoracle.install.db.config.starterdb.storage=FILE_SYSTEM
#使用文件系统存放数据库文件才需要指定备份恢复目录
#-------------------------------------------------------------------------------
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/apps/oracle/app/fast_recovery_area
#-------------------------------------------------------------------------------
# Specify the existing ASM disk groups tobe used for storage.
# Applicable only whenoracle.install.db.config.starterdb.storage=ASM
#使用ASM存放数据库文件才需要指定存放的磁盘组
#-------------------------------------------------------------------------------
#oracle.install.db.config.asm.diskGroup=
#-------------------------------------------------------------------------------
# Specify the password for ASMSNMP user ofthe ASM instance.
# Applicable only whenoracle.install.db.config.starterdb.storage=ASM_SYSTEM
#使用ASM存放数据库文件才需要指定ASM实例密码
#-------------------------------------------------------------------------------
#oracle.install.db.config.asm.ASMSNMPPassword=
#------------------------------------------------------------------------------
# Specify the My Oracle Support AccountUsername.
# Example :MYORACLESUPPORT_USERNAME=metalink
#指定metalink账户用户名
#------------------------------------------------------------------------------
#MYORACLESUPPORT_USERNAME=
#------------------------------------------------------------------------------
# Specify the My Oracle Support AccountUsername password.
# Example : MYORACLESUPPORT_PASSWORD=password
# 指定metalink账户密码
#------------------------------------------------------------------------------
#MYORACLESUPPORT_PASSWORD=
#------------------------------------------------------------------------------
# Specify whether to enable the user to setthe password for
# My Oracle Support credentials. The valuecan be either true or false.
# If left blank it will be assumed to befalse.
# Example : SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
# 用户是否可以设置metalink密码
#------------------------------------------------------------------------------
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
#------------------------------------------------------------------------------
# Specify whether user wants to give anyproxy details for connection.
# The value can be either true or false. Ifleft blank it will be assumed to be false.
# Example : DECLINE_SECURITY_UPDATES=false
# False表示不需要设置安全更新,注意,在11.2的静默安装中疑似有一个BUG
# Response File中必须指定为true,否则会提示错误,不管是否正确填写了邮件地址
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
#------------------------------------------------------------------------------
# Specify the Proxy server name. Lengthshould be greater than zero.
#代理服务器名
# Example : PROXY_HOST=proxy.domain.com
#------------------------------------------------------------------------------
#PROXY_HOST=
#------------------------------------------------------------------------------
# Specify the proxy port number. Should beNumeric and atleast 2 chars.
#代理服务器端口
# Example : PROXY_PORT=25
#------------------------------------------------------------------------------
#PROXY_PORT=
#------------------------------------------------------------------------------
# Specify the proxy user name. LeavePROXY_USER and PROXY_PWD
# blank if your proxy server requires noauthentication.
#代理服务器用户名
# Example : PROXY_USER=username
#------------------------------------------------------------------------------
#PROXY_USER=
#------------------------------------------------------------------------------
# Specify the proxy password. LeavePROXY_USER and PROXY_PWD
# blank if your proxy server requires noauthentication.
#代理服务器密码
# Example : PROXY_PWD=password
#------------------------------------------------------------------------------
#PROXY_PWD=
步骤2: 安装数据库
切换到Oracle用户并执行静默安装命令:
su - oracle
cd /apps/oracle/app/database
./runInstaller -silent -force -responseFile /apps/oracle/etc/db_install.rsp -ignorePrereq
出现以下报错:
原因: 主产品清单位于 Oracle 基目录中。
操作: Oracle 建议将此主产品清单放置在 Oracle 基目录之外的位置中。
稍等4-5分钟
问题解决如下:
以 root 用户的身份执行以下脚本:
1./apps/oracle/app/oraInventory/orainstRoot.sh
2./apps/oracle/app/product/11.2.0/db_1/root.sh
若有其他报错,大概率是内存给的不够,我这里给的是3G:
步骤3: 监听安装
安装监听器并配置监听器服务:
cd /apps/oracle/app/product/11.2.0/db_1/bin
./netca /silent /responsefile /apps/oracle/app/database/response/netca.rsp
如果出现UnsatisfiedLinkError
错误,解决方法如下:
cp /apps/oracle/app/database/stage/ext/lib/libclntsh.so.11.1 /apps/oracle/app/product/11.2.0/lib/
步骤4:配置环境变量
切换到root用户,编辑/etc/profile文件:
ORACLE_BASE=/apps/oracle/app
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_BASE ORACLE_HOME LD_LIBRARY_PATH PATH
步骤5:监听状态查看
进入cd /apps/oracle/app/product/11.2.0/db_1/bin
检查监听器的状态是否正常:
./lsnrctl status
./lsnrctl start #服务器重启后需要启动监听
步骤6:静默建库
创建数据库实例(如果安装数据库软件的时候已经创建了数据库,当前步骤可以不执行,以后如果有新的库创建可以使用该方法):
./dbca -silent -templateName General_Purpose.dbc -gdbname orcl -sid orcl -characterSet AL32UTF8 -sysPassword Abc123456 -systemPassword Abc123456 -createAsContainerDatabase false -ignorePreReqs
./dbca -silent -responseFile /apps/oracle/app/database/response/dbca.rsp
步骤7:登录查看
使用SQL*Plus工具登录到数据库并验证其状态:
sqlplus / as sysdba
若登录时需要密码,退出登录状态后执行以下语句:
export ORACLE_SID=orcl
步骤8:使用Oracle SQL Developer测试
输入相关信息之后,点击测试,出现以下情况即为成功:
若出现ORA-12505报错信息,如下:
解决方法为:
在登录之后输入指令startup
,出现以下信息:
回去再点击测试即可。