Linux下静默安装Oracle 11g
Serviceiptables stop iptables服务停掉
Vim /etc/selinux/config
SELINUX=enforcing 改成 SELINUX=disabled(重启生效)
setenforce 0 / /临时关闭,不用重启
同时主机名称要提前设置好hostname;
1) 检查系统软件包
binutils-2.15.92.0.2-13.EL4
compat-db-4.1.25-9
compat-libstdc++-296-2.96-132.7.2
control-center-2.8.0-12
gcc-3.4.3-22.1.EL4
gcc-c++-3.4.3-22.1.EL44
glibc-2.3.4-2.9
glibc-common-2.3.4-2.9
gnome-libs-1.4.1.2.90-44.1
libstdc++-3.4.3-22.1
libstdc++-devel-3.4.3-22.1
make-3.80-5
pdksh-5.2.14-30
sysstat-5.0.5-1
xscreensaver-4.18-5.rhel4.2
libaio-0.3.103-3
使用rpm检查哪些依赖包没有安装
rpm -q binutils compat-libstdc++-33 elfutils-libelfelfutils-libelf-devel gcc gcc-c++ glibc-2.5 glibc-common glibc-develglibc-headers ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel makesysstat unixODBC unixODBC-devel
如果依赖包有显示is not installed(没安装),就用yum install 命令安装
yum install compat-db compat-libstdc++ control-centergcc gcc-c++ glibc glibc-common gonme-libs libstdc++ libstdc++-devel make pdkshsysstat libai
#rpm -qa gcc*
#rpm -Uvh --force binutils-2.15.92.0.2-13.0.0.0.2.x86_64.rpm
2)创建安装目录(可根据情况,选择比较多空间的目录创建)
mkdir -p /u01/app
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app
3) 创建用户和组
# /usr/sbin/groupadd oinstall
# /usr/sbin/groupadd dba
# /usr/sbin/useradd -g oinstall -G dba -d/u01/app/oracle oracle
设置oracle用户密码
# passwd oracle
4)配置核心参数
vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912 //用于定义单个共享内存段的最大值
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
修改后,使设置生效
/sbin/sysctl �Cp
可能会报错:
error:"net.bridge.bridge-nf-call-ip6tables" is an unknown key
error: "net.bridge.bridge-nf-call-iptables"is an unknown key
error:"net.bridge.bridge-nf-call-arptables" is an unknown key
解决方法如下:
modprobe bridge
lsmod|grep bridge
/sbin/sysctl �Cp
5)修改用户限制
vim /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
6)在/etc/pam.d/login 文件中,使用文本编辑器或vi命令增加或修改以下内容
vim /etc/pam.d/login
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
7)检查交换分区和内存的大小
# grep SwapTotal /proc/meminfo
# grep MemTotal /proc/meminfo
tmp >=400m
8)设置oracle环境变量
su �C oracle
vim.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export NLS_LANG=AMERICAN_AMERICA.UTF8
检查环境变量:
env
同时,在使用静默安装的时候会检查DISPLAY的设置,如果经常说检查DISPLAY不行的话,到root用户下执行“xhost + 你的ip:0.0“
重新加载.bash_profile文件
source .bash_profile
9)解压oracle安装文件
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
10)复制响应文件模板
mkdir etc
cp /home/oracle/database/response/* /u01/app/oracle/etc
设置响应文件权限
su - root
chmod 700 /u01/app/oracle/etc/*.rsp(注意所有者,oinstall)
11)执行安装脚本
$./runInstaller
$ vi $DISTRIB/db_swonly.rsp
#--------------------------------------------------------------------
#以下参数不要更改
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
DECLINE_SECURITY_UPDATES=true
#以下参数根据实际情况更改,一般也无需更改
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN,zh_TW
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=true
oracle.install.db.customComponents=oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
#--------------------------------------------------------------------
各参数含义如下:
-silent 表示以静默方式安装,不会有任何提示
-force 允许安装到一个非空目录
-noconfig 表示不运行配置助手netca
-responseFile 表示使用哪个响应文件,必需使用绝对路径
oracle.install.responseFileVersion 响应文件模板的版本,该参数不要更改
oracle.install.option 安装选项,本例只安装oracle软件,该参数不要更改
DECLINE_SECURITY_UPDATES 是否需要在线安全更新,设置为false,该参数不要更改
ORACLE_HOSTNAME 安装主机名
UNIX_GROUP_NAME oracle 用户用于安装软件的组名
INVENTORY_LOCATION oracle产品清单目录
SELECTED_LANGUAGES oracle运行语言环境,一般包括引文和简繁体中文
ORACLE_HOME Oracle安装目录
ORACLE_BASE oracle基础目录
oracle.install.db.InstallEdition 安装版本类型,一般是企业版
oracle.install.db.isCustomInstall 是否定制安装,默认Partitioning,OLAP,RAT都选上了
oracle.install.db.customComponents 定制安装组件列表:除了以上默认的,可加上Label Security和DatabaseVault
oracle.install.db.DBA_GROUP oracle用户用于授予OSDBA权限的组名
oracle.install.db.OPER_GROUP oracle用户用于授予OSOPER权限的组名
也可使用有图形的机器,使用图形界面来生成responsfile:
$ ./runInstaller &
一步步设置到Summary页, 然后点击SaveResponse File按钮, 选择合适的存放路径并Finish后, 回到Summary页, 点击Cancel退出OUI
1) 通过response文件静默安装, 大概2-3分钟:
$ ./runInstaller -silent -force -noconfig-responseFile /u01/app/oracle/etc
安装中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了,到日志目录下查找错误日志。
控制台直到出现以下提示则表示安装完成:
#-------------------------------------------------------------------
[oracle@xen_200_102 database]$ The followingconfiguration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scriptsto run
/u01/app/oracle/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.
#-------------------------------------------------------------------
2) 安装期间查看安装日志信息了解安装进度:
$ cd $ORACLE_BASE/oraInventory/logs
$ tail -f installActions*.log
3) 安装的软件信息会写入inventory.xml文件, 如果需重运行则把该文件的对应安装条目信息删除即可:
$ vi$ORACLE_BASE/oraInventory/ContentsXML/inventory.xml
若本机第一次安装oracle软件, 则执行orainstRoot.sh来建立oraInst.loc文件和修改权限:
$ su -
# /u01/app/oracle/oraInventory/orainstRoot.sh
# more /etc/oraInst.loc
执行$ORACLE_HOME下的root.sh来建立oratab,dbhome,oraenv,coraenv文件, 如果提示则一直回车:
# /u01/app/oracle/product/11.2.0/db_1/root.sh
# more /etc/oratab
通过response文件运行netca, 生成sqlnet.ora和listener.ora文件, 位于$ORACLE_HOME/network/admin目录下:
# su - oracle
$ $ORACLE_HOME/bin/netca /silent /responsefile$DISTRIB/response/netca.rsp
$ ll $ORACLE_HOME/network/admin/*.ora
$ lsnrctl status
执行完后, 监听就已经启动了, 默认端口是1521, 默认是动态监听,只要实例启动了就会监听到.
1) 生成响应文件模板:
$ vi /u01/app/oracle/etc/db_create.rsp
#--------------------------------------------------------------------
#以下参数不要更改
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
#以下参数必须设置
[CREATEDATABASE]
GDBNAME = "orcl.LK"
TEMPLATENAME = "General_Purpose.dbc"
#以下参数不设置则使用默认值,建议设置
CHARACTERSET = "AMERICAN_AMERICA.UTF8"
TOTALMEMORY = "1024"
#--------------------------------------------------------------------
2) dbca静默建库, 大概3-4分钟:
种子数据库和控制文件位于$ORACLE_HOME/assistants/dbca/templates/下,即Seed_Database.dfb和Seed_Database.ctl文件, 实际上建库就是基于通过rman恢复种子数据库和控制文件来实现的.
$ $ORACLE_HOME/bin/dbca -silent -responseFile /u01/app/oracle/etc/db_create.rsp
Enter SYS user password:
<输入sys用户密码>
Enter SYSTEM user password:
<输入system用户密码>
Copying database files
...
37% complete
Creating and starting Oracle instance
...
62% complete
Completing Database Creation
...
100% complete
Look at the log file"/u01/app/oracle/cfgtoollogs/dbca/ORCL/ORCL.log" for further details.
各参数含义如下:
-silent 表示以静默方式安装
-responseFile 表示使用哪个响应文件,必需使用绝对路径
RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改
OPERATION_TYPE 安装类型,该参数不要更改
GDBNAME 全局数据库名,点号前面默认是db_name,点号后面默认就是db_domain
TEMPLATENAME 建库模板名,参考各模板定义:$ORACLE_HOME/assistants/dbca/templates/*.dbc
CHARACTERSET 字符集,默认是WE8MSWIN1252
TOTALMEMORY 实例内存,默认是服务器物理内存的40%
3) 安装期间查看日志信息了解进度:
$ tail -f$ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log
4) 建库后实例检查
$ ps -ef | grep ora_ | grep -v grep | wc -l
21
$ ps -ef | grep ora_ | grep -v grep
oracle 1855 1 0 10:07 ? 00:00:00 ora_pmon_ORCL
oracle 1857 1 0 10:07 ? 00:00:00 ora_vktm_ORCL
oracle 1861 1 0 10:07 ? 00:00:00 ora_gen0_ORCL
oracle 1863 1 0 10:07 ? 00:00:00 ora_diag_ORCL
oracle 1865 1 010:07 ? 00:00:00 ora_dbrm_ORCL
oracle 1867 1 0 10:07 ? 00:00:00 ora_psp0_ORCL
oracle 1869 1 0 10:07 ? 00:00:00 ora_dia0_ORCL
oracle 1871 1 0 10:07 ? 00:00:00 ora_mman_ORCL
oracle 1873 1 0 10:07 ? 00:00:00 ora_dbw0_ORCL
oracle 1875 1 0 10:07 ? 00:00:00 ora_lgwr_ORCL
oracle 1877 1 0 10:07 ? 00:00:00 ora_ckpt_ORCL
oracle 1879 1 0 10:07 ? 00:00:00 ora_smon_ORCL
oracle 1881 1 0 10:07 ? 00:00:00 ora_reco_ORCL
oracle 1883 1 0 10:07 ? 00:00:00 ora_mmon_ORCL
oracle 1885 1 0 10:07 ? 00:00:00 ora_mmnl_ORCL
oracle 1887 1 0 10:07 ? 00:00:00 ora_d000_ORCL
oracle 1889 1 0 10:07 ? 00:00:00 ora_s000_ORCL
oracle 1969 1 0 10:07 ? 00:00:00 ora_qmnc_ORCL
oracle 1985 1 0 10:07 ? 00:00:00 ora_cjq0_ORCL
oracle 2003 1 0 10:08 ? 00:00:00 ora_q000_ORCL
oracle 2005 1 0 10:08 ? 00:00:00 ora_q001_ORCL
5) 建库后监听检查
$ lsnrctl status
...
Services Summary...
Service "ORCL.LK" has 1 instance(s).
Instance"ORCL", status READY, has 1 handler(s) for this service...
Service "ORCLXDB.LK" 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 1611:11:46 2009
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP,Data Mining,
Oracle Database Vault and Real Application Testingoptions
$SQL> alter system register;
6) 改为归档模式并重启
$ sqlplus / as sysdba
SQL> shutdown immediate;
SQL> startup mount;
SQL> alter database archivelog;
SQL> alter database flashback on; (如果要启用数据库闪回功能则执行)
SQL> alter database open;
SQL> execute utl_recomp.recomp_serial(); (重新编译所有可能失效对象)
SQL> alter system archive log current; (手工归档测试)
到此建库完毕!
7) 默认安装的数据库用户:
SQL> set lines 256 pages 500
SQL> selectUSER_ID,USERNAME,ACCOUNT_STATUS,DEFAULT_TABLESPACE from dba_users order by1;
USER_IDUSERNAME ACCOUNT_STATUS DEFAULT_TABLESPACE
---------- -------------------------------------------------------------- ------------------------------
0SYS OPEN SYSTEM
5SYSTEM OPEN SYSTEM
9OUTLN EXPIRED& LOCKED SYSTEM
14DIP EXPIRED& LOCKED USERS
21ORACLE_OCM EXPIRED& LOCKED USERS
30DBSNMP EXPIRED& LOCKED SYSAUX
31APPQOSSYS EXPIRED& LOCKED SYSAUX
32WMSYS EXPIRED& LOCKED SYSAUX
42EXFSYS EXPIRED& LOCKED SYSAUX
43CTXSYS EXPIRED& LOCKED SYSAUX
45XDB EXPIRED& LOCKED SYSAUX
46ANONYMOUS EXPIRED& LOCKED SYSAUX
53ORDSYS EXPIRED& LOCKED SYSAUX
54ORDDATA EXPIRED& LOCKED SYSAUX
55ORDPLUGINS EXPIRED& LOCKED SYSAUX
56SI_INFORMTN_SCHEMA EXPIRED& LOCKED SYSAUX
57MDSYS EXPIRED& LOCKED SYSAUX
61OLAPSYS EXPIRED& LOCKED SYSAUX
65MDDATA EXPIRED& LOCKED USERS
67SPATIAL_WFS_ADMIN_USR EXPIRED& LOCKED USERS
70SPATIAL_CSW_ADMIN_USR EXPIRED& LOCKED USERS
72SYSMAN EXPIRED& LOCKED SYSAUX
74MGMT_VIEW EXPIRED& LOCKED SYSTEM
75 FLOWS_FILES EXPIRED & LOCKED SYSAUX
76APEX_PUBLIC_USER EXPIRED& LOCKED USERS
78APEX_030200 EXPIRED& LOCKED SYSAUX
79 OWBSYS EXPIRED &LOCKED SYSAUX
83OWBSYS_AUDIT EXPIRED& LOCKED SYSAUX
84SCOTT EXPIRED& LOCKED USERS
2147483638 XS$NULL EXPIRED &LOCKED USERS
30 rows selected.
8) 默认安装的组件:
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_schemasfrom dba_registry order by 1;
COMP_ID COMP_NAME VERSION SCHEMA OTHER_SCHEMAS
-------- ----------------------------------------------- ------------ ---------------------------------------------
AMD OLAPCatalog 11.2.0.1.0 OLAPSYS
APEX OracleApplication Express 3.2.1.00.10 APEX_030200 FLOWS_FILES
APS OLAPAnalytic Workspace 11.2.0.1.0 SYS
CATALOG OracleDatabase Catalog Views 11.2.0.1.0 SYS
CATJAVA OracleDatabase Java Packages 11.2.0.1.0 SYS
CATPROC OracleDatabase Packages and Types 11.2.0.1.0 SYS APPQOSSYS,DBSNMP,DIP,ORACLE_OCM,OUTLN,SYSTEM
CONTEXT OracleText 11.2.0.1.0 CTXSYS
EM OracleEnterprise Manager 11.2.0.1.0 SYSMAN
EXF OracleExpression Filter 11.2.0.1.0 EXFSYS
JAVAVM JServerJAVA Virtual Machine 11.2.0.1.0 SYS
ORDIM OracleMultimedia 11.2.0.1.0 ORDSYS MDSYS,ORDDATA,ORDPLUGINS,SI_INFORMTN_SCHEMA
OWB OWB 11.2.0.1.0 OWBSYS
OWM OracleWorkspace Manager 11.2.0.1.0 WMSYS
RUL OracleRules Manager 11.2.0.1.0 EXFSYS
SDO Spatial 11.2.0.1.0 MDSYS
XDB OracleXML Database 11.2.0.1.0 XDB ANONYMOUS,XS$NULL
XML OracleXDK 11.2.0.1.0 SYS
XOQ OracleOLAP API 11.2.0.1.0 SYS
18 rows selected.
1) 生成响应文件模板:
$ vi /tmp/database/response/db_delete.rsp
#--------------------------------------------------------------------
#以下参数不能更改
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "deleteDatabase"
#以下参数根据实际情况更改
[DELETEDATABASE]
SOURCEDB = "ORCL"
#--------------------------------------------------------------------
2) dbca静默删库, 无需手工停库, 大概1分钟:
$ $ORACLE_HOME/bin/dbca-silent -responseFile /tmp/database/response/db_delete.rsp
Connecting to database
...
47% complete
Updating network configuration files
...
52% complete
Deleting instance and datafiles
...
100% complete
Look at the log file"/u01/app/oracle/cfgtoollogs/dbca/ORCL.log" for further details.
各参数含义如下:
-silent 表示以静默方式删除
-responseFile 表示使用哪个响应文件,必需使用绝对路径
RESPONSEFILE_VERSION 响应文件模板的版本,该参数不要更改
OPERATION_TYPE 安装类型,该参数不要更改
SOURCEDB 数据库名,不是全局数据库名,即不包含db_domain
3) 删除期间查看日志信息了解进度:
$ tail -f$ORACLE_BASE/cfgtoollogs/dbca/$ORACLE_SID/$ORACLE_SID.log
Oracle 11g提供了两个命令expdp、impdp,前者用来对数据库的进行逻辑备份,后者用来执行恢复操作。导出、导入操作可以在不同的Oracle 11g服务器中执行,从而便于实现数据的迁移。
1)配置备份目录
# mkdir /opt/mydbbackup
# chown oracle:oinstall /opt/mydbbackup/
# slqplus sys as sysdba
# Enter password: //输入管理密码
SQL> create DIRECTORY dmpdir AS ‘/opt/mydbbackup/’; //指定备份目录位置
Directory created.
SQL> grant read,write ON DIRECTORY dmpdir TO system;
Grant successded.
2)备份(导出)数据
执行备份操作时,需指定备份操作用户(如system),然后结合DIRECTORY参数指定Oracle管理的备份位置,结合DUMPFILE参数指定备份文件名称。例如:以下操作将把用户system所拥有的数据导出为orc120150130.dmp文件,保存到/opt/mydbbackup/目录。
# expdp systemDIRECTORY=dmpdir DUMPFILE=orc120150130.dmp
# password: //输入管理密码
# ls �Clh /opt/mydbbackup/orc120150130.dmp
3)恢复(导入)数据
执行恢复操作时,同样需指定操作用户(如system),然后结合DIRECTORY参数指定Oracle管理的备份位置,结合DUMPFILE参数指定备份文件。例如,以下操作将从备份文件orc120150130.dmp中读取数据,导入到用户system所拥有的数据库中。
#impdp systemDIRECTORY=dmpdir DUMPFILE=orc120150130.dmp REUSE_DATAFILES=Y TABLE_EXISTS_ACTION=REPLACE
Password: //输入管理密码
其中,REUSE_DATAFILES=Y表示重用原有的数据文件,TABLE_EXISTS_ACTION=REPLACE表示覆盖已存在的表。
http://blog.itpub.net/29510932/viewspace-1135313/也可以参考这个。
(本人新手,如有错误,欢迎指正。希望对你有所帮助,祝你成功!)