[关闭]
@clisdodo 2019-11-19T17:03:58.000000Z 字数 18117 阅读 1997

Oracle 18c SI ASM UDEV方式静默搭建(OEL 7.7)

OEL7.7 18c SingleInstance ASM


AskScuti :搭建类 2-0-2 Oracle 18c 单实例ASM采用UDEV方式静默搭建

你需要知道的

磁盘 容量 作用
/dev/sdb 32.2 GB Oracle Software
/dev/sdc 1073 MB OCR1
/dev/sdd 1073 MB OCR2
/dev/sde 1073 MB OCR3
/dev/sdf 214.7 GB Data1
/dev/sdg 214.7 GB Data2
/dev/sdh 107.4 GB Archived
/dev/sdi 536.9 GB Backup

1 操作系统安装

2 环境配置

2.1 磁盘分区及格式化

2.2 主机环境设置

  1. su - oracle
  2. vim .bash_profile
  3. PS1="[`whoami`@`hostname`:"'$PWD]$'
  4. export PS1
  5. export TMP=/tmp
  6. export TMPDIR=$TMP
  7. ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
  8. ORACLE_HOME=$ORACLE_BASE/product/18.0.0/dbhome_1; export ORACLE_HOME
  9. ORACLE_SID=SIASM18C; export ORACLE_SID
  10. ORACLE_TERM=xterm; export ORACLE_TERM
  11. NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
  12. NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
  13. PATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/18.0.0/dbhome_1/bin:$ORACLE_HOME/bin; export PATH
  14. THREADS_FLAG=native; export THREADS_FLAG
  15. if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
  16. if [ $SHELL = "/bin/ksh" ]; then
  17. ulimit -p 16384
  18. ulimit -n 65536
  19. else
  20. ulimit -u 16384 -n 65536
  21. fi
  22. umask 022
  23. fi
  1. su - grid
  2. vim .bash_profile
  3. PS1="[`whoami`@`hostname`:"'$PWD]$'
  4. export PS1
  5. umask 022
  6. export TMP=/tmp
  7. export TMPDIR=$TMP
  8. ORACLE_SID=+ASM; export ORACLE_SID
  9. ORACLE_TERM=xterm; export ORACLE_TERM
  10. ORACLE_BASE=/u01/app/grid; export ORACLE_BASE
  11. ORACLE_HOME=/u01/app/18.0.0/grid; export ORACLE_HOME
  12. NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
  13. PATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin; export PATH
  14. THREADS_FLAG=native; export THREADS_FLAG
  15. if [ $USER = "oracle" ] || [ $USER = "grid" ]; then
  16. if [ $SHELL = "/bin/ksh" ]; then
  17. ulimit -p 16384
  18. ulimit -n 65536
  19. else
  20. ulimit -u 16384 -n 65536
  21. fi
  22. umask 022
  23. fi

3 ASM 磁盘配置

3.1 设置白名单

echo "options=-g" > /etc/scsi_id.config

3.2 确认SCSI标识符

分区 SCSI标识符
/usr/lib/udev/scsi_id -g -u -d /dev/sdc1 36000c2976a776add818a93264891b590
/usr/lib/udev/scsi_id -g -u -d /dev/sdd1 36000c29312aa0a9406f202760c690e9d
/usr/lib/udev/scsi_id -g -u -d /dev/sde1 36000c29e98d5ab3b8fe9cc4bba81f723
/usr/lib/udev/scsi_id -g -u -d /dev/sdf1 36000c299f75c2fea6123eede18dc7f3b
/usr/lib/udev/scsi_id -g -u -d /dev/sdg1 36000c29de5af3331b80aac9bfc85e7aa
/usr/lib/udev/scsi_id -g -u -d /dev/sdh1 36000c298de4210b35dfe718a1e146866
/usr/lib/udev/scsi_id -g -u -d /dev/sdi1 36000c29c7f5fa636f0b246b2e98789dd

