虚拟机静默安装oracle11g数据库+常见问题


由于参照了整合了几位前人的博客,具体细节处尚未处理,目前上传只是备忘

参照来源  http://blog.csdn.net/isaiah282485068/article/details/50329609

    https://www.cnblogs.com/zydev/p/5827207.html



linux安装oracle

 

下载路径 http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html;


http://blog.csdn.net/winewei/article/details/57409206?locationNum=4&fps=1;


http://download.csdn.net/download/huneyqq/7713011;


虚拟机网络配置:

注意几点:  1.首先是桥接模式  位于虚拟机设置里的网络适配器,勾选上就可以了

        2.其次是防火墙,虚拟机安装后开机时的防火墙默认是打开状态,几个指令就可以解决(systemctl stop firewalld.service   关闭防火墙   systemctl status firewalld   查看防火墙状态     systemctl  disable firewalld.service  禁止防火墙开机启动

        3.配置文件参数 :/etc/sysconfig/network-scripts/ifcfg-ens33   这里有几个参数需要注意

BOOTPROTO=none  //这里默认的设置会自动获取分配的ip地址,拿到个分配的地址后再设置成固定的ip

ONBOOT=yes  //一定要选择yes,否则无法ping通网络

//以下为手动配置ip时设置

IPADDR=192.168.1.164

PREFIX=24

GATEWAY=192.168.1.1

DNS1=192.168.1.1

网络配置好之后便可以联网并且可以用FTP及SecureCRT等软件进行连接


由于需要上传文件到虚拟机 首先将所需要的文件准备好

linux.x64_11gR2_database_1of2.zip  linux.x64_11gR2_database_2of2.zip

安装前的准备:

1.修改主机名

#sed -i"s/HOSTNAME=localhost.localdomain/HOSTNAME=oracledb.01/"/etc/sysconfig/network

2.添加主机名与IP对应记录

# vim /etc/hosts 

192.168.0.71 oracledb.01

3.关闭Selinux

#sed -i"s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config 

# setenforce 0


一.yum安装相关软件  总共31个包

检查:

[root@docker ~]# rpm -q binutils compat-libcap1compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devellibgcc libstdc++ libstdc++-devel libXi libXtst make sysstat  unixODBC unixODBC-devel

安装:

yum -y install binutils compat-libcap1compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-develglibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devellibgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devellibstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstatunixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

 

# 后跟命令表示以操作系统下root用户操作; 

$ 后跟命令表示以操作系统下oracle用户操作;


创建oinstall和dba组

/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba

创建oracle用户

/usr/sbin/useradd -g oinstall -G dba oracle

设置oracle用户密码

passwd oracle

验证创建是否正确

[root@docker ~]# id oracle
uid=1001(oracle) gid=1001(oinstall) groups=1001(oinstall),1002(dba)

 

配置内核参数

复制代码
[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/.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 = 536870912   #最低:536870912,最大值:比物理内存小1个字节的值,建议超过物理内存的一半
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 = 1048576
复制代码

参数的值不能小于上面的配置,这是oracle官方建议的最小值,生产环境建议调整这些参数,以优化系统性能。

修改后使之生效

/sbin/sysctl -p

 

修改用户限制

复制代码
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
复制代码
在/etc/pam.d/login 文件中,使用文本编辑器或vi命令增加或修改以下内容
session required /lib/security/pam_limits.so
session required pam_limits.so

在/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

 

创建安装目录

mkdir -p /u01/app/
chown -R oracle:oinstall /u01/app/
chmod -R 775 /u01/app/

 

配置环境变量

[oracle@docker ~]$ vim ~/.bash_profile 

export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=dbsrv2

使之生效

source ~/.bash_profile

解压oracle软件

[root@docker src]# unzip linux.x64_11gR2_database_1of2.zip
[root@docker src]# unzip linux.x64_11gR2_database_2of2.zip

此处可能出现没有指令的问题

#yum list | grep zip/unzip 

#yum installzip

#yum installunzip

基本完成,如果在编译的时候出现错误:gcc : error trying to exec 'cc1plus': execvp : No sunchfile or directory

可以用gcc -v/g++ -v来查看gcc 版本,会发现没有安装。安装如下:

#yum list | grepgcc

#yum installgcc-c++

#yum install unzip


复制响应文件模板

[oracle@docker ~]$ mkdir etc
[oracle@docker ~]$ cp  /usr/local/src/database/response/* /home/oracle/etc/
[oracle@docker ~]$ ls etc
dbca.rsp  db_install.rsp  netca.rsp

设置响应文件权限

[oracle@docker ~]$ su - root

[root@docker ~]# chmod 700 /home/oracle/etc/*.rsp

 

静默安装Oracle软件

su - oracle
修改安装Oracle软件的响应文件/home/oracle/etc/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:不管地址对不对)
复制代码

开始静默安装

[oracle@docker database]$ ./runInstaller -silent -responseFile /home/oracle/etc/db_install.rsp

查看安装日志

tail -f /u01/app/oraInventory/logs/installActions2016-08-31_06-56-29PM.log
出现类似如下提示表示安装完成:
------------------------------------------------------------------------

The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run

/u01/app/oraInventory/orainstRoot.sh
/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用户执行脚本
su - root
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/db_1/root.sh

增加或修改oracle的环境变量

复制代码
su  - oracle
vim ~/.bash_profile

#for oracle
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=dbsrv2
export ROACLE_PID=ora11g
#export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export PATH=$PATH:$ORACLE_HOME/bin

export LANG="zh_CN.UTF-8"
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'

复制代码

配置监听程序

复制代码

[oracle@docker ~]$ netca /silent /responsefile /home/oracle/etc/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/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@docker ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-SEP-2016 11:23:31

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

Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/docker/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=docker)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                01-SEP-2016 11:23:31
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/docker/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb.01)(PORT=1521)))
The listener supports no services
The command completed successfully
复制代码
此处可能会失败,有关于host的有三处必须设置成相同

通过response文件运行netca, 生成sqlnet.ora和listener.ora文件, 位于$ORACLE_HOME/network/admin目录下:

su - oracle

netca /silent /responsefile /home/oracle/etc/netca.rsp

ll $ORACLE_HOME/network/admin/*.ora

lsnrctl status

执行完后, 监听就已经启动了, 默认端口是1521, 默认是动态监听, 只要实例启动了就会监听到. 

 (此处注意监听所对应的hostname有三处都得相同,

一是主机名

sed -i"s/HOSTNAME=localhost.localdomain/HOSTNAME=oracledb.01/"/etc/sysconfig/network

二是修改listener.ora文件

$ vi/u01/app/oracle/product/12.1/db1/network/admin/listener.ora

# listener.oraNetwork Configuration File:/u01/app/oracle/product/12.1/db1/network/admin/listener.ora

# Generated byOracle configuration tools.

 

LISTENER =

 (DESCRIPTION_LIST =

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST = oracledb.01)(PORT = 1521))

     (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

    )

  )

 

三是HOST文件

$ vi /etc/hosts

#127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4

#::1        localhost localhost.localdomain localhost6 localhost6.localdomain6

127.0.0.1 localhostmwd

192.168.78.17 oracledb.01

 



静默dbca建库

编辑应答文件

复制代码
[oracle@docker ~]$ vi etc/dbca.rsp

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "dbsrv2"
SID = "dbsrv2"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "AL32UTF8"

复制代码

建库

复制代码
[oracle@docker ~]$ dbca -silent -responseFile 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/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
复制代码

查看输出日志

复制代码
[oracle@docker ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log
Copying database files
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
Creating and starting Oracle instance
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
Completing Database Creation
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
 /u01/app/oracle/cfgtoollogs/dbca/orcl11g.
Database Information:
Global Database Name:orcl11g.us.oracle.com
System Identifier(SID):dbsrv2
复制代码

 至此完成数据库实例的创建。




你可能感兴趣的:(虚拟机静默安装oracle11g数据库+常见问题)