【Oracle学习04】Oracle Grid Infrastructure (GI)
1. 介绍
Grid Infrastructure (简称GI)是11gR2版本新出现的安装包,使用独立的grid用户进行安装。如果要使用Clusterware、ASM、ACFS、ASM动态卷等功能时都需要先安装此包。Grid Infrastructure封装了Clusterware集群软件和ASM存储软件,此外,对ASM的管理也同样独立出来,新建了ASMADMIN、ASMDBA和ASMOPER 3个系统组来完善对ASM的管理。11g 版本中的ASM能够存放包括OCR和Votedisk在内的文件。
2. 准备工作
2.1 存储准备
建立两个12G的盘,这两个盘是在VirtualBox中分配的动态磁盘,并挂载到主机。主机认到磁盘为sdc和sdd:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdd 8:48 0 12G 0 disk
sdb 8:16 0 15.6G 0 disk
sdc 8:32 0 12G 0 disk
sda 8:0 0 36.5G 0 disk
├─sda2 8:2 0 36G 0 part
│ ├─vg_main-lv_swap 252:1 0 4G 0 lvm [SWAP]
│ └─vg_main-lv_root 252:0 0 32G 0 lvm /
└─sda1 8:1 0 500M 0 part /boot
格式化磁盘,输入的指令为n,p,回车,回车,回车,w
# fdisk dev/sdc
# fdisk dev/sdd
可以看到分区sdc1和sdd1建立成功:
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdd 8:48 0 12G 0 disk
└─sdd1 8:49 0 12G 0 part
sdb 8:16 0 15.6G 0 disk
sdc 8:32 0 12G 0 disk
└─sdc1 8:33 0 12G 0 part
sda 8:0 0 36.5G 0 disk
├─sda2 8:2 0 36G 0 part
│ ├─vg_main-lv_swap 252:1 0 4G 0 lvm [SWAP]
│ └─vg_main-lv_root 252:0 0 32G 0 lvm /
└─sda1 8:1 0 500M 0 part /boot
2.2 创建GI用户
这一部分非常重要,不要漏任何group,否则在安装过程中会报错,基本都是组没赋完整。参考文档第6章,GI的安装需要grid用户和以下组:
$groupadd -g 54321 oinstall
$groupadd -g 54322 dba
$groupadd -g 54323 oper
$groupadd -g 54324 backupdba
$groupadd -g 54325 dgdba
$groupadd -g 54326 kmdba
$groupadd -g 54327 asmdba
$groupadd -g 54328 asmoper
$groupadd -g 54329 asmadmin
$groupadd -g 54330 racdba
接下来创建GI用户,安装手册中提到:
The Grid user must be a member of the OSASM group (asmadmin) and the OSDBA for ASM group (asmdba). For Oracle Restart installations, to successfully install Oracle Database, ensure that the grid user is a member of the racdba group.
意思是说,如果如果在Oracle Restart环境下安装Oracle数据库,GI用户必须有racdba的权限。
$useradd -u 54322 -g oinstall -G asmadmin,asmdba,asmoper,dba,racdba grid
$id grid
uid=54322(grid) gid=54321(oinstall) groups=54321(oinstall),54322(dba),54327(asmdba),54329(asmadmin)
#设置密码
$passwd grid
2.3 创建目录结构
GI用户也有自己的ORACLEHOME和ORACLEBASE。ORACLEHOME设置为/u01/app/19.0.0/grid,比oracle用户的/u01/app/oracle/product/12.2.0.1/dbhome1简洁;ORACLE_BASE设为/u01/app/grid,和oracle用户的/u01/app/oracle类似。
# 使用root用户执行
mkdir -p /u01/app/19.0.0/grid
mkdir -p /u01/app/grid
chown -R grid:oinstall /u01/app/19.0.0/grid
chown -R grid:oinstall /u01/app/grid
2.4 下载软件
下载地址:https://www.oracle.com/database/technologies/oracle12c-linux-12201-downloads.html
从OTN下载。文件名为 linuxx64_12201_grid_home.zip
,约2.8G。
2.5 设置环境变量
在~grid/.bash_profile中添加:
export ORACLE_HOME=/u01/app/19.0.0/grid
export ORACLE_BASE=/u01/app/grid
export PATH=$ORACLE_HOME/bin:$PATH
3. 安装
3.1 解压软件
GI准备用grid用户安装。安装GI要求主机内存至少8G。在12.2之后,GI的安装就是解压,目标是预设的ORACLE_HOME目录。使用grid用户解压。安装完成后大约7G。解压需要近5分钟。
$ cd $ORACLE_HOME
$ unzip -q /vagrant/LINUX.X64_193000_grid_home.zip
3.2 配置及安装软件
使用GI用户grid启动配置界面:
$ cd $ORACLE_HOME
$ ./gridSetup.sh
第一次仅设置软件(Set Up Software Only)
只有一个节点,不配置RAC。直接下一步:
配置ASM操作系统组:ORACLEHOME在安装时就确定了,这一步确定的是ORACLEBASE:root脚本执行配置:先决条件检查,忽略警告:安装前回顾:开始安装:
执行root脚本:
# u01/app/19.0.0/grid/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/19.0.0/grid
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.
To configure Grid Infrastructure for a Cluster or Grid Infrastructure for a Stand-Alone Server execute the following command as grid user:
/u01/app/19.0.0/grid/gridSetup.sh
This command launches the Grid Infrastructure Setup Wizard. The wizard also supports silent operation, and the parameters can be passed through the response file that is available in the installation media.
配置完成:
3.3 配置存储持久化
ASM设备必须设置存储持久化,就是保证设备名,设备的权限在重启后不变化。有3中方式,udev,ASMLIB和ASM Filter Driver (Oracle ASMFD)。ASMFD是最新的,不是每一个操作系统都支持,我们另文介绍。ASMLIB过时了,不再讨论。udev是操作系统自带的,好处是不需要额外安装驱动。此处使用udev,参考这篇文章,写得非常全面,感谢作者。首先获取磁盘的SCSI ID,这是唯一不变的信息:
参考:
https://blog.csdn.net/stevensxiao/article/details/100609030
https://xiaoyu.blog.csdn.net/article/details/100608440
https://blog.csdn.net/yitu1314/article/details/72765684
UDEV SCSI Rules Configuration In Oracle Linux 5, 6 and 7
Grid Infrastructure Installation and Upgrade Guide (19c for Linux)