oracle:11g静默安装部署

概述

oracle数据库的静默安装,相比于mysql和PG来说,oracle的安装稍微复杂一点。一方面对于系统本身有许多要求限制,另一方面oracle自己也有许多特殊的地方。因为我之前没有接触过,第一次安装,还是踩了不少坑的。好在作为全球最流行的数据库,各种文档应有尽有,查阅起来还是很方便的。所以在整个过程还算顺利,分享给大家

安全前准备

检查OS需求

[root@stephen ~]# grep MemTotal /proc/meminfo 
MemTotal: 1882296 kB
内存推荐大于2GB

[root@stephen ~]# grep SwapTotal /proc/meminfo 
SwapTotal: 2097148 kB
swap 推荐大于2GB

[root@stephen ~]# df -k /dev/shm/
Filesystem 1K-blocks Used Available Use% Mounted on
tmpfs 941148 0 941148 0% /dev/shm
硬盘空间至少大于10G,推荐大于40G

[root@stephen ~]# df -h /tmp
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 27G 1.8G 26G 7% /
tmp需要大于400M

依赖包检查并安装

检查是否有安装
rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst  make sysstat  unixODBC unixODBC-devel

安装依赖
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

准备用户

[root@stephen ~]# groupadd oinstall
[root@stephen ~]# groupadd dba
[root@stephen ~]# chattr -i /etc/passwd /etc/shadow
[root@stephen ~]# useradd -g oinstall -G dba oracle
[root@stephen ~]# passwd oracle
Changing password for user oracle.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@stephen ~]# chattr +i /etc/passwd /etc/shadow

设置内核参数

(1)修改/etc/sysctl.conf文件,增加以下内容:
# oracle
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 8388608
kernel.shmmax = 34359738368
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 = 1048586
 
(2)修改后:sysctl –p
 
说明:如果遇见报错信息如下:
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
解决方法如下:
modprobe bridge
lsmod|grep bridge

检查Oracle软件安装的资源限制

vim /etc/security/limits.conf
# oracleoracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

创建安装目录

[root@stephen ~]# mkdir /home/u01
[root@stephen ~]# ln -s /home/u01 /u01
[root@stephen ~]# mkdir -p /u01/app/oracle/
[root@stephen ~]# chown -R oracle:oinstall /u01/
[root@stephen ~]# chmod -R 775 /u01/

修改/etc/pam.d/login文件,增加以下内容:
session required pam_limits.so
修改/etc/profile文件,增加以下内容:
# oracle
if [ \$USER = "oracle" ]; then
         if [ \$SHELL = "/bin/ksh" ]; then
             ulimit -p 16384
             ulimit -n 65536
         else
             ulimit -u 16384 -n 65536
         fi
fi

设置Oracle用户变量

vi  .bash_profile

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=stephen
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LANG="en_US.UTF-8"
export NLS_LANG=american_AMERICA.UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

安装oracle

上传安装包

从官网上下载两个安装包
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip

上传到/u01  目录下,分别解压

unzip linux.x64_11gR2_database_1of2.zip 
unzip linux.x64_11gR2_database_2of2.zip 

准备配置文件

将以下涉及到的参数替换
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=srolequery.cyou.com
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/u01/app/oraInventory
ORACLE_HOME=/home/u01/app/oracle/product/11.2.4/db_1
ORACLE_BASE=/home/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=true
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.3.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
说明:其它未涉及到的参数不用管

执行安装脚本

[oracle@stephen database]$ ./runInstaller -silent -force -noconfig -responseFile /u01/database/response/db_install_stephen.rsp
Starting Oracle Universal Installer...

