根据oracle官档安装相关的rpm包体(每个rac/node都需要);
yum install -y binutils* compat-libstdc++ elfutils-libelf elfutils-libelf-devel elfutils-libelf-devel-static gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel
#rpm -qa |grep libgcc
创建用户名及相关配置(grid,oracle),在root下操作:
A,创建grid相关用户组
#groupadd -g 1000 oinstall
#groupadd -g 1200 asmadmin
#groupadd -g 1201 asmdba
#groupadd -g 1202 asmoper
#useradd -m -u 1100 -g oinstall -G asmadmin,asmdba,asmoper grid
#id grid
uid=1100(grid) gid=1000(oinstall) groups=1000(oinstall),1200(asmadmin),1201(asmdba),1202(asmoper)
#su - grid
$vim .bash_profile
B,创建oracle相关用户组
#groupadd -g 1300 dba
#groupadd -g 1301 oper
#useradd -m -u 1101 -g oinstall -G dba,oper,asmdba,asmadmin oracle ---在这里必须把oracle也加入asmadmin组,和rac有些不同。
#id oracle
uid=1101(oracle) gid=1000(oinstall) groups=1000(oinstall),1201(asmdba),1300(dba),1301(oper)
#su - oracle
#vim .bash_profile
编辑grid,oracle的环境参数 ----另一个节点也需要
vim /home/grid/.bash_profile
# for oracle11g grid
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2/grid
export ORACLE_SID=+ASM1
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export PATH=$PATH:$HOME/bin
export LANG=C
vim /home/oracle/.bash_profile
##for oracle11g
export ORACLE_SID=rac1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2/dbhome_1
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin:$PATH
export LANG=C
#export ORACLE_HOSTNAME=localhost
umask 022
$ . .bash_profile
$ echo $ORACLE_SID
$ echo $ORACLE_HOME
#id nobody
创建rac相关关目录
#mkdir -p /u01/app/grid
#mkdir -p /u01/app/grid/11.2/grid ---home目录
#chown -R grid:oinstall /u01
#mkdir -p /u01/app/oracle
#mkdir -p $ORACLE_BASE/product/11.2/dbhome_1
#chown oracle:oinstall /u01/app/oracle
#chmod -R 755 /u01
linux系统参数配置:
# vim /etc/security/limits.conf
# for oracle11g_db
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
# for ora11g_grid
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
修改login文件:
#vim /etc/pam.d/login
session required pam_limits.so
修改profile文件:
#vim /etc/profile
cat >>/etc/profile <<EOF
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF
修改sysctl.conf文件:
#vim /etc/syscrl.conf
cat >> /etc/sysctl.conf <<EOF
#
## for oracle11g r2 install
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
EOF
#sysctl -p ---执行及时生效
存储配置:两总方式:
A,裸设备 绑定,通过undev
系统操作:root 下
uname -a 查看系统版本号(我这里是linux系统),这里以第二种方式笔记整理,第一种,见oracle_rac 实施总结。
oraclelib 存储插件,可在官网下载(地址:http://www.oracle.com/technetwork/topics/linux/asmlib/index-101839.html)。
安装包: rpm -ivh xxxxx
格式磁盘:
#fdisk -l
#fdisk /dev/sd* ----详见linux系统磁盘管理,创建磁盘。(不需要mkfs 格式化为系统级文件)
--在这里,不需要通过udev绑定,直接通过oracleasm 创建(如果走裸设备的话,就需要undev 绑定)
#/etc/init.d/oracleasm ---直接回车,会出现帮组,
创建盘,通过oracleasm:
先把asm 指定用户和组:
创建ASM盘
查看创建的ASM盘
提示:如果这里创建错误,可通过 /etc/init.d /oracleasm deletedisk 盘符名 /dev/sd*
受权限对ASM盘:
#chown -R grid:oinstall /dev/sd*
#chmod -R 775 /dev/sd*
---否然,看不见盘,在安装grid时
1安装grid:
解压软件 unzip xxx -d /home/oracle ---解压路劲可自定义
执行
grid 用户下 ,cd 解压路径,运行 ./ runInstaller ---可以不需要检测
执行runInstaller后,进入安装界面:
Installationoption:
---选择installand configure Grid Infrastructure for a standalone server,点击next
--- 选择磁盘,作为仲裁磁盘 grid
---选择默认的用户组 OSDBA(asmdba组) OSOPER(asmoper组) OSASM(asmadmin组)
-- 继续下面的安装,约。。。
--安装完成,检测进程crs
---#/u01/app/11.2/grid/bin/
./crsctl status resource -t 或者 ./crsctl -s -t -v
2安装oracle soft 软件 ----(约)文件系统差不多
3安装asm规划磁盘:
在grid 下 asmca 创建:
4netmgr 常见监听
5dbca 建库
9 unzip grid software -d /home/oracle
[root@lmocm1 ~]# usermod -d /u01 oracle --- 重定义oracle home ,另一个目录也属于oracle,环境变量不同
[root@lmocm1 ~]# cp -p /home/oracle/.bash
-----原因:因为只有一个用户,所以重新定义环境变量。如果不定义也可,每次就需要export ORACLE_SID 和 ORACLE_HOME,这样麻烦,直接重定义路径为oracle第二个环境变量。
.bash_history .bash_logout .bash_profile .bashrc
[root@lmocm1 ~]# cp -p /home/oracle/.bash* /u01/
-------------------------------------------------
[oracle@lmocm1 ~]$ pwd
/u01
[oracle@lmocm1 ~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
# User specific environment and startup programs
export ORACLE_SID=lmocm1 ---改为+ASM
export ORACLE_BASE=/u01/app/oracle --这里不变,是因为安装的时候,指定base 目录就为此 --多用户就不同了
export ORACLE_HOME=$ORACLE_BASE/product/11.2/lmocm_1 ---改为grid安装的目录/u01/app/11.2/grid
export PATH=$ORACLE_HOME/bin:/u01/app/11.2/grid/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/root/bin
export SQL_PATH='/home/oracle'
export LD_LIBRARY_PATH=/lib
export DISPLAY=192.168.97.127:0.0
#alias sqlplus='rlwrap sqlplus'
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
#alias rman='rlwrap rman'
#alias dgmgrl='rlwrap dgmgrl'
#alias tailoraalert="/admin//bdump/alert_.log"
-------------------------------------------------------------------
10 规划磁盘
# fdisk -l
# fdisk /dev/sd*
11 根据 OS的版本号,安装oraclelib 插件,
12 oracleasm 指定:
[root@lmocm1 ~]# /etc/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 <ENTER> without typing an
answer will keep that current value. Ctrl-C will abort.
Default user to own the driver interface [oracle]: oracle
Default group to own the driver interface [dba]: dba
Start Oracle ASM library driver on boot (y/n) [y]: 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@lmocm1 ~]# /etc/init.d/oracleasm listdisks
ARCHIVE
DBFILE1
DBFILE2
FLASH
GRID
GRID1
13 配置 时间同步 ---ntpd
14 $ cd 到grid 解压的路径下,运行 ./runInstaller
14-1
---root下运行脚本后,在/u01/app/11.2/grid/root.sh 之后需要执行显示的结果脚本:
--------------------------------------------------------------------------------------------------
[root@lmocm1 ~]# /u01/app/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@lmocm1 ~]# /u01/app/11.2/grid/root.sh
Performing root user operation for Oracle 11g
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/11.2/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:
/u01/app/11.2/grid/perl/bin/perl -I/u01/app/11.2/grid/perl/lib -I/u01/app/11.2/grid/crs/install /u01/app/11.2/grid/crs/install/roothas.pl
To configure Grid Infrastructure for a Cluster execute the following command:
/u01/app/11.2/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.
[root@lmocm1 ~]# /u01/app/11.2/grid/crs/config/config.sh
ERROR: You must not be logged in as root to run this tool.
Log in as Oracle user and rerun this tool.
[root@lmocm1 ~]# /u01/app/11.2/grid/perl/bin/perl -I/u01/app/11.2/grid/perl/lib -I/u01/app/11.2/grid/crs/install /u01/app/11.2/grid/crs/install/roothas.pl
Using configuration parameter file: /u01/app/11.2/grid/crs/install/crsconfig_params
Creating trace directory
User ignored Prerequisites during installation
LOCAL ADD MODE
Creating OCR keys for user 'oracle', 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 lmocm1 successfully pinned.
Adding Clusterware entries to inittab
lmocm1 2013/04/27 15:09:48 /u01/app/11.2/grid/cdata/lmocm1/backup_20130427_150948.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server
---------------------------------------------------------------------------------------------------
15 运行ASM 之前,需要先配置监听 netca netmgr
16 检测grid 是否成功
$ cd /u01/app/11.2/grid/bin
$crs_ctl -t 或者 crsctl status resource -t
16-1 asmca 创建asm 磁盘
-----完成后
17 安装 db soft软件
18 dbca
grid asm 教程:$ cd /u01/app/11.2/grid/bin
$crs_ctl -t 或者 crsctl status resource -t
ASM 其他操作
--关于ASM动态视图:v$asm_diskgroup磁盘组信息、v$asm_disk信息资料、v$asm_disk_stat与v$asm_disk类似
v$asm_file显示ASM文件、 v$asm_operation:显示ASM重新负载平衡操作过程。
NAME PATH MODE_ST STATE
------------------------------ ------------------------------ ------- --------
ASM_DISKGROUP_0002 /dev/raw/raw3 ONLINE NORMAL
ASM_DISKGROUP_0001 /dev/raw/raw2 ONLINE NORMAL
ASM_DISKGROUP_0000 /dev/raw/raw1 ONLINE NORMAL --10g 显示路劲为这样。
---创建磁盘,首先需要现在系统级别下创建磁盘组
SQL> create diskgroup LMOCM normal redundancy failgroup f1 disk 'ORCL:TEST1' failgroup f2 disk 'ORCL:TEST';
Diskgroup created.
SQL> select name, state, type, total_mb, free_mb from v$asm_diskgroup;
NAME STATE TYPE TOTAL_MB FREE_MB
-------------------- ----------- ------ ---------- ----------
DB_FILE MOUNTED EXTERN 2047320421
ARCHIVE MOUNTED EXTERN 10236 8208
DBFILE MOUNTED NORMAL 2047220366
FLASH MOUNTED EXTERN 10236 9828
OCRVDISK MOUNTED NORMAL 4094 3974
LMOCM MOUNTED NORMAL 1022810126
----如果没有走10g 的裸设备,需要查看绝对路径:系统级别下: # /etc/init.d/oracleasm querydisk /dev/sd*
eg:
[root@lmocm1 ~]# /etc/init.d/oracleasm querydisk /dev/sd*
Device "/dev/sda" is not marked as an ASM disk
Device "/dev/sda1" is not marked as an ASM disk
Device "/dev/sda2" is not marked as an ASM disk
Device "/dev/sda3" is not marked as an ASM disk
Device "/dev/sdb" is not marked as an ASM disk
Device "/dev/sdb1" is marked an ASM disk with the label "GRID"
Device "/dev/sdc" is not marked as an ASM disk
Device "/dev/sdc1" is marked an ASM disk with the label "GRID1"
Device "/dev/sdd" is not marked as an ASM disk
Device "/dev/sdd1" is marked an ASM disk with the label "FLASH"
Device "/dev/sde" is not marked as an ASM disk
Device "/dev/sde1" is marked an ASM disk with the label "ARCHIVE"
Device "/dev/sdf" is not marked as an ASM disk
Device "/dev/sdf1" is marked an ASM disk with the label "DBFILE1"
Device "/dev/sdg" is not marked as an ASM disk
Device "/dev/sdg1" is marked an ASM disk with the label "DBFILE2"
Device "/dev/sdh" is not marked as an ASM disk
Device "/dev/sdh1" is marked an ASM disk with the label "DBFILE3"