本文描述没有图形化界面,直接采用命令行方式进行静默安装Oracle11g的过程。
前面的基础准备,可以参考图形化的安装操作:https://blog.csdn.net/sunny05296/article/details/56840775
别忘了系统内核参数优化。
本文从创建用户和组开始介绍。
创建用户和组
groupadd oinstall
groupadd dba
useradd -g oinstall -g dba -m oracle
passwd oracle
创建Oracle数据库的安装目录(for静默安装)
mkdir -p /opt/oracle
mkdir -p /opt/oraInventory
mkdir -p /opt/database
mkdir -p /opt/oracle/product/11.2.0
mkdir -p /opt/oracle/oradata
mkdir -p /opt/oracle/flash_recovery_area
chown -R oracle:oinstall /opt/oracle
chown -R oracle:oinstall /opt/oracle/oradata
chown -R oracle:oinstall /opt/oraInventory
chown -R oracle:oinstall /opt/database
chmod -R 775 /opt/oracle
su - oracle
vim .bash_profile 添加如下内容:
# 注意:
# 1. ORACLE_SID 必须与创建的数据库实例名称一致,否则数据库启动后无法访问
# 2. ORACLE_HOME 根据实际情况填写,安装完毕以后,再检查一下,如果有误,需要调整,确保正确
ORACLE_BASE=/opt/oracle
#ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
执行生效:
source .bash_profile
检查是否生效
echo $ORACLE_HOME
解压
cd /opt
unzip linux.x64_11gR2_database_1of2.zip -d /opt/database
unzip linux.x64_11gR2_database_2of2.zip -d /opt/database
用root账号创建/etc/oraInst.loc文件,否则安装时会报错:
SEVERE: [FATAL] [INS-32038] The operating system group specified for central inventory (oraInventory) ownership is invalid.
vi /etc/oraInst.loc
inventory_loc=/opt/oraInventory
inst_group=oinstall
安装未安装的package
验证命令26个包,如果没有安装,需要先安装
rpm -qa binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers pdksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel
yum install -y binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers glibc-static kernel-headers pdksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel libstdc++-static make numactl-devel sysstat unixODBC unixODBC-devel
注意,安装完以后,可以再重新执行一次 yum install 确认一下,是否有未安装的包。
如果出现 pdksh-5.2.14 没有安装,需要单独额外安装:
下面提供多个下载地址,如果不能下,就挨个尝试:
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
wget ftp://ftp.icm.edu.pl/vol/rzm6/linux-scientificlinux/obsolete/58/x86_64/updates/fastbugs/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
wget ftp://ftp.gwdg.de/linux/scientificlinux/scientific/58/x86_64/updates/fastbugs/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
wget ftp://ftp.icm.edu.pl/vol/rzm6/linux-scientificlinux/obsolete/59/x86_64/SL/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
安装pdksh:
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
编辑静默安装响应文件
su oracle
cp -R /opt/database/database/response/ /home/oracle/
[oracle@localhost ~]$ ls -l /home/oracle/response/
total 76
-rw-r--r-- 1 oracle dba 44969 May 18 16:16 dbca.rsp
-rw-r--r-- 1 oracle dba 22665 May 18 16:20 db_install.rsp
-rwxr-xr-x 1 oracle dba 5740 May 18 16:16 netca.rsp
[oracle@localhost ~]$
可见在response目录下有三个模板文件。
其中dbca.rsp是用来创建数据库的。
db_install.rsp是用来安装Oracle软件的。
netca.rsp是用来创建监听器的。
当然也可在db_install.rsp中直接创建数据库。
修改安装Oracle软件的模板文件:
cd /home/oracle/response/
vim db_install.rsp
db_install.rsp需要设置的选项如下:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=localhost
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/opt/oracle/product/11.2.0
ORACLE_BASE=/opt/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
注意:
如果服务器设置了hostname,则ORACLE_HOSTNAME需要设置一致。需要进行下面hostname相关的修改。
如果没有设置hostname,默认localhost,则可以跳过下面步骤,直接进入静默安装操作。
注意如果后期修改hostname,也需要参考下面的修改(“myhost”根据你自己设置的实际hostname进行替换):
1. vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
16.54.136.81 myhost
2. vi /etc/sysconfig/network 添加如下
NETWORKING=yes
HOSTNAME=myhost
3. vi $ORACLE_HOME/network/admin/listener.ora
修改HOST由HOST=localhost改为HOST=myhost
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /opt/oracle
4. $ORACLE_HOME/network/admin/tnsnames.ora 文件可改,也可不修改
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
静默安装
根据响应文件静默安装Oracle11g
su oracle
cd /opt/database/database
./runInstaller -silent -responseFile /home/oracle/response/db_install.rsp -ignorePrereq
如果执行以上命令出错,会提示有参数格式,按照提示参数格式修改修改即可,一般是由于word中的字体、符号格式复制到客户端命令行后不一致引起,修改即可
开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
可以在以下位置找到本次安装会话的日志: /tmp/OraInstall2018-05-18_04-35-03PM
可以切换终端执行top命令查看后台进程一直是在安装的,du -sh /opt 目录也在不断增大
=====>>>>>>>>
当出现以下提示时,代表安装成功:
[oracle@localhost database]$ The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/opt/oracle/product/11.2.0/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
按照要求打开终端,以root身份,执行脚本
exit 退出oracle,回到root的shell界面执行:
sh /opt/oracle/product/11.2.0/root.sh
执行结果如下:
[root@localhost opt]# sh /opt/oracle/product/11.2.0/root.sh
Check /opt/oracle/product/11.2.0/install/root_localhost.localdomain_2018-05-18_16-42-48.log for the output of root script
[root@localhost opt]#
[root@localhost opt]# cat /opt/oracle/product/11.2.0/install/root_localhost.localdomain_2018-05-18_16-42-48.log
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /opt/oracle/product/11.2.0
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
[root@localhost opt]#
以静默方式配置监听
重新使用oracle用户登录
su - oracle
cd /home/oracle/response/
netca /silent /responseFile /home/oracle/response/netca.rsp
注意此处,必须使用/silent /responseFile格式,而不是-silent -responseFile,因为是静默安装
执行结果:
[oracle@localhost ~]$ netca /silent /responseFile /opt/database/database/response/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /opt/database/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/opt/oracle/product/11.2.0/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@localhost ~]$
查看端口是否开启:
netstat -an | grep 1521
[oracle@localhost ~]$ netstat -an | grep 1521
tcp6 0 0 :::1521 :::* LISTEN
unix 2 [ ACC ] STREAM LISTENING 21798 /var/tmp/.oracle/sEXTPROC1521
[oracle@localhost ~]$
如果netstat目录没有安装,需要以root身份安装:yum install -y net-tools
如果执行 netca 失败,提示netca command not found
检查环境变量设置是否正确:
netca /silent /responseFile /opt/database/database/response/netca.rsp
vim /home/oracle/.bash_profile
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0 #设置是否正确
修改以后,source /home/oracle/.bash_profile
如果遇到错误:/opt/oracle/product/11.2.0/lib/libnjni11.so: libclntsh.so.11.1: cannot open shared object file: No such file or directory
解决办法:
1. cp /opt/oracle/product/11.2.0/inventory/Scripts/ext/lib/libclntsh.so.11.1 /opt/oracle/product/11.2.0/lib/
再重新执行netca
2.或者执行:$ORACLE_HOME/bin/relink all
3.vim /home/oracle/.bash_profile
EXPORT LD_LIBRARY_PATH = $ORACLE_HOME/lib:/usr/lib:/usr/local/lib;
source /home/oracle/.bash_profile
4.ls -l /opt/oracle/product/11.2.0/lib/libclntsh*
缺少软连接
cp /opt/oracle/product/11.2.0/inventory/Scripts/ext/lib/libclntsh.so.11.1 /opt/oracle/product/11.2.0/lib/
ln -s /opt/oracle/product/11.2.0/lib/libclntsh.so.11.1 /opt/oracle/product/11.2.0/lib/libclntsh.so
ln -s /opt/oracle/product/11.2.0/lib/libclntsh.so /opt/oracle/product/11.2.0/lib/libclntsh.so.10.1
ll /opt/oracle/product/11.2.0/network/admin/
成功运行后,在 /opt/oracle/product/11.2.0/network/admin/ 中生成listener.ora和sqlnet.ora
通过netstat命令可以查看1521端口正在监听。
Yum安装netstat软件,软件包是在net-tools中。
# yum install net-tools
# netstat -tnulp | grep 1521
查看监听状态:
lsnrctl status
[oracle@localhost ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 19-MAY-2018 18:45:03
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 19-MAY-2018 18:25:40
Uptime 0 days 0 hr. 19 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@localhost ~]$
[oracle@localhost ~]$
接下来建库
以静默方式建立新库,同时也建立一个对应的实例。
vim /home/oracle/response/dbca.rsp
设置以下参数:
GDBNAME= "orcl"
SID ="orcl"
SYSPASSWORD= "1q2w3e"
SYSTEMPASSWORD= "1q2w3e"
SYSMANPASSWORD= "1q2w3e"
DBSNMPPASSWORD= "1q2w3e"
#DATAFILEDESTINATION=$ORACLE_BASE/oradata #该参数配置注释掉,不修改,使用默认的,否则建库会报错。
RECOVERYAREADESTINATION=$ORACLE_BASE/flash_recovery_area
CHARACTERSET= "AL32UTF8"
TOTALMEMORY= "6553"
#其中TOTALMEMORY ="6553" 为6553MB,物理内存8G*80%
进行静默建库:
$ dbca -silent -responseFile /home/oracle/response/dbca.rsp
如果出错1:
sh:/bin/ksh:No such file or directory
先安装ksh:yum install ksh
如果提示查看日志,内容:The file path $ORACLE_BASE/oradata/orcl/system01.dbf is invalid. Please check the permissions.
原因:$ORACLE_BASE/oradata/orcl 路径不存在。
创建数据库实例时默认的log路径datafile/oradata是根路径未知的路径,可将路径修改为{ORACLE_BASE}/oradata,sysaux01.dbf的路径为{ORACLE_BASE}/oradata/sysaux01.dbf,异常消除!
如果出错2:提示你查看日志信息,日志信息显示db文件 invalid:
cat /opt/oracle/cfgtoollogs/dbca/orcl.log
The file path $ORACLE_BASE/oradata/orcl/system01.dbf is invalid. Please check the permissions.
[oracle@localhost response]$
尝试了多种解决办法,最终通过取消配置,保持默认。用#号注释掉。
#DATAFILEDESTINATION = $ORACLE_BASE/oradata
如果我显式的配置成DATAFILEDESTINATION = $ORACLE_BASE/oradata,创建库的时候,就会出错。默认则不会出错。原因没有找到。注销即可。
建库后进行实例进程检查:
ps -ef | grep ora_ | grep -v grep
登录查看实例状态:
sqlplus / as sysdba
select status from v$instance
接下来需要创用户、表空间和授权远程访问等操作。参考图形化安装的创建用户、表空间、授权等操作即可:
https://blog.csdn.net/sunny05296/article/details/56840775
来源:CSDN
作者:sunny05296
链接:https://blog.csdn.net/sunny05296/article/details/80372256