# 后跟命令表示以操作系统下root用户操作;
$ 后跟命令表示以操作系统下oracle用户操作;
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 \ pdksh \ sysstat \ unixODBC \ unixODBC-devel | grep "not installed";
如果有缺失的包,手动安装;
除 pdksh 外,都可一通过yum安装;
手动安装pdksh包
wget http://mirror.centos.org/centos/5/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
# id oracle (确认oracle用户是否存在) # /usr/sbin/groupadd oinstall (建立产品清单管理组) # /usr/sbin/groupadd dba (建立数据库安装组) # /usr/sbin/groupadd asmadmin (建立ASM管理组) # /usr/sbin/groupadd asmdba (建立Grid管理组) # /usr/sbin/useradd -g oinstall -G dba,asmdba oracle -d /home/oracle (oinstall为主要组,确保/home/oracle原不存在) # id oracle (记住oracle用户的uid和gid) uid=501(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),504(asmdba) # passwd oracle
编辑内核参数配置文件 vi /etc/sysctl.conf,在该文件下修改或添加如下行:
fs.file-max = 6815744 fs.aio_max_nr=1048576 kernel.shmall = 2097152 kernel.shmmax = 2147483648 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
再执行以下命令使以上配置立即生效: sysctl -p;
编辑系统资源限制配置文件 vi /etc/security/limits.conf,在该文件下添加如下行: oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536 oracle soft stack 10240
# mkdir -p /u01/app/oracle/ (Oracle基础目录, 一般为/mount_point/app/oracle_owner) # chown -R oracle:oinstall /u01 # chmod -R 775 /u01
# su - oracle $ vi ~/.bash_profile export ORACLE_HOSTNAME=master export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export ORACLE_SID=ORCL export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH export LC_ALL="en_US" export LANG="en_US" export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK" export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
$ cd /home/oracle/11g $ unzip linux.x64_11gR2_database_1of2.zip -d /home/oracle/11g/ (解压到 /home/oracle/11g/目录下,可选目录) $ unzip linux.x64_11gR2_database_2of2.zip -d /home/oracle/11g/ $ cd /home/oracle/11g/database $ export DISTRIB=`pwd`
在解压后oracle软件的response目录里有各种响应文件的模版.
$ 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 [oracle 不建议把 Inventory 目录放到oracle的base目录下,我在安装的过程中出现此问题] 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.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和Database Vault oracle.install.db.DBA_GROUP oracle用户用于授予OSDBA权限的组名 oracle.install.db.OPER_GROUP oracle用户用于授予OSOPER权限的组名
1) 通过response文件静默安装, 大概2-3分钟:
$ ./runInstaller -silent -force -noconfig -responseFile $DISTRIB/db_swonly.rsp 控制台直到出现以下提示则表示安装完成: #------------------------------------------------------------------- ... /u01/app/oracle/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/dbhome_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. #-------------------------------------------------------------------
$ cd $ORACLE_BASE/oraInventory/logs $ tail -100f installActions*.log
若本机第一次安装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/dbhome_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 $DISTRIB/db_create.rsp #-------------------------------------------------------------------- #以下参数不要更改 [GENERAL] RESPONSEFILE_VERSION = "11.2.0" OPERATION_TYPE = "createDatabase" #以下参数必须设置 [CREATEDATABASE] GDBNAME = "ORCL.LK" TEMPLATENAME = "General_Purpose.dbc" #以下参数不设置则使用默认值,建议设置 CHARACTERSET = "ZHS16GBK" TOTALMEMORY = "1024" #--------------------------------------------------------------------
$ $ORACLE_HOME/bin/dbca -silent -responseFile $DISTRIB/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 -100f $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 0 10: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) 建库后监听检查
[oracle@master admin]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 07-JUL-2015 10:29:55 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 07-JUL-2015 09:32:12 Uptime 0 days 0 hr. 57 min. 42 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/master/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=master)(PORT=1521))) 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
总结: 安装过程中,由于hostname设置错误,地址监听和静默建库都出错了,修改正确后重新建库成功。
启动监听 lsnrctl start 报 ORA-12545: Connect failed because target host or object does not exist
修改 /u01/app/oracle/product/11.2.0/dbhome_1/network/admin 下的 listener.ora 和 tnsname.ora 的 host