在快乐时,朋友会认识我们;在患难时,我们会认识朋友。--------柯林斯
虽然现行市面上大力呼吁去“IOE”,且部分业务机构也逐渐抛弃传统的架构进行搭建系统,然而Oracle数据库依旧是最活跃的关系型数据库软件。作为数据库管理员,不仅仅需要跟上潮流,实现创新,也需要详细了解各大主流数据库的基本功能。
Oracle rac提供了集群软件和存储管理软件,实现多节点负载均衡;提供高可用:故障容错和无缝切换功能,将硬件和软件错误造成的影响最小化;通过并行执行技术提高事务响应时间----通常用于数据分析系统;通过横向扩展提高每秒交易数和连接数----通常对于联机事务系统;节约硬件成本,可以用多个廉价PC服务器代替昂贵的小型机或大型机,同时节约相应维护成本;可扩展性好,可以方便添加删除节点,扩展硬件资源。作为DBA,能够搭建一套rac是一项基本要求。
一, 安装vmware workstation
vmware workstation 9.0
二,安装red hat enterprise server 5.5
2.1,内存 2048GB
2.2,两块磁盘 一块本地磁盘30GB 一块共享磁盘15GB
在rac1.vmx配置文件里面加入配置参数
disk.locking = "false"
diskLib.dataCacheMaxSize = "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.dataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
scsi1:0.deviceType = "disk"
2.3,两块网卡 采用host only方式
三,配置linux环境
3.1,禁用iptables
chkconfig iptables off
3.2,禁用selinux
修改/ect/selinux/config文件,修改selinux=disable
3.3,配置主机名
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.73.128 rac1
192.168.73.129 rac2
10.1.1.10 rac1-priv
10.1.1.11 rac2-priv
192.168.73.130 rac1-vip
192.168.73.131 rac2-vip
192.168.73.132 racscan
3.4,配置网络
vi /etc/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
IPADDR=192.168.73.128
NETMASK=255.255.255.0
GATEWAY=192.168.73.1
#HWADDR=00:0C:29:1D:80:83
ONBOOT=yes
DHCP_HOSTNAME=rac1
vi /etc/ifcfg-eth1
DEVICE=eth1
BOOTPROTO=static
IPADDR=10.1.1.10
NETMASK=255.255.255.0
GATEWAY=10.1.1.1
#HWADDR=00:0C:29:1D:80:8D
ONBOOT=yes
DHCP_HOSTNAME=rac1
四,配置oracle参数环境
4.1,增加组和用户
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
groupadd -g 504 asmadmin
groupadd -g 505 asmoper
groupadd -g 506 asmdba
useradd -g oinstall -G dba,asmdba,oper,asmadmin,asmoper oracle
passwd oracle
useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
passwd oracle
4.2,创建目录
mkdir -p /opt/oracle/app/grid
mkdir -p /opt/oracle/app/oracle
mkdir -p /opt/oracle/app/gridbase
mkdir -p /opt/oracle/app/oraInventory
chmod -R 775 /opt/oracle
chown -R grid:oinstall /opt/oracle
chown -R oracle:oinstall /opt/oracle/app/oracle
4.3,修改系统参数
vi /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
vi /etc/pam.d/login
session required pam_limits.so
vi /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 3200 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
service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.org
rm /etc/ntp.conf
修改共享内存
vi /dev/shm
none /dev/shm tmpfs defaults,size=1024M
使之生效
mount -o remount /dev/shm
umount /dev/shm
mount -a
4.4,配置环境变量
grid用户
export CVUQDISK_GRP=oinstall
export ORACLE_HOSTNAME=rac1
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_SID=+ASM1
export ORACLE_BASE=/opt/oracle/app/gridbase
export ORACLE_HOME=/opt/oracle/app/grid/product/grid11gr2
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export THREADS_FLAG=native
export PATH=$ORACLE_HOME/bin:$PATH
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
oracle用户
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/opt/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/db11gr2
export ORACLE_SID=ywdb01
export ORACLE_HOSTNAME=rac1
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
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
四、配置信任关系
oracle用户和grid用户都需要执行
4.1,生产公钥和私钥(两个节点都执行)
su - oracle或者grid
mkdir ~/.ssh
chmod 700 ~/.ssh
ssh-keygen -t rsa
ssh-keygen -t dsa
4.2,在主节点上执行以下操作
cat ~/.ssh/id_rsa.pub >> ./.ssh/authorized_keys
cat ~/.ssh/id_dsa.pub >> ./.ssh/authorized_keys
ssh rac2 cat ~/.ssh/id_rsa.pub >> ./.ssh/authorized_keys
ssh rac2 cat ~/.ssh/id_dsa.pub >> ./.ssh/authorized_keys
scp ~/.ssh/authorized_keys rac2:~/.ssh/authorized_keys
4.3,在oracle和grid用户下面分别执行检验操作
ssh rac1 date
ssh rac1-priv date
ssh rac2 date
ssh rac2-priv date
五,配置asm磁盘
5.1,查看操作系统版本
uname -a
Linux rac1 2.6.18-194.el5xen #1 SMP Tue Mar 16 22:01:26 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
5.2,到官网下载对应的asm包
注意:在redhat 6及以上版本中,oracle官网中不再有支持的lib包,用户可以自己通过udev(或者其他工具)来将块设备转换为字符设备直接使用。
oracleasm-2.6.18-194.el5xen-2.0.5-1.el5.x86_64.rpm
oracleasmlib-2.0.4-1.el5.x86_64.rpm
oracleasm-support-2.1.8-1.el5.x86_64.rpm
5.3,安装rpm包
rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpm
rpm -ivh oracleasm-support-2.1.8-1.el5.x86_64.rpm
rpm -ivh oracleasm-2.6.18-194.el5xen-2.0.5-1.el5.x86_64.rpm
5. 4,格式化磁盘
fdisk -l
fdisk /dev/sdb
分配/dev/sdb为两个区,分别为投票盘和数据盘
Device Boot Start End Blocks Id System
/dev/sdb1 1 500 4016218+ 83 Linux
/dev/sdb2 501 1958 11711385 83 Linux
5.5,配置asm(两个节点都执行)
/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
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 ]
5.6,创建asm盘
/etc/init.d/oracleasm createdisk VOTE /dev/sdb1
Marking disk "VOTE" as an ASM disk: [ OK ]
/etc/init.d/oracleasm createdisk DATA /dev/sdb2
Marking disk "VOTE" as an ASM disk: [ OK ]
5.7,扫盘
/etc/init.d/oracleasm scandisks
Scanning the system for Oracle ASMLib disks: [ OK ]
5.8,列盘
/etc/init.d/oracleasm listdisks
DATA
VOTE
六、安装grid
6.1,验证环境
安装cvuqdisk包(在grid安装包里面)
rpm -ivh cvuqdisk-1.0.7-1.rpm
设置cvuqdisk环境变量
export CVUQDISK_GRP = oinstall
./runcluvfy.sh stage -pre crsinst -n rac1,rac2 -fixup -verbose
检查硬件环境
./runcluvfy.sh stage -post hwos -n rac1,rac2 -verbose
6.2,安装
su - grid
./runInstaller
a,安装和配置集群的网格基础结构
b,高级安装
c,网格即插即用
scan名称即写/etc/hosts里面的racscan
不勾选“配置GNS”
d,集群节点信息
加入rac2和rac2-vip,测试ssh无口令连接正常不
e,存储信息
选择自动存储管理,创建磁盘组VOTE,方式为外部,如果查看不到磁盘,扫描路径为/dev/oracleasm/disks
f,最后安装完成后,先在主节点执行oraInve....sh和root.sh脚本,再在次节点上执行。
g,安装完成后,执行asmca,把DATA磁盘组也加入到库中
安装完成grid后,安装oracle数据库
su - oracle
./runInstaller
喜欢的朋友可以扫描以下二维码进行关注,公众号将每天更新文章: