一、安装必要的包
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.conf kernel.shmall = 2097152 #该参数表示系统一次可以使用的共享内存总量(以页为单位)。缺省值就是2097152,通常不需要修改 #就是 2097152*4k/1024/1024 = 8G 就是说可用共享内存一共 8G getconf PAGE_SIZE可以查看系统页大小 kernel.shmmax = 2147483648 #该参数定义了共享内存段的最大尺寸(以字节为单位)。缺省为32M,对于oracle来说,该缺省值太低了,通常将其设置为2G kernel.shmmni = 4096 #这个内核参数用于设置系统范围内共享内存段的最大数量。该参数的默认值是 4096 。通常不需要更改 # semaphores: semmsl, semmns, semopm, semmni kernel.sem = 250 32000 100 128 fs.file-max = 65536 net.ipv4.ip_local_port_range = 1024 65000 net.core.rmem_default=262144 net.core.rmem_max=262144 net.core.wmem_default=262144 net.core.wmem_max=262144
参数补充说明
可以通过ipcs -lm命令查看目前系统共享内存的参数限制:
[root@centos5 oracle]# ipcs -lm ------ Shared Memory Limits -------- max number of segments = 4096 max seg size (kbytes) = 67108864 max total shared memory (kbytes) = 17179869184 min seg size (bytes) = 1
SHMMAX
含义:单个共享内存段最大字节数
设置:比SGA略大
查看:cat /proc/sys/kernel/shmmax
$ cat /proc/sys/kernel/shmmax
68719476736
SHMMNI
含义:共享内存段最大个数
设置:至少4096
查看:cat /proc/sys/kernel/shmmni
# cat /proc/sys/kernel/shmmni
4096
SHMALL
含义:系统中共享内存页总数
设置:至少ceil(shmmax/PAGE_SIZE);ORACLE DOC 默认值:2097152*4096=8GB
查看:cat /proc/sys/kernel/shmall
$ getconf PAGE_SIZE 4096
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/login session required /lib/security/pam_limits.so session required pam_limits.so
关闭selinux
[root@centos5 home]# vi /etc/selinux/config SELINUX=enforcing 修改为 SELINUX=disabled
修改环境变量
vi /etc/oraInst.loc inventory_loc=/home/oracle/oraInventory inst_group=oracle
[root@centos5 ~]# su - oracle [oracle@centos5 ~]$ vi .bash_profile export ORACLE_BASE=/home/oracle export ORACLE_HOME=$ORACLE_BASE/product/10g LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33 TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN NLS_LANG=american_america.US7ASCII; export NLS_LANG CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib; export CLASSPATH PATH=$PATH:$ORACLE_HOME/bin:/usr/sbin; export PATH LANG=en_US; export LANG ORACLE_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=false RESTART_REMOTE_SYSTEM=false ORACLE_HOSTNAME=localhost COMPONENT_LANGUAGES={"zh_CN"} s_nameForDBAGrp="dba" n_configurationOption=3 ORACLE_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.sh need 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.rsp UNIX_GROUP_NAME=”oinstall” FROM_LOCATION="../stage/products.xml" ORACLE_HOME= "/home/oracle/product/10g" ORACLE_HOME_NAME="ORACLEHOME" RESTART_SYSTEM=false COMPONENT_LANGUAGES={"zh_CN"}
执行升级
./runInstaller -silent -responseFile /home/db/Disk1/response/patchset.rsp End 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.sh To 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.rsp Template General Purpose does not exist. Please specify an existing template for database creation. [oracle@centos5 database]$ dbca -silent -responseFile /home/db/database/response/dbca.rsp Not 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 : <db_name>.<db_domain> - when database domain isn't NULL # <db_name> - 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.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 "/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 sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Sat May 11 01:44:32 2013 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> 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.rsp Exception 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.<clinit>(DebugHelper.java:29) at java.awt.Component.<clinit>(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.ora LISTENER = (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 start LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 11-MAY-2013 02:08:30 Copyright (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 - Production System parameter file is /home/oracle/product/10g/network/admin/listener.ora Log messages written to /home/oracle/product/10g/network/log/listener.log Listening 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 LISTENER Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production Start Date 11-MAY-2013 02:08:31 Uptime 0 days 0 hr. 0 min. 0 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /home/oracle/product/10g/network/admin/listener.ora Listener Log File /home/oracle/product/10g/network/log/listener.log Listening 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 sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon May 13 23:56:50 2013 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> 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