Centos6.5 Oracle11g 静默离线安装完整版教程(无需图形化界面)

13 篇文章 0 订阅

1 修改/etc/security/limits.conf文件,修改用户的SHELL的限制

[root@hqc-test-hdp3 database]# vim /etc/security/limits.conf

#@student        -       maxlogins       4
oracle   soft    nproc    2047
oracle   hard    nproc    16384
oracle   soft    nofile   1024
oracle   hard    nofile   65536
#End of file

2 修改/etc/pam.d/login 文件

[root@hqc-test-hdp3 database]# vim /etc/pam.d/login 

-session   optional     pam_ck_connector.so

session   required    /lib/security/pam_limits.so
session   required    pam_limits.so

3 修改linux内核,修改/etc/sysctl.conf文件

[root@hqc-test-hdp3 database]# vim /etc/sysctl.conf 

#Controls the maximum size of a message, in bytes
kernel.msgmax = 65536

#Controls the maximum shared segment size, in bytes
#kernel.shmmax = 68719476736

#Controls the maximum number of shared memory segments, in pages
#kernel.shmall = 4294967296

fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

4 输入命令:sysctl -p,使/etc/sysctl.conf配置文件立即生效

[root@hqc-test-hdp3 ~]# sysctl -p
net.ipv4.ip_forward = 0
net.ipv4.conf.default.rp_filter = 1
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables" is an unknown key
error: "net.bridge.bridge-nf-call-arptables" is an unknown key
kernel.msgmnb = 65536
kernel.msgmax = 65536
fs.file-max = 6815744
fs.aio-max-nr = 1048576
kernel.shmall = 2097152
kernel.shmmax = 2147483648
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576

5 修改/etc/profile

[root@hqc-test-hdp3 ~]# vim /etc/profile

unset i
unset -f pathmunge
export JAVA_HOME=/opt/java
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=$JAVA_HOME/lib
export CLASSPATH=$CLASSPATH:$JAVA_HOME/jre/lib

if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
  ulimit -p 16384
  ulimit -n 65536
else
  ulimit -u 16384 -n 65536
fi
fi

6.创建用户和组

6.1 创建用户组oinstall、dba

[root@hqc-test-hdp3 ~]# groupadd  oinstall
[root@hqc-test-hdp3 ~]# groupadd  dba

6.2 创建oracle用户,主组为oinstall,副组dba

[root@hqc-test-hdp3 ~]# useradd -g oinstall -G dba -m oracle

6.3 设置用户oracle密码,输入两次密码

[root@hqc-test-hdp3 ~]# passwd  oracle
更改用户 oracle 的密码 。
新的 密码:drguo@oracle123
重新输入新的 密码:drguo@oracle123
passwd: 所有的身份验证令牌已经成功更新。

7 创建数据库软件目录和数据文件存放目录

