📢📢📢📣📣📣
哈喽!大家好,我是【IT邦德】,江湖人称jeames007,10余年DBA及大数据工作经验
一位上进心十足的【大数据领域博主】!😜😜😜
中国DBA联盟(ACDU)成员,目前服务于工业互联网
擅长主流Oracle、MySQL、PG、高斯及Greenplum运维开发,备份恢复,安装迁移,性能优化、故障应急处理等。
✨ 如果有对【数据库】感兴趣的【小可爱】,欢迎关注【IT邦德】💞💞💞
❤️❤️❤️感谢各位大可爱小可爱!❤️❤️❤️
文章目录
- 前言
- 📣 1.环境准备
- 📣 2.yum安装依赖
- ✨ 2.1 yum源的配置
- ✨ 2.2 安装依赖
- 📣 3. database-preinstall
- 📣 4.目录及权限设置
- 📣 5.环境变量
- 📣 6.上传oracle安装包
- 📣 7.创建GI用户
- 📣 8.GI资源配置
- 📣 9.绑定共享磁盘
- 📣 10.创建GI目录
- 📣 11.配置GI环境变量
- 📣 12.上传GI安装包
- 📣 13.安装 cvuqdisk
- 📣 14.安装GI
- 14.ASM创建磁盘组
- 15.安装Oracle软件
- 16.DBCA建库
- 17.日常管理
前言
本文祥细阐述了ASM管理Oracle 19C单实例部署📣 1.环境准备
通过虚拟机克隆来提供部署需要OEL7.9的操作系统
1.1 环境检查
[root@oel79 ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.9 (Maipo)
[root@oel79 ~]# cat /etc/oracle-release
Oracle Linux Server release 7.9
[root@oel79 ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 4.3G 0 4.3G 0% /dev
tmpfs tmpfs 4.4G 0 4.4G 0% /dev/shm
tmpfs tmpfs 4.4G 11M 4.4G 1% /run
tmpfs tmpfs 4.4G 0 4.4G 0% /sys/fs/cgroup
/dev/mapper/ol-root ext4 43G 4.4G 36G 11% /
/dev/sda1 ext4 1.1G 213M 741M 23% /boot
/dev/mapper/ol-u01 ext4 52G 55M 49G 1% /u01
tmpfs tmpfs 864M 29k 864M 1% /run/user/0
/dev/sr0 iso9660 4.9G 4.9G 0 100% /run/media/root/OL-7.9 Server.x86_64
[root@oel79 ~]# free -m
total used free shared buff/cache available
Mem: 8238 634 6916 15 687 7338
Swap: 10239 0 10239
[root@oel79 ~]# free -g
total used free shared buff/cache available
Mem: 8 0 6 0 0 7
Swap: 9 0 9
[root@oel79 ~]#
[root@oel79 ~]#
[root@oel79 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.6.20 netmask 255.255.255.0 broadcast 192.168.6.255
inet6 fe80::e08:b228:bbf4:4168 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6b:eb:f4 txqueuelen 1000 (Ethernet)
RX packets 291 bytes 28044 (27.3 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 260 bytes 40332 (39.3 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 176 bytes 13512 (13.1 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 176 bytes 13512 (13.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:d9:8d:56 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
1.2 挂存储
把新添加的磁盘虚拟设备节点改成从 1: 0 开始,第二个磁盘就是 1: 1, 重复添加磁盘的操作, 20G 一个、 0.5G 七个。
##打开虚拟机的配置文件.vmx,将以下内容粘贴进去
scsi1:0.deviceType = "disk"
scsi1:1.deviceType = "disk"
scsi1:2.deviceType = "disk"
scsi1:3.deviceType = "disk"
scsi1:4.deviceType = "disk"
scsi1:5.deviceType = "disk"
scsi1:6.deviceType = "disk"
scsi1:8.deviceType = "disk"
disk.locking ="FALSE"
diskLib.dataCacheMaxSize= "0"
diskLib.dataCacheMaxReadAheadSize = "0"
diskLib.DataCacheMinReadAheadSize = "0"
diskLib.dataCachePageSize = "4096"
diskLib.maxUnsyncedWrites = "0"
disk.EnableUUID="TRUE"
[root@oel79 ~]# fdisk -l | grep dev
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 209715199 103808000 8e Linux LVM
Disk /dev/sdg: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdc: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors
Disk /dev/sdd: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdf: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sde: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdi: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/sdh: 536 MB, 536870912 bytes, 1048576 sectors
Disk /dev/mapper/ol-root: 42.9 GB, 42949672960 bytes, 83886080 sectors
Disk /dev/mapper/ol-swap: 10.7 GB, 10737418240 bytes, 20971520 sectors
Disk /dev/mapper/ol-u01: 52.6 GB, 52609155072 bytes, 102752256 sectors
1.3 关闭防火墙
[root@oel79 ~]# systemctl status firewalld.service
[root@oel79 ~]# systemctl stop firewalld.service
[root@oel79 ~]# systemctl disable firewalld.service
1.4 关闭selinx的安全服务
[root@oel79 ~]# cat /etc/selinux/config
修改SELINUX=enforcing为SELINUX=disabled
1.5 host解析
[root@oel79 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
##新增以下内容
192.168.6.20 oel79
📣 2.yum安装依赖
✨ 2.1 yum源的配置
[root@oel79 ~]# vi /etc/yum.repos.d/local.repo
[server]
name=Linux
baseurl=file:///run/media/root/OL-7.9%20Server.x86_64
enabled=1
gpgcheck=0
✨ 2.2 安装依赖
[root@oel79 ~]# yum install compat-libcap1 ksh libaio-devel glibc-devel libstdc++-devel -y
📣 3. database-preinstall
## root用户下执行
[root@oel79 opt]# rpm -ivh oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
warning: oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:oracle-database-preinstall-19c-1.################################# [100%]
该 rpm会创建oracle用户、相关用户组、以及配置系统的参数
如 /etc/security/limits.d/oracle-database-preinstall-19c.conf
## 设置 oracle 口令
echo "oracle" | passwd --stdin oracle
📣 4.目录及权限设置
##创建目录
mkdir -p /u01/app/oracle/product/19.0.0/dbhome_1/
chown -R oracle:oinstall /u01
chmod -R 775 /u01
📣 5.环境变量
## 以下内容oracle用户下执行
su - oracle
vi .bash_profile
export ORACLE_SID=prod
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.0.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export CLASSPATH=$ORACLE_HOME/JRE:ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
##环境变量生效
source .bash_profile
📣 6.上传oracle安装包
注:软件包上传到 ORACLE_HOME 目录(oracle 用户解压)
## 校验密钥
[root@oel79 opt]# sha256sum LINUX.X64_193000_db_home.zip
ba8329c757133da313ed3b6d7f86c5ac42cd9970a28bf2e6233f3235233aa8d8 LINUX.X64_193000_db_home.zip
[oracle@oel79 ~]$ echo $ORACLE_HOME
/u01/app/oracle/product/19.0.0/dbhome_1
chown oracle:oinstall -R LINUX.X64_193000_db_home.zip
chmod 755 -R LINUX.X64_193000_db_home.zip
unzip LINUX.X64_193000_db_home.zip
📣 7.创建GI用户
## 添加组
/usr/sbin/groupadd -g 1020 asmadmin
/usr/sbin/groupadd -g 1021 asmdba
/usr/sbin/groupadd -g 1022 asmoper
## 添加grid用户
/usr/sbin/useradd -u 1102 -g oinstall -G dba,asmdba,backupdba,dgdba,kmdba,asmoper,asmadmin,racdba grid
## 改密码
echo "grid" | passwd --stdin grid
## 修改oracle用户
usermod -g oinstall -G dba,asmadmin,asmdba,asmoper,backupdba,dgdba,kmdba,oper,racdba oracle
📣 8.GI资源配置
编辑资源配置,在最后一行里面增加
vi /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
📣 9.绑定共享磁盘
[root@oel79 ~]# ls -l /dev/sd*
brw-rw----. 1 root disk 8, 0 Sep 3 09:55 /dev/sda
brw-rw----. 1 root disk 8, 1 Sep 3 09:55 /dev/sda1
brw-rw----. 1 root disk 8, 2 Sep 3 09:55 /dev/sda2
brw-rw----. 1 root disk 8, 16 Sep 3 09:55 /dev/sdb
brw-rw----. 1 root disk 8, 32 Sep 3 09:55 /dev/sdc
brw-rw----. 1 root disk 8, 48 Sep 3 09:55 /dev/sdd
brw-rw----. 1 root disk 8, 64 Sep 3 09:55 /dev/sde
brw-rw----. 1 root disk 8, 80 Sep 3 09:55 /dev/sdf
brw-rw----. 1 root disk 8, 96 Sep 3 09:55 /dev/sdg
brw-rw----. 1 root disk 8, 112 Sep 3 09:55 /dev/sdh
brw-rw----. 1 root disk 8, 128 Sep 3 09:55 /dev/sdi
for i in b c d e f g h i; do echo "KERNEL==\"sd*[!0-9]\",ENV{DEVTYPE}==\"disk\",SUBSYSTEM==\"block\",PROGRAM==\"/usr/lib/udev/scsi_id -g -u -d\$devnode\",RESULT==\"`/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", SYMLINK+=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\",MODE=\"0660\"" >> /etc/udev/rules.d/99-oracle-asmdevices.rules; done;
[root@oel79 ~]# cat /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c29653e86c5f015ab3d2e7e9bbae", SYMLINK+="asm-diskb", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c29a052769eb43d01664ca55a894", SYMLINK+="asm-diskc", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c29c19465340359f4408bd2a4dff", SYMLINK+="asm-diskd", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c2906dc37bda2eb23b86b441831e", SYMLINK+="asm-diske", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c29b6a9e99f76a60e4c1e2c47838", SYMLINK+="asm-diskf", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c29b39f1155952c12d89c5823467", SYMLINK+="asm-diskg", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c297eb5d57761da1c873da5cc8e4", SYMLINK+="asm-diskh", OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd*[!0-9]",ENV{DEVTYPE}=="disk",SUBSYSTEM=="block",PROGRAM=="/usr/lib/udev/scsi_id -g -u -d$devnode",RESULT=="36000c29a6afc8636a8162bf7f92e9bdd", SYMLINK+="asm-diski", OWNER="grid", GROUP="asmadmin",MODE="0660"
##生效
/sbin/udevadm trigger
##查看
[root@oel79 ~]# ls -l /dev/sd*
brw-rw----. 1 root disk 8, 0 Sep 3 12:19 /dev/sda
brw-rw----. 1 root disk 8, 1 Sep 3 12:19 /dev/sda1
brw-rw----. 1 root disk 8, 2 Sep 3 12:19 /dev/sda2
brw-rw----. 1 grid asmadmin 8, 16 Sep 3 12:19 /dev/sdb
brw-rw----. 1 grid asmadmin 8, 32 Sep 3 12:19 /dev/sdc
brw-rw----. 1 grid asmadmin 8, 48 Sep 3 12:19 /dev/sdd
brw-rw----. 1 grid asmadmin 8, 64 Sep 3 12:19 /dev/sde
brw-rw----. 1 grid asmadmin 8, 80 Sep 3 12:19 /dev/sdf
brw-rw----. 1 grid asmadmin 8, 96 Sep 3 12:19 /dev/sdg
brw-rw----. 1 grid asmadmin 8, 112 Sep 3 12:19 /dev/sdh
brw-rw----. 1 grid asmadmin 8, 128 Sep 3 12:19 /dev/sdi
[root@oel79 ~]# ls -l /dev/asm*
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diskb -> sdb
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diskc -> sdc
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diskd -> sdd
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diske -> sde
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diskf -> sdf
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diskg -> sdg
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diskh -> sdh
lrwxrwxrwx. 1 root root 3 Sep 3 12:19 /dev/asm-diski -> sdi
📣 10.创建GI目录
mkdir -p /u01/app/grid/19.0.0/grid
chown -R grid:oinstall /u01/app/grid
📣 11.配置GI环境变量
##切换到 grid 用户
su - grid
vi /home/grid/.bash_profile
export ORACLE_SID=+ASM
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/grid/19.0.0/grid
export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin
umask 022
##环境变量生效
source /home/grid/.bash_profile
📣 12.上传GI安装包
## 校验密钥
将 GI 包上传/u01/app/grid/19.0.0/grid 目录下,并解压(grid 用户)
注意: gi 包的所有者为 grid, 所属组为 oinstall
[root@oel79 opt]# cp LINUX.X64_193000_grid_home.zip /u01/app/grid/19.0.0/grid
[root@oel79 opt]# chown grid:oinstall -R /u01/app/grid/19.0.0/grid
[root@oel79 opt]# chmod 775 -R /u01/app/grid/19.0.0/grid
[grid@oel79 ~]$ cd $ORACLE_HOME
[grid@oel79 grid]$ unzip LINUX.X64_193000_grid_home.zip
📣 13.安装 cvuqdisk
[root@oel79 ~]# cd /u01/app/grid/19.0.0/grid/cv/rpm
[root@oel79 rpm]# export CVUQDISK_GRP=oinstall
[root@oel79 rpm]# rpm -ivh cvuqdisk-1.0.10-1.rpm
Preparing... ################################# [100%]
Updating / installing...
1:cvuqdisk-1.0.10-1 ################################# [100%]
📣 14.安装GI
[root@oel79 ~]# su - grid
[grid@oel79 ~]$ cd $ORACLE_HOME
[grid@oel79 grid]$ echo $ORACLE_HOME
/u01/app/grid/19.0.0/grid
[grid@wl ~]$ export DISPLAY=192.168.6.1:0.0
[grid@wl grid]$ ./gridSetup.sh
##root下执行脚本
/u01/app/oraInventory/orainstRoot.sh
/u01/app/grid/19.0.0/grid/root.sh
##安装之后状态检查
[grid@oel79 grid]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE oel79 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE oel79 STABLE
ora.asm
ONLINE ONLINE oel79 Started,STABLE
ora.ons
OFFLINE OFFLINE oel79 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE oel79 STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE oel79 STABLE
--------------------------------------------------------------------------------
14.ASM创建磁盘组
##创建快闪区的磁盘组以及归档的磁盘组
[grid@oel79 grid]$ asmca
15.安装Oracle软件
[root@oel79 ~]# su - oracle
[oracle@oel79 ~]$ cd $ORACLE_HOME
[oracle@oel79 dbhome_1]$ export DISPLAY=192.168.6.1:0.0
[oracle@oel79 dbhome_1]$ ./runInstaller
##root用户执行以下脚本
/u01/app/oracle/product/19.0.0/dbhome_1/root.sh
16.DBCA建库
[root@oel79 ~]# su - oracle
[oracle@oel79 ~]$ export DISPLAY=192.168.6.1:0.0
[oracle@oel79 ~]$ env | grep ORACLE_SID
ORACLE_SID=prod
[oracle@oel79 ~]$ dbca
17.日常管理
1.集群状态
[grid@oel79 ~]$ crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ARCH.dg
ONLINE ONLINE oel79 STABLE
ora.DATA.dg
ONLINE ONLINE oel79 STABLE
ora.FRA.dg
ONLINE ONLINE oel79 STABLE
ora.LISTENER.lsnr
ONLINE ONLINE oel79 STABLE
ora.asm
ONLINE ONLINE oel79 Started,STABLE
ora.ons
OFFLINE OFFLINE oel79 STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE oel79 STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE oel79 STABLE
ora.prod.db
1 ONLINE ONLINE oel79 Open,HOME=/u01/app/o
racle/product/19.0.0
2.数据库的状态
[oracle@oel79 ~]$ srvctl status database -d prod
Database is running.
3.启动关闭顺序
关闭:先关闭 rdbms 实例---->关闭 ASM 实例
开启:先开启 ASM 实例---->再开启 rdbms 实例
注意:重启 linux 后,ASM和RDBMS自动启动