打杂
全部博文(524)
分类: Oracle
2015-02-04 17:42:02
Oracle 11gR2 for Linux 安装
一. 硬、软件环境:
1.硬件:IBM x3650 M2,2颗Intel Xeon E5405 2.0Ghz CPU,2G*2=4G内存,3块146G SAS硬盘,做raid0配置。
2.软件:RHEL5.4 32位版本,linux_11gR2_grid,linux_11gR2_database,SecureCRT6.1,Xmanager3.0。注:Xmanager3.0用于上传软件文件和x窗口映射。
二.安装完操作系统后以root用户创建oracle相关的用户和组
参照oracle的官方文档,创建两个用户grid和oracle,grid用户用来安装grid软件,oracle用户安装oracle软件,数据库文件使用ASM管理。
注:#开头的命令对应root用户执行,
$开始的命令对应grid和oracle用户
首先,创建四个组oinstall, dba, asmadmin, asmdba:
#groupadd -g 1000 oinstall
#groupadd -g 1100 dba
#groupadd -g 1200 asmadmin
#groupadd -g 1300 asmdba
再创建两个用户grid和oracle:
#useradd -u 1001 -g oinstall -G asmdba,asmadmin,dba grid
#passwd grid
#useradd -u 1002 -g oinstall -G dba,asmdba oracle
#passwd oracle
创建目录和授权:
#mkdir -p /u01/app/grid 注:此目录用来安装grid软件
#chown -R grid:oinstall /u01
#chmod -R 775 /u01
#mkdir -p /u02/app/oracle 注:此目录用来安装oracle软件
#chown -R oracle:oinstall /u02
#chmod -R 775 /u02
三.所需的rpm包,参照oracle官方文档,根据不同的操作系统版本,rpm包的版本有所区别,包名肯定是一样的。
binutils-2.17.50.0.6
compat-libstdc++-33-3.2.3
elfutils-libelf-0.125
elfutils-libelf-devel-0.125
elfutils-libelf-devel-static-0.125
gcc-4.1.2
gcc-c++-4.1.2
glibc-2.5-24
glibc-common-2.5
glibc-devel-2.5
glibc-headers-2.5
kernel-headers-2.6.18
ksh-20060214
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.2
libgomp-4.1.2
libstdc++-4.1.2
libstdc++-devel-4.1.2
make-3.81
sysstat-7.0.2
unixODBC-2.2.11
unixODBC-devel-2.2.11
pdksh
四.编辑grid和oracle用户的.bash_profile,设置环境变量:
1.grid 用户的.bash_profile
umask 022
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_BASE=/u01/app
export ORACLE_HOME=$ORACLE_BASE/grid
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM
export ORACLE_HOSTNAME=rhel54 注:rhel54是我的计算机名
2.oracle 用户的.bash_profile
umask 022
export TMP=/tmp
export TMPDIR=/tmp
export ORACLE_BASE=/u02/app
export ORACLE_HOME=$ORACLE_BASE/oracle
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=ora11g
export ORACLE_HOSTNAME=rhel54 注:rhel54是我的计算机名
五.编辑如下文件,设置相关的值。
1.编辑/etc/security/limits.conf ,添加如下行:
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
2.编辑/etc/pam.d/login 添加如下行:
session required pam_limits.so
编辑/etc/profile ,添加如下行:
if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
3.编辑/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 = 1048586
执行 #sysctl –p命令,使设置生效。
六.安装asmlib包:
去 下载asmlib相关的三个包,并上传到服务器上:oracleasm-2.6.18-164.el5PAE-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.3-1.el5.i386.rpm
注:第一个包一定要和操作系统内核的版本相对应
用#uname –r查看内核版本:
[root@rhel54 test]# uname -r
2.6.18-164.el5PAE
2.安装asmlib包
#rpm -Uvh oracleasm*.rpm
安装完asmlib包之后,执行如下命令:
#/usr/sbin/oracleasm configure -i
输入用户grid,输入用户组asmadmin
执行#/usr/sbin/oracleasm init 命令
3.创建asm磁盘,我创建了两个asm磁盘。
操作系统的分区情况如下:
[root@rhel54 grid]# fdisk -l
Disk /dev/sda: 440.0 GB, 440073715712 bytes
255 heads, 63 sectors/track, 53502 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 7649 61440561 83 Linux
/dev/sda2 7650 8171 4192965 82 Linux swap / Solaris
/dev/sda3 8172 53502 364121257+ 5 Extended
/dev/sda5 8172 10662 20008926 83 Linux
/dev/sda6 10663 13153 20008926 83 Linux
/dev/sda7 13154 15644 20008926 83 Linux
#chown grid:asmadmin /dev/sda5
#chown grid:asmadmin /dev/sda6
#/usr/sbin/oracleasm createdisk VOL1 /dev/sda5
#/usr/sbin/oracleasm createdisk VOL2 /dev/sda6
#/usr/sbin/oracleasm scandisks
[root@rhel54 grid]# /usr/sbin/oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks..
#/usr/sbin/oracleasm listdisks
[root@rhel54 grid]# /usr/sbin/oracleasm listdisks
VOL1
VOL2
NTP setting:
#/sbin/service ntpd stop
#chkconfig ntpd off
#mv /etc/ntp.conf /etc/ntp.conf.bak
上面所有配置完成后,重启一下服务器。
七.安装grid软件:
将数据库软件上传到服务器,并解压,上传软件个人建议使用Xmanager3.0,这是个非常好的软件,速度快,走ssh,安全。
以grid用户登录服务器,进入到grid软件所在目录,
$cd /test/grid
$./runInstaller 开始安装grid,直接上图:
下图中选择第二项:
下图中是创建asm磁盘组:
下图设置sys和asmsnmp用户口令,会有口令强度不足的警告提示,直接next
下图中选yes,直接继续:
下图中,各选项默认即可:
下图中是Grid的安装目录:
当安装到76%时,提示执行以下脚本,以root用户执行:
确认安装是否成功:
[grid@rhel54 ~]$ ps -ef |grep +ASM
grid 8379 1 0 14:47 ? 00:00:00 asm_pmon_+ASM
grid 8381 1 0 14:47 ? 00:00:00 asm_vktm_+ASM
grid 8385 1 0 14:47 ? 00:00:00 asm_gen0_+ASM
grid 8387 1 0 14:47 ? 00:00:00 asm_diag_+ASM
grid 8389 1 0 14:47 ? 00:00:00 asm_psp0_+ASM
grid 8391 1 0 14:47 ? 00:00:00 asm_dia0_+ASM
grid 8393 1 0 14:47 ? 00:00:00 asm_mman_+ASM
grid 8395 1 0 14:47 ? 00:00:00 asm_dbw0_+ASM
grid 8397 1 0 14:47 ? 00:00:00 asm_lgwr_+ASM
grid 8399 1 0 14:47 ? 00:00:00 asm_ckpt_+ASM
grid 8401 1 0 14:47 ? 00:00:00 asm_smon_+ASM
grid 8403 1 0 14:47 ? 00:00:00 asm_rbal_+ASM
grid 8405 1 0 14:47 ? 00:00:00 asm_gmon_+ASM
grid 8407 1 0 14:47 ? 00:00:00 asm_mmon_+ASM
grid 8409 1 0 14:47 ? 00:00:00 asm_mmnl_+ASM
[grid@rhel54 ~]$ sqlplus / as sysasm
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jan 7 14:57:49 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Automatic Storage Management option
SQL> select name from v$asm_disk;
NAME
------------------------------
VOL1
SQL> select name from v$asm_diskgroup;
NAME
------------------------------
DG1
SQL>
八.安装oracle软件:
以oracle用户登录
$cd /test/database
$./runInstaller
开始安装oracle软件:
下图中两项均为空:
下图中点yes,忽略错误:
下图中选第二项,只安装oracle软件,稍后以dbca创建数据库:
下图中选第一项,单实例数据库:
下图中各选项默认即可:
当安装到94%时,提示执行如下脚本,以root用户执行:
#sh /u02/app/oracle/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u02/app/oracle
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]:
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
九.创建数据库
以oracle用户登录,输入dbca,开始建库:
下图中“storage type” 项选asm
耐心等待:
验证结果:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
SQL> select * from v$option;
PARAMETER VALUE
---------------------------------------- ----------------------------------------
Partitioning TRUE
Objects TRUE
Real Application Clusters FALSE
Advanced replication TRUE
Bit-mapped indexes TRUE
Connection multiplexing TRUE
Connection pooling TRUE
Database queuing TRUE
Incremental backup and recovery TRUE
Instead-of triggers TRUE
Parallel backup and recovery TRUE
PARAMETER VALUE
---------------------------------------- ----------------------------------------
Parallel execution TRUE
Parallel load TRUE
Point-in-time tablespace recovery TRUE
Fine-grained access control TRUE
Proxy authentication/authorization TRUE
Change Data Capture TRUE
Plan Stability TRUE
Online Index Build TRUE
Coalesce Index TRUE
Managed Standby TRUE
Materialized view rewrite TRUE
PARAMETER VALUE
---------------------------------------- ----------------------------------------
Materialized view warehouse refresh TRUE
Database resource manager TRUE
Spatial TRUE
Automatic Storage Management TRUE
Export transportable tablespaces TRUE
Transparent Application Failover TRUE
Fast-Start Fault Recovery TRUE
Sample Scan TRUE
Duplexed backups TRUE
Java TRUE
OLAP Window Functions TRUE
PARAMETER VALUE
---------------------------------------- ----------------------------------------
Block Media Recovery TRUE
Fine-grained Auditing TRUE
Application Role TRUE
Enterprise User Security TRUE
Oracle Data Guard TRUE
Oracle Label Security FALSE
OLAP TRUE
Basic Compression TRUE
Join index TRUE
Trial Recovery TRUE
Data Mining TRUE
PARAMETER VALUE
---------------------------------------- ----------------------------------------
Online Redefinition TRUE
Streams Capture TRUE
File Mapping TRUE
Block Change Tracking TRUE
Flashback Table TRUE
Flashback Database TRUE
Transparent Data Encryption TRUE
Backup Encryption TRUE
Unused Block Compression TRUE
Oracle Database Vault FALSE
Result Cache TRUE
PARAMETER VALUE
---------------------------------------- ----------------------------------------
SQL Plan Management TRUE
SecureFiles Encryption TRUE
Real Application Testing TRUE
Flashback Data Archive TRUE
DICOM TRUE
Active Data Guard TRUE
Server Flash Cache TRUE
Advanced Compression TRUE
XStream TRUE
Deferred Segment Creation TRUE
65 rows selected.
十.修改ora.cssd和ora.diskmon资源的属性:
以grid用户登录,执行如下命令:
$crsctl modify resource "ora.cssd" -attr "AUTO_START=1"
$crsctl modify resource "ora.diskmon" -attr "AUTO_START=1"
否则服务器重启后,启动asm实例会报can't to connect cluster syncron service 错误