RHEL6.5_x64上静默安装Oracle 11g R2
RHEL6.5_x64上静默安装Oracle 11g R2
测试Oracle 11g R2静默安装软件、静态配置监听、静态建库,环境是vmware平台虚拟机。
一、下载地址
http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html
Oracle 11g 联机文档:http://www.oracle.com/pls/db112/homepage
二、系统要求
操作系统:CetnOS6.2x64最小化安装,已配置好网络IP:172.16.2.182,物理内存8GB,硬盘100GB。
下载:linux.x64_11gR2_database_1of2.zip
linux.x64_11gR2_database_2of2.zip
数据库软件存放目录:/u01/app/
内存:1G(官方最低要求1G)
硬盘:40G(企业版安装所需4.29G和1.7G数据文件)
选择合适的操作系统版本
[root@dg01 ~]# cat /etc/issue
Red Hat Enterprise Linux Server release 6.5 (Santiago)
Kernel \r on an \m
尽量选择当前主流的操作系统,centos和redhat为主,版本可以选择5和6均可。
检查的命令:
内存
# grep MemTotal /proc/meminfo
交换空间
# grep SwapTotal /proc/meminfo
Swap分区和根目录:
其余的保证根分区适宜,然后在内存小于等于8gb,swap分区分配2倍的物理内存大小,在大于等于8gb时,直接分配16gb给swap分区即可。
存储阵列级别建议
尽量做成raid 0+1或者raid 1+0的存储方案,这个是处于安全性和性能方面考虑,如果由于磁盘数量不足也可以做成raid 5或者raid 1,raid 5的写入由于要进行基偶校验相比其他级别的阵列
较慢,如果将redo放到raid 5上面,而事务又比较频繁,经常会看见log file sync和log file parallel write两个等待事件成为性能瓶颈。
操作系统的分区
[root@dg01 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_dg01-lv_root
50G 2.4G 45G 6% /
tmpfs 3.9G 1.9G 2.1G 48% /dev/shm
/dev/sda1 485M 35M 425M 8% /boot
/dev/mapper/vg_dg01-lv_home
859G 12G 804G 2% /u01
/u01分区:
分区可以根据实际的磁盘容量来设置,尽量保证多余的容量分给/u01这个分区,因为如果没有外接的存储,会将数据库软件和数据库都存储在/u01这个目录下。
root用户登录后
# yum install vim unzip
# cd /u01/app
# unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
三、安装前系统准备
1、修改主机名
# hostname
# sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=server17.example.com/" /etc/sysconfig/network
# hostname server17.example.com
2、添加主机名与IP对应记录
# vim /etc/hosts
172.16.2.182 server17.example.com
3、关闭Selinux及防火墙
# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
# setenforce 0 //关闭selinux
# service iptables stop //临时关闭防火墙
4、安装必须的包
检查依赖
# rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel | grep 'not installed'
# yum -y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat elfutils-libelf elfutils-libelf-devel unixODBC unixODBC-deve
# rpm -q --queryformat \"%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n" binutils \
compat-libstdc++-33 compat-db control-center elfutils-libelf elfutils-libelf-devel gcc \
gcc-c++ glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ \
libstdc++-devel make sysstat unixODBC glibc-headers unixODBC-devel \
oracleasm oracleasmlib oracleasm-support \
pdksh sysstat xscreensaver | grep not | grep -v grep | awk '{print "yum install -y " $2 }'
5、准备安装用户及用户组
# groupadd oinstall
# groupadd dba
# useradd -g oinstall -G dba -d /home/oracle oracle
# echo "oracle" | passwd --stdin oracle //设置oracle密码
6、修改内核参数文件
# vim /etc/sysctl.conf //文件后追加
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
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 = 1048586
# /sbin/sysctl -p //使参数生效
# sysctl -a //检查参数是否正确
7、修改用户资源限制
# 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
保存文件。
8、修改用户验证
vim /etc/pam.d/login
session required /lib64/security/pam_limits.so //64位系统千万别写成/lib/security/pam_limits.so,否则导致无法登录
session required pam_limits.so
9、修改全局环境变量
vim /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
10、设置oracle用户环境变量
[oracle@oracledb ~]# su - oracle
[oracle@oracledb ~]$ vim ~/.bash_profile
# User specific environment and startup programs
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_TERM=xterm
export ORACLE_SID=orcl
export ORACLE_OWNER=oracle
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:/usr/sbin:/usr/local/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
umask 022
export EDITOR=/usr/bin/vim
alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'
alias dgmgrl='rlwrap dgmgrl'
[oracle@oracledb ~]$ source ~/.bash_profile
查看环境变量是否完成
[oracle@oracledb ~]$ env | grep ORA
ORACLE_BASE=/u01/app/oracle
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
创建/etc/oraInst.loc文件,内容如
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
更改文件的权限
chown oracle:oinstall /etc/oraInst.loc
chmod 664 /etc/oraInst.loc
11、修改静默安装响应文件
在/u01/app/database/response目录下有三个rsp文件,用来作为静默安装时应答文件的模板,三个文件作用分别是:
db_install.rsp //数据库安装应答文件
dbca.rsp //创建数据库应答文件
netca.rsp //建立监听、网络服务名应答文件
将create database段中内容设置好即可
[oracle@server17 ~]# su - Oracle
[oracle@server17 ~]$ cd /u01/app/database/response
[oracle@server17 response]$ grep -v \# db_install.rsp |grep -v ^$ > db_install_orcl.rsp
[oracle@server17 response]$ vim db_install_orcl.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
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.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
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.memoryLimit=1500
oracle.install.db.config.starterdb.installExampleSchemas=true
oracle.install.db.config.starterdb.enableSecuritySettings=true
oracle.install.db.config.starterdb.password.ALL=oracle
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY //安装类型 /*只装软件不装库*/
ORACLE_HOSTNAME= //主机名称(对应的主机名称,可利用hostname查询)
UNIX_GROUP_NAME=oinstall //安装组
INVENTORY_LOCATION=/u01/app/oraInventory //Inventory目录清单,必须在ORACLE_BASE路径以外
SELECTED_LANGUAGES=en,zh_CN //选择语言
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 //$ORACLE_HOMO
ORACLE_BASE=/u01/app/oracle //$ORACLE_BASE
oracle.install.db.InstallEdition=EE //Oracle版本
oracle.install.db.EEOptionsSelection=false
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.4.0,oracle.rdbms.rat:11.2.0.4.0 //保持系统默认值
oracle.install.db.DBA_GROUP=dba //dba用户组
oracle.install.db.OPER_GROUP=oinstall //oper用户组
oracle.install.db.CLUSTER_NODES=
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //数据库类型
oracle.install.db.config.starterdb.globalDBName=orcl //全局数据库名
oracle.install.db.config.starterdb.SID=orcl //SID
oracle.install.db.config.starterdb.characterSet=ZHS16GBK //数据库字符集
oracle.install.db.config.starterdb.memoryOption=true //是否自动管理内存
oracle.install.db.config.starterdb.memoryLimit=1500 //AMM内存的最小内存(M)
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.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL=
oracle.install.db.config.starterdb.automatedBackup.enable=false //是否开启自动备份
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE //存储类型
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_area
oracle.install.db.config.asm.diskGroup=
oracle.install.db.config.asm.ASMSNMPPassword=
MYORACLESUPPORT_USERNAME=
MYORACLESUPPORT_PASSWORD=
SECURITY_UPDATES_VIA_MYORACLESUPPORT=true
DECLINE_SECURITY_UPDATES=true //设置安全更新为true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
12、静默安装Oracle数据库软件
[oracle@server17 response]$ /u01/app/database/runInstaller -silent -force -ignorePrereq -ignoreSysPrereqs -responseFile /u01/app/database/response/db_install_orcl.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 23382 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4095 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2015-12-15_09-17-24PM. Please wait ...[oracle@server17 response]$ You can find the log of this install session at:
/u01/app/oraInventory/logs/installActions2015-12-15_09-17-24PM.log
各参数含义如下:
-silent 表示以静默方式安装,不做任何提示
-force 允许安装到一个非空目录
-noconfig 表示不运行配置助手netca
-responseFile 表示使用制定的响应文件,必需使用绝对路径
-ignorePrereq To ignore running the prerequisite checks. 如果哪块没有符合要求,不添加可能就安装不过去
-ignoreSysPrereqs For ignoring the results of the system pre-requisite checks.
注意:安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了。
开启一个新终端实时跟踪查看安装日志,了解软件安装进度
# tail -100f /u01/app/oracle/oraInventory/logs/installActions*.log
安装完后新开一个终端,以"root"身份依次执行以下脚本。
/u01/app/oracle/inventory/orainstRoot.sh
/u01/app/oracle/product/11.2.0/dbhome_1/root.sh
13、静默创建侦听
$ netca /silent /responseFile /u01/app/database/response/netca.rsp
正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /u01/app/database/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle Net Services 配置:
完成概要文件配置。
Oracle Net监听程序启动:
正在运行监听程序控制:
/u01/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
监听程序控制完成。
监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置。
成功运行后,在/u01/app/oracle/product/11.2.0/network/admin目录下生成sqlnet.ora和listener.ora两个文件。
查看监听状态
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2012 07:09:03
Copyright (c) 1991, 2009, Oracle. All rights reserved.
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 14-MAR-2012 06:16:50
Uptime 0 days 0 hr. 52 min. 15 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/11.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/oracle11gcentos6/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "orcl.dlxg.gov.cn" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.dlxg.gov.cn" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
通过命令查看
$ netstat -tlnp | grep 1521
tcp 0 0 :::1521 :::* LISTEN 5477/tnslsnr
说明监听器已经在1521端口上开始工作。
14、创建安装目录并设置文件权限
mkdir -p /u01/app/oracle/{oradata/orcl,fast_recovery_area/{orcl,ORCL/archivelog},admin/orcl/{{a,dp}dump,pfile,scripts}}
mkdir /u01/app/oradata_back
chown -R oracle:oinstall /u01/app
chmod -R 755 /u01/app
15、修改建库脚本(同时建立一个对应的实例)
修改静默建库脚本:
[oracle@server17 ~]$ cd /u01/app/database/response
[oracle@server17 ~]$ grep -v \# dbca.rsp |grep -v ^$ > dbca_orcl.rsp
[oracle@server17 ~]$ vim /u01/app/database/response/dbca.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0" //响应文件模板的版本,该参数不要更改
OPERATION_TYPE = "createDatabase" //安装类型,该参数不要更改
[CREATEDATABASE]
GDBNAME = "orcl" //全局数据库名,点号前面默认是db_name,点号后面默认就是db_domain
SID = "orcl" //实例名
TEMPLATENAME = "General_Purpose.dbc" //建库模板名,参考各模板定义:$ORACLE_HOME/assistants/dbca/templates/*.dbc
修改部分
SYSPASSWORD = "oracle" //SYS管理员密码
SYSTEMPASSWORD = "oracle" //SYSTEM管理员密码
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION = /u01/app/oracle/oradata //数据文件存放目录
RECOVERYAREADESTINATION= /u01/app/oracle/fast_recovery_area //恢复数据存放目录
STORAGETYPE=FS //数据库存储类型
CHARACTERSET = "ZHS16GBK" //数据库字符集,默认是WE8MSWIN1252
TOTALMEMORY = "1024" //实例内存,默认是服务器物理内存的40%
DATABASETYPE = "MULTIPURPOSE"
AUTOMATICMEMORYMANAGEMENT = "FALSE"
使用OEM需修改
EMCONFIGURATION="LOCAL"
SYSMANPASSWORD="oracle"
DBSNMPPASSWORD="oracle"
种子数据库和控制文件位于$ORACLE_HOME/assistants/dbca/templates/下,即Seed_Database.dfb和Seed_Database.ctl文件, 实际上建库就是基于通过rman恢复种子数据库和控制文件来实现
的。
16、静默方式创建数据库和实例
种子数据库和控制文件位于$ORACLE_HOME/assistants/dbca/templates/目录下, 即Seed_Database.dfb和Seed_Database.ctl文件, 实际上建库就是基于通过rman恢复种子数据库和控制文件来
实现的.
$ dbca -silent -responseFile /u01/app/database/response/dbca_orcl.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/ora11g/ora11g.log" for further details.
查看建库日志
$ cat /u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log
复制数据库文件
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 26%
DBCA_PROGRESS : 37%
正在创建并启动 Oracle 实例
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 55%
DBCA_PROGRESS : 56%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 62%
正在进行数据库创建
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 85%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
数据库创建完成。有关详细信息, 请查看以下位置的日志文件:/u01/app/oracle/cfgtoollogs/dbca/orcl。
数据库信息:
全局数据库名:orcl.dlxg.gov.cn
系统标识符 (SID):orcl
另外,附上静默删除数据库的命令
静默删库(可选)
1) 生成响应文件模板:
$ vim $DISTRIB/db_delete.rsp
#--------------------------------------------------------------------
#以下参数不能更改
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "deleteDatabase"
#以下参数根据实际情况更改
[DELETEDATABASE]
SOURCEDB = "ORCL"
#--------------------------------------------------------------------
2) dbca静默删库, 无需手工停库, 大概1分钟:
$ dbca -silent -responseFile /u01/app/database/response/db_delete.rsp
或
$ dbca -silent -deleteDatabase -sourceDB orcl -sysDBAUserName sys -sysDBAPassword "oracle"
各参数含义如下:
-silent 表示以静默方式删除
-responseFile 表示指定响应文件,必需使用绝对路径
RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改
OPERATION_TYPE 安装类型,该参数不要更改
SOURCEDB 数据库名,不是全局数据库名,即不包含db_domain
3)删除期间查看日志信息了解进度:
$ tail -100f $ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log
建库后实例检查:
$ ps -ef | grep ora_ | grep -v grep | wc -l
21
$ ps -ef | grep ora_ | grep -v grep
oracle 5955 1 0 07:03 ? 00:00:00 ora_pmon_orcl
oracle 5957 1 0 07:03 ? 00:00:00 ora_vktm_orcl
oracle 5961 1 0 07:03 ? 00:00:00 ora_gen0_orcl
oracle 5963 1 0 07:03 ? 00:00:00 ora_diag_orcl
oracle 5965 1 0 07:03 ? 00:00:00 ora_dbrm_orcl
oracle 5967 1 0 07:03 ? 00:00:00 ora_psp0_orcl
oracle 5969 1 0 07:03 ? 00:00:00 ora_dia0_orcl
oracle 5971 1 0 07:03 ? 00:00:00 ora_mman_orcl
oracle 5973 1 0 07:03 ? 00:00:00 ora_dbw0_orcl
oracle 5975 1 0 07:03 ? 00:00:00 ora_lgwr_orcl
oracle 5977 1 0 07:03 ? 00:00:00 ora_ckpt_orcl
oracle 5979 1 0 07:03 ? 00:00:00 ora_smon_orcl
oracle 5981 1 0 07:03 ? 00:00:00 ora_reco_orcl
oracle 5983 1 0 07:03 ? 00:00:00 ora_mmon_orcl
oracle 5985 1 0 07:03 ? 00:00:00 ora_mmnl_orcl
oracle 5987 1 0 07:03 ? 00:00:00 ora_d000_orcl
oracle 5989 1 0 07:03 ? 00:00:00 ora_s000_orcl
oracle 5999 1 0 07:03 ? 00:00:00 ora_qmnc_orcl
oracle 6020 1 0 07:03 ? 00:00:00 ora_cjq0_orcl
oracle 6022 1 0 07:04 ? 00:00:00 ora_q000_orcl
oracle 6024 1 0 07:04 ? 00:00:00 ora_q001_orcl
建库后监听检查
$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 14-MAR-2012 07:35:52
Copyright (c) 1991, 2009, Oracle. All rights reserved.
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 14-MAR-2012 07:35:38
Uptime 0 days 0 hr. 0 min. 13 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/oracle/11.2.0/network/admin/listener.ora
Listener Log File /opt/oracle/diag/tnslsnr/oracle11gCentOS6/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "orcl.dlxg.gov.cn" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.dlxg.gov.cn" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
实例被动态注册到监听程序了.
如果未被动态注册到监听程序, 则可以手工注册:
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Sep 16 11:11:46 2009
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> alter system register;
17、开启归档模式、开启闪回功能(只有在归档模式下才能热备份及增量备份)
$ export Oracle_SID=orcl
$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 14 07:18:16 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name,open_mode,status from v$database,v$instance;
NAME OPEN_MODE STATUS
--------- -------------------- ------------
ORCL READ WRITE OPEN
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2213776 bytes
Variable Size 402655344 bytes
Database Buffers 1191182336 bytes
Redo Buffers 7360512 bytes
Database mounted.
SQL> select log_mode,flashback_on from v$database;
LOG_MODE FLASHBACK_ON
------------ ------------------
NOARCHIVELOG NO
SQL> alter database archivelog;
alter database flashback on;
SQL> select log_mode,flashback_on from v$database;
LOG_MODE FLASHBACK_ON
------------ ------------------
ARCHIVELOG YES
SQL> alter database open;
Database altered.
SQL> execute utl_recomp.recomp_serial(); //重新编译所有可能失效对象
PL/SQL procedure successfully completed.
SQL> alter system archive log current; //手工归档
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 2
Next log sequence to archive 4
Current log sequence 4
SQL> alter system archive log current;
System altered.
检查安装的默认数据库用户:
SQL> set lines 256 pages 500
SQL> select USER_ID,USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users order by 1;
USER_ID USERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE
---------- ------------------------------ -------------------------------- ------------------------------
0 SYS OPEN SYSTEM
5 SYSTEM OPEN SYSTEM
9 OUTLN EXPIRED & LOCKED SYSTEM
14 DIP EXPIRED & LOCKED USERS
21 ORACLE_OCM EXPIRED & LOCKED USERS
30 DBSNMP EXPIRED & LOCKED SYSAUX
31 APPQOSSYS EXPIRED & LOCKED SYSAUX
32 WMSYS EXPIRED & LOCKED SYSAUX
42 EXFSYS EXPIRED & LOCKED SYSAUX
43 CTXSYS EXPIRED & LOCKED SYSAUX
45 XDB EXPIRED & LOCKED SYSAUX
46 ANONYMOUS EXPIRED & LOCKED SYSAUX
53 ORDSYS EXPIRED & LOCKED SYSAUX
54 ORDDATA EXPIRED & LOCKED SYSAUX
55 ORDPLUGINS EXPIRED & LOCKED SYSAUX
56 SI_INFORMTN_SCHEMA EXPIRED & LOCKED SYSAUX
57 MDSYS EXPIRED & LOCKED SYSAUX
61 OLAPSYS EXPIRED & LOCKED SYSAUX
65 MDDATA EXPIRED & LOCKED USERS
67 SPATIAL_WFS_ADMIN_USR EXPIRED & LOCKED USERS
70 SPATIAL_CSW_ADMIN_USR EXPIRED & LOCKED USERS
72 SYSMAN EXPIRED & LOCKED SYSAUX
74 MGMT_VIEW EXPIRED & LOCKED SYSTEM
75 FLOWS_FILES EXPIRED & LOCKED SYSAUX
76 APEX_PUBLIC_USER EXPIRED & LOCKED USERS
78 APEX_030200 EXPIRED & LOCKED SYSAUX
79 OWBSYS EXPIRED & LOCKED SYSAUX
83 OWBSYS_AUDIT EXPIRED & LOCKED SYSAUX
84 SCOTT EXPIRED & LOCKED USERS
2147483638 XS$NULL EXPIRED & LOCKED USERS
30 rows selected.
检查默认安装的组件:
SQL> col COMP_ID format a8
col COMP_NAME format a35
col VERSION format a12
col schema format a12
col OTHER_SCHEMAS format a45
SQL> select comp_id,comp_name,version,schema,other_schemas from dba_registry order by 1;
COMP_ID COMP_NAME VERSION SCHEMA OTHER_SCHEMAS
-------- ----------------------------------- ------------ ------------ ---------------------------------------------
AMD OLAP Catalog 11.2.0.1.0 OLAPSYS
APEX Oracle Application Express 3.2.1.00.10 APEX_030200 FLOWS_FILES
APS OLAP Analytic Workspace 11.2.0.1.0 SYS
CATALOG Oracle Database Catalog Views 11.2.0.1.0 SYS
CATJAVA Oracle Database Java Packages 11.2.0.1.0 SYS
CATPROC Oracle Database Packages and Types 11.2.0.1.0 SYS APPQOSSYS,DBSNMP,DIP,ORACLE_OCM,OUTLN,SYSTEM
CONTEXT Oracle Text 11.2.0.1.0 CTXSYS
EM Oracle Enterprise Manager 11.2.0.1.0 SYSMAN
EXF Oracle Expression Filter 11.2.0.1.0 EXFSYS
JAVAVM JServer JAVA Virtual Machine 11.2.0.1.0 SYS
ORDIM Oracle Multimedia 11.2.0.1.0 ORDSYS MDSYS,ORDDATA,ORDPLUGINS,SI_INFORMTN_SCHEMA
OWB OWB 11.2.0.1.0 OWBSYS
OWM Oracle Workspace Manager 11.2.0.1.0 WMSYS
RUL Oracle Rules Manager 11.2.0.1.0 EXFSYS
SDO Spatial 11.2.0.1.0 MDSYS
XDB Oracle XML Database 11.2.0.1.0 XDB ANONYMOUS,XS$NULL
XML Oracle XDK 11.2.0.1.0 SYS
XOQ Oracle OLAP API 11.2.0.1.0 SYS
18 rows selected.
查看是否正常
SQL> show parameter;
或
SQL> select table_name from dba_tables;
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
18、修改oracle启动配置文件
$ vim /etc/oratab
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:Y
这样就可以通过dbstart启动此实例,也可以通过dbshut关闭此实例了。
$ dbshut $ORACLE_HOME
Processing Database instance "orcl": log file /opt/oracle/11.2.0/shutdown.log
此时所有oracle的进程关闭,监听器也停止。
$ dbstart $ORACLE_HOME
Processing Database instance "orcl": log file /opt/oracle/11.2.0/startup.log
19、建立表空间及用户
$ export Oracle_SID=orcl;
$ sqlplus / as sysdba
创建临时表空间
SQL> create temporary tablespace user_temp tempfile '/u01/app/oracle/oradata/orcl/user_temp.dbf' size 100m autoextend on next 50m maxsize 20480m extent management local;
创建数据表空间
SQL> create tablespace user_data logging datafile '/u01/app/oracle/oradata/orcl/user_data.dbf' size 100m autoextend on next 50m maxsize 20480m extent management local;
创建用户并指定默认表空间
SQL> create user test identified by "oracle" default tablespace user_data temporary tablespace user_temp;
给用户授予权限
SQL> grant connect,resource to test;
在其他机器上远程登录此用户:
$ sqlplus test/oracle@192.168.4.17/orcl
20、用新建的用户连接数据库,并建立一个表
$ export NLS_LANG=American_America.AL32UTF8
注意:UTF8是为了使得sqlplus和linux终端环境一致起来,此时发往数据库的是UTF8,数据库存储前会转为ZHS16GBK.
当读取时,Sqlplus会把收到的ZHS16GBK转换为UTF8发送到Linux终端。
$ sqlplus test/oracle@192.168.4.17/orcl
SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 14 08:22:11 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> create table STUDENT (ID int,NAME varchar(20));
Table created.
SQL> insert into STUDENT values(1,'张三');
1 row created.
SQL> select * from student;
ID NAME
---------- --------
1 张三
21、使用OEM管理和监控数据库,需要启动dbconsole,如下:
$ emctl start dbconsole
报这种错误:出现如下错误:
Environment variable ORACLE_UNQNAME not defined. Please set ORACLE_UNQNAME to database unique name.
据网上说ORACLE_UNQNAME就是ORACL_SID,但$ export ORACLE_SID=xxx设置后重新运行还是不行,不过报的是另外的错。
根据网上解决方法,可以重新创建 EM 资料档案库:
一、首先尝试重建试下
尝试解决步骤:
1、修改DBSNMP密码:
重新配置DBCONSOLE,需要输入DBSNMP密码,但任何密码都会显示错误,需要预先修改。
sql> alter user dbsnmp identified by xxx;
2、删除早期DBCONSOLE创建的用户:
sql> drop role MGMT_USER;
sql> drop user MGMT_VIEW cascade;
sql> drop user sysman cascade;
3、删除早期DBCONSOLE创建的对象:
sql> drop PUBLIC SYNONYM MGMT_TARGET_BLACKOUTS;
sql> drop public synonym SETEMVIEWUSERCONTEXT;
$ emca -config dbcontrol db -repos create
按照提示做下去,一般会成功创建新资料档案库的,如果还是报错。
查看日志发现如下错误:
oracle.sysman.assistants.util.sqlEngine.SQLFatalErrorException: ORA-00955:nameis already used by an existing object
二、接下来使用如下方法:
Drop the Repository using RepManager:
例 如:
$ cd /u01/app/oracle/product/11.2.0/dbhome_1/sysman/admin/emdrep/bin
$ ./RepManager bobower 1521 racl -action drop
三、最后再重新建库
$ emca -config dbcontrol db -repos create
这样基本就是搞定了。
最后启动em
$ emctl start dbconsole
$ netstat -tunpl |grep 1158
通过用浏览器访问https://hostname(或IP):1158/em登陆。
至此,已经成功创建了ORCL 数据库。
========================================================================================================================================================================
下面以SYS 用户连接数据库并执行以下SQL 文件中的代码:
@$ORACLE_HOME/rdbms/admin/catalog.sql
@$ORACLE_HOME/rdbms/admin/catproc.sql
@$ORACLE_HOME/rdbms/admin/catblock.sql
@$ORACLE_HOME/rdbms/admin/catoctk.sql
@$ORACLE_HOME/rdbms/admin/owminst.plb
以SYSTEM 用户连接数据库并执行以下SQL 文件:
conn system/oracle
@$ORACLE_HOME/sqlplus/admin/pupbld.sql
@$ORACLE_HOME/sqlplus/admin/help/hlpbld.sql helpus.sql
以SYS 用户登录并执行以下SQL 脚本:
conn sys/oracle as sysdba;
@$ORACLE_HOME/javavm/install/initjvm.sql;
@$ORACLE_HOME/xdk/admin/initxml.sql;
@$ORACLE_HOME/xdk/admin/xmlja.sql;
@$ORACLE_HOME/rdbms/admin/catjava.sql;
@$ORACLE_HOME/rdbms/admin/catexf.sql;
以SYS 用户连接并执行以下:
@$ORACLE_HOME/rdbms/admin/dminst.sql SYSAUX TEMP;
@$ORACLE_HOME/ctx/admin/catctx change_on_install SYSAUX TEMP NOLOCK;
alter user CTXSYS identified by change_on_install account unlock;
connect "CTXSYS"/"change_on_install"
@$ORACLE_HOME/ctx/admin/defaults/dr0defin.sql "AMERICAN";
以SYS 用户连接并执行以下:
@$ORACLE_HOME/rdbms/admin/catqm.sql change_on_install SYSAUX TEMP;
connect / as SYSDBA
@$ORACLE_HOME/rdbms/admin/catxdbj.sql;
@$ORACLE_HOME/rdbms/admin/catrul.sql;
以SYS 用户连接并执行以下:
@$ORACLE_HOME/ord/admin/ordinst.sql SYSAUX SYSAUX;
以SYS 用户连接并执行以下:
@$ORACLE_HOME/ord/im/admin/iminst.sql;
以SYS 用户连接并执行以下:
@$ORACLE_HOME/olap/admin/olap.sql SYSAUX TEMP;
以SYS 用户连接并执行以下:
@$ORACLE_HOME/md/admin/mdinst.sql;
以SYS 用户连接并执行以下:
@$ORACLE_HOME/sysman/admin/emdrep/sql/emreposcre $ORACLE_HOME SYSMAN &&sysmanPassword TEMP ON;
WHENEVER SQLERROR CONTINUE;
以SYS 用户连接并执行以下:
Create spfile='$ORACLE_HOME/dbs/spfileorcl.ora' FROM pfile='/home/oracle/initorcl.ora';
shutdown immediate;
connect "SYS"/"&&sysPassword" as SYSDBA
startup ;
alter user SYSMAN identified by "&&sysmanPassword" account unlock;
alter user DBSNMP identified by "&&dbsnmpPassword" account unlock;
select 'utl_recomp_begin: ' || to_char(sysdate, 'HH:MI:SS') from dual;
execute utl_recomp.recomp_serial();
select 'utl_recomp_end: ' || to_char(sysdate, 'HH:MI:SS') from dual;
host $ORACLE_HOME/bin/emca -config dbcontrol db -silent -DB_UNIQUE_NAME orcl -PORT 1521 -EM_HOME $ORACLE_HOME -LISTENER LISTENER -SERVICE_NAME orcl.ocp10g
-SYS_PWD &&sysPassword -SID orcl -ORACLE_HOME $ORACLE_HOME -DBSNMP_PWD &&dbsnmpPassword -HOST OCP10g -LISTENER_OH $ORACLE_HOME
-LOG_FILE $ORACLE_BASE/admin/orcl/scripts/emConfig.log -SYSMAN_PWD &&sysmanPassword;
========================================================================================================================================================================
22、查看数据库字符集
1)、数据库服务器字符集,其来源于props$,是表示数据库的字符集。
SQL> select * from nls_database_parameters
客户端字符集环境,其来源于v$parameter,表示客户端的字符集的设置,可能是参数文件,环境变量或者是注册表
SQL> select * from nls_instance_parameters
会话字符集环境,表示会话自己的设置,可能是会话的环境变量或者是alter session完成,如果会话没有特殊的设置,将与nls_instance_parameters一致。
SQL> select * from nls_session_parameters,其来源于v$nls_parameters
2)、客户端的字符集要求与服务器一致,才能正确显示数据库的非Ascii字符。如果多个设置存在的时候,alter session>环境变量>注册表>参数文件
字符集要求一致,但是语言设置却可以不同,语言设置建议用英文。如字符集是zhs16gbk,则nls_lang可以是American_America.zhs16gbk。
涉及三方面的字符集,
1. oracel server端的字符集;
2. oracle client端的字符集;
3. dmp文件的字符集。
在做数据导入的时候,需要这三个字符集都一致才能正确导入。
23、修改Linux数据库字符集以及客户端相关问题
如果Linux能够利用sqlplus / as sysdba 显示SQL> 表示数据库已经安装成功,但是由于安装的时候使用的是AL32UTF8需要改为ZHS16GBK
SQL> conn /as sysdba (sqlplus / as sysdba)
SQL> shutdown immediate; (如果无反应shutdown abort)
SQL> startup mount
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;
SQL> alter database open;
SQL> ALTER DATABASE CHARACTER SET AL32UTF8;
ORA-12712: new character set must be a superset of old character set
提示我们的字符集:新字符集必须为旧字符集的超集,这时我们可以跳过超集的检查做更改:
SQL> ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;
--我们看到这个过程和之前ALTER DATABASE CHARACTER SET操作的内部过程是完全相同的,也就是说INTERNAL_USE提供的帮助就是使Oracle数据库绕过了子集与超集的校验.
SQL> shutdown immediate;
SQL> startup
以后安装oracle的时候记得选择自定义安装,把这个字符集的事情事先弄好。
涉及三方面的字符集,
1. oracel server端的字符集;
2. oracle client端的字符集;
3. dmp文件的字符集。
在做数据导入的时候,需要这三个字符集都一致才能正确导入。
查询oracle server端的字符集
SQL> select userenv('language') from dual;
客户端添加环境变量NLS_LANG。
AMERICAN_AMERICA.ZHS16GBK
$ echo "NLS_LANG=AMERICAN_AMERICA.ZHS16GBK" >> .bash_profile
$ echo NLS_LANG
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Oracle 11g使用DBCA以非交互(静默)方式创建数据库
通过执行dbca -h | -help来查看帮助选项
[Oracle@jyrac1 ~]$ dbca -help
dbca [-silent | -progressOnly | -customCreate] { } | { [ [options] ] -responseFile } [-continueOnNonFatalErrors]
Please refer to the manual for details.
You can enter one of the following command:
创建一个数据库:
Create a database by specifying the following parameters:
-createDatabase
-templateName 现有模板的名称
[-cloneTemplate]
-gdbName 全局数据库名
[-policyManaged | -adminManaged ]
[-createServerPool ]
[-force ]
-serverPoolName
-[cardinality ]
[-sid ] 数据库系统标识符
[-sysPassword ]
[-systemPassword ]
[-emConfiguration
-dbsnmpPassword
-sysmanPassword
[-hostUserName
-hostUserPassword
-backupSchedule ]
[-smtpServer
-emailAddress ]
[-centralAgent ]]
[-disableSecurityConfiguration
[-datafileDestination 所有数据文件的目标位置 | -datafileNames ]
[-redoLogFileSize ]
[-recoveryAreaDestination ]
[-datafileJarLocation ] 数据文件jar的位置,只用于复制数据库的创建
[-storageType < FS | ASM >
[-asmsnmpPassword ]
-diskGroupName
-recoveryGroupName
[-characterSet ] 数据库的字符集
[-nationalCharacterSet ] 数据库的国家字符集
[-registerWithDirService
-dirServiceUserName 目录服务的用户名
-dirServicePassword 目录服务的口令
-walletPassword ]
[-listeners ] 监听程序列表,该列表用于配置具有如下对象的数据库
[-variablesFile ]] 用于模板中成对变量和值的文件名
[-variables ]
[-initParams ]
[-memoryPercentage ]
[-automaticMemoryManagement ]
[-totalMemory ]
[-databaseType ]]
配制一个数据库:
Configure a database by specifying the following parameters:
-configureDatabase
-sourceDB
[-sysDBAUserName
-sysDBAPassword ]
[-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword
-dirServiceUserName
-dirServicePassword
-walletPassword ]
[-disableSecurityConfiguration
[-enableSecurityConfiguration
[-emConfiguration
-dbsnmpPassword
-symanPassword
[-hostUserName
-hostUserPassword
-backupSchedule ]
[-smtpServer
-emailAddress ]
[-centralAgent ]]
从一个已存在的数据库上创建一个模板:
Create a template from an existing database by specifying the following parameters:
-createTemplateFromDB
-sourceDB ::> < 服务采用 :: 格式
-templateName 新的模板名
-sysDBAUserName 具有SYSDBA权限的用户名
-sysDBAPassword 具有SYSDBA权限的用户名的口令
[-maintainFileLocations ]
使用现有数据库上创建一个复制模板:
Create a clone template from an existing database by specifying the following parameters:
-createCloneTemplate
-sourceSID 源数据库sid
-templateName 新的模板名
[-sysDBAUserName 具有SYSDBA权限的用户名
-sysDBAPassword ] 具有SYSDBA权限的用户名的口令
[-maintainFileLocations ]
[-datafileJarLocation ] 存放压缩格式数据文件的目录
为创建的数据库生成一个脚本:
Generate scripts to create database by specifying the following parameters:
-generateScripts
-templateName
-gdbName
[-scriptDest ]
通过指定参数来删除数据库
Delete a database by specifying the following parameters:
-deleteDatabase
-sourceDB
[-sysDBAUserName
-sysDBAPassword ]
使用silent模式可以通过数据库创建模板和通过模板来创建数据库
通过模板来创建数据库
[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname orcl -sid orcl -responseFile NO_VALUE -characterSet ZHS16GBK -memoryPercentage 30 -emConfiguration LOCAL
Enter SYS user password:
Enter SYSTEM user password:
Enter DBSNMP user password:
Enter SYSMAN user password:
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/ora11g/ora11g.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.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/orcl/orcl.log
Database Information:
Global Database Name:orcl
System Identifier(SID):ora11gThe Database Control URL is https://jyrac1:5500/em
Management Repository has been placed in secure mode wherein Enterprise Manager data will be encrypted.
The encryption key has been placed in the file: /u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman/config/emkey.ora. Please ensure this file is backed up as the encrypted
data will become unusable if this file is lost.
数据库创建成功执行下面命令查看orcl的进程信息
[Oracle@jyrac1 ~]$ ps -ef | grep orcl
oracle 6014 1 0 09:42 pts/1 00:00:00 /u01/app/oracle/11.2.0/db/perl/bin/perl /u01/app/oracle/11.2.0/db/bin/emwd.pl dbconsole /u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman/log/emdb.nohup
oracle 6032 6014 4 09:42 pts/1 00:00:44 /u01/app/oracle/11.2.0/db/jdk/bin/java -server -Xmx384M -XX:MaxPermSize=400M -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -DORACLE_HOME=/u01/app/oracle/11.2.0/db -Doracle.home=/u01/app/oracle/11.2.0/db/oc4j -Doracle.oc4j.localhome=/u01/app/oracle/11.2.0/db/jyrac1_ora11g/sysman -DEMSTATE=/u01/app/oracle/11.2.0/db/jyrac1_ora11g -Doracle.j2ee.dont.use.memory.archive=true -Djava.protocol.handler.pkgs=HTTPClient -Doracle.security.jazn.config=/u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/jazn.xml -Djava.security.policy=/u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/java2.policy -Djavax.net.ssl.KeyStore=/u01/app/oracle/11.2.0/db/sysman/config/OCMTrustedCerts.txt-Djava.security.properties=/u01/app/oracle/11.2.0/db/oc4j/j2ee/home/config/jazn.security.props -DEMDROOT=/u01/app/oracle/11.2.0/db/jyrac1_ora11g -Dsysman.md5password=true -Drepapi.oracle.home=/u01/app/oracle/11.2.0/db -Ddisable.checkForUpdate=true -Doracle.sysman.ccr.ocmSDK.websvc.keystore=/u01/app/oracle/11.2.0/db/jlib/emocmclnt.ks -Dice.pilots.html4.ignoreNonGenericFonts=true -Djava.awt.headless=true -jar /u01/app/oracle/11.2.0/db/oc4j/j2ee/home/oc4j.jar -config /u01/app/oracle/11.2.0/db/oc4j/j2ee/OC4J_DBConsole_jyrac1_ora11g/config/server.xml
oracle 6083 1 1 09:42 ? 00:00:11 oracleora11g (LOCAL=NO)
oracle 6132 1 0 09:42 ? 00:00:02 oracleora11g (LOCAL=NO)
oracle 6220 1 0 09:43 ? 00:00:00 oracleora11g (LOCAL=NO)
oracle 6466 1 0 09:43 ? 00:00:00 oracleora11g (LOCAL=NO)
oracle 6468 1 0 09:43 ? 00:00:00 oracleora11g (LOCAL=NO)
oracle 6480 1 0 09:43 ? 00:00:02 oracleora11g (LOCAL=NO)
oracle 6658 1 0 09:43 ? 00:00:01 oracleora11g (LOCAL=NO)
oracle 6664 1 1 09:43 ? 00:00:12 oracleora11g (LOCAL=NO)
oracle 6718 1 0 09:43 ? 00:00:00 oracleora11g (LOCAL=NO)
oracle 6720 1 0 09:43 ? 00:00:00 oracleora11g (LOCAL=NO)
oracle 8954 1 0 09:58 ? 00:00:00 ora_j000_ora11g
oracle 8956 1 0 09:58 ? 00:00:00 ora_j001_ora11g
oracle 8962 29918 0 09:59 pts/1 00:00:00 grep ora11g
oracle 31058 1 0 09:40 ? 00:00:00 ora_pmon_ora11g
oracle 31060 1 0 09:40 ? 00:00:00 ora_vktm_ora11g
oracle 31064 1 0 09:40 ? 00:00:00 ora_gen0_ora11g
oracle 31066 1 0 09:40 ? 00:00:00 ora_diag_ora11g
oracle 31068 1 0 09:40 ? 00:00:00 ora_dbrm_ora11g
oracle 31070 1 0 09:40 ? 00:00:00 ora_psp0_ora11g
oracle 31072 1 0 09:40 ? 00:00:00 ora_dia0_ora11g
oracle 31074 1 0 09:40 ? 00:00:00 ora_mman_ora11g
oracle 31076 1 0 09:40 ? 00:00:00 ora_dbw0_ora11g
oracle 31078 1 0 09:40 ? 00:00:00 ora_lgwr_ora11g
oracle 31080 1 0 09:40 ? 00:00:00 ora_ckpt_ora11g
oracle 31082 1 0 09:40 ? 00:00:00 ora_smon_ora11g
oracle 31084 1 0 09:40 ? 00:00:00 ora_reco_ora11g
oracle 31086 1 0 09:40 ? 00:00:00 ora_mmon_ora11g
oracle 31088 1 0 09:40 ? 00:00:00 ora_mmnl_ora11g
oracle 31090 1 0 09:40 ? 00:00:00 ora_d000_ora11g
oracle 31092 1 0 09:40 ? 00:00:00 ora_s000_ora11g
oracle 31161 1 0 09:40 ? 00:00:00 ora_qmnc_ora11g
oracle 31177 1 0 09:40 ? 00:00:00 ora_cjq0_ora11g
oracle 31262 1 0 09:40 ? 00:00:00 ora_q000_ora11g
oracle 31264 1 0 09:40 ? 00:00:00 ora_q001_ora11g
oracle 31344 1 0 09:41 ? 00:00:00 ora_smco_ora11g
oracle 31346 1 0 09:41 ? 00:00:00 ora_w000_ora11g
以silent方式来删除数据库
[oracle@jyrac1 ~]$ dbca -silent -deleteDatabase -sourceDB orcl -sysDBAUserName sys -sysDBAPassword oracle
Connecting to database
4% complete
9% complete
14% complete
19% complete
23% complete
28% complete
47% complete
Updating network configuration files
48% complete
52% complete
Deleting instance and datafiles
76% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/orcl/orcl.log
The Database Configuration Assistant will delete the Oracle instance and datafiles for your database. All information in the database will be destroyed. Do you want to proceed?
Connecting to database
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 14%
DBCA_PROGRESS : 19%
DBCA_PROGRESS : 23%
DBCA_PROGRESS : 28%
DBCA_PROGRESS : 47%
Updating network configuration files
DBCA_PROGRESS : 48%
DBCA_PROGRESS : 52%
Deleting instance and datafiles
DBCA_PROGRESS : 76%
DBCA_PROGRESS : 100%
Database deletion completed.
删除数据库后执行下面的命令来查看ora11g进程信息发现没有了
[oracle@jyrac1 ~]$ ps -ef | grep orcl
oracle 11194 29918 0 10:05 pts/1 00:00:00 grep orcl
[oracle@jyrac1 ~]$ ps -ef | grep pmon
oracle 9288 1 0 Apr04 ? 00:00:07 ora_pmon_jycs
oracle 11285 29918 0 10:06 pts/1 00:00:00 grep pmon
使用现有数据库来创建模板
[oracle@jyrac1 ~]$ dbca -silent -createTemplateFromDB -sourceDB jycs -templateName jycstemplate -sysDBAUserName sys -sysDBAPassword zzh_2046
Creating a template from the database
10% complete
20% complete
30% complete
40% complete
50% complete
60% complete
70% complete
80% complete
90% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/silent.log
Creating a template from the database
DBCA_PROGRESS : 10%
DBCA_PROGRESS : 20%
DBCA_PROGRESS : 30%
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 60%
DBCA_PROGRESS : 70%
DBCA_PROGRESS : 80%
DBCA_PROGRESS : 90%
DBCA_PROGRESS : 100%
The template "jycstemplate" creation completed.
[oracle@jyrac1 templates]$ ls -lrt /u01/app/oracle/11.2.0/db/assistants/dbca/templates
total 285632
-rw-r--r-- 1 oracle oinstall 11492 Feb 25 2009 New_Database.dbt
-rw-r--r-- 1 oracle oinstall 5106 Aug 15 2009 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall 4986 Aug 15 2009 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 258654208 Aug 15 2009 Seed_Database.dfb
-rwxr-xr-x 1 oracle oinstall 9748480 Aug 15 2009 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall 1179648 Aug 15 2009 example.dmp
-rwxr-xr-x 1 oracle oinstall 22544384 Aug 15 2009 example01.dfb
-rw-r----- 1 oracle oinstall 5124 Mar 24 13:31 jycs.dbc
-rw-r----- 1 oracle oinstall 13476 Apr 8 10:12 jycstemplate.dbt
使用现有数据库创建带数据文件的模板
[oracle@jyrac1 ~]$ dbca -silent -createCloneTemplate -sourceDB jycs -templateName jycsCloneTemplate -sysDBAUserName sys -sysDBAPassword zzh_2046 -datafileJarLocation /u01/app/oracle/11.2.0/db/assistants/dbca/templates
Gathering information from the source database
4% complete
8% complete
13% complete
17% complete
22% complete
Backup datafiles
28% complete
88% complete
Creating template file
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/silent0.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/silent0.log
Gathering information from the source database
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 8%
DBCA_PROGRESS : 13%
DBCA_PROGRESS : 17%
DBCA_PROGRESS : 22%
Backup datafiles
DBCA_PROGRESS : 28%
DBCA_PROGRESS : 88%
Creating template file
DBCA_PROGRESS : 100%
The generation of the clone database template "jycsCloneTemplate" is successful.
查看生成的模板文件
[Oracle@jyrac1 templates]$ ls -lrt
total 621628
-rw-r--r-- 1 oracle oinstall 11492 Feb 25 2009 New_Database.dbt
-rw-r--r-- 1 oracle oinstall 5106 Aug 15 2009 Data_Warehouse.dbc
-rw-r--r-- 1 oracle oinstall 4986 Aug 15 2009 General_Purpose.dbc
-rwxr-xr-x 1 oracle oinstall 258654208 Aug 15 2009 Seed_Database.dfb
-rwxr-xr-x 1 oracle oinstall 9748480 Aug 15 2009 Seed_Database.ctl
-rwxr-xr-x 1 oracle oinstall 1179648 Aug 15 2009 example.dmp
-rwxr-xr-x 1 oracle oinstall 22544384 Aug 15 2009 example01.dfb
-rw-r----- 1 oracle oinstall 5124 Mar 24 13:31 jycs.dbc
-rw-r----- 1 oracle oinstall 13476 Apr 8 10:12 jycstemplate.dbt
-rw-r----- 1 oracle oinstall 333955072 Apr 8 10:24 jycsCloneTemplate.dfb
-rw-r----- 1 oracle oinstall 9748480 Apr 8 10:24 jycsCloneTemplate.ctl
-rw-r----- 1 oracle oinstall 4903 Apr 8 10:24 jycsCloneTemplate.dbc
利用带数据文件的模板jycsCloneTemplate生成克隆数据库
[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName jycsCloneTemplate.dbc -gdbName test -sid test -datafileJarLocation /u01/app/oracle/11.2.0/db/assistants/dbca/templates -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:
Enter SYSTEM user password:
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/test/test.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/test/test.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/test.
Database Information:
Global Database Name:test
System Identifier(SID):test
[oracle@jyrac1 ~]$ ps -ef | grep pmon
oracle 12381 1 0 10:22 ? 00:00:00 ora_pmon_jycs
oracle 14396 1 0 10:39 ? 00:00:00 ora_pmon_test
oracle 14689 29918 0 10:41 pts/1 00:00:00 grep pmon
利用不带数据文件的模板生成新的数据库
[oracle@jyrac1 ~]$ dbca -silent -createDatabase -templateName New_Database.dbt -gdbname jytest -sid jytest -datafileDestination /u01/app/oracle/oradata -responseFile NO_VALUE -characterset ZHS16GBK
Enter SYS user password:
Enter SYSTEM user password:
Creating and starting Oracle instance
1% complete
3% complete
Creating database files
4% complete
7% complete
Creating data dictionary views
8% complete
9% complete
10% complete
11% complete
12% complete
13% complete
14% complete
16% complete
17% complete
18% complete
19% complete
Adding Oracle JVM
25% complete
30% complete
36% complete
38% complete
Adding Oracle Text
40% complete
41% complete
Adding Oracle XML DB
43% complete
44% complete
45% complete
49% complete
Adding Oracle Multimedia
50% complete
60% complete
Adding Oracle OLAP
61% complete
62% complete
63% complete
64% complete
Adding Oracle Spatial
65% complete
66% complete
67% complete
71% complete
Adding Enterprise Manager Repository
73% complete
75% complete
Adding Oracle Application Express
78% complete
82% complete
Adding Oracle Warehouse Builder
86% complete
90% complete
Completing Database Creation
91% complete
92% complete
93% complete
96% complete
100% complete
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/jytest/jytest.log" for further details.
[oracle@jyrac1 ~]$ cat /u01/app/oracle/cfgtoollogs/dbca/jytest/jytest.log
Creating and starting Oracle instance
DBCA_PROGRESS : 1%
DBCA_PROGRESS : 3%
Creating database files
DBCA_PROGRESS : 4%
DBCA_PROGRESS : 7%
Creating data dictionary views
DBCA_PROGRESS : 8%
DBCA_PROGRESS : 9%
DBCA_PROGRESS : 10%
DBCA_PROGRESS : 11%
DBCA_PROGRESS : 12%
DBCA_PROGRESS : 13%
DBCA_PROGRESS : 14%
DBCA_PROGRESS : 16%
DBCA_PROGRESS : 17%
DBCA_PROGRESS : 18%
DBCA_PROGRESS : 19%
Adding Oracle JVM
DBCA_PROGRESS : 25%
DBCA_PROGRESS : 30%
DBCA_PROGRESS : 36%
DBCA_PROGRESS : 38%
Adding Oracle Text
DBCA_PROGRESS : 40%
DBCA_PROGRESS : 41%
Adding Oracle XML DB
DBCA_PROGRESS : 43%
DBCA_PROGRESS : 44%
DBCA_PROGRESS : 45%
DBCA_PROGRESS : 49%
Adding Oracle Multimedia
DBCA_PROGRESS : 50%
DBCA_PROGRESS : 60%
Adding Oracle OLAP
DBCA_PROGRESS : 61%
DBCA_PROGRESS : 62%
DBCA_PROGRESS : 63%
DBCA_PROGRESS : 64%
Adding Oracle Spatial
DBCA_PROGRESS : 65%
DBCA_PROGRESS : 66%
DBCA_PROGRESS : 67%
DBCA_PROGRESS : 71%
Adding Enterprise Manager Repository
DBCA_PROGRESS : 73%
DBCA_PROGRESS : 75%
Adding Oracle Application Express
DBCA_PROGRESS : 78%
DBCA_PROGRESS : 82%
Adding Oracle Warehouse Builder
DBCA_PROGRESS : 86%
DBCA_PROGRESS : 90%
Completing Database Creation
DBCA_PROGRESS : 91%
DBCA_PROGRESS : 92%
DBCA_PROGRESS : 93%
DBCA_PROGRESS : 96%
DBCA_PROGRESS : 100%
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/jytest.
Database Information:
Global Database Name:jytest
System Identifier(SID):jytest
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Oracle 11g静默安装软件+手工建库
使用二次跳转+远程操作,使用无图形界面安装。采用静默安装数据库软件+手工创建数据库的方式完成需求。
1.静默模式安装Oracle软件,配置监听程序、Net服务名;
2.手工建库;
3.检查各组件是否符合要求?
1. 静默模式安装Oracle软件及配置监听程序
默认已经安装了所有Oracle软件依赖的安装包,调整了操作系统的相关参数。
安装软件前的准备工作不清楚可参见:Linux平台oracle 11g单实例安装部署配置 快速参考 http://www.linuxidc.com/Linux/2015-05/117559.htm
解压的数据库安装包,在database文件夹中的response文件夹下,有配置文件db_install.rsp,根据需求修改这个配置文件。
$ cd /u01/app/database/response
修改db_install.rsp的内容参考(由于是只安装软件,有关数据库的未作修改):
$ vim /u01/app/database/response/db_install.rsp
#------------------------------------------------------------------------------
# Do not change the following system generated value.
#------------------------------------------------------------------------------
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#------------------------------------------------------------------------------
# Specify the installation option.
# It can be one of the following:
# - INSTALL_DB_SWONLY
# - INSTALL_DB_AND_CONFIG
# - UPGRADE_DB
#-------------------------------------------------------------------------------
oracle.install.option=INSTALL_DB_SWONLY
#-------------------------------------------------------------------------------
# Specify the hostname of the system as set during the install. It can be used
# to force the installation to use an alternative hostname rather than using the
# first hostname found on the system. (e.g., for systems with multiple hostnames
# and network interfaces)
#-------------------------------------------------------------------------------
ORACLE_HOSTNAME=CRNOPHQDW12
#-------------------------------------------------------------------------------
# Specify the Unix group to be set for the inventory directory.
#-------------------------------------------------------------------------------
UNIX_GROUP_NAME=oinstall
#-------------------------------------------------------------------------------
# Specify the location which holds the inventory files.
# This is an optional parameter if installing on
# Windows based Operating System.
#-------------------------------------------------------------------------------
INVENTORY_LOCATION=/opt/app/oracle/oraInventory
#-------------------------------------------------------------------------------
# Specify the languages in which the components will be installed.
#
# en : English ja : Japanese
# fr : French ko : Korean
# ar : Arabic es : Latin American Spanish
# bn : Bengali lv : Latvian
# pt_BR: Brazilian Portuguese lt : Lithuanian
# bg : Bulgarian ms : Malay
# fr_CA: Canadian French es_MX: Mexican Spanish
# ca : Catalan no : Norwegian
# hr : Croatian pl : Polish
# cs : Czech pt : Portuguese
# da : Danish ro : Romanian
# nl : Dutch ru : Russian
# ar_EG: Egyptian zh_CN: Simplified Chinese
# en_GB: English (Great Britain) sk : Slovak
# et : Estonian sl : Slovenian
# fi : Finnish es_ES: Spanish
# de : German sv : Swedish
# el : Greek th : Thai
# iw : Hebrew zh_TW: Traditional Chinese
# hu : Hungarian tr : Turkish
# is : Icelandic uk : Ukrainian
# in : Indonesian vi : Vietnamese
# it : Italian
#
# all_langs : All languages
#
# Specify value as the following to select any of the languages.
# Example : SELECTED_LANGUAGES=en,fr,ja
#
# Specify value as the following to select all the languages.
# Example : SELECTED_LANGUAGES=all_langs
#------------------------------------------------------------------------------
SELECTED_LANGUAGES=en,zh_CN
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Home.
#------------------------------------------------------------------------------
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
#------------------------------------------------------------------------------
# Specify the complete path of the Oracle Base.
#------------------------------------------------------------------------------
ORACLE_BASE=/u01/app/oracle
#------------------------------------------------------------------------------
# Specify the installation edition of the component.
#
# The value should contain only one of these choices.
# - EE : Enterprise Edition
# - SE : Standard Edition
# - SEONE : Standard Edition One
# - PE : Personal Edition (WINDOWS ONLY)
#------------------------------------------------------------------------------
oracle.install.db.InstallEdition=EE
#------------------------------------------------------------------------------
# This variable is used to enable or disable custom install and is considered
# only if InstallEdition is EE.
#
# true : Components mentioned as part of 'optionalComponents' property
# are considered for install.
# false : Value for 'optionalComponents' is not considered.
#------------------------------------------------------------------------------
oracle.install.db.EEOptionsSelection=false
#------------------------------------------------------------------------------
# This variable is considered only if 'EEOptionsSelection' is set to true.
#
# Description: List of Enterprise Edition Options you would like to enable.
#
# The following choices are available. You may specify any
# combination of these choices. The components you choose should
# be specified in the form "internal-component-name:version"
# Below is a list of components you may specify to enable.
#
# oracle.oraolap:11.2.0.4.0 - Oracle OLAP
# oracle.rdbms.dm:11.2.0.4.0 - Oracle Data Mining
# oracle.rdbms.dv:11.2.0.4.0 - Oracle Database Vault
# oracle.rdbms.lbac:11.2.0.4.0 - Oracle Label Security
# oracle.rdbms.partitioning:11.2.0.4.0 - Oracle Partitioning
# oracle.rdbms.rat:11.2.0.4.0 - Oracle Real Application Testing
#------------------------------------------------------------------------------
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.4.0,oracle.rdbms.rat:11.2.0.4.0
#------------------------------------------------------------------------------
# The DBA_GROUP is the OS group which is to be granted OSDBA privileges.
#------------------------------------------------------------------------------
oracle.install.db.DBA_GROUP=dba
#------------------------------------------------------------------------------
# The OPER_GROUP is the OS group which is to be granted OSOPER privileges.
# The value to be specified for OSOPER group is optional.
#------------------------------------------------------------------------------
oracle.install.db.OPER_GROUP=
#------------------------------------------------------------------------------
# Specify whether user doesn't want to configure Security Updates.
# The value for this variable should be true if you don't want to configure
# Security Updates, false otherwise.
#
# The value can be either true or false. If left blank it will be assumed
# to be false.
#
# Example : DECLINE_SECURITY_UPDATES=false
#------------------------------------------------------------------------------
DECLINE_SECURITY_UPDATES=true
注意:选项DECLINE_SECURITY_UPDATES=false默认值为false,要改为true。
使用修改后的db_install.rsp安装数据库软件
$ ./runInstaller -silent -force -ignorePrereq -ignoreSysPrereqs -responseFile /data/database/response/db_install.rsp
正在启动 Oracle Universal Installer...
检查临时空间: 必须大于 120 MB。 实际为 8122 MB 通过
检查交换空间: 必须大于 150 MB。 实际为 255999 MB 通过
准备从以下地址启动 Oracle Universal Installer /tmp/OraInstall2015-07-09_01-40-01PM. 请稍候...
[oracle@CRNOPHQDW12 database]$ [WARNING] [INS-32055] 主产品清单位于 Oracle 基目录中。
原因: 主产品清单位于 Oracle 基目录中。
操作: Oracle 建议将此主产品清单放置在 Oracle 基目录之外的位置中。
可以在以下位置找到本次安装会话的日志:
/opt/app/oracle/oraInventory/logs/installActions2015-07-09_01-40-01PM.log
Oracle Database 11g 的 安装 已成功。
请查看'/opt/app/oracle/oraInventory/logs/silentInstall2015-07-09_01-40-01PM.log'以获取详细资料。
以root用户的身份执行以下脚本:
1. /opt/app/oracle/oraInventory/orainstRoot.sh
2. /opt/app/oracle/product/11.2.0/dbhome_1/root.sh
Successfully Setup Software.
然后按提示root用户执行2个脚本,第2个脚本执行结果参见屏幕提示给出的日志文件。
netca静默创建监听:
$ netca /silent /responsefile /data/database/response/netca.rsp //netca.rsp不需修改,直接建立监听
正在对命令行参数进行语法分析:
参数"silent" = true
参数"responsefile" = /data/database/response/netca.rsp
完成对命令行参数进行语法分析。
Oracle Net Services 配置:
完成概要文件配置。
Oracle Net 监听程序启动:
正在运行监听程序控制:
/opt/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
监听程序控制完成。
监听程序已成功启动。
监听程序配置完成。
成功完成 Oracle Net Services 配置。退出代码是0
2、手工建库
新建参数文件$ORACLE_HOME/dbs/initcrnophq.ora
db_name=crnophq
memory_target=100G
建库脚本:
CREATE DATABASE cndba CONTROLFILE REUSE
USER SYS IDENTIFIED BY oracle
USER SYSTEM IDENTIFIED BY oracle
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/cndba/redo1.log') SIZE 50M BLOCKSIZE 512,
GROUP 2 ('/u01/app/oracle/oradata/cndba/redo2.log') SIZE 50M BLOCKSIZE 512,
GROUP 3 ('/u01/app/oracle/oradata/cndba/redo3.log') SIZE 50M BLOCKSIZE 512
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXLOGHISTORY 1
MAXDATAFILES 100
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/cndba/system01.dbf' SIZE 325M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/cndba/sysaux01.dbf' SIZE 325M REUSE
DEFAULT TABLESPACE users
DATAFILE '/u01/app/oracle/oradata/cndba/users01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/u01/app/oracle/oradata/cndba/temp01.dbf'
SIZE 20M REUSE
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/cndba/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;
执行下面脚本,创建数据字典和存储过程等
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL> @?/sqlplus/admin/pupbld.sql
关于手工建库,更多可以参见转载的文章:Oracle 11g 手工建库
3. 检查各组件是否符合要求
最后验证
SQL> conn /as sysdba
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
-------------------------------- ------------------------
cndba OPEN
col comp_name for a60
col version for a15
col status for a20
set linesize 1000
select comp_id,comp_name,version,status from sys.dba_registry;
COMP_NAME VERSION STATUS
---------------------------------------- ---------- --------------------
Oracle Database Catalog Views 11.2.0.4.0 VALID
Oracle Database Packages and Types 11.2.0.4.0 VALID
用DBCA 创建的实例的组件:
SQL> select comp_name,version,status from sys.dba_registry;
COMP_NAME VERSION STATUS
---------------------------------------- --------------- --------------------
OWB 11.2.0.4.0 VALID
Oracle Application Express 3.2.1.00.12 VALID
Oracle Enterprise Manager 11.2.0.4.0 VALID
OLAP Catalog 11.2.0.4.0 VALID
Spatial 11.2.0.4.0 VALID
Oracle Multimedia 11.2.0.4.0 VALID
Oracle XML Database 11.2.0.4.0 VALID
Oracle Text 11.2.0.4.0 VALID
Oracle Expression Filter 11.2.0.4.0 VALID
Oracle Rules Manager 11.2.0.4.0 VALID
Oracle Workspace Manager 11.2.0.4.0 VALID
Oracle Database Catalog Views 11.2.0.4.0 VALID
Oracle Database Packages and Types 11.2.0.4.0 VALID
JServer JAVA Virtual Machine 11.2.0.4.0 VALID
Oracle XDK 11.2.0.4.0 VALID
Oracle Database Java Packages 11.2.0.4.0 VALID
OLAP Analytic Workspace 11.2.0.4.0 VALID
Oracle OLAP API 11.2.0.4.0 VALID
18 rows selected.
缺少的组件也继续可以运行脚本创建。
这里添加OLAP 和Spatial组件:
SQL> @?/olap/admin/olap.sql SYSAUX TEMP;
SQL> @?/md/admin/mdinst.sql
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
静默安装Oracle 11g R2软件并手工建库
1、前期准备:设置Oracle用户的环境变量~/.bash_profile
[oracle@localhost ~]$ vim .bash_profile
umask 022
export ORACLE_SID=ora11g
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2.0.1/db_1
export LD_LIBRARY_PATH=/usr/lib:/usr/X11R6/lib
export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:$PATH
2、安装环境配置完成后,把oracle 11g R2的安装介质拷贝到服务器上,然后进行解压。
--修改静默安装响应文件db_insatll.rsp的内容
$ vim /u01/app/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=server17
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
DECLINE_SECURITY_UPDATES=true
执行静默安装的命令
[oracle@localhost database]$ ./runInstaller -silent -force -noconfig -responseFile /u01/app/database/response/db_install.rsp
在执行过程中出现下面的问题:
-----------------------------
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 80 MB. Actual 127047 MB Passed
Checking swap space: must be greater than 150 MB. Actual 4000 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2009-11-30_08-48-47PM. Please wait ...[oracle@localhost database]$ [SEVERE] - Email Address Not Specified
处理方法配置下面的参数在responsefile 文件中:
DECLINE_SECURITY_UPDATES=true
3、手工创建数据库
上面的操作只安装了oracle 11g R2数据库软件,在nomount状态下创建数据库,需要创建实例启动用的参数文件。
在程序默认的参数文件里修改即可:重命名规则initSID.ora
[oracle@localhost ~]$ vim initora11g.ora
db_name='ora11g' --修改
memory_target=900m
sga_target=200m --添加
pga_aggregate_target=60m --添加
processes = 150
audit_file_dest='/u01/app/oracle/admin/orcl/adump' --建立目录
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' --建立目录
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle' ---修改
dispatchers='(PROTOCOL=TCP) (SERVICE=orclXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
3、创建相应的目录
mkdir -p /u01/app/oracle/admin/orcl/{{a,dp}dump,pfile,script}
mkdir -p /u01/app/oracle/fast_recovery_area/{orcl,ORCL/archivelog}
mkdir -p /u01/app/oracle/oradata/orcl
4、创建密码文件:orapwSID命名规则
Linux下:orapw+实例名
Windows下:pwd+实例名
[oracle@linuxidc dbs]$ orapwd file=orapworcl password=oracle entries=30
[oracle@linuxidc dbs]$ ls
hc_ora11g.dat initora11g.ora lkORA11G ora_control1 ora_control2 orapwora11g peshm_ora11g_0
5、启动实例创建数据库
SQL> startup nomount pfile="/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initora11g.ora";
SQL> create spfile from pfile;
SQL> CREATE DATABASE "orcl" CONTROLFILE RESUE
USER SYS IDENTIFIED BY "oracle"
USER SYSTEM IDENTIFIED BY "oracle"
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/orcl/log01.dbf') SIZE 50M,
GROUP 2 ('/u01/app/oracle/oradata/orcl/log02.dbf') SIZE 50M,
GROUP 3 ('/u01/app/oracle/oradata/orcl/log03.dbf') SIZE 50M
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/orcl/system01.dbf' SIZE 1024M REUSE
SYSAUX DATAFILE '/u01/app/oracle/oradata/orcl/sysaux01.dbf' SIZE 500M REUSE
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/oracle/oradata/orcl/temp01.dbf' SIZE 20M REUSE
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/u01/app/oracle/oradata/orcl/undo01.dbf' SIZE 300M REUSE;
6、创建USERS表空间
SQL> CREATE SMALLFILE TABLESPACE "USERS" LOGGING DATAFILE '/u01/app/oracle/oradata/orcl/user01.dbf' SIZE 1000M REUSE EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DEFAULT TABLESPACE "USERS";
7、执行脚本命令
使用sys用户编译以下脚本
sqlplus / as sysdba
SQL> show user;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catalog.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catproc.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catblock.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catoctk.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/owminst.plb;
使用system用户编译
@/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/pupbld.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/sqlplus/admin/help/hlpbld.sql helpus.sql;
使用sys用户编译
@/u01/app/oracle/product/11.2.0/dbhome_1/javavm/install/initjvm.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/xdk/admin/initxml.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/xdk/admin/xmlja.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catjava.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catexf.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catqm.sql change_on_install SYSAUX TEMP YES;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catxdbj.sql;
@/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/admin/catrul.sql;
spool /u01/app/oracle/admin/orcl/script/ordinst.log append
@/u01/app/oracle/product/11.2.0/dbhome_1/ord/admin/ordinst.sql SYSAUX SYSAUX;
spool off
spool /u01/app/oracle/admin/orcl/script/interMedia.log append
@/u01/app/oracle/product/11.2.0/dbhome_1/ord/im/admin/iminst.sql;
spool off
set echo on
spool /u01/app/oracle/admin/orcl/script/lockAccount.log append
BEGIN
FOR item IN (SELECT USERNAME FROM DBA_USERS WHERE ACCOUNT_STATUS IN ('OPEN','LOCKED','EXPIRED') AND USERNAME NOT IN ('SYS','SYSTEM'))
LOOP
dbms_output.put_line('Locking and Expiring: ' || item.USERNAME);
execute immediate 'alter user' || sys.dbms_assert.enquote_name(sys.dbms_assert.schema_name(item.USERNAME),false) || 'password expire account lock';
END LOOP;
END;
/
spool off