Checking Temp space: must be greater than 120 MB. Actual 25715 MB Passed
Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-11-13_05-42-54PM. Please wait ...[oracle@stephen database]$ [WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2019-11-13_05-42-54PM/installActions2019-11-13_05-42-54PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2019-11-13_05-42-54PM/installActions2019-11-13_05-42-54PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
[WARNING] [INS-13014] Target environment do not meet some optional requirements.
   CAUSE: Some of the optional prerequisites are not met. See logs for details. /tmp/OraInstall2019-11-13_05-42-54PM/installActions2019-11-13_05-42-54PM.log
   ACTION: Identify the list of failed prerequisite checks from the log: /tmp/OraInstall2019-11-13_05-42-54PM/installActions2019-11-13_05-42-54PM.log. Then either from the log file or from installation manual find the appropriate configuration to meet the prerequisites and fix it manually.
You can find the log of this install session at:
 /home/u01/app/oraInventory/logs/installActions2019-11-13_05-42-54PM.log

[oracle@stephen database]$ The following configuration scripts need to be executed as the "root" user. 
 #!/bin/sh 
 #Root scripts to run

/home/u01/app/oraInventory/orainstRoot.sh
/home/u01/app/oracle/product/11.2.0/db_1/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

[root@stephen oraInventory]# ./orainstRoot.sh 
Changing permissions of /home/u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /home/u01/app/oraInventory to oinstall.
The execution of the script is complete.

[root@stephen db_1]# ./root.sh 
Check /home/u01/app/oracle/product/11.2.0/db_1/install/root_stephen_2019-11-14_13-45-11.log for the output of root script

配置监听

[oracle@stephen response]$ $ORACLE_HOME/bin/netca /silent /responseFile /u01/database/response/netca.rsp

Parsing command line arguments:
    Parameter "silent" = true
    Parameter "responsefile" = /u01/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /home/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
    Listener Control complete.
    Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0


可以查看到监听目录
[oracle@stephen response]$ ll /u01/app/oracle/product/11.2.0/db_1/network/admin/
total 12
-rw-r--r--. 1 oracle oinstall 373 Nov 14 13:55 listener.ora
drwxr-xr-x. 2 oracle oinstall 64 Nov 13 17:44 samples
-rw-r--r--. 1 oracle oinstall 187 May 7 2007 shrept.lst
-rw-r--r--. 1 oracle oinstall 224 Nov 14 13:55 sqlnet.ora

可以查看到端口监听
[root@stephen ~]# netstat -anp |grep 1521
tcp6 0 0 :::1521 :::* LISTEN 5436/tnslsnr        
unix 2 [ ACC ] STREAM LISTENING 21575 5436/tnslsnr /var/tmp/.oracle/sEXTPROC1521

停止后需要手动去起监听
lsnrctl start

建库

vi dbca.rsp文件,将以下涉及到的参数替换:
GDBNAME = "stephen"
SID = "stephen"
CHARACTERSET = "UTF8"
TOTALMEMORY = "512" 说明:测试环境总内存比较小,正式环境按情况而定
SOURCEDB = "127.0.0.1:1521:stephen"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"


说明:
1、CHARACTERSET和TOTALMEMORY这2个参数默认是被注释掉的,需要打开注释
2、sid、GDBNAME只能为字母和数字,不能有下划线之类的
创建库
$ORACLE_HOME/bin/dbca -silent -responseFile /u01/database/response/dbca.rsp
Copying database files                                             
1% complete                                                        
3% complete                                                        
11% complete                                                       
18% complete                                                       
26% complete                                                       
37% complete                                                       
Creating and starting Oracle instance                              
40% complete                                                       
45% complete                                                       
50% complete                                                       
55% complete                                                       
56% complete                                                       
60% complete                                                       
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/stephen/stephen.log" for further details.

使用

[oracle@stephen db_1]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Tue Nov 19 10:52:22 2019
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area 534462464 bytes
Fixed Size	2215064 bytes
Variable Size	343933800 bytes
Database Buffers	184549376 bytes
Redo Buffers	3764224 bytes
Database mounted.
Database opened.

查看控制文件
SQL> show parameter control_files;

NAME	TYPE	VALUE
------------------------------------ ----------- ------------------------------
control_files	string	/u01/app/oracle/oradata/stephe
       n/control01.ctl, /u01/app/orac
       le/flash_recovery_area/stephen
       /control02.ctl

至此,静默安装oracle数据库完成

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值