@clisdodo
2019-11-28T09:14:34.000000Z
字数 15951
阅读 3339
2级类
RHEL7.6
ASM
AskScuti :搭建类 2-0-4 Oracle 12cR2 单实例ASM采用UDEV方式图形化搭建(补丁)
0级搭建类
1级搭建类
磁盘 | 容量 | 作用 |
---|---|---|
/dev/sdb | 53.7 GB | Oracle Oinstall /u01 |
/dev/sdc | 21.5 GB | /soft |
/dev/sdd | 1073 MB | OCR1 |
/dev/sde | 1073 MB | OCR2 |
/dev/sdf | 1073 MB | OCR3 |
/dev/sdg | 10.7 GB | Data1 |
/dev/sdh | 10.7 GB | Data2 |
/dev/sdi | 5368 MB | Archived |
/dev/sdj | 5368 MB | Archived |
最终磁盘分区格式呈现如下
[root@henry ~]# ls /dev/sd*1 |grep -v sda1
/dev/sdb1
/dev/sdc1
/dev/sdd1
/dev/sde1
/dev/sdf1
/dev/sdg1
/dev/sdh1
/dev/sdi1
/dev/sdj1
格式化分区并创建文件系统(仅 /dev/sdb1
和 /dev/sdc1
),其他分区用于ASM存储
[root@henry ~]# mkfs.xfs /dev/sdb1
[root@henry ~]# mkfs.xfs /dev/sdc1
[root@henry ~]# mkdir /u01
[root@henry ~]# mkdir /soft
[root@henry ~]# mount /dev/sdb1 /u01/
[root@henry ~]# mount /dev/sdc1 /soft/
[root@henry ~]# blkid /dev/sdb1
/dev/sdb1: UUID="1d68c26e-1539-49cc-9be7-c370b18bd00d" TYPE="xfs"
[root@henry ~]# blkid /dev/sdc1
/dev/sdc1: UUID="1b54c98d-011c-4511-ae01-36ccc82462e4" TYPE="xfs"
[root@henry ~]# vim /etc/fstab
/*** 编辑文件,添加以下行
UUID=1d68c26e-1539-49cc-9be7-c370b18bd00d /u01 xfs defaults 0 0
UUID=1b54c98d-011c-4511-ae01-36ccc82462e4 /soft xfs defaults 0 0
***/
[root@henry ~]# mount -a
[root@henry ~]# df -Th
主机名及IP
[root@henry ~]# echo "192.168.1.9 henry" >> /etc/hosts
用户和组
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 asmadmin
/usr/sbin/groupadd -g 54325 asmoper
/usr/sbin/groupadd -g 54326 asmdba
/usr/sbin/useradd -g oinstall -G dba,asmdba,oper oracle
/usr/sbin/useradd -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
passwd oracle --> Changing password for user oracle.
passwd grid --> Changing password for user grid.
创建文件夹及授权
mkdir -p /u01/app/grid
mkdir -p /u01/app/12.2.0.1/grid
mkdir -p /u01/app/oracle/product/12.2.0.1/db_1
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01
chown -R grid:oinstall /u01/app/grid
chown -R grid:oinstall /u01/app/12.2.0.1
chmod -R 775 /u01/
RPM包安装
mv /etc/yum.repos.d/* /tmp/
echo "[local_yum]" >> /etc/yum.repos.d/henry.repo
echo "name = henry_repo" >> /etc/yum.repos.d/henry.repo
echo "baseurl = file:///mnt/" >> /etc/yum.repos.d/henry.repo
echo "enabled = 1" >> /etc/yum.repos.d/henry.repo
echo "gpgcheck = 0" >> /etc/yum.repos.d/henry.repo
mount /dev/cdrom /mnt/
yum -y install autoconf
yum -y install automake
yum -y install binutils
yum -y install binutils-devel
yum -y install bison
yum -y install cpp
yum -y install dos2unix
yum -y install ftp
yum -y install gcc
yum -y install gcc-c++
yum -y install lrzsz
yum -y install python-devel
yum -y install compat-libcap1
yum -y install compat-libstdc++-33
yum -y install compat-libstdc++-33.i686
yum -y install glibc-*
yum -y install glibc-*.i686
yum -y install libXpm-*.i686
yum -y install libXext
yum -y install libXext.i686
yum -y install libXtst
yum -y install libXtst.i686
yum -y install libX11
yum -y install libX11.i686
yum -y install libXau
yum -y install libXau.i686
yum -y install libxcb
yum -y install libxcb.i686
yum -y install libXi
yum -y install libXi.i686
yum -y install libstdc++.i686
yum -y install libstdc++-devel
yum -y install libstdc++-devel.i686
yum -y install libaio
yum -y install libaio.i686
yum -y install libaio-devel
yum -y install libaio-devel.i686
yum -y install ksh
yum -y install libXp
yum -y install libaio-devel
yum -y install numactl
yum -y install numactl-devel
yum -y install make -y
yum -y install sysstat -y
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install elfutils-libelf-devel
yum -y install redhat-lsb-core
yum -y install unzip
yum -y install libXrender
yum -y install libXrender-devel
yum -y install nfs-utils
yum -y install smartmontools
yum -y install tigervnc
资源限制
编辑文件 /etc/security/limits.conf
添加以下行
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
grid hard stack 32768
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
编辑文件 /etc/sysctl.conf
添加以下行
fs.aio-max-nr = 1048576
fs.file-max = 6815744
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
kernel.panic_on_oops = 1
kernel.shmmax = 3865470566
kernel.shmall = 943718
kernel.shmmni = 4096
执行 `sysctl -p` 生效
SHELL限制
echo "session required pam_limits.so" >> /etc/pam.d/login
关闭防火墙
systemctl status firewalld.service
systemctl stop firewalld.service
systemctl disable firewalld.service
关闭SELinux
vim /etc/selinux/config
SELINUX=disabled
Oracle用户环境变量
切换至 Oracle
用户,编辑 .bash_profile
[root@henry ~]# su - oracle
[oracle@henry ~]$ vim .bash_profile
# 添加以下行
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
export TMPDIR=$TMP
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0.1/db_1; export ORACLE_HOME
ORACLE_SID=SIASMCDB; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/12.2.0.1/db_1/bin:$ORACLE_HOME/bin; export PATH
THREADS_FLAG=native; export THREADS_FLAG
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
Grid用户环境变量
切换至 Grid
用户,编辑 .bash_profile
[root@henry ~]# su - grid
[grid@henry ~]$ vim .bash_profile
添加以下行
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
umask 022
export TMP=/tmp
export TMPDIR=$TMP
ORACLE_SID=+ASM; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
ORACLE_HOME=/u01/app/12.2.0.1/grid; export ORACLE_HOME
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin; export PATH
THREADS_FLAG=native; export THREADS_FLAG
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
编辑文件 /etc/scsi_id
添加选项 options=-g
,如果没有那么创建它。
[root@henry ~]# echo "options=-g" > /etc/scsi_id.config
通过命令 /usr/lib/udev/scsi_id -g -u -d 分区名
确认标识符,最终对应关系如下
分区 | SCSI标识符 |
---|---|
/usr/lib/udev/scsi_id -g -u -d /dev/sdd1 | 36000c29e076a000862d076f7a78e49fa |
/usr/lib/udev/scsi_id -g -u -d /dev/sde1 | 36000c291247d41ae0b6e4de1010a804e |
/usr/lib/udev/scsi_id -g -u -d /dev/sdf1 | 36000c2988874adeef1f38ace210f5880 |
/usr/lib/udev/scsi_id -g -u -d /dev/sdg1 | 36000c291e32472781a955708abf73555 |
/usr/lib/udev/scsi_id -g -u -d /dev/sdh1 | 36000c29ba3f4122dc84d6da542853dbb |
/usr/lib/udev/scsi_id -g -u -d /dev/sdi1 | 36000c29ed0661d93abe1b463b8d98223 |
/usr/lib/udev/scsi_id -g -u -d /dev/sdj1 | 36000c29670666047c13b65aace55e38c |
vim /etc/udev/rules.d/99-oracle-asmdevices.rules
,按以下格式编辑条目,替换 RESULT
对应的SCSI标识符
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29e076a000862d076f7a78e49fa", SYMLINK+="oracleasm/asm-ocr1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c291247d41ae0b6e4de1010a804e", SYMLINK+="oracleasm/asm-ocr2", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c2988874adeef1f38ace210f5880", SYMLINK+="oracleasm/asm-ocr3", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c291e32472781a955708abf73555", SYMLINK+="oracleasm/asm-data1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29ba3f4122dc84d6da542853dbb", SYMLINK+="oracleasm/asm-data2", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29ed0661d93abe1b463b8d98223", SYMLINK+="oracleasm/asm-archived1", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29670666047c13b65aace55e38c", SYMLINK+="oracleasm/asm-archived2", OWNER="grid", GROUP="asmadmin", MODE="0660"
执行 partprobe 识别
/sbin/partprobe /dev/sdd1
/sbin/partprobe /dev/sde1
/sbin/partprobe /dev/sdf1
/sbin/partprobe /dev/sdg1
/sbin/partprobe /dev/sdh1
/sbin/partprobe /dev/sdi1
/sbin/partprobe /dev/sdj1
重启UDEV服务
udevadm control --reload-rules
查看磁盘
请确保所有链接磁盘均可见,并具有对应的正确权限,否则,在进行下一步之前请解决该问题。
[root@henry ~]# ls -lathr /dev/oracleasm/*
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-ocr1 -> ../sdd1
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-ocr2 -> ../sde1
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-ocr3 -> ../sdf1
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-data1 -> ../sdg1
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-data2 -> ../sdh1
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-archived1 -> ../sdi1
lrwxrwxrwx 1 root root 7 Nov 18 23:09 /dev/oracleasm/asm-archived2 -> ../sdj1
上面链接归 root 用户所有,但是链接所指向的磁盘是拥有正确权限的。
[root@henry ~]# ls -lathr /dev/sd*1 |grep -v sda1 |grep -v sdb1 |grep -v sdc1
brw-rw---- 1 grid asmadmin 8, 49 Nov 18 23:09 /dev/sdd1
brw-rw---- 1 grid asmadmin 8, 65 Nov 18 23:09 /dev/sde1
brw-rw---- 1 grid asmadmin 8, 81 Nov 18 23:09 /dev/sdf1
brw-rw---- 1 grid asmadmin 8, 97 Nov 18 23:09 /dev/sdg1
brw-rw---- 1 grid asmadmin 8, 113 Nov 18 23:09 /dev/sdh1
brw-rw---- 1 grid asmadmin 8, 129 Nov 18 23:09 /dev/sdi1
brw-rw---- 1 grid asmadmin 8, 145 Nov 18 23:09 /dev/sdj1
20190921OCP 班的同学们,拿到环境后,从这里开始。环境已完成标题1至标题3的所有搭建,同时在
/soft
文件夹里包含OPatch工具及GI补丁。请按照以下步骤完成所有操作。你也可以选择从零开始,按照文档搭建新环境。
授权解压
chown -R oracle:oinstall /soft
chmod -R 775 /soft
su - oracle
cd /soft/
unzip -q 12c-linuxx64_12201_database.zip
运行程序
[oracle@henry ~]$ cd /soft/database/
[oracle@henry database]$ ./runInstaller
netca
# 切换 grid 用户进行解压
[grid@henry ~]$ cd $ORACLE_HOME
[grid@henry grid]$ unzip -q /soft/12c-linuxx64_12201_grid_home.zip
# 查看当前默认 OPatch 版本
[grid@henry grid]$ OPatch/opatch version
OPatch Version: 12.2.0.1.6
OPatch succeeded.
# 解压 OPatch 工具覆盖当前文件夹,提示输入:A
[grid@henry grid]$ unzip /soft/p6880880_122010_Linux-x86-64.zip
Archive: /soft/p6880880_122010_Linux-x86-64.zip
inflating: OPatch/emdpatch.pl
replace OPatch/oplan/oplan? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
# 查看当前 OPatch 工具版本
[grid@henry grid]$ OPatch/opatch version
OPatch Version: 12.2.0.1.17
OPatch succeeded.
[grid@henry grid]$ cd /soft/
[grid@henry soft]$ unzip -q p29708720_122010_Linux-x86-64.zip
[grid@henry soft]$ cd $ORACLE_HOME
[grid@henry grid]$ ./gridSetup.sh -applyPSU /soft/29708720/
Preparing the home to patch...
Applying the patch /soft/29708720/...
Successfully applied the patch.
The log can be found at: /u01/app/oraInventory/logs/GridSetupActions2019-11-19_02-07-56PM/installerPatchActions_2019-11-19_02-07-56PM.log
Launching Oracle Grid Infrastructure Setup Wizard...
这里有两个警告:物理内存建议8G/集群验证包。你可选择忽略警告,因为是单实例,它们不会阻止后面的安装操作。为保证完整性,你也可以选择安装集群验证包,12cR2 版本中,你可以在 oracle 数据库解压目录中找到它
/soft/database/rpm
;也可以在 oracle 家目录中找到它/u01/app/oracle/product/12.2.0.1/db_1/cv/rpm
# 切换 root 进行安装
[grid@henry ~]$ su - root
[root@henry rpm]# rpm -ivh cvuqdisk-1.0.10-1.rpm
Preparing... ################################# [100%]
Updating / installing...
1:cvuqdisk-1.0.10-1 ################################# [100%]
# 点击 Check Again
脚本执行成功后,点击
OK
继续安装,如果报以下错误,说明没有对GI进行补丁。
# 错误消息示例片段
2019/07/09 23:45:46 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2019/07/09 23:48:02 CLSRSC-400: A system reboot is required to continue installing.
The command '/u01/app/12.2.0/grid/perl/bin/perl -I/u01/app/12.2.0/grid/perl/lib -I/u01/app/12.2.0/grid/crs/install /u01/app/12.2.0/grid/crs/install/roothas.pl ' execution failed
# 查看集群组件状态
[grid@henry:/home/grid]$crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
ONLINE ONLINE henry STABLE
ora.OCR.dg
ONLINE ONLINE henry STABLE
ora.asm
ONLINE ONLINE henry Started,STABLE
ora.ons
OFFLINE OFFLINE henry STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE henry STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.driver.afd
1 ONLINE ONLINE henry STABLE
ora.evmd
1 ONLINE ONLINE henry STABLE
--------------------------------------------------------------------------------
# 查看 ASM 实例监听
[grid@henry:/home/grid]$lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-NOV-2019 15:00:57
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=henry)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 19-NOV-2019 14:51:16
Uptime 0 days 0 hr. 9 min. 40 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/12.2.0.1/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/henry/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=henry)(PORT=1522)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1522)))
Services Summary...
Service "+ASM" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
Service "+ASM_OCR" has 1 instance(s).
Instance "+ASM", status READY, has 1 handler(s) for this service...
The command completed successfully
asmca
路径不对无法映射?看下后面第 10 小节的
错误处理
asmca -silent -createDiskGroup \
-diskGroupName ARCHIVED \
-disk '/dev/oracleasm/asm-archived1' \
-disk '/dev/oracleasm/asm-archived2' \
-redundancy NORMAL \
-au_size 4 \
-compatible.asm '12.2.0.1.0' \
-compatible.rdbms '12.2.0.1.0' \
-compatible.advm '12.2.0.1.0'
dbca
[root@henry ~]# su - oracle
[oracle@henry:/home/oracle]$sqlplus / as sysdba
SQL> select name from v$datafile where con_id=1;
NAME
------------------------------------------------
+DATA/SIASMCDB/DATAFILE/system.256.1024763769
+DATA/SIASMCDB/DATAFILE/sysaux.257.1024763839
+DATA/SIASMCDB/DATAFILE/undotbs1.258.1024763875
+DATA/SIASMCDB/DATAFILE/users.259.1024763875
[root@henry ~]# su - grid
[grid@henry:/home/grid]$sqlplus / as sysasm
set linesize 200
col name for a10
col failgroup for a10
col path for a50
col group_number for 99
col disk_number for 99
SQL> select group_number,name,type,total_mb,free_mb,usable_file_mb from v$asm_diskgroup;
GROUP_NUMBER NAME TYPE TOTAL_MB FREE_MB USABLE_FILE_MB
------------ ---------- ------ ---------- ---------- --------------
1 OCR NORMAL 3060 2772 876
2 DATA NORMAL 20472 13096 6548
3 ARCHIVED NORMAL 10232 10056 5028
关闭:先关闭RDBMS实例,再关闭ASM实例
# RDBMS 实例
SQL> shutdown immediate;
# ASM 实例
SQL> shutdown immediate;
# 直接关闭ASM将报错
ORA-15097: cannot SHUTDOWN ASM instance with connected client (process 9480)
开启:先开启ASM实例,再开启RDBMS实例
# ASM 实例
SQL> startup
# RDBMS 实例
SQL> startup
# 直接启动RDBMS实例将报错
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/12.2.0.1/db_1/dbs/initSIASMCDB.ora'
创建 ASM 磁盘报错
原因:asm_diskstring 参数默认值指向问题
[grid@henry:/home/grid]$sqlplus / as sysasm
SQL> show parameter asm_diskst
NAME TYPE VALUE
------------------- ----------- -------------
asm_diskstring string AFD:*
方案
# 创建静态参数文件
sqlplus / as sysasm
SQL> create pfile from spfile;
File created.
exit;
# 编辑静态参数文件
cd $ORACLE_HOME/dbs
vim init+ASM.ora
# 修改和添加以下行
*.asm_diskstring='/dev/oracleasm/*'
asm_diskgroups='OCR'
# 以静态参数文件启动实例
sqlplus / as sysasm
SQL> shutdown immediate;
ASM diskgroups volume disabled
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup pfile='/u01/app/12.2.0.1/grid/dbs/init+ASM.ora';
ASM instance started
Total System Global Area 1140850688 bytes
Fixed Size 8629704 bytes
Variable Size 1107055160 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
ASM diskgroups volume enabled
# 以当前内存数据创建动态参数文件
SQL> create spfile from memory;
File created.
# 重启ASM实例加载动态参数文件
SQL> startup force;
ASM instance started
Total System Global Area 1140850688 bytes
Fixed Size 8629704 bytes
Variable Size 1107055160 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
ASM diskgroups volume enabled
SQL> show parameter spfile
NAME TYPE VALUE
----------- ----------- -----------------------------------------
spfile string /u01/app/12.2.0.1/grid/dbs/spfile+ASM.ora