一、介绍
因业务需要,最近在主系统的基础上搭建DADATAGUARD系统,本文只讲ORACLE数据库+ASM磁盘管理工具的安装;
1.服务器系统版本:OEL 5.7 x64Bit ,kernel 2.6.18-274.el5
2.磁盘分区格式: gpt
3.ORACLE软件版本: p10404530_112030_Linux-x86-64
4.ASM 组件版本:
oracleasm-2.6.18-274.el5-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-274.el5debug-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-274.el5-debuginfo-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-274.el5xen-2.0.5-1.el5.x86_64.rpm
oracleasmlib-2.0.4-1.el5.x86_64.rpm
oracleasm-support-2.1.7-1.el5.x86_64.rpm
二、安装实施准备
1.创建用户和组成员
[root@popdg ~]# groupadd oinstall
[root@popdg ~]# groupadd dba
[root@popdg ~]# groupadd oper
[root@popdg ~]# groupadd asmadmin
[root@popdg ~]# groupadd asmdba
[root@popdg ~]# groupadd asmoper
[root@popdg ~]# useradd -g oinstall -G dba,asmdba,oper -d /home/oracle oracle
[root@popdg ~]#useradd -g oinstall -G dba,asmadmin,asmdba,asmoper -d /home/grid grid
2.创建用户的密码
passwd oracle
new unix password: oracle
passwd grid
new unix password: grid
3.大容量磁盘分区
[root@popdg mapper]# parted mpath2
GNU Parted 1.8.1
Using /dev/mapper/mpath2
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath2: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 4700GB 4700GB primary
(parted) rm 1
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath2: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) mkpart p 0 1024G
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath2: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1024GB 1024GB p
(parted) mkpart p 1024G 2048G
(parted) mkpart p 2048G 3096G
(parted) mkpart p 3096G 4120G
(parted) mkpart p 4120G 4724G
(parted) PRINT
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath2: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1024GB 1024GB p
2 1024GB 2048GB 1024GB p
3 2048GB 3096GB 1048GB p
4 3096GB 4120GB 1024GB p
5 4120GB 4724GB 604GB p
[root@popdg mapper]# parted mpath3
GNU Parted 1.8.1
Using /dev/mapper/mpath3
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath3: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 4700GB 4700GB primary
(parted) rm 1
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath3: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
(parted) mkpart p 0G 1024G
(parted) print
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath3: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1024GB 1024GB p
2 1024GB 2048GB 1024GB p
3 2048GB 3096GB 1048GB p
(parted) mkpart p 3096G 4724G
(parted) PRINT
Model: Linux device-mapper (dm)
Disk /dev/mapper/mpath3: 4724GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Number Start End Size File system Name Flags
1 17.4kB 1024GB 1024GB p
2 1024GB 2048GB 1024GB p
3 2048GB 3096GB 1048GB p
4 3096GB 4724GB 1628GB p
[root@popdg mapper]# mkfs.ext3 /dev/mapper/mpath3p4
mke2fs 1.39 (29-May-2006)
warning: 76 blocks unused.
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
199175328 inodes, 397574144 blocks
19878711 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
12133 block groups
32768 blocks per group, 32768 fragments per group
16416 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000, 214990848
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
4.挂载文件系统
[root@popdg ~]# mkdir -p /fs
[root@popdg ~]# mount /dev/mapper/mpath3p4 /fs
[root@popdg ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 508G 9.5G 472G 2% /
/dev/sda1 996M 78M 867M 9% /boot
tmpfs 127G 0 127G 0% /dev/shm
/dev/mapper/mpath3p4 1.5T 198M 1.4T 1% /fs
[root@popdg ~]# vi /etc/fstab
LABEL=/ / ext3 defaults 1 1
LABEL=/boot1 /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0
5.修改启动内核
[root@popdg grub]# vi grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda3
# initrd /initrd-version.img
#boot=/dev/sda
default=2
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
kernel /vmlinuz-2.6.32-200.13.1.el5uek ro root=LABEL=/ rhgb quiet numa=o initrd /initrd-2.6.32-200.13.1.el5uek.img
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/sda3
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
initrd /initrd-2.6.32-200.13.1.el5uek.img
module /initrd-2.6.18-274.el5xen.img
title Oracle Linux Server-base (2.6.18-274.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-274.el5 ro root=LABEL=/ rhgb quiet numa=off
#boot=/dev/sda
"grub.conf" 26L, 988C written
6.安装ASM包
[root@popdg soft]# cd asmlib
[root@popdg asmlib]# ls
oracleasm-2.6.18-274.el5-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-274.el5debug-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-274.el5-debuginfo-2.0.5-1.el5.x86_64.rpm
oracleasm-2.6.18-274.el5xen-2.0.5-1.el5.x86_64.rpm
oracleasmlib-2.0.4-1.el5.x86_64.rpm
oracleasm-support-2.1.7-1.el5.x86_64.rpm
[root@popdg asmlib]# rpm -uvh oracleasm*.rpm
-uvh: unknown option
[root@popdg asmlib]# rpm -ivh oracleasm*.rpm
如果系统已经安装以上ASMLIB包,最好是先卸载相关的包,然后重启后重新安装相关的系统包!
7.创建安装目录
[root@popdg ~]# mkdir -p /u01/app/11.2.0.3/grid
[root@popdg ~]# mkdir -p /u01/app/grid
[root@popdg ~]# mkdir -p /u01/app/oracle/product/11.2.0.3/db_1
[root@popdg ~]# chown -R grid:oinstall /u01
[root@popdg ~]# chown -R oracle:oinstall /u01/app/oracle
[root@popdg ~]# chmod -R 775 /u01
8.修改环境变量
[oracle@popdg ~]$ vim .bash_profile
export ORACLE_SID=popdg
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=American_america.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin:.
-------------------------------------------------------------
[grid@popdg ~]$ vim .bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0.3/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=American_america.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin:.
export ORACLE_SID=+ASM
9.修改系统参数
[root@popdg ~]# vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 8589934592
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
执行/sbin/sysctl -p使设置立即生效
# sysctl -p
修改文件数和安全设置
#vim /etc/security/limits.conf
//增加以下内容
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 1024
增加session连接限制库
#vim /etc/pam.d/login
//增加以下内容
session required /lib/security/pam_limits.so
修改hosts文件和主机名
#vim /etc/hosts
192.168.1.10 popdg
# vim /etc/sysconfig/network
//修改HOSTNAME,使其永久生效
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=popdg
GATEWAY=192.168.1.1
三、安装grid软件和ASM组件
1.安装ASM
2.配置ASM
root用户登录,(本次安装为单实例),执行:
[root@popdg ~]# cd /etc/init.d/
[root@popdg init.d]# ./oracleasm
Usage: ./oracleasm {start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}
[root@popdg init.d]# ./oracleasm configure
Configuring the Oracle ASM library driver.
This will configure the on-boot properties of the Oracle ASM library
driver. The following questions will determine whether the driver is
loaded on boot and what permissions it will have. The current values
will be shown in brackets ('[]'). Hitting without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface []: grid
Default group to own the driver interface []: asmadmin
Start Oracle ASM library driver on boot (y/n) [n]: y
Scan for Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@popdg init.d]# ./oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [ OK ]
3.创建ASM磁盘
[root@popdg init.d]# ./oracleasm createdisk VOL1 /dev/mapper/mpath2p1
Marking disk "VOL2" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL2 /dev/mapper/mpath2p2
Marking disk "VOL2" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL3 /dev/mapper/mpath2p3
Marking disk "VOL3" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL4 /dev/mapper/mpath2p4
Marking disk "VOL4" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL5 /dev/mapper/mpath2p5
Marking disk "VOL5" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL6 /dev/mapper/mpath3p1
Marking disk "VOL6" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL7 /dev/mapper/mpath3p2
Marking disk "VOL7" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm createdisk VOL8 /dev/mapper/mpath3p3
Marking disk "VOL8" as an ASM disk: [ OK ]
[root@popdg init.d]# ./oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@popdg init.d]# ./oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5
VOL6
VOL7
VOL8
4.启动VNCSERVER
[grid@popdg soft]$ vncserver
You will require a password to access your desktops.
Password:
Verify:
xauth: creating new authority file /home/oracle/.Xauthority
New 'popdg:2 (grid)' dedsktop is popdg:2
Creating default startup script. /home/oracle/.vnc/xstartup
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/popdg:2.log
5.安装grid组件
//图形界面grid用户登录,进入/backup/
#unzip p10404530_112030_Linux-x86-64_3of7.zip
#cd grid
#./runinstall
[root@popdg ~]# cd /u01/app/oraInventory/
[root@popdg oraInventory]# ls
ContentsXML logs oraInst.loc orainstRoot.sh oui
[root@popdg oraInventory]# ./orainstRoot.sh
Changing permissions of /u01/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oraInventory to oinstall.
The execution of the script. is complete.
[root@popdg oraInventory]# cd /u01/app/11.2.0/grid/
//注意:在ORACLE单实例中执行./root.sh 后,显示说明:
##################################################
To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
/u01/app/11.2.0/grid/perl/bin/perl -I/u01/app/11.2.0/grid/perl/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl
##################################################
//提示:在执行root.sh后,再执行/u01/app/11.2.0/grid/crs/install/roothas.pl
//否则后面的creade asm将会出错
[root@popdg grid]# ./root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/11.2.0/grid
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
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 script.
Now product-specific root actions will be performed.
To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:
//大概是说:配置grid为一个独立的节点(单实例),需要root用户:(执行roothas.pl)
/u01/app/11.2.0/grid/perl/bin/perl -I/u01/app/11.2.0/grid/perl/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl
To configure Grid Infrastructure for a Cluster execute the following command:
/u01/app/11.2.0/grid/crs/config/config.sh
This command launches the Grid Infrastructure Configuration Wizard. The wizard also supports silent operation, and the parameters can be passed through the response file that is available in the installation media.
6.ASMCA创建ASM磁盘组
$asmca
//asmca创建ASM磁盘介绍
创建两个磁盘组
DATA_DM02
RECO_DM02
//注意:如果上述在执行./root.sh后没有执行,/u01/app/11.2.0/grid/crs/install/roothas.pl
//那么将会出现:
Oracle Grid Infrastructure is not configured properly. ASMCA needs Oracle Grid Infrastructure to configure ASM.
//如果你错过了,那么现在执行还来得及;
[root@popdg install]# ./roothas.pl
Using configuration parameter file: ./crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node popdg successfully pinned.
Adding Clusterware entries to inittab
popdg 2012/10/29 02:03:01 /u01/app/11.2.0/grid/cdata/popdg/backup_20121029_020301.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server
注:如果识别不了磁盘信息需要手工指定磁盘路径
输入路径:/dev/oracleasm/disks/*
[root@popdg install]#
//执行roothas.pl 脚本后,再检查has进程是否启动;
#ps -ef |grep has
//确定进程已经启动后,再图形下执行Create ASM
ASM磁盘创建完成后CRS状态
/7.使用Oracle用户图形下安装oralce软件
[oracle@popdg ]$ cd /u02/
[oracle@popdg ]$unzip p10404530_112030_Linux-x86-64_1of7.zip
[oracle@popdg ]$unzip p10404530_112030_Linux-x86-64_2of7.zip
[oracle@popdg database]$./runInstaller
//oracle软件安装介绍
[root@popdg db_1]# ./root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.2.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The contents of "dbhome" have not changed. No need to overwrite.
The contents of "oraenv" have not changed. No need to overwrite.
The contents of "coraenv" have not changed. No need to overwrite.
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 script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
[root@popdg db_1]#
四:简单管理
1.单实例+ASM 的监听
安装好grid后,无论是管理磁盘、磁盘数据、oralce启动与停止、监听等均可由grid来操作;
使用grid用户netca创建监听
2.日常管理ORACLE
[grid@popdg ~]$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type OFFLINE OFFLINE
ora....ER.lsnr ora....er.type ONLINE ONLINE ctp-...rver
ora.asm ora.asm.type OFFLINE OFFLINE
ora.cssd ora.cssd.type ONLINE OFFLINE
ora.diskmon ora....on.type OFFLINE OFFLINE
ora.evmd ora.evm.type ONLINE ONLINE ctp-...rver
ora.ons ora.ons.type OFFLINE OFFLINE
ora.zxxj.db ora....se.type OFFLINE OFFLINE
[grid@popdg ~]$
[grid@popdg ~]$ crs_stat //资源项目
NAME=ora.DATA.dg
TYPE=ora.diskgroup.type
TARGET=OFFLINE
STATE=OFFLINE
NAME=ora.LISTENER.lsnr
TYPE=ora.listener.type
TARGET=ONLINE
STATE=ONLINE on popdg
NAME=ora.asm
TYPE=ora.asm.type
TARGET=OFFLINE
STATE=OFFLINE
NAME=ora.cssd
TYPE=ora.cssd.type
TARGET=ONLINE
STATE=OFFLINE
NAME=ora.diskmon
TYPE=ora.diskmon.type
TARGET=OFFLINE
STATE=OFFLINE
NAME=ora.evmd
TYPE=ora.evm.type
TARGET=ONLINE
STATE=ONLINE on popdg
NAME=ora.ons
TYPE=ora.ons.type
TARGET=OFFLINE
STATE=OFFLINE
NAME=ora.zxxj.db
TYPE=ora.database.type
TARGET=OFFLINE
STATE=OFFLINE
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/14507784/viewspace-762533/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/14507784/viewspace-762533/