3.3 编辑UDEV规则文件

  1. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c2976a776add818a93264891b590", SYMLINK+="oracleasm/asm-ocr1", OWNER="grid", GROUP="asmadmin", MODE="0660"
  2. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29312aa0a9406f202760c690e9d", SYMLINK+="oracleasm/asm-ocr2", OWNER="grid", GROUP="asmadmin", MODE="0660"
  3. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29e98d5ab3b8fe9cc4bba81f723", SYMLINK+="oracleasm/asm-ocr3", OWNER="grid", GROUP="asmadmin", MODE="0660"
  4. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c299f75c2fea6123eede18dc7f3b", SYMLINK+="oracleasm/asm-data1", OWNER="grid", GROUP="asmadmin", MODE="0660"
  5. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29de5af3331b80aac9bfc85e7aa", SYMLINK+="oracleasm/asm-data2", OWNER="grid", GROUP="asmadmin", MODE="0660"
  6. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c298de4210b35dfe718a1e146866", SYMLINK+="oracleasm/asm-archived", OWNER="grid", GROUP="asmadmin", MODE="0660"
  7. KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id -g -u -d /dev/$parent", RESULT=="36000c29c7f5fa636f0b246b2e98789dd", SYMLINK+="oracleasm/asm-backup", OWNER="grid", GROUP="asmadmin", MODE="0660"

4 数据库软件安装(静默)

chown -R oracle:oinstall /soft
chmod -R 775 /soft
su - oracle
cd $ORACLE_HOME (注意oracle用户家目录:/u01/app/oracle/product/18.0.0/dbhome_1)
unzip -q /soft/LINUX.X64_180000_db_home.zip 

./runInstaller -ignorePrereq -waitforcompletion -silent \
-responseFile /u01/app/oracle/product/18.0.0/dbhome_1/install/response/db_install.rsp \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oraInventory \
SELECTED_LANGUAGES=en,en_GB \
ORACLE_HOME=/u01/app/oracle/product/18.0.0/dbhome_1 \
ORACLE_BASE=/u01/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=oper \
oracle.install.db.OSBACKUPDBA_GROUP=dba \
oracle.install.db.OSDGDBA_GROUP=dba \
oracle.install.db.OSKMDBA_GROUP=dba \
oracle.install.db.OSRACDBA_GROUP=dba \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \
DECLINE_SECURITY_UPDATES=true

su - root

As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh
2. /u01/app/oracle/product/18.0.0/dbhome_1/root.sh

5 创建并启动监听(静默)

su - oracle
cd $ORACLE_HOME
lsnrctl stop

netca -silent -responseFile /u01/app/oracle/product/18.0.0/dbhome_1/assistants/netca/netca.rsp

lsnrctl status
lsnrctl start

6 GI 软件安装(静默)

6.1 配置安装

su - grid
cd $ORACLE_HOME (注意grid用户家目录:/u01/app/18.0.0/grid)
unzip -q /soft/LINUX.X64_180000_grid_home.zip

su - root
cd /u01/app/18.0.0/grid/cv/rpm
chmod +x *
rpm -ivh cvuqdisk-1.0.10-1.rpm

su - grid
cd $ORACLE_HOME

