linux,CentOS7安装Oracle11g—静默安装,亲测有效
一、安装前准备工作:
1、下载Oracle安装包:linux.x64_11gR2_database_1of2.zip和 linux.x64_11gR2_database_2of2.zip
2、HostName修改:oracle
hostnamectl set-hostname oracle
3.关闭selinux:vi /etc/selinux/config,设置如下,重启系统reboot;
4.配置内核参数
[root@docker ~]# vim /etc/sysctl.conf
# System default settings live in /usr/lib/sysctl.d/00-system.conf.
# To override those settings, enter new settings here, or in an /etc/sysctl.d/<name>.conf file
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 7516192768 #7Gkernel.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
5.修改用户权限
#root用户
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
oracle hard stack 10240
5.在/etc/pam.d/login 文件中,使用文本编辑器或vi命令增加或修改以下内容
session required /lib64/security/pam_limits.so
session required pam_limits.so
6.在/etc/profile 文件中,使用文本编辑器或vi命令增加或修改以下内容
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
二、安装oracle主要步骤:
1.创建oracle用户,及用户组
2.配置oracle用户环境变量
3.修改安装Oracle软件的响应文件db_install.rsp,静默安装
4.静默dbca建库,编辑应答文件dbca.rsp
5.登陆数据库,测试是否安装成功
三、具体步骤
1.创建oracle用户,及用户组
#创建oinstall和dba组
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
#创建Oracle用户:-d /u01/oracle,将用户创建到/u01下,默认是在/home下
useradd -g oinstall -G dba oracle -d /u01/oracle
#设置oracle密码
passwd oracle
#验证创建及所属组是否正确:id oracle
#输出结果如下
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)
2.配置oracle用户环境变量
su - oracle
vim ~/.bash_profile
#添加如下内容,注意修改的是oracle用户的环境变量,su - oracle切换用户
export ORACLE_BASE=/u01/oracle/tools/oracle11g
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=orcl
export ORACLE_UNQNAME=orcl
export NLS_LANG=.AL32UTF8
export PATH=${PATH}:${ORACLE_HOME}/bin/:$ORACLE_HOME/lib64
#使配置生效
source ~/.bash_profile
3.修改安装Oracle软件的响应文件db_install.rsp
su - oracle
创建响应文件配置目录
mkdir -p /u01/oracle/etc
创建oracle安装目录
mkdir -p /u01/oracle/tools/oracle11g
#将下载的压缩文件解压到/u01/oracle目录下,解压完成后/u01/oracle目录下会生成一个database目录
unzip linux.x64_11gR2_database_1of2.zip -d /u01/oracle
unzip linux.x64_11gR2_database_2of2.zip -d /u01/oracle
#将/u01/oracle/database/response下dbca.rsp,db_install.rsp,netca.rsp的文件拷贝到/u01/oracle/etc下
cp /u01/oracle/database/response/* /u01/oracle/etc
#编辑/u01/oracle/etc下的db_install.rsp文件(注意要用oracle用户编辑)
vi /u01/oracle/etc/db_install.rsp
#在db_install.rsp中找到要修改的配置,db_install.rsp文件如下图
db_install.rsp中要修改的配置如下
oracle.install.option=INSTALL_DB_SWONLY // 安装类型
ORACLE_HOSTNAME=oracle// 主机名称(hostname查询)
UNIX_GROUP_NAME=oinstall // 安装组
INVENTORY_LOCATION=/u01/oracle/tools/oraInventory //INVENTORY目录(不填就是默认值)
SELECTED_LANGUAGES=en,zh_CN,zh_TW // 选择语言
ORACLE_HOME=/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1 //oracle_home
ORACLE_BASE=/u01/oracle/tools/oracle11g //oracle_base
oracle.install.db.InstallEdition=EE // oracle版本
oracle.install.db.EEOptionsSelection=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=orcl //SID
oracle.install.db.config.starterdb.memoryLimit=81920 //自动管理内存的内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle //设定所有数据库用户使用同一个密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //(手动写了false)
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/oracle/tools/oracle11g/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/oracle/tools/oracle11g/fast_recovery_area
DECLINE_SECURITY_UPDATES=true //设置安全更新(貌似是有bug,这个一定要选true,否则会无限提醒邮件地址有问题,终止安装。PS:不管地址对不对)
#用db_install.rsp开始静默安装oracle
su - oracle
cd /u01/oracle/database
./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /u01/oracle/etc/db_install.rsp
#安装完成,提示Successfully Setup Software.如下
==========================================================
/u01/oracle/tools/oraInventory/orainstRoot.sh
/u01/oracle/tools/oracle/oracle11g/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.
==========================================================
#退出oracle 用户,用root用户执行脚本。安装完后会在Successfully Setup Software上方出现执行脚本路径
exit
sh /u01/oracle/tools/oraInventory/orainstRoot.sh
sh /u01/oracle/tools/oracle/oracle11g/product/11.2.0/db_1/root.sh
4.静默dbca建库(创建orcl实例),编辑应答文件dbca.rsp (/u01/oracle/etc/dbca.rsp)
su - oracle
vi /u01/oracle/etc/dbca.rsp
GDBNAME="orcl.oracle" //大概在78行位置
SID="orcl" //大概在149行位置
SYSPASSWORD = "oracle" //大概在190行位置
SYSTEMPASSWORD = "oracle" //大概在200行位置
CHARACTERSET="AL32UTF8" //大概在415行位置
NATIONALCHARACTERSET="UTF8" //大概在425行位置
# 执行:
$ORACLE_HOME/bin/dbca -silent -responseFile /u01/oracle/etc/dbca.rsp
Enter SYS user password: oracle
Enter SYSTEM user password:oracle
执行结果如下
====================================================================
[oracle@docker ~]$$ORACLE_HOME/bin/dbca -silent -responseFile /u01/oracle/etc/dbca.rsp
Enter SYS user password:
Enter SYSTEM user password:
sh: /bin/ksh: No such file or directory
sh: /bin/ksh: No such file or directory
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
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file Look at the log file "/u01/oracle/tools/oracle11g/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
====================================================================
#若实例创建错误,删除实例命令:
$ORACLE_HOME/bin/dbca -silent -deleteDatabase -sourcedb orcl
#设置Oracle开机启动
vi /etc/oratab
orcl:/u01/oracle/tools/oracle11g/product/11.2.0/dbhome_1:Y # //把“N”改成“Y”
5.登陆数据库
su - oracle
sqlplus / as sysdba
# 启动oracle实例
SQL> startup
ORACLE instance started.
Total System Global Area 6680915968 bytes
Fixed Size 2213936 bytes
Variable Size 3892316112 bytes
Database Buffers 2751463424 bytes
Redo Buffers 34922496 bytes
Database mounted.
Database opened.
#启动成功