一、安装必要的包
yum install compat-gcc-34 compat-gcc-34-c++ compat-libstdc++-33 gcc gcc-c++ glibc-devel libstdc++-devel sysstat libXp
二、修改Linux发行版本信息
[root@centos5 oracle]# vi /etc/redhat-release#CentOS release 5.8 (Final)Red Hat Enterprise Linux AS release 4 (Nahant Update 4)
三、修改系统设置及内核参数
vi /etc/sysctl.confkernel.shmall = 2097152 #该参数表示系统一次可以使用的共享内存总量(以页为单位)。缺省值就是2097152,通常不需要修改#就是 2097152*4k/1024/1024 = 8G 就是说可用共享内存一共 8G getconf PAGE_SIZE可以查看系统页大小kernel.shmmax = 2147483648#该参数定义了共享内存段的最大尺寸(以字节为单位)。缺省为32M,对于oracle来说,该缺省值太低了,通常将其设置为2Gkernel.shmmni = 4096#这个内核参数用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096 。通常不需要更改# semaphores: semmsl, semmns, semopm, semmnikernel.sem = 250 32000 100 128fs.file-max = 65536net.ipv4.ip_local_port_range = 1024 65000net.core.rmem_default=262144net.core.rmem_max=262144net.core.wmem_default=262144net.core.wmem_max=262144
参数补充说明
可以通过ipcs -lm命令查看目前系统共享内存的参数限制:[root@centos5 oracle]# ipcs -lm------ Shared Memory Limits --------max number of segments = 4096max seg size (kbytes) = 67108864max total shared memory (kbytes) = 17179869184min seg size (bytes) = 1
SHMMAX
含义:单个共享内存段最大字节数设置:比SGA略大查看:cat /proc/sys/kernel/shmmax$ cat /proc/sys/kernel/shmmax68719476736SHMMNI含义:共享内存段最大个数设置:至少4096查看:cat /proc/sys/kernel/shmmni# cat /proc/sys/kernel/shmmni4096SHMALL含义:系统中共享内存页总数设置:至少ceil(shmmax/PAGE_SIZE);ORACLE DOC 默认值:2097152*4096=8GB查看:cat /proc/sys/kernel/shmall$ getconf PAGE_SIZE4096
Oracle建议对每个Linux账户可以使用的进程数和打开的文件数设置限制(可选设置)
打开文件limits.conf[root@centos5 home]# vi /etc/security/limits.conf* soft nproc 2047* hard nproc 16384* soft nofile 1024* hard nofile 65536
[root@centos5 home]# vi /etc/pam.d/loginsession required /lib/security/pam_limits.sosession required pam_limits.so
关闭selinux
[root@centos5 home]# vi /etc/selinux/configSELINUX=enforcing修改为SELINUX=disabled
vi /etc/oraInst.locinventory_loc=/home/oracle/oraInventoryinst_group=oracle
[root@centos5 ~]# su - oracle[oracle@centos5 ~]$ vi .bash_profileexport ORACLE_BASE=/home/oracleexport ORACLE_HOME=$ORACLE_BASE/product/10gLD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATHORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMINNLS_LANG=american_america.US7ASCII; export NLS_LANGCLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib; export CLASSPATHPATH=$PATH:$ORACLE_HOME/bin:/usr/sbin; export PATHLANG=en_US; export LANGORACLE_SID=osa
cpio -idmv < 10201_database_linux_x86_64.cpio
创建用户
[root@centos5 db]# groupadd dba[root@centos5 db]# groupadd oinstall[root@centos5 db]# useradd -m -g oinstall -G dba oracle
修改安装配置文件:
[oracle@localhost database]$ cd response/[oracle@localhost response]$ vi enterprise.rsp修改必要的参数UNIX_GROUP_NAME=”oinstall”FROM_LOCATION= "../stage/products.xml"ORACLE_HOME= "/home/oracle/product/10g"ORACLE_HOME_NAME="ORACLEHOME"RESTART_SYSTEM=falseRESTART_REMOTE_SYSTEM=falseORACLE_HOSTNAME=localhostCOMPONENT_LANGUAGES={ "zh_CN"}s_nameForDBAGrp="dba"n_configurationOption=3ORACLE_HOME_NAME="ORACLEHOME" ---这里注意补丁时ORACLE_HOME必须设置为一致,否则升级失败
开始安装
./runInstaller -silent -responseFile /home/db/database/response/enterprise.rsp.....End of install phases.(Sat May 11 00:48:25 CST 2013)WARNING:The following configuration scripts/home/oracle/product/10g/root.shneed to be executed as root for configuring the system. If you skip the execution of the configuration tools, the configuration will not be complete and the product wont function properly. In order to get the product to function properly, you will be required to execute the scripts and the configuration tools after exiting the OUI.根据提示在root下执行/home/oracle/product/10g/root.sh
安装补丁
修改响应文件vi /home/db/Disk1/response/patchset.rspUNIX_GROUP_NAME=”oinstall”FROM_LOCATION="../stage/products.xml"ORACLE_HOME= "/home/oracle/product/10g"ORACLE_HOME_NAME="ORACLEHOME"RESTART_SYSTEM=falseCOMPONENT_LANGUAGES={ "zh_CN"}
执行升级
./runInstaller -silent -responseFile /home/db/Disk1/response/patchset.rspEnd of install phases.(Saturday, May 11, 2013 1:13:38 AM CST)WARNING:The following configuration scripts need to be executed as the "root" user.#!/bin/sh#Root script to run/home/oracle/product/10g/root.shTo execute the configuration scripts: 1. Open a terminal window 2. Log in as "root" 3. Run the scripts
以root身份执行
/home/oracle/product/10g/root.sh
五、静默建立数据库
修改响应文件response子目录下的应答文件 dbca.rsp
OPERATION_TYPE = "createDatabase"GDBNAME = "osa"SID = "osa"SYSPASSWORD = "sys"SYSTEMPASSWORD = "system"CHARACTERSET = "ZHS16GBK"TEMPLATENAME = "/home/oracle/product/10g/assistants/dbca/templates/General_Purpose.dbc"EMCONFIGURATION = "LOCAL"SYSMANPASSWORD = "sysman"DBSNMPPASSWORD = "dbsnmp"
[oracle@centos5 database]$ dbca -silent -responseFile /home/db/database/response/dbca.rspTemplate General Purpose does not exist. Please specify an existing template for database creation.[oracle@centos5 database]$ dbca -silent -responseFile /home/db/database/response/dbca.rspNot all required options provided for the command "createDatabase".Please refer to the manual for details.Not all required options provided for the command "createDatabase".Please refer to the manual for details.
报错处理:
注意一下TEMPLATENAME应该是在CREATEDATABASE目录里[CREATEDATABASE]#-----------------------------------------------------------------------------# Name : GDBNAME# Datatype : String# Description : Global database name of the database# Valid values :. - when database domain isn't NULL# - when database domain is NULL# Default value : None# Mandatory : Yes#-----------------------------------------------------------------------------GDBNAME = "osa" TEMPLATENAME = "/home/oracle/product/10g/assistants/dbca/templates/General_Purpose.dbc"
解决问题后开始执行静默创建
[oracle@centos5 database]$ dbca -silent -responseFile /home/db/database/response/dbca.rspCopying database files1% complete3% complete11% complete18% complete26% complete37% completeCreating and starting Oracle instance40% complete45% complete50% complete55% complete56% complete60% complete62% completeCompleting Database Creation66% complete70% complete73% complete85% complete96% complete100% completeLook at the log file "/home/oracle/product/10g/cfgtoollogs/dbca/osa/osa.log" for further details.
然后编辑 /etc/oratab将
<Oracle的SID>:<Oracle的主目录>:N修改为<Oracle的SID>:<Oracle的主目录>:Y安装完成!查看数据库
[oracle@centos5 oraInventory]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.4.0 - Production on Sat May 11 01:44:32 2013Copyright (c) 1982, 2007, Oracle. All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select open_mode from v$database;OPEN_MODE----------READ WRITE
六、静默listen设置
编辑Oracle安装目录里response子目录下的应答文件 netca.rsp,修改以下项目。INSTALL_TYPE=""custom"" 安装的类型LISTENER_NUMBER=1 监听器数量LISTENER_NAMES={ "LISTENER"} 监听器的名称列表LISTENER_PROTOCOLS={ "TCP;1521"} 监听器使用的通讯协议列表LISTENER_START=""LISTENER"" 监听器启动的名称
netca遇到错误
[oracle@centos5 response]$ netca -silent -responseFile /home/db/database/response/netca.rsp ****DISPLAY environment variable not set! Oracle Net Configuration Assistant is a GUI tool which requires that DISPLAY specify a location where GUI tools can display. Set and export DISPLAY, then re-run.[oracle@centos5 response]$ export DISPLAY=localhost:0.0[oracle@centos5 response]$ netca -silent -responseFile /home/db/database/response/netca.rspException in thread "main" java.lang.UnsatisfiedLinkError: /home/oracle/product/10g/jdk/jre/lib/i386/libawt.so: libXt.so.6: cannot open shared object file: No such file or directory at java.lang.ClassLoader$NativeLibrary.load(Native Method) at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1586) at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1503) at java.lang.Runtime.loadLibrary0(Runtime.java:788) at java.lang.System.loadLibrary(System.java:834) at sun.security.action.LoadLibraryAction.run(LoadLibraryAction.java:50) at java.security.AccessController.doPrivileged(Native Method) at sun.awt.NativeLibLoader.loadLibraries(NativeLibLoader.java:38) at sun.awt.DebugHelper.(DebugHelper.java:29) at java.awt.Component. (Component.java:506)[oracle@centos5 response]$ netca -silent -responseFile /home/db/database/response/netca.rsp
懒得解决,直接使用手工listen配置文件
[oracle@centos5 ~]$ cd /home/oracle/product/10g/network/admin/[oracle@centos5 admin]$ vi listener.oraLISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 172.16.64.120)(PORT = 1521)) ) ) )SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = osa) (ORACLE_HOME = /home/oracle/product/10g) (SID_NAME = osa) ) ) "listener.ora" [New] 17L, 323C written[oracle@centos5 admin]$ lsnrctl startLSNRCTL for Linux: Version 10.2.0.4.0 - Production on 11-MAY-2013 02:08:30Copyright (c) 1991, 2007, Oracle. All rights reserved.Starting /home/oracle/product/10g/bin/tnslsnr: please wait...TNSLSNR for Linux: Version 10.2.0.4.0 - ProductionSystem parameter file is /home/oracle/product/10g/network/admin/listener.oraLog messages written to /home/oracle/product/10g/network/log/listener.logListening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.64.120)(PORT=1521)))Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.16.64.120)(PORT=1521)))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 10.2.0.4.0 - ProductionStart Date 11-MAY-2013 02:08:31Uptime 0 days 0 hr. 0 min. 0 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Parameter File /home/oracle/product/10g/network/admin/listener.oraListener Log File /home/oracle/product/10g/network/log/listener.logListening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=172.16.64.120)(PORT=1521)))Services Summary...Service "osa" has 1 instance(s). Instance "osa", status UNKNOWN, has 1 handler(s) for this service...The command completed successfully
七、建立测试用户及表空间
[oracle@centos5 dbs]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.4.0 - Production on Mon May 13 23:56:50 2013Copyright (c) 1982, 2007, Oracle. All Rights Reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> create tablespace osa_test datafile '/home/oracle/oradata/osa/osa_test.dbf' size 500m;Tablespace created.SQL> create user osa_test identified by osa_test default tablespace osa_test temporary tablespace temp;User created.SQL> grant connect,resource to osa_test;Grant succeeded.
测试完毕 by cycsa