./gridSetup.sh -ignorePrereq -waitforcompletion -silent \
-responseFile /u01/app/18.0.0/grid/install/response/gridsetup.rsp \
oracle.install.option=HA_CONFIG \
INVENTORY_LOCATION=/u01/app/oraInventory \
ORACLE_BASE=/u01/app/grid \
oracle.install.asm.storageOption=ASM \
oracle.install.asm.SYSASMPassword=oracle \
oracle.install.asm.monitorPassword=oracle \
oracle.install.asm.diskGroup.name=ocr \
oracle.install.asm.diskGroup.redundancy=NORMAL \
oracle.install.asm.diskGroup.AUSize=4 \
oracle.install.asm.diskGroup.diskDiscoveryString=/dev/oracleasm/* \
oracle.install.asm.diskGroup.disks=/dev/oracleasm/asm-ocr1,/dev/oracleasm/asm-ocr2,/dev/oracleasm/asm-ocr3 \
oracle.install.asm.OSDBA=asmdba \
oracle.install.asm.OSOPER=asmoper \
oracle.install.asm.OSASM=asmadmin \
oracle.install.crs.config.gpnp.configureGNS=false \
oracle.install.crs.config.useIPMI=false \
oracle.install.asm.upgradeASM=false

# root 执行脚本(等待 root 用户执行完毕,再去执行 grid 脚本)
As a root user, execute the following script(s):
    1. /u01/app/18.0.0/grid/root.sh

# grid 执行脚本(Attention! 执行这个脚本前,请先仔细阅读 6.2 小节:脚本补充说明)
As install user, execute the following command to complete the configuration.
/u01/app/18.0.0/grid/gridSetup.sh -executeConfigTools -responseFile /u01/app/18.0.0/grid/install/response/gridsetup.rsp [-silent]

6.2 脚本补充说明

6.3 查看 ASM 集群组件状态

[grid@asmsi18c:/u01/app/18.0.0/grid]$crsctl stat res -t
--------------------------------------------------------------------------------
Name           Target  State        Server                   State details       
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
               ONLINE  ONLINE       asmsi18c                 STABLE
ora.OCR.dg
               ONLINE  ONLINE       asmsi18c                 STABLE
ora.asm
               ONLINE  ONLINE       asmsi18c                 Started,STABLE
ora.ons
               OFFLINE OFFLINE      asmsi18c                 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
      1        ONLINE  ONLINE       asmsi18c                 STABLE
ora.diskmon
      1        OFFLINE OFFLINE                               STABLE
ora.evmd
      1        ONLINE  ONLINE       asmsi18c                 STABLE
--------------------------------------------------------------------------------

6.4 查看 ASM 实例监听状态

[grid@asmsi18c:/u01/app/18.0.0/grid]$lsnrctl status

LSNRCTL for Linux: Version 18.0.0.0.0 - Production on 11-NOV-2019 22:43:22

Copyright (c) 1991, 2018, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=asmsi18c)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 18.0.0.0.0 - Production
Start Date                11-NOV-2019 21:36:32
Uptime                    0 days 1 hr. 6 min. 49 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/18.0.0/grid/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/asmsi18c/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=asmsi18c)(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

7 创建 ASM 磁盘组

7.1 图形化创建(略)

7.2 静默创建

# 创建 ASM 磁盘组:DATA (/dev/oracleasm/asm-data1 | /dev/oracleasm/asm-data2)

asmca -silent -createDiskGroup \
-diskGroupName data \
-disk '/dev/oracleasm/asm-data1' \
-disk '/dev/oracleasm/asm-data2' \
-redundancy NORMAL \
-au_size 4 \
-compatible.asm '18.0.0.0.0' \
-compatible.rdbms '18.0.0.0.0' \
-compatible.advm '18.0.0.0.0'

7.3 SQL 语句创建

  1. [grid@asmsi18c:/u01/app/18.0.0/grid]$sqlplus / as sysasm
  2. SQL*Plus: Release 18.0.0.0.0 - Production on Mon Nov 11 23:12:45 2019
  3. Version 18.3.0.0.0
  4. Copyright (c) 1982, 2018, Oracle. All rights reserved.
  5. Connected to:
  6. Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
  7. Version 18.3.0.0.0
  8. SQL> set linesize 200
  9. SQL> col name for a10
  10. SQL> col failgroup for a10
  11. SQL> col path for a50
  12. SQL> col group_number for 99
  13. SQL> col disk_number for 99
  14. # 查询当前 ASM 磁盘组
  15. SQL> select group_number,name,type,total_mb,free_mb,usable_file_mb from v$asm_diskgroup;
  16. GROUP_NUMBER NAME TYPE TOTAL_MB FREE_MB USABLE_FILE_MB
  17. ------------ ---------- ------ ---------- ---------- --------------
  18. 1 OCR NORMAL 3060 2716 848
  19. 2 DATA NORMAL 409592 409392 204696
  20. # 查询当前 ASM 磁盘
  21. SQL> select group_number,disk_number,mount_status,name,failgroup,create_date,path from v$asm_disk order by 1,2;
  22. GROUP_NUMBER DISK_NUMBER MOUNT_S NAME FAILGROUP CREATE_DA PATH
  23. ------------ ----------- ------- ---------- ---------- --------- ----------------------------
  24. 0 0 CLOSED /dev/oracleasm/asm-archived
  25. 0 1 CLOSED /dev/oracleasm/asm-backup
  26. 1 0 CACHED OCR_0000 OCR_0000 11-NOV-19 /dev/oracleasm/asm-ocr3
  27. 1 1 CACHED OCR_0001 OCR_0001 11-NOV-19 /dev/oracleasm/asm-ocr2
  28. 1 2 CACHED OCR_0002 OCR_0002 11-NOV-19 /dev/oracleasm/asm-ocr1
  29. 2 0 CACHED DATA_0000 DATA_0000 11-NOV-19 /dev/oracleasm/asm-data1
  30. 2 1 CACHED DATA_0001 DATA_0001 11-NOV-19 /dev/oracleasm/asm-data2
  31. # SQL 语句创建磁盘组 ARCHIVE 和 BAK
  32. SQL> create diskgroup archive external redundancy disk '/dev/oracleasm/asm-archived' attribute 'au_size'='4M';
  33. Diskgroup created.
  34. SQL> create diskgroup bak external redundancy disk '/dev/oracleasm/asm-backup' attribute 'au_size'='4M';
  35. Diskgroup created.
  36. # 查询 ASM 磁盘组
  37. SQL> select group_number,name,type,total_mb,free_mb,usable_file_mb from v$asm_diskgroup;
  38. GROUP_NUMBER NAME TYPE TOTAL_MB FREE_MB USABLE_FILE_MB
  39. ------------ ---------- ------ ---------- ---------- --------------
  40. 1 OCR NORMAL 3060 2716 848
  41. 2 DATA NORMAL 409592 409392 204696
  42. 3 ARCHIVE EXTERN 102396 102316 102316
  43. 4 BAK EXTERN 511996 511916 511916

8 创建数据库(静默)

dbca -silent -createDatabase -templateName General_Purpose.dbc \
-gdbname SIASM18C \
-sid SIASM18C \
-databaseConfigType SI \
-createAsContainerDatabase TRUE \
-numberOfPDBs 1 \
-pdbName orders \
-useLocalUndoForPDBs TRUE \
-pdbAdminPassword oracle \
-sysPassword oracle \
-systemPassword oracle \
-characterSet AL32UTF8 \
-memoryPercentage 40 \
-storageType ASM \
-diskGroupName DATA \
-asmsnmpPassword oracle
  1. [oracle@asmsi18c:/home/oracle]$sqlplus / as sysdba
  2. SQL*Plus: Release 18.0.0.0.0 - Production on Tue Nov 12 00:29:47 2019
  3. Version 18.3.0.0.0
  4. Copyright (c) 1982, 2018, Oracle. All rights reserved.
  5. Connected to:
  6. Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
  7. Version 18.3.0.0.0
  8. SQL> show pdbs
  9. CON_ID CON_NAME OPEN MODE RESTRICTED
  10. ---------- ------------------------------ ---------- ----------
  11. 2 PDB$SEED READ ONLY NO
  12. 3 ORDERS READ WRITE NO
  13. SQL> alter session set container=orders;
  14. Session altered.
  15. SQL> select name from v$datafile;
  16. NAME
  17. ---------------------------------------------------------------------------------
  18. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/system.271.1024100231
  19. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/sysaux.272.1024100231
  20. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/undotbs1.270.1024100231
  21. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/users.274.1024100247
  22. SQL> create tablespace askscuti datafile '+DATA' size 10m;
  23. Tablespace created.
  24. SQL> select name from v$datafile;
  25. NAME
  26. ---------------------------------------------------------------------------------
  27. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/system.271.1024100231
  28. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/sysaux.272.1024100231
  29. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/undotbs1.270.1024100231
  30. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/users.274.1024100247
  31. +DATA/SIASM18C/971576BF22F65ACAE0530C01A8C01D9B/DATAFILE/askscuti.275.1024101305

9 实例的开启与关闭

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注