>> /etc/rc.local <<"EOF"
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
EOF
chmod +x /etc/rc.d/rc.local
sh /etc/rc.local
cat /sys/kernel/mm/transparent_hugepage/defrag
cat /sys/kernel/mm/transparent_hugepage/enabled
注意:18c解压后的文件所在目录就是grid home。所以解压的时候,就要把文件解压到之前定的GRID_HOME下。在12c R2之前是安装的时候,软件会自动复制过去。
Starting with Oracle Database 18c, the Oracle Database software is available as an image file for download and installation. Extract the image software into the directory where you want your Oracle home to be located, and then run the runInstaller script to start the Oracle Database installation.
Starting with Oracle Database 18c, installation and configuration of Oracle Database software is simplified with Image-Based installation. 五、安装前预检查
raclhr-21c-n1 date
ssh raclhr-21c-n2 date
ssh raclhr-21c-n1-priv date
ssh raclhr-21c-n2-priv date
第二次执行时不再提示输入口令,并且可以成功执行命令,则表示SSH对等性配置成功。
5.3、cluster硬件检测--安装前预检查配置信息
Use Cluster Verification Utility (cvu)
Before installing Oracle Clusterware, use CVU to ensure that your cluster is prepared for an installation:
Oracle provides CVU to perform system checks in preparation for an installation, patch updates, or other system changes. In addition, CVU can generate fixup scripts that can change many kernel parameters to at lease the minimum settings required for a successful installation.
Using CVU can help system administrators, storage administrators, and DBA to ensure that everyone has completed the system configuration and preinstallation steps.
./runcluvfy.sh -help
./runcluvfy.sh stage -pre crsinst -n rac1,rac2 –fixup -verbose
Install the operating system package cvuqdisk to both Oracle RAC nodes. Without cvuqdisk, Cluster Verification Utility cannot discover shared disks, and you will receive the error message "Package cvuqdisk not installed" when the Cluster Verification Utility is run (either manually or at the end of the Oracle grid infrastructure installation). Use the cvuqdisk RPM for your hardware architecture (for example, x86_64 or i386). The cvuqdisk RPM can be found on the Oracle grid infrastructure installation media in the rpm directory. For the purpose of this article, the Oracle grid infrastructure media was extracted to the /home/grid/software/oracle/grid directory on racnode1 as the grid user.
/dev/shm mounted as temporary file system ...FAILED
raclhr-21c-n2: PRVE-0421 : No entry exists in /etc/fstab for mounting /dev/shm
raclhr-21c-n1: PRVE-0421 : No entry exists in /etc/fstab for mounting /dev/shm
login manager IPC parameter ...FAILED
raclhr-21c-n2: PRVE-10233 : Systemd login manager parameter 'RemoveIPC' entry
does not exist or is commented out in the configuration file
"/etc/systemd/logind.conf" on node "raclhr-21c-n2".
[Expected="no"]
raclhr-21c-n1: PRVE-10233 : Systemd login manager parameter 'RemoveIPC' entry
does not exist or is commented out in the configuration file
"/etc/systemd/logind.conf" on node "raclhr-21c-n1".
[Expected="no"]
Time Protocol (NTP) ...FAILED
raclhr-21c-n2: PRVG-1017 : NTP configuration file "/etc/ntp.conf" is present on
nodes "raclhr-21c-n2,raclhr-21c-n1" on which NTP daemon or
service was not running
raclhr-21c-n1: PRVG-1017 : NTP configuration file "/etc/ntp.conf" is present on
nodes "raclhr-21c-n2,raclhr-21c-n1" on which NTP daemon or
service was not running
[root@raclhr-21c-n2 ~]# /u01/app/21.3.0/grid/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/21.3.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.
Relinking oracle with rac_on option
Using configuration parameter file: /u01/app/21.3.0/grid/crs/install/crsconfig_params
The log of current session can be found at:
/u01/app/grid/crsdata/raclhr-21c-n2/crsconfig/rootcrs_raclhr-21c-n2_2021-08-20_08-51-42AM.log
2021/08/20 08:51:48 CLSRSC-594: Executing installation step 1 of 19: 'SetupTFA'.
2021/08/20 08:51:48 CLSRSC-594: Executing installation step 2 of 19: 'ValidateEnv'.
2021/08/20 08:51:48 CLSRSC-594: Executing installation step 3 of 19: 'CheckFirstNode'.
2021/08/20 08:51:50 CLSRSC-594: Executing installation step 4 of 19: 'GenSiteGUIDs'.
2021/08/20 08:51:50 CLSRSC-594: Executing installation step 5 of 19: 'SetupOSD'.
2021/08/20 08:51:50 CLSRSC-594: Executing installation step 6 of 19: 'CheckCRSConfig'.
2021/08/20 08:51:51 CLSRSC-594: Executing installation step 7 of 19: 'SetupLocalGPNP'.
2021/08/20 08:51:52 CLSRSC-594: Executing installation step 8 of 19: 'CreateRootCert'.
2021/08/20 08:51:52 CLSRSC-594: Executing installation step 9 of 19: 'ConfigOLR'.
2021/08/20 08:51:52 CLSRSC-594: Executing installation step 10 of 19: 'ConfigCHMOS'.
2021/08/20 08:52:23 CLSRSC-594: Executing installation step 11 of 19: 'CreateOHASD'.
2021/08/20 08:52:24 CLSRSC-594: Executing installation step 12 of 19: 'ConfigOHASD'.
2021/08/20 08:52:25 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
2021/08/20 08:52:55 CLSRSC-594: Executing installation step 13 of 19: 'InstallAFD'.
2021/08/20 08:52:55 CLSRSC-594: Executing installation step 14 of 19: 'InstallACFS'.
2021/08/20 08:52:57 CLSRSC-594: Executing installation step 15 of 19: 'InstallKA'.
2021/08/20 08:52:58 CLSRSC-594: Executing installation step 16 of 19: 'InitConfig'.
2021/08/20 08:53:04 CLSRSC-4002: Successfully installed Oracle Autonomous Health Framework (AHF).
2021/08/20 08:53:08 CLSRSC-594: Executing installation step 17 of 19: 'StartCluster'.
2021/08/20 08:54:09 CLSRSC-343: Successfully started Oracle Clusterware stack
2021/08/20 08:54:09 CLSRSC-594: Executing installation step 18 of 19: 'ConfigNode'.
2021/08/20 08:54:28 CLSRSC-594: Executing installation step 19 of 19: 'PostConfig'.
2021/08/20 08:54:38 CLSRSC-325: Configure Oracle Grid Infrastructure for a Cluster ... succeeded
最后输出Configure Oracle Grid Infrastructure for a Cluster ... succeeded表示成功,查看:
[root@raclhr-21c-n1 ~]# su - oracle
Last login: Thu Aug 19 15:26:38 CST 2021 on pts/0
[oracle@raclhr-21c-n1 ~]$ cd $ORACLE_HOME
[oracle@raclhr-21c-n1 dbhome_1]$ export DISPLAY=192.168.59.1:0.0
[oracle@raclhr-21c-n1 dbhome_1]$ ./runInstaller
节点1和节点2分别执行:
[root@raclhr-21c-n1 ~]# /u01/app/oracle/product/21.3.0/dbhome_1/root.sh
Performing root user operation.
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/21.3.0/dbhome_1
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.
执行完后,点击OK:
6.3、创建磁盘组
以 grid 用户执行 asmca 命令,创建DATA和FRA两个磁盘组。:
[root@raclhr-21c-n1 ~]# su - grid
Last login: Fri Aug 20 09:59:53 CST 2021
[grid@raclhr-21c-n1 ~]$ export DISPLAY=192.168.59.1:0.0
[grid@raclhr-21c-n1 ~]$ asmca
查看:
[grid@raclhr-21c-n1 ~]$ $ORACLE_HOME/bin/kfod disks=all st=true ds=true
--------------------------------------------------------------------------------
Disk Size Header Path Disk Group User Group
================================================================================
1: 1024 MB MEMBER /dev/asm-diskd OCR grid asmadmin
2: 1024 MB MEMBER /dev/asm-diske OCR grid asmadmin
3: 1024 MB MEMBER /dev/asm-diskf OCR grid asmadmin
4: 10240 MB CANDIDATE /dev/asm-diskg # grid asmadmin
5: 10240 MB CANDIDATE /dev/asm-diskh # grid asmadmin
6: 10240 MB CANDIDATE /dev/asm-diski # grid asmadmin
7: 15360 MB MEMBER /dev/asm-diskj DATA grid asmadmin
8: 15360 MB MEMBER /dev/asm-diskk DATA grid asmadmin
9: 15360 MB MEMBER /dev/asm-diskl DATA grid asmadmin
10: 10240 MB MEMBER /dev/asm-diskm FRA grid asmadmin
11: 10240 MB MEMBER /dev/asm-diskn FRA grid asmadmin
12: 10240 MB MEMBER /dev/asm-disko FRA grid asmadmin
--------------------------------------------------------------------------------
ORACLE_SID ORACLE_HOME
================================================================================
[oracle@raclhr-21c-n1 ~]$ dbca -silent -ignorePreReqs -ignorePrereqFailure -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
> -gdbname rac21c -sid rac21c \
> -createAsContainerDatabase TRUE \
> -sysPassword lhr -systemPassword lhr -dbsnmpPassword lhr \
> -datafileDestination '+DATA' -recoveryAreaDestination '+FRA' \
> -storageType ASM \
> -characterset AL32UTF8 \
> -totalMemory 1024 \
> -databaseType OLTP \
> -emConfiguration none \
> -nodeinfo raclhr-21c-n1,raclhr-21c-n2
[WARNING] [DBT-06208] The 'SYS' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'SYSTEM' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
[WARNING] [DBT-06208] The 'PDBADMIN' password entered does not conform to the Oracle recommended standards.
CAUSE:
a. Oracle recommends that the password entered should be at least 8 characters in length, contain at least 1 uppercase character, 1 lower case character and 1 digit [0-9].
b.The password entered is a keyword that Oracle does not recommend to be used as password
ACTION: Specify a strong password. If required refer Oracle documentation for guidelines.
Prepare for db operation
7% complete
Copying database files
27% complete
Creating and starting Oracle instance
28% complete
31% complete
35% complete
37% complete
40% complete
Creating cluster database views
41% complete
53% complete
Completing Database Creation
57% complete
59% complete
60% complete
80% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/rac21c.
Database Information:
Global Database Name:rac21c
System Identifier(SID) Prefix:rac21c
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/rac21c/rac21c.log" for further details.
[oracle@raclhr-21c-n1 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.LISTENER.lsnr
ONLINE ONLINE raclhr-21c-n1 STABLE
ONLINE ONLINE raclhr-21c-n2 STABLE
ora.chad
ONLINE ONLINE raclhr-21c-n1 STABLE
ONLINE ONLINE raclhr-21c-n2 STABLE
ora.net1.network
ONLINE ONLINE raclhr-21c-n1 STABLE
ONLINE ONLINE raclhr-21c-n2 STABLE
ora.ons
ONLINE ONLINE raclhr-21c-n1 STABLE
ONLINE ONLINE raclhr-21c-n2 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.ASMNET1LSNR_ASM.lsnr(ora.asmgroup)
1 ONLINE ONLINE raclhr-21c-n1 STABLE
2 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.DATA.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-21c-n1 STABLE
2 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.FRA.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-21c-n1 STABLE
2 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.LISTENER_SCAN1.lsnr
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.LISTENER_SCAN2.lsnr
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.LISTENER_SCAN3.lsnr
1 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.OCR.dg(ora.asmgroup)
1 ONLINE ONLINE raclhr-21c-n1 STABLE
2 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.asm(ora.asmgroup)
1 ONLINE ONLINE raclhr-21c-n1 Started,STABLE
2 ONLINE ONLINE raclhr-21c-n2 Started,STABLE
ora.asmnet1.asmnetwork(ora.asmgroup)
1 ONLINE ONLINE raclhr-21c-n1 STABLE
2 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.cdp1.cdp
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.cdp2.cdp
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.cdp3.cdp
1 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.cvu
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.qosmserver
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.rac21c.db
1 ONLINE ONLINE raclhr-21c-n1 Open,HOME=/u01/app/o
racle/product/21.3.0
/dbhome_1,STABLE
2 ONLINE ONLINE raclhr-21c-n2 Open,HOME=/u01/app/o
racle/product/21.3.0
/dbhome_1,STABLE
ora.raclhr-21c-n1.vip
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.raclhr-21c-n2.vip
1 ONLINE ONLINE raclhr-21c-n2 STABLE
ora.scan1.vip
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.scan2.vip
1 ONLINE ONLINE raclhr-21c-n1 STABLE
ora.scan3.vip
1 ONLINE ONLINE raclhr-21c-n2 STABLE
--------------------------------------------------------------------------------
[oracle@raclhr-21c-n1 ~]$ sas
SQL*Plus: Release 21.0.0.0.0 - Production on Mon Aug 23 10:32:50 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SYS@rac21c1> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
7.5、创建PDB数据库
@rac21c1> show parameter db_create_file_dest
NAME TYPE VALUE
------------------------------------ ---------------------- ------------------------------
db_create_file_dest string +DATA
SYS@rac21c1> create pluggable database PDBLHR1 admin user lhr identified by lhr;
Pluggable database created.
SYS@rac21c1> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBLHR1 MOUNTED
SYS@rac21c1> alter pluggable database pdblhr1 open;
Pluggable database altered.
SYS@rac21c1> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBLHR1 READ WRITE NO
SYS@rac21c1> alter pluggable database all save state;
Pluggable database altered.
[oracle@raclhr-21c-n1 ~]$ export ORACLE_PDB_SID=PDBLHR1
[oracle@raclhr-21c-n1 ~]$ sas
SQL*Plus: Release 21.0.0.0.0 - Production on Mon Aug 23 10:45:11 2021
Version 21.3.0.0.0
Copyright (c) 1982, 2021, Oracle. All rights reserved.
Connected to:
Oracle Database 21c Enterprise Edition Release 21.0.0.0.0 - Production
Version 21.3.0.0.0
SYS@rac21c1> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
3 PDBLHR1 READ WRITE NO
SYS@rac21c1> show con_name
CON_NAME
------------------------------
PDBLHR1
[root@raclhr-21c-n1 ~]# crsctl status resource -w "TYPE = ora.database.type" -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.rac21c.db
1 ONLINE ONLINE raclhr-21c-n1 Open,HOME=/u01/app/o
racle/product/21.3.0
/dbhome_1,STABLE
2 ONLINE ONLINE raclhr-21c-n2 Open,HOME=/u01/app/o
racle/product/21.3.0
/dbhome_1,STABLE
--------------------------------------------------------------------------------
[root@raclhr-21c-n1 ~]# crsctl status resource -w "TYPE = ora.pdb.type" -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.rac21c.pdblhr1.pdb
1 ONLINE ONLINE raclhr-21c-n1 STABLE
2 ONLINE ONLINE raclhr-21c-n2 STABLE
--------------------------------------------------------------------------------
八、修改基本配置
8.1、禁用crs和db的自启动
-- 禁用crs自启动
crsctl disable has
-- 禁用db自启动
crsctl modify resource ora.rac21c.db -attr AUTO_START=never -unsupported
crsctl stat res ora.rac21c.db -p | grep AUTO_START
8.2、修改SQL提示符
oracle和grid均修改:
>> $ORACLE_HOME/sqlplus/admin/glogin.sql <<"EOF"
set linesize 9999 pagesize 9999
set sqlprompt "_USER'@'_CONNECT_IDENTIFIER> "
EOF