欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

静默安装oracle11g

程序员文章站 2022-07-28 21:27:21
oracle:11.2.0.4 linux:红帽6.5 依赖包,是全部都写上来了,按照需求选择,也可以全部都安装一遍 yum install -y binutils-* compat-libstdc++-33-* elfutils-libelf-* elfutils-libelf-devel-* g ......

oracle:11.2.0.4

linux:红帽6.5

 

依赖包,是全部都写上来了,按照需求选择,也可以全部都安装一遍

yum install -y binutils-* compat-libstdc++-33-* elfutils-libelf-* elfutils-libelf-devel-* gcc-* gcc-c++-* glibc-* glibc-common-* glibc-devel-* glibc-headers-* ksh-* libaio-* libgcc-* libstdc++-* make-* sysstat-* unixodbc-* unixodbc-devel-* ld-linux.so.2 libxp.so.6 libxt.so.6 libxtst.so.6 glibc.i686 libgcc.i686 glibc-devel.i686
yum install -y binutils compat-libcap1 compat-libstdc++-33 e2fsprogs e2fsprogs-libs glibc glibc-devel ksh libaio-devel libaio libgcc libstdc++ libstdc++-devel libxcb libx11 libxau libxi libxtst make net-tools nfs-utils smartmontools sysstat gcc-c++-4.* gcc-4.*
yum install binutils-2.* compat-libstdc++-33* elfutils-libelf-0.* elfutils-libelf-devel-* gcc-4.* gcc-c++-4.* glibc-2.* glibc-common-2.* glibc-devel-2.* glibc-headers-2.* libaio-0.* libaio-devel-0.* libgcc-4.* libstdc++-4.* libstdc++-devel-4.* make-3.* sysstat-7.* unixodbc-2.* unixodbc-devel-2.*
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


创建oracle用户和属组,grid用户,这里是嫌麻烦,所以就直接创建了oracle和grid用户
groupadd oinstall
groupadd dba
useradd -m -g oinstall -g dba oracle
passwd oracle

useradd -m -g oinstall -g dba grid
passwd grid


vim /etc/hosts
--------------------------
192.168.100.100 oracle
--------------------------

 

vim /etc/selinux/config
----------------------
selinux=disabled
---------------------

 

修改oracle用户限制
vi /etc/security/limits.conf
----------------------------------------
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
----------------------------------------

 

修改系统参数
vi /etc/sysctl.conf
----------------------------------------
kernel.shmmax = 536870912
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
fs.aio-max-nr = 1048576
fs.file-max = 6815744
----------------------------------------
sysctl -p


最全创建目录,按照需求创建目录,给予权限,为了方便,我把grid目录也创建了:
mkdir -p /u01/app
chown -r grid:oinstall /u01/app/
chmod -r 775 /u01/app/
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle
chown -r grid:oinstall /u01/app/grid/
chown -r oracle:oinstall /u01/app/oracle/
chmod -r 775 /u01/app/grid/
chmod -r 775 /u01/app/oracle/
mkdir -p /u01/app/11.2.0/grid
chown -r grid:oinstall /u01/app/11.2.0/grid
chmod -r 775 /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle/oradata
chown -r oracle:oinstall /u01/app/oracle/oradata
chmod -r 775 /u01/app/oracle/oradata
mkdir -p /u01/app/orainventory
chown -r oracle:oinstall /u01/app/orainventory
chmod -r 775 /u01/app/orainventory
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -r oracle:oinstall /u01/app/oracle/product/11.2.0/db_1
chmod -r 775 /u01/app/oracle/product/11.2.0/db_1

设置 oracle 帐号登录时环境
(以下以 oracle 身份登录): 编辑文件
su - oracle
vim .bash_profile
添加如下行:
-----------------------------
oracle_base=/u01/app/oracle
oracle_home=$oracle_base/product/11.2.0/db_1
oracle_sid=ora11g
ld_library_path=$oracle_home/lib
path=$path:$oracle_home/bin:$home/bin
export oracle_base oracle_home oracle_sid ld_library_path path
-----------------------------
保存退出后执行如下命令使以上设置立即生效:
source .bash_profile

 

