CentOS7 静默安装Oracle 11gR2(11.2.0.1)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7 静默安装Oracle 11gR2(11.2.0.1)相关的知识,希望对你有一定的参考价值。
最近有个项目需要迁移,项目中数据库用的是oracle,期间折腾了好久,特此记录。
一,下载Oracle
1,首先下载Oracle 11gR2,地址如下:
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html?spm=a2c4e.11153940.blogcont566703.10.36ae6c23iChOrf
2,在页面上方勾选同意许可:
3,在下方选择对应的oracle版本,这里选择11gR2的linux x86_64版本:
一共有两个文件,注意下载前需要登录oracle账号,没有的话,注册一个就好。
下载完这两个包即可
linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
二,安装前检查
1,查看操作系统版本:
[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
2,查看内核版本:
[[email protected] ~]# uname -r
3.10.0-693.2.2.el7.x86_64
3,查看系统内存大小(oracle 11g官方建议物理内存在2G以上):
[[email protected] ~]# cat /proc/meminfo | grep MemTotal
MemTotal: 8010460 kB
4,检查防火墙是否开启:
[[email protected] ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: active (running) since Mon 2018-07-02 17:50:42 CST; 1s ago
Docs: man:firewalld(1)
Main PID: 20136 (firewalld)
CGroup: /system.slice/firewalld.service
└─20136 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
关闭防火墙:
[[email protected] ~]# systemctl stop firewalld
关闭自启动:
[[email protected] ~]# systemctl is-enabled firewalld
enabled
[[email protected] ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] ~]# systemctl is-enabled firewalld
disabled
5,关闭selinux:
[[email protected] ~]# sed -i ‘s#SELINUX=enforcing#SELINUX=disabled#g‘ /etc/sysconfig/selinux
[[email protected] ~]# setenforce 0
6,安装相关依赖包:
yum -y install binutils compat-libstdc++-33 compat-libcap1 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make elfutils-libelf-devel sysstat
7,设置/dev/shm空间:
[[email protected] ~]# vi /etc/fstab
在fstab文件中追加如下内容:
shmfs /dev/shm tmpfs size=7g 0 0
[[email protected] ~]# mount -a
[[email protected] ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 ext4 59G 3.8G 53G 7% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
shmfs tmpfs 7.0G 0 7.0G 0% /dev/shm
三,安装Oracle 11g
1,创建相关用户:
[[email protected] ~]# /usr/sbin/groupadd oinstall
[[email protected] ~]# /usr/sbin/groupadd dba
[[email protected] ~]# /usr/sbin/groupadd asmadmin
[[email protected] ~]# /usr/sbin/groupadd asmdba
[[email protected] ~]# /usr/sbin/useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
[[email protected] ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1001(dba),1003(asmdba)
[[email protected] ~]# passwd oracle
2,调整内核参数(编辑/etc/sysctl.conf,追加如下内容):
kernel.shmall = 2097152
kernel.shmmax = 4294967295
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6553600
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
#配置生效
[[email protected] ~]# sysctl -p
3,增加shell限制(编辑/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
修改/etc/pam.d/login文件
session required /lib/security/pam_limits.so
session required pam_limits.so
修改/etc/profile文件,追加如下内容:
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
4,创建必要的目录,并修改权限:
[[email protected] ~]# mkdir -p /home/app/oracle/
[[email protected] ~]# chown -R oracle:oinstall /home/app/
[[email protected] ~]# chmod -R 755 /home/app/
[[email protected] ~]# chown -R oracle:oinstall /home/oracle
[[email protected] ~]# chmod -R 775 /home/oracle
5,配置/etc/hosts文件:
10.56.90.212 oracle
6,配置oracle用户的环境变量:
[[email protected] ~]# su - oracle
[[email protected] ~]$ vi .bash_profile
#添加如下内容
export ORACLE_HOSTNAME=oracle
export ORACLE_UNQNAME=ora11g
export ORACLE_BASE=/home/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=ORCL
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export TMP=/tmp
export TMPDIR=$TMP
umask 022
7,解压oracle安装文件:
[[email protected] ~]$ unzip linux.x64_11gR2_database_1of2.zip
[[email protected] ~]$ unzip linux.x64_11gR2_database_2of2.zip
进入到database目录,并生成响应文件:
[[email protected] ~]$ mkdir scripts
[[email protected] ~]$ cp -R database/response/ scripts/
修改response目录中的db_install.rsp文件的参数:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=oracle
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/app/oracle/product/11.2.0
ORACLE_BASE=/home/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
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=ZHS16GBK
oracle.install.db.config.starterdb.memoryOption=true
oracle.install.db.config.starterdb.installExampleSchemas=false
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.automatedBackup.enable=false
8,开始静默安装数据库软件:
[[email protected] database]$ ./runInstaller -silent -responseFile /home/oracle/scripts/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 51039 MB Passed
Checking swap space: 0 MB available, 150 MB required. Failed <<<<
Some requirement checks failed. You must fulfill these requirements before
continuing with the installation,
这里有一个报错,提示swap不够,由于是阿里云的机器,默认没有swap空间,因此要手动创建:
[[email protected] ~]# dd if=/dev/zero of=/home/swapfile bs=1M count=2049
[[email protected] ~]# mkswap /home/swapfile
[[email protected] ~]# swapon /home/swapfile
再次执行静默安装,发现又有一个报错:
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-07-02_08-45-55PM. Please wait ...[[email protected] database]$ Exception in thread "main" java.lang.UnsatisfiedLinkError: /tmp/OraInstall2018-07-02_08-45-55PM/jdk/jre/lib/amd64/xawt/libmawt.so: libXext.so.6: cannot open shared object file: No such file or directory
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1647)
at java.lang.Runtime.load0(Runtime.java:769)
at java.lang.System.load(System.java:968)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1751)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1668)
at java.lang.Runtime.loadLibrary0(Runtime.java:822)
at java.lang.System.loadLibrary(System.java:993)
at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50)
at java.security.AccessController.doPrivileged(Native Method)
at java.awt.Toolkit.loadLibraries(Toolkit.java:1509)
at java.awt.Toolkit.<clinit>(Toolkit.java:1530)
at java.awt.Font.<clinit>(Font.java:141)
at oracle.sysman.oii.oiif.oiifo.OiifoOCMUI.<init>(OiifoOCMUI.java:104)
at oracle.sysman.oii.oiif.oiifo.OiifoOCMInterfaceManager.<init>(OiifoOCMInterfaceManager.java:79)
at oracle.sysman.oii.oiif.oiifo.OiifoOCMInterfaceManager.getInstance(OiifoOCMInterfaceManager.java:124)
at oracle.install.ivw.db.driver.DBInstaller.run(DBInstaller.java:123)
at oracle.install.commons.util.Application.startup(Application.java:869)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:164)
at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:265)
at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:114)
at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:132)
解决办法是安装libXext:
[[email protected] ~]# yum install libXext -y
看到如下信息时,表示数据库安装完成:
#!/bin/sh
#Root scripts to run
/home/app/oracle/oraInventory/orainstRoot.sh
/home/app/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用户):
[[email protected] ~]# sh /home/app/oracle/oraInventory/orainstRoot.sh
[[email protected] ~]$ more /etc/oraInst.loc
inventory_loc=/home/app/oracle/oraInventory
inst_group=oinstall
[[email protected] ~]# sh /home/app/oracle/product/11.2.0/root.sh
9,配置静默监听:
通过response文件运行netca, 生成sqlnet.ora和listener.ora文件, 位于$ORACLE_HOME/network/admin目录下
[[email protected] ~]$ netca -silent -responsefile /home/oracle/scripts/response/netca.rsp
这里可能会有一个报错:
****DISPLAY environment variable not set!
Oracle Net Configuration Assistant is a GUI tool
which requires that DISPLAY specify a location
where GUI tools can display.
Set and export DISPLAY, then re-run.
需要设置一个DISPLAY环境变量:
[[email protected] ~]$ export DISPLAY=10.66.90.222:0.0 #ip设为本机即可
配置好后查看端口,发现1521已监听:
[[email protected] ~]$ netstat -tnlp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 23795/tnslsnr
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
10,最后一步,静默建库。
修改response目录下的dbca.rsp文件:
SID = "ORCL"
开始静默建库:
[[email protected] ~]$ dbca -silent -responseFile /home/oracle/scripts/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 "/home/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
启动oracle:
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jul 2 21:53:11 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area 3273641984 bytes
Fixed Size 2217792 bytes
Variable Size 1795164352 bytes
Database Buffers 1459617792 bytes
Redo Buffers 16642048 bytes
Database mounted.
Database opened.
至此,oracle11g安装完成。
以上是关于CentOS7 静默安装Oracle 11gR2(11.2.0.1)的主要内容,如果未能解决你的问题,请参考以下文章
linux CentOS7最小化安装环境静默安装Oracle11GR2数据库(静默创建实例)