[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oracle
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oradata
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oraInventory
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/fast_recovery_area
[root@hqc-test-hdp3 ~]# mkdir /home/oracle/app/oracle/product

8 修改目录权限,更改目录属主为Oracle用户所有

[root@hqc-test-hdp3 ~]# chown -R oracle:oinstall /home/oracle/app  

9 配置oracle用户的环境变量

9.1 用命令su - oracle切换到oracle用户且其家目录下

[root@hqc-test-hdp3 ~]# su - oracle
[oracle@hqc-test-hdp3 ~]$ 

9.2 修改.bash_profile

[oracle@hqc-test-hdp3 ~]$ vim .bash_profile 
#.bash_profile

#Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

#User specific environment and startup programs

export ORACLE_BASE=/home/oracle/app
export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib

10 解压安装文件
oracle11g安装文件下载地址 https://download.csdn.net/download/dr_guo/11459608

[root@hqc-test-hdp3 database]# unzip linux.x64_11gR2_database_1of2.zip 
[root@hqc-test-hdp3 database]# unzip linux.x64_11gR2_database_2of2.zip 

11 创建/etc/oraInst.loc文件,否则安装时会报错:
SEVERE: [FATAL] [INS-32038] The operating system group specified for central inventory (oraInventory) ownership is invalid.

[oracle@hqc-test-hdp3 ~]$ su
密码:
[root@hqc-test-hdp3 oracle]# vim /etc/oraInst.loc

inventory_loc=/home/oracle/app/oraInventory
inst_group=oinstall

12 安装未安装的package

可以访问外网:

[root@hqc-test-hdp3 oracle]# yum install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make pdksh sysstat unixODBC unixODBC-devel

不能访问外网:
依赖包下载地址 https://download.csdn.net/download/dr_guo/11459600

[root@hqc-test-hdp3 data]# cd package/
[root@hqc-test-hdp3 package]# rpm -ivh *.rpm

13 准备responseFile文件
从Oracle软件中获取文件模板

[root@hqc-test-hdp3 data]# cd database/response/
[root@hqc-test-hdp3 response]# ls
dbca.rsp  db_install.rsp  netca.rsp

其中database是Oracle软件解压后生成的目录。可见在response目录下有三个模板,其中dbca.rsp是用来创建数据库的。db_install.rsp是用来安装Oracle软件的。netca.rsp是用来创建监听器的。当然也可在db_install.rsp中直接创建数据库。在这里,为求方便,我们选择db_install.rsp模板一并安装软件,创建数据库。

14 编辑responseFile文件

[root@hqc-test-hdp3 response]# vim db_install.rsp 

oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_AND_CONFIG
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/home/oracle/app
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
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
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=orcl
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.memoryLimit=400
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=1Password
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=xxxx@xxxx.com
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/app/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/home/oracle/app/fast_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=

15 改用oracle用户登录,静默安装

[root@hqc-test-hdp3 response]# su oracle
[oracle@hqc-test-hdp3 response]$ cd /data/database/
[oracle@hqc-test-hdp3 database]$ ./runInstaller -silent -ignorePrereq -responseFile /data/database/response/db_install.rsp

正在启动 Oracle Universal Installer...

检查临时空间: 必须大于 120 MB。   实际为 39013 MB    通过
检查交换空间: 必须大于 150 MB。   实际为 3967 MB    通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2019-08-01_12-38-52PM. 请稍候...[oracle@hqc-test-hdp3 database]$ 可以在以下位置找到本次安装会话的日志:
 /home/oracle/app/oraInventory/logs/installActions2019-08-01_12-38-52PM.log

查看日志

[oracle@hqc-test-hdp3 database]$ tail -f  /home/oracle/app/oraInventory/logs/installActions2019-08-01_12-38-52PM.log
TODO

如果在日志文件中看到如上的内容,证明安装已经完成。

[oracle@hqc-test-hdp3 database]$ watch -d -n 2 'du -sh /home/oracle'
Every 2.0s: du -sh /home/oracle                                                                     Thu Aug  1 16:17:06 2019

3.6G    /home/oracle

[root@hqc-test-hdp2 samples]# cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/
[root@hqc-test-hdp2 dbhome_1]# sh root.sh 
Check /home/oracle/app/oracle/product/11.2.0/dbhome_1/install/root_hqc-test-hdp2_2019-08-12_15-19-12.log for the output of root script

以静默方式配置监听
[oracle@hqc-test-hdp2 ~]$ netca /silent /responseFile /data/database/response/netca.rsp

正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /data/database/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle Net Services 配置:
完成概要文件配置。
Oracle Net 监听程序启动:
    正在运行监听程序控制: 
      /home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
    监听程序控制完成。
    监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置。退出代码是0

以静默方式建立新库,同时也建立一个对应的实例

[root@hqc-test-hdp2 dbhome_1]# vim /data/database/response/dbca.rsp
[oracle@hqc-test-hdp2 ~]$ dbca -silent -responseFile /data/database/response/dbca.rsp 
复制数据库文件
1% 已完成
2% 已完成
4% 已完成
37% 已完成
正在创建并启动 Oracle 实例
38% 已完成
40% 已完成
45% 已完成
50% 已完成
51% 已完成
56% 已完成
57% 已完成
61% 已完成
62% 已完成
正在进行数据库创建
66% 已完成
70% 已完成
73% 已完成
74% 已完成
85% 已完成
86% 已完成
98% 已完成
100% 已完成
有关详细信息, 请参阅日志文件 "/home/oracle/app/cfgtoollogs/dbca/orcl/orcl.log"[oracle@hqc-test-hdp2 ~]$ ps -ef | grep ora_ | grep -v grep
[oracle@hqc-test-hdp2 ~]$ lsnrctl status

16 启动数据库

[oracle@hqc-test-hdp3 database]$ source /home/oracle/.bash_profile 
[oracle@hqc-test-hdp3 package]$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory

报错了,切换到root用户看一下有没有这个文件

[root@hqc-test-hdp3 lib]# find / -name libclntsh.so.11.1
/home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/Scripts/ext/lib/libclntsh.so.11.1
/home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/backup/2019-08-01_02-05-05PM/Scripts/ext/lib/libclntsh.so.11.1
/data/database/stage/ext/lib/libclntsh.so.11.1

有的话拷到oracle目录下

[root@hqc-test-hdp3 lib]# cp /home/oracle/app/oracle/product/11.2.0/dbhome_1/inventory/Scripts/ext/lib/libclntsh.so.11.1 /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib/
[root@hqc-test-hdp3 lib]# cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/lib

修改权限或改所有者,千万别忘了!

[root@hqc-test-hdp3 lib]# chmod 777 libclntsh.so.11.1

没有的话,点此下载:https://download.csdn.net/download/dr_guo/11460107

切换到oracle用户

[oracle@hqc-test-hdp3 package]$ sqlplus / as sysdba
sqlplus: error while loading shared libraries: libclntsh.so.11.1: cannot open shared object file: No such file or directory

如果还是报错,再切换到root用户,在 /etc/ld.so.conf 加入 ORCALE_HOME/lib 目录

[oracle@hqc-test-hdp3 package]$ su
密码:
[root@hqc-test-hdp3 lib]# vim /etc/ld.so.conf
include ld.so.conf.d/*.conf
/home/oracle/app/oracle/product/11.2.0/dbhome_1/lib

[oracle@hqc-test-hdp3 database]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 1 14:58:04 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.
ERROR:
ORA-12547: TNS:lost contact

报另一个错ORA-12547: TNS:lost contact
修改权限

[root@hqc-test-hdp3 ~]# cd /home/oracle/app/oracle/product/11.2.0/dbhome_1/
[root@hqc-test-hdp3 dbhome_1]# cd bin/
[root@hqc-test-hdp3 bin]# chmod 6751 oracle

检查ORACLE_HOME/bin/oracle和ORACLE_HOME/rdbms/lib/config.o的文件大小是否为0

[root@hqc-test-hdp3 dbhome_1]# ll rdbms/lib/config.o
-rw-r--r-- 1 oracle oinstall 0 8月   1 14:06 rdbms/lib/config.o
[root@hqc-test-hdp3 dbhome_1]# ll bin/oracle
-rwsr-s--x 1 oracle oinstall 0 8月  15 2009 bin/oracle

如果大小为0,那么需要先备份config.o文件,然后重新编译oracle软件:

[root@hqc-test-hdp3 dbhome_1]# mv rdbms/lib/config.o rdbms/lib/config.o.bak
[root@hqc-test-hdp3 dbhome_1]# su oracle
[oracle@hqc-test-hdp3 dbhome_1]$ bin/relink all

17 大功告成

[root@hqc-test-hdp3 lib]# sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Thu Aug 1 15:42:39 2019

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> start
SP2-1506: START, @ or @@ command has no arguments
SQL> startup
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

光于前裕于后

您的打赏将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值