好了,前期安装准备,都是一样的,接下来是静默安装的

 

响应文件所在的目录:
vim /u01/database/response/db_install.rsp
--------------------------------------------------------
oracle.install.option=install_db_swonly     // 安装类型
oracle_hostname=docker        // 主机名称(hostname查询)
unix_group_name=oinstall     // 安装组
inventory_location=/u01/app/orainventory   //inventory目录(不填就是默认值)
selected_languages=en,zh_cn,zh_tw // 选择语言
oracle_home=/u01/app/oracle/product/11.2.0/db_1    //oracle_home
oracle_base=/u01/app/oracle     //oracle_base
oracle.install.db.installedition=ee     // oracle版本
oracle.install.db.iscustominstall=false   //自定义安装,否,使用默认组件
oracle.install.db.dba_group=dba /  / dba用户组
oracle.install.db.oper_group=oinstall // oper用户组
oracle.install.db.config.starterdb.type=general_purpose //数据库类型
oracle.install.db.config.starterdb.globaldbname=orcl //globaldbname
oracle.install.db.config.starterdb.sid=dbsrv2      //sid
oracle.install.db.config.starterdb.memorylimit=81920 //自动管理内存的内存(m)
oracle.install.db.config.starterdb.password.all=oracle //设定所有数据库用户使用同一个密码
security_updates_via_myoraclesupport=false         //(手动写了false)
decline_security_updates=true   //设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。ps:不管地址对不对)

 -------------------------------------------------------------------------------------------------------------------------

 

运行静默安装

su -oracle

./runinstaller -silent -ignoresysprereqs -showprogress -responsefile  /u01/database/response/db_install.rsp

其中-silent指的是静默安装,-ignoreprereq忽略prerequisite的检查结果,showprogress显示进度,responsefile是种子文件。

查看安装日志

tail -f /u01/app/orainventory/logs/installactions2018-11-27_06-56-29pm.log

运行完成后,会让执行两个脚本

root用户执行以下两个脚本

/u01/app/orainventory/orainstroot.sh
/u01/app/oracle/product/11.2.0.4/db_1/root.sh

 

运行静默安装监听

netca.rsp在 /u01/app/database/response中

我因为是默认的,所以就没改

netca -silent -responsefile /u01/app/database/response/netca.rsp

 

 

静默安装库,需要修改项

vim /u01/database/response/dbca.rsp

 -------------------------------------------------------

responsefile_version = "10.0.0"
operation_type = "createdatabase"
gdbname = "ora11g"                                          //数据库全局名称
sid = "ora11g"             //这个sid 必须要和前面的/home/oracle/.bash_profile文件中的sid相同
templatename = "new_database.dbt"
syspassword = "oracle"                    //sys 用户的初始密码 
systempassword = "oracle"             //system 用户的初始密码 
datafiledestination ="/u01/app/oracle/oradata/"
recoveryareadestination="/u01/app/oracle/flash_recovery_area"
storagetype=fs
characterset = "zhs16gbk"          //数据库字符集(中文为 zhs16gbk ) 
memorypercentage = "40"
scriptdestination ="/u01/app/oracle/admin/ora10g/scripts"
emconfiguration=”local”
sysmanpassword = "system"
dbsnmppassword = "system"
其中最后1项不是必须的,这个的目的是在建立数据库的同时生成脚本。
下面就可以开始silent模式的数据库创建了。

----------------------------------------------------------------

 

dbca -silent -responsefile /u01/database/response/dbca.rsp

 执行后,如果出现清屏,请一定要检查,实例名、sys密码、system密码的正确性

 

如果出现错误:

sql> startup
ora-01081: cannot start already-running oracle - shut it down first

解决方法:

shutdown abort;

 

startup;

即可

 

 

 

 

 

 

 

 

 

 

 

 

shutdown abort;

startup;