Oracle Linux 7.9 + ASM安装Oracle 12CR2

2023年 9月 28日 76.1k 0

目录

  • 一、前言
  • 二、Oracle ASM简介
  • 三、安装前准备
    • 1、环境规划
    • 2、Linux系统参数设置
      • 2.1、hosts文件配置
      • 2.2、配置语言环境
      • 2.3、修改 /dev/shm大小
      • 2.4、创建数据库用户组和系统用户
      • 2.5、创建数据库安装目录并授权
      • 2.6、配置YUM源
      • 2.7、安装Oracle数据库所需软件包
      • 2.8、配置内核参数
      • 2.9、修改资源限制参数
      • 2.10、控制给用户分配的资源
      • 2.11、关闭透明页
      • 2.12、关闭numa功能
      • 2.13、禁用SELINUX
      • 2.14、修改时区
      • 2.15、关闭防火墙
      • 2.16、设置系统默认字符界面启动
      • 2.17、配置Oracle用户环境变量
      • 2.18、配置grid环境变量
    • 3、配置ASM磁盘
      • 3.1、虚拟机配置文件修改
      • 3.2、虚拟机添加硬盘(ASM磁盘组用)
      • 3.3、查看磁盘UUID
      • 3.4、配置规则
      • 3.5、加载规则
  • 四、安装Oracle Grid软件
    • 1、上传Oracle Grid安装软件到服务器并解压
    • 2、操作系统启动VNC服务
    • 3、使用VNC客户端连接服务器
    • 4、运行Oracle Grid安装向导以安装Grid软件
    • 5、创建ASM磁盘组
      • 5.1、创建dgsystem磁盘组
      • 5.2、创建dgrecovery磁盘组
      • 5.3、创建dgdata磁盘组
      • 5.4、查看ASM磁盘组状态
  • 五、安装Oracle数据库
    • 1、上传Oracle数据库安装软件到服务器并解压
    • 2、操作系统启动VNC服务
    • 3、使用VNC客户端连接服务器
    • 4、运行Oracle数据库安装向导以安装Oracle数据库
    • 5、创建数据库
    • 6、登录数据库
    • 7、基础维护
      • 7.1、取消180天密码过期限制
      • 7.2、关闭审计
      • 7.3、修改最大进程数
      • 7.4、修改游标数
      • 7.5、调整undo大小
      • 7.6、调整db_files
  • 六、Oracle Grid相关操作
    • 1、添加环境变量
    • 2、查看服务状态
    • 3、查看资源状态
    • 4、启动、停止服务
      • 4.1、启动服务
      • 4.2、停止服务
  • 七、Oracle数据库的启停
    • 1、启动
    • 2、停止
  • 八、总结
  • 九、写在后面

一、前言

  欢迎阅读本篇技术文档,本文档将帮助大家顺利完成Oracle Linux 7.9 + ASM安装Oracle 12CR2的过程。在本文档中,您将学到如何准备安装前的环境、如何正确配置ASM磁盘、如何安装Oracle 12CR2,以及如何进行基本配置。希望通过这份文档,能够帮助大家更好地理解Oracle数据库的安装和配置流程,能够更加轻松地进行相关操作。希望本文档能够为您提供有价值的信息,并使您能够成功安装和配置Oracle 12CR2数据库。

二、Oracle ASM简介

  Oracle ASM是用于Oracle数据库文件的卷管理器和文件系统,支持单实例Oracle数据库和Oracle Real Application Clusters(Oracle RAC)配置。Oracle ASM是Oracle推荐的存储管理解决方案,它提供了传统卷管理器、文件系统和裸设备的替代方案。Oracle ASM 使用磁盘组来存储数据文件;Oracle ASM 磁盘组是 Oracle ASM 作为一个单元管理的磁盘集合。在磁盘组中,Oracle ASM 公开 Oracle 数据库文件的文件系统接口。存储在磁盘组中的文件内容均匀分布,以消除热点并在磁盘之间提供统一的性能。性能可与裸设备的性能相媲美。

图 1-1 Oracle ASM for Single-Instance Oracle Databases

三、安装前准备

1、环境规划

2、Linux系统参数设置

2.1、hosts文件配置

[root@hellodba ~]# echo "192.168.0.58 hellodba">> /etc/hosts
[root@hellodba ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.58 hellodba

2.2、配置语言环境

[root@hellodba ~]# echo "export LANG=en_US.UTF-8" >> ~/.bash_profile
[root@hellodba ~]# source ~/.bash_profile

2.3、修改 /dev/shm大小

[root@hellodba ~]# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
tmpfs 7.8G 0 7.8G 0% /dev/shm
[root@hellodba ~]# echo "none /dev/shm tmpfs defaults,size=16384m 0 0" >> /etc/fstab
[root@hellodba ~]# mount -o remount /dev/shm
[root@hellodba ~]# df -h /dev/shm
Filesystem Size Used Avail Use% Mounted on
tmpfs 16G 0 16G 0% /dev/shm

//关于/dev/shm
在Linux系统中,'/dev/shm'目录是一个特殊的目录,用于实现共享内存,默认是系统内存的50%。它是一个临时文件系统,通常位于RAM(内存)中,而不是硬盘上,并且在系统重启时会被清空。因此,'/dev/shm'目录只适合用于短期存储和进程间通信,不能用于长期存储数据。
'/dev/shm'大小应该大于SGA+PGA的总内存大小,在Linux系统上,如果操作系统'/dev/shm'装载大小对于Oracle系统全局区域(SGA)和程序全局区域(PGA)来说太小,则会导致ORA-00845错误。

2.4、创建数据库用户组和系统用户

[root@hellodba ~]# /usr/sbin/groupadd -g 50001 oinstall
[root@hellodba ~]# /usr/sbin/groupadd -g 50002 dba
[root@hellodba ~]# /usr/sbin/groupadd -g 50003 oper
[root@hellodba ~]# /usr/sbin/groupadd -g 50004 backupdba
[root@hellodba ~]# /usr/sbin/groupadd -g 50005 dgdba
[root@hellodba ~]# /usr/sbin/groupadd -g 50006 kmdba
[root@hellodba ~]# /usr/sbin/groupadd -g 50007 asmdba
[root@hellodba ~]# /usr/sbin/groupadd -g 50008 asmoper
[root@hellodba ~]# /usr/sbin/groupadd -g 50009 asmadmin
[root@hellodba ~]# useradd -u 51001 -g oinstall -G dba,asmdba,asmadmin,backupdba,dgdba,kmdba,oper oracle
[root@hellodba ~]# useradd -u 51002 -g oinstall -G asmadmin,asmdba,asmoper,dba,oper grid
[root@hellodba ~]# echo "oracle" | passwd --stdin oracle
[root@hellodba ~]# echo "oracle" | passwd --stdin grid

2.5、创建数据库安装目录并授权

[root@hellodba ~]# mkdir -p /oracle/app/grid
[root@hellodba ~]# mkdir -p /oracle/app/12.2/grid
[root@hellodba ~]# mkdir -p /oracle/app/oracle
[root@hellodba ~]# mkdir -p /oracle/app/oraInventory
[root@hellodba ~]# mkdir -p /soft
[root@hellodba ~]# chown -R grid:oinstall /oracle
[root@hellodba ~]# chown -R grid:oinstall /oracle/app/oraInventory
[root@hellodba ~]# chown -R oracle:oinstall /oracle/app/oracle
[root@hellodba ~]# chown -R oracle:oinstall /soft
[root@hellodba ~]# chmod -R 775 /oracle
[root@hellodba ~]# chmod -R 775 /soft

2.6、配置YUM源

//挂载光驱
[root@hellodba ~]# mount /dev/cdrom /mnt

//配置YUM源
[root@hellodba ~]# cd /etc/yum.repos.d
[root@hellodba yum.repos.d]# mkdir bak
[root@hellodba yum.repos.d]# mv *.repo bak
[root@hellodba yum.repos.d]# echo "[EL]" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "name=Linux 7.9 DVD" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "baseurl=file:///mnt" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "gpgcheck=0" >> hellodba.repo
[root@hellodba yum.repos.d]# echo "enabled=1" >> hellodba.repo

2.7、安装Oracle数据库所需软件包

[root@hellodba ~]#
yum -y install smartmontools
yum -y install libXrender*
yum -y install libgcc*
yum -y install bc*
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 gcc
yum -y install gcc-c++
yum -y install lrzsz
yum -y install python-devel
yum -y install compat-db*
yum -y install compat-gcc-34
yum -y install compat-gcc-34-c++
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 libXp.so.6
yum -y install libXt.so.6
yum -y install libXtst.so.6
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 libXtst
yum -y install libstdc++-docs
yum -y install libgcc_s.so.1
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
yum -y install sysstat
yum -y install unixODBC
yum -y install unixODBC-devel
yum -y install elfutils-libelf-devel-0.97
yum -y install elfutils-libelf-devel
yum -y install redhat-lsb-core
yum -y install *vnc*

2.8、配置内核参数

[root@hellodba ~]# vi /etc/sysctl.conf
#ORACLE SETTING
#可以拥有的异步IO请求数
fs.aio-max-nr = 1048576
#允许文件句柄的最大数目
fs.file-max = 6815744
#信号参数
kernel.sem = 250 32000 100 128
#IP V4的端口范围
net.ipv4.ip_local_port_range = 9000 65500
#启用反向过滤
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
#启动IP数据包转发
net.ipv4.ip_forward=1
#缓存区的缺省值
net.core.rmem_default = 262144
#缓存区的最大值
net.core.rmem_max = 4194304
#发送缓存区的缺省值
net.core.wmem_default = 262144
#发送缓存区的最大值
net.core.wmem_max = 1048586
#当系统检测到oops时,重新启动系统,以便系统能够重新初始化恢复正常工作
kernel.panic_on_oops = 1
#单个共享内存段最大值,让数据库在一个共享段里面的可以容纳整个SGA
#SGA=物理内存*80%*80% PGA=物理内存*80%*20%
#(kernel.shmmax = 物理内存*1024*1024*1024-1)
kernel.shmmax = 9620726743
#控制共享内存页数(kernel.shmall = shmmax/4096)
kernel.shmall = 2348810
#共享内存的最大数量
kernel.shmmni = 4096
#当系统内存使用90%的时候开始使用交换页面
vm.swappiness=10
#默认是100,增大这个参数设置了虚拟内存回收directory和i-node缓冲的倾向,这个值越大。越容易回收。
vm.vfs_cache_pressure=200
#大页内存,物理内存大于8G一定要配 (sga_max_size+1g) / 2M
vm.nr_hugepages = 4000

[root@hellodba ~]# sysctl -p
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.conf.all.rp_filter = 2
net.ipv4.conf.default.rp_filter = 2
net.ipv4.ip_forward = 1
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 = 9620726743
kernel.shmall = 2348810
kernel.shmmni = 4096
vm.swappiness = 10
vm.vfs_cache_pressure = 200
vm.nr_hugepages = 4000

2.9、修改资源限制参数

[root@hellodba ~]# vi /etc/security/limits.conf
#ORACLE SETTING
#打开文件描述符大小
grid soft nproc 16384
grid hard nproc 16384
oracle soft nproc 16384
oracle hard nproc 16384
#单个用户可用的进程数
grid soft nofile 65536
grid hard nofile 65536
oracle soft nofile 65536
oracle hard nofile 65536
#进程堆栈段的大小
grid soft stack 32768
grid hard stack 32768
oracle soft stack 32768
oracle hard stack 32768
#内存锁,略低于物理内存
oracle hard memlock 12000000
oracle soft memlock 12000000

[root@hellodba ~]# vi /etc/security/limits.d/20-nproc.conf
* soft nproc 16384

2.10、控制给用户分配的资源

[root@hellodba ~]# echo "session required pam_limits.so" >> /etc/pam.d/login

2.11、关闭透明页

// 开了大内存页,一定要关闭透明页,透明的 HugePages 可能会导致运行时内存分配延迟
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
[root@hellodba ~]# vi /etc/rc.d/rc.local
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

[root@hellodba ~]# chmod +x /etc/rc.d/rc.local
[root@hellodba ~]# init 6
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/defrag
always madvise [never]
[root@hellodba ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

2.12、关闭numa功能

//NUMA关闭前
[root@hellodba ~]# dmesg | grep -i numa
[ 0.000000] NUMA: Node 0 [mem 0x00000000-0x0009ffff] + [mem 0x00100000-0xbfffffff] -> [mem 0x00000000-0xbfffffff]
[ 0.000000] NUMA: Node 0 [mem 0x00000000-0xbfffffff] + [mem 0x100000000-0x43fffffff] -> [mem 0x00000000-0x43fffffff]

[root@hellodba ~]# vi /etc/default/grub
将 GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet"
改 GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet numa=off"
[root@hellodba ~]# grub2-mkconfig -o /etc/grub2.cfg

//MUMA关闭后
[root@hellodba ~]# dmesg | grep -i numa
[ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-957.el7.x86_64 root=UUID=22013bb0-679e-4f14-9797-92f3d0948444 ro crashkernel=auto rhgb quiet numa=off
[ 0.000000] NUMA turned off
[ 0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-3.10.0-957.el7.x86_64 root=UUID=22013bb0-679e-4f14-9797-92f3d0948444 ro crashkernel=auto rhgb quiet numa=off

2.13、禁用SELINUX

[root@hellodba ~]# getenforce
Enforcing
[root@hellodba ~]# vi /etc/selinux/config
将 SELINUX=enforcing
改 SELINUX= disabled
[root@hellodba ~]# setenforce 0
[root@hellodba ~]# getenforce
Permissive

2.14、修改时区

[root@hellodba ~]# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
[root@hellodba ~]# hwclock

2.15、关闭防火墙

//关闭防火墙
[root@hellodba ~]# systemctl stop firewalld

//查看防火墙状态
[root@hellodba ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Thu 2023-09-21 07:02:26 CST; 20s ago
Docs: man:firewalld(1)
Process: 782 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 782 (code=exited, status=0/SUCCESS)

Sep 20 22:32:18 hellodba systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 20 22:32:18 hellodba systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 20 22:32:18 hellodba firewalld[782]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future rel...ing it now.
Sep 21 07:02:25 hellodba systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 21 07:02:26 hellodba systemd[1]: Stopped firewalld - dynamic firewall daemon.
Hint: Some lines were ellipsized, use -l to show in full.

//禁止开机启动防火墙
[root@hellodba ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

2.16、设置系统默认字符界面启动

[root@hellodba ~]# systemctl set-default multi-user.target
[root@hellodba ~]# systemctl get-default
multi-user.target

2.17、配置Oracle用户环境变量

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ vi ~/.bash_profile
export PS1
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export TZ=Asia/Shanghai
export ORACLE_UNQNAME=hellodb
ORACLE_SID=hellodb; export ORACLE_SID
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2/dbhome_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
#设置Oracle客户端字符集,必须与Oracle安装时设置的字符集保持一致,否则出现数据导入导出中文乱码问题
#NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
NLS_LANG=AMERICAN_AMERICA.UTF8;export NLS_LANG
PATH=.:$PATH:$HOME/.local/bin:$HOME/bin:$ORACLE_BASE/product/12.2/dbhome_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

[oracle@hellodba ~]$ source ~/.bash_profile
[oracle@hellodba ~]$ env | grep ORACLE
ORACLE_UNQNAME=hellodb
ORACLE_SID=hellodb
ORACLE_BASE=/oracle/app/oracle
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/app/oracle/product/12.2/dbhome_1

2.18、配置grid环境变量

[root@hellodba ~]# su - grid
[grid@hellodba ~]$ vi ~/.bash_profile
export PS1
umask 022
export TMP=/tmp
export LANG=en_US.UTF8
export TMPDIR=$TMP
export TZ=Asia/Shanghai
ORACLE_SID=+ASM; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
ORACLE_BASE=/oracle/app/grid; export ORACLE_BASE
ORACLE_HOME=/oracle/app/12.2/grid; export ORACLE_HOME
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
PATH=$PATH:$HOME/.local/bin:$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

[grid@hellodba ~]$ source ~/.bash_profile
[grid@hellodba ~]$ env | grep ORACLE
ORACLE_SID=+ASM
ORACLE_BASE=/oracle/app/grid
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/app/12.2/grid

3、配置ASM磁盘

3.1、虚拟机配置文件修改

1) 将虚拟机关机。
2) 虚拟机配置文件(Oracle Linux 7.9+ASM+Oracle 12CR2.vmx)最后行添加disk.EnableUUID="TRUE",才可以获取磁盘的UUID。

3.2、虚拟机添加硬盘(ASM磁盘组用)

//dggrid
[root@hellodba ~]# fdisk -l | grep '/dev/sd*' | grep '1073 MB'
Disk /dev/sdg: 1073 MB, 1073741824 bytes, 2097152 sectors
Disk /dev/sdh: 1073 MB, 1073741824 bytes, 2097152 sectors
Disk /dev/sdj: 1073 MB, 1073741824 bytes, 2097152 sectors
Disk /dev/sdk: 1073 MB, 1073741824 bytes, 2097152 sectors
Disk /dev/sdi: 1073 MB, 1073741824 bytes, 2097152 sectors

//dgsystem
[root@hellodba ~]# fdisk -l | grep "/dev/sd*" | grep '214.7 GB'
Disk /dev/sdd: 214.7 GB, 214748364800 bytes, 419430400 sectors
Disk /dev/sde: 214.7 GB, 214748364800 bytes, 419430400 sectors
Disk /dev/sdf: 214.7 GB, 214748364800 bytes, 419430400 sectors

//dgrecovery
[root@hellodba ~]# fdisk -l | grep "/dev/sd*" | grep '322.1 GB'
Disk /dev/sdl: 322.1 GB, 322122547200 bytes, 629145600 sectors
Disk /dev/sdm: 322.1 GB, 322122547200 bytes, 629145600 sectors
Disk /dev/sdn: 322.1 GB, 322122547200 bytes, 629145600 sectors

//dgdata
[root@hellodba ~]# fdisk -l | grep "/dev/sd*" | grep '429.5 GB'
Disk /dev/sdo: 429.5 GB, 429496729600 bytes, 838860800 sectors
Disk /dev/sdp: 429.5 GB, 429496729600 bytes, 838860800 sectors
Disk /dev/sdq: 429.5 GB, 429496729600 bytes, 838860800 sectors

3.3、查看磁盘UUID

//dggrid
[root@hellodba ~]#
for i in g h i j k;
do
echo "KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`",SYMLINK+="asm-disk$i",OWNER="grid", GROUP="asmadmin",MODE="0660""
done

KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29654ec88d9f30124f666b5b2d4",SYMLINK+="asm-diskg",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c294cc0bc4da20bc842057dbebb6",SYMLINK+="asm-diskh",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29541731eee199c2b8aec669209",SYMLINK+="asm-diski",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2969b4426467fa3dccbaa947023",SYMLINK+="asm-diskj",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29dba7cd7d84e13409ebeb53cd8",SYMLINK+="asm-diskk",OWNER="grid", GROUP="asmadmin",MODE="0660"

//dgsystem
[root@hellodba ~]#
for i in d e f;
do
echo "KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`",SYMLINK+="asm-disk$i",OWNER="grid", GROUP="asmadmin",MODE="0660""
done

KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2990339d80a043e0476bdf65dde",SYMLINK+="asm-diskd",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c294802856e833ca64aaf9e2f9fe",SYMLINK+="asm-diske",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29db0c27af9326d25599b3d15e4",SYMLINK+="asm-diskf",OWNER="grid", GROUP="asmadmin",MODE="0660"

//dgrecovery
[root@hellodba ~]#
for i in l m n;
do
echo "KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`",SYMLINK+="asm-disk$i",OWNER="grid", GROUP="asmadmin",MODE="0660""
done

KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2977403930a3b5307aa8ca8476d",SYMLINK+="asm-diskl",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2922c8950284a58fc1bb43e7454",SYMLINK+="asm-diskm",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2966b2cd42206940d647eeafe2a",SYMLINK+="asm-diskn",OWNER="grid", GROUP="asmadmin",MODE="0660"

//dgdata
[root@hellodba ~]#
for i in o p q;
do
echo "KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`",SYMLINK+="asm-disk$i",OWNER="grid", GROUP="asmadmin",MODE="0660""
done

KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29bbe40a0ac3c54fc408efe0801",SYMLINK+="asm-disko",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2949a247a756650606d1bd9b75b",SYMLINK+="asm-diskp",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c290437ffb87637bf83d37cc16ef",SYMLINK+="asm-diskq",OWNER="grid", GROUP="asmadmin",MODE="0660"

3.4、配置规则

[root@hellodba ~]# vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29654ec88d9f30124f666b5b2d4",SYMLINK+="asm-dggrid01",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c294cc0bc4da20bc842057dbebb6",SYMLINK+="asm-dggrid02",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29541731eee199c2b8aec669209",SYMLINK+="asm-dggrid03",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2969b4426467fa3dccbaa947023",SYMLINK+="asm-dggrid04",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29dba7cd7d84e13409ebeb53cd8",SYMLINK+="asm-dggrid05",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2990339d80a043e0476bdf65dde",SYMLINK+="asm-dgsystem01",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c294802856e833ca64aaf9e2f9fe",SYMLINK+="asm-dgsystem02",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29db0c27af9326d25599b3d15e4",SYMLINK+="asm-dgsystem03",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2977403930a3b5307aa8ca8476d",SYMLINK+="asm-dgrecovery01",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2922c8950284a58fc1bb43e7454",SYMLINK+="asm-dgrecovery02",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2966b2cd42206940d647eeafe2a",SYMLINK+="asm-dgrecovery03",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c29bbe40a0ac3c54fc408efe0801",SYMLINK+="asm-dgdata01",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c2949a247a756650606d1bd9b75b",SYMLINK+="asm-dgdata02",OWNER="grid", GROUP="asmadmin",MODE="0660"
KERNEL=="sd?",SUBSYSTEM=="block", PROGRAM=="/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/$name",RESULT=="36000c290437ffb87637bf83d37cc16ef",SYMLINK+="asm-dgdata03",OWNER="grid", GROUP="asmadmin",MODE="0660"

3.5、加载规则

[root@itpuxbbdb54 ~]# /sbin/udevadm trigger --type=devices --action=change
[root@hellodba sbin]# ls -lsa /dev/asm*
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgdata01 -> sdo
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgdata02 -> sdp
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgdata03 -> sdq
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dggrid01 -> sdg
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dggrid02 -> sdh
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dggrid03 -> sdi
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dggrid04 -> sdj
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dggrid05 -> sdk
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgrecovery01 -> sdl
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgrecovery02 -> sdm
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgrecovery03 -> sdn
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgsystem01 -> sdd
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgsystem02 -> sde
0 lrwxrwxrwx 1 root root 3 Sep 21 11:24 /dev/asm-dgsystem03 -> sdf

四、安装Oracle Grid软件

1、上传Oracle Grid安装软件到服务器并解压

//通过grid用户上传Oracle Grid安装软件到服务器 /soft 目录
[root@hellodba ~]# su - grid
[grid@hellodba ~]$ cd /soft
[grid@hellodba soft]$ ll
-rw-r--r-- 1 grid oinstall 3453696911 Sep 21 13:10 linuxx64_12201_database.zip
-rw-r--r-- 1 grid oinstall 2994687209 Sep 21 13:10 linuxx64_12201_grid_home.zip
[grid@hellodba soft]$ cd $ORACLE_HOME
[grid@hellodba grid]$ unzip -q /soft/linuxx64_12201_grid_home.zip

2、操作系统启动VNC服务

//以grid用户启动VNC服务
[grid@hellodba ~]$ vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
xauth: file /home/grid/.Xauthority does not exist

New 'hellodba:1 (grid)' desktop is hellodba:1

Creating default startup script /home/grid/.vnc/xstartup
Creating default config /home/grid/.vnc/config
Starting applications specified in /home/grid/.vnc/xstartup
Log file is /home/grid/.vnc/hellodba:1.log

3、使用VNC客户端连接服务器

4、运行Oracle Grid安装向导以安装Grid软件

[grid@hellodba ~]$ cd $ORACLE_HOME
[grid@hellodba grid]$ ./gridSetup.sh











[root@hellodba ~]# cd /oracle/app/12.2/grid/cv/rpm
[root@hellodba rpm]# rpm -ivh cvuqdisk-1.0.10-1.rpm
Preparing... ################################# [100%]
Using default group oinstall to install package
Updating / installing...
1:cvuqdisk-1.0.10-1 ################################# [100%]




[root@hellodba ~]# /oracle/app/oraInventory/orainstRoot.sh
Changing permissions of /oracle/app/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /oracle/app/oraInventory to oinstall.
The execution of the script is complete.
[root@hellodba ~]# /oracle/app/12.2/grid/root.sh
Performing root user operation.

The following environment variables are set as:
ORACLE_OWNER= grid
ORACLE_HOME= /oracle/app/12.2/grid

Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...

Creating /etc/oratab file...
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.
Using configuration parameter file: /oracle/app/12.2/grid/crs/install/crsconfig_params
The log of current session can be found at:
/oracle/app/grid/crsdata/hellodba/crsconfig/roothas_2023-09-22_11-26-30AM.log
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp 'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
CRS-4664: Node hellodba successfully pinned.
2023/09/22 11:26:33 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'hellodba'
CRS-2673: Attempting to stop 'ora.evmd' on 'hellodba'
CRS-2677: Stop of 'ora.evmd' on 'hellodba' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'hellodba' has completed
CRS-4133: Oracle High Availability Services has been stopped.
CRS-4123: Oracle High Availability Services has been started.

hellodba 2023/09/22 11:27:07 /oracle/app/12.2/grid/cdata/hellodba/backup_20230922_112707.olr 0
2023/09/22 11:27:08 CLSRSC-327: Successfully configured Oracle Restart for a standalone server


5、创建ASM磁盘组

5.1、创建dgsystem磁盘组

[grid@hellodba ~]$ asmca -silent -createDiskGroup -diskGroupName dgsystem -diskList '/dev/asm-dgsystem01','/dev/asm-dgsystem02','/dev/asm-dgsystem03' -redundancy HIGH -au_size 8

5.2、创建dgrecovery磁盘组

[grid@hellodba ~]$ asmca -silent -createDiskGroup -diskGroupName dgrecovery -diskList '/dev/asm-dgrecovery01','/dev/asm-dgrecovery02','/dev/asm-dgrecovery03' -redundancy HIGH -au_size 8

5.3、创建dgdata磁盘组

[grid@hellodba ~]$ asmca -silent -createDiskGroup -diskGroupName dgdata -diskList '/dev/asm-dgdata01','/dev/asm-dgdata02','/dev/asm-dgdata03' -redundancy HIGH -au_size 8

5.4、查看ASM磁盘组状态

[grid@hellodba ~]$ asmcmd lsdg
State Type Rebal Sector Logical_Sector Block AU Total_MB Free_MB Req_mir_free_MB Usable_file_MB Offline_disks Voting_files Name
MOUNTED HIGH N 512 512 4096 8388608 1228800 1228392 0 409464 0 N DGDATA/
MOUNTED HIGH N 512 512 4096 8388608 5120 4616 2048 856 0 N DGGRID/
MOUNTED HIGH N 512 512 4096 8388608 921600 921192 0 307064 0 N DGRECOVERY/
MOUNTED HIGH N 512 512 4096 8388608 614400 613992 0 204664 0 N DGSYSTEM/

五、安装Oracle数据库

1、上传Oracle数据库安装软件到服务器并解压

//通过oracle用户上传Oracle数据库安装软件到服务器 /soft 目录
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ cd /soft
[oracle@hellodba soft]$ ll
-rw-r--r-- 1 oracle oinstall 3453696911 Sep 22 12:37 linuxx64_12201_database.zip
-rw-r--r-- 1 grid oinstall 2994687209 Sep 22 11:16 linuxx64_12201_grid_home.zip
[oracle@hellodba soft]$ unzip -q linuxx64_12201_database.zip
[oracle@hellodba soft]$ ll
drwxr-xr-x 7 oracle oinstall 117 Jan 27 2017 database
-rw-r--r-- 1 oracle oinstall 3453696911 Sep 22 12:37 linuxx64_12201_database.zip
-rw-r--r-- 1 grid oinstall 2994687209 Sep 22 11:16 linuxx64_12201_grid_home.zip

2、操作系统启动VNC服务

//以oracle用户启动VNC服务
[oracle@hellodba ~]$ vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
xauth: file /home/oracle/.Xauthority does not exist

New 'hellodba:2 (oracle)' desktop is hellodba:2

Creating default startup script /home/oracle/.vnc/xstartup
Creating default config /home/oracle/.vnc/config
Starting applications specified in /home/oracle/.vnc/xstartup
Log file is /home/oracle/.vnc/hellodba:2.log

3、使用VNC客户端连接服务器

4、运行Oracle数据库安装向导以安装Oracle数据库

[oracle@hellodba ~]$ cd /soft/database
[oracle@hellodba database]$ ./runInstaller









[root@hellodba ~]# /oracle/app/oracle/product/12.2/dbhome_1/root.sh
Performing root user operation.

The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /oracle/app/oracle/product/12.2/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.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] :

Oracle Trace File Analyzer (TFA - User Mode) is available at :
/oracle/app/oracle/product/12.2/dbhome_1/suptools/tfa/release/tfa_home/bin/tfactl

OR

Oracle Trace File Analyzer (TFA - Daemon Mode) can be installed by running this script :
/oracle/app/oracle/product/12.2/dbhome_1/suptools/tfa/release/tfa_home/install/roottfa.sh


5、创建数据库

[oracle@hellodba ~]$ dbca



























6、登录数据库

//登录数据库
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ sqlplus / as sysdba

//查看数据库基础信息
SQL> select name,log_mode,open_mode,platform_name,db_unique_name from v$database;
NAME LOG_MODE OPEN_MODE PLATFORM_NAME DB_UNIQUE_NAME
--------------------------------------------------------------------------------------
HELLODB NOARCHIVELOG READ WRITE Linux x86 64-bit hellodb

//查看数据库版本
SQL> select BANNER from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
PL/SQL Release 12.2.0.1.0 - Production
CORE 12.2.0.1.0 Production
TNS for Linux: Version 12.2.0.1.0 - Production
NLSRTL Version 12.2.0.1.0 - Production

//查看数据库字符集
SQL> select * from nls_database_parameters;
PARAMETER VALUE
--------------------------------------------------------------------------------
NLS_RDBMS_VERSION 12.2.0.1.0
NLS_NCHAR_CONV_EXCP FALSE
NLS_LENGTH_SEMANTICS BYTE
NLS_COMP BINARY
NLS_DUAL_CURRENCY $
NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR
NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR
NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM
NLS_TIME_FORMAT HH.MI.SSXFF AM
NLS_SORT BINARY
NLS_DATE_LANGUAGE AMERICAN
NLS_DATE_FORMAT DD-MON-RR
NLS_CALENDAR GREGORIAN
NLS_NUMERIC_CHARACTERS .,
NLS_NCHAR_CHARACTERSET UTF8
NLS_CHARACTERSET AL32UTF8
NLS_ISO_CURRENCY AMERICA
NLS_CURRENCY $
NLS_TERRITORY AMERICA
NLS_LANGUAGE AMERICAN

//查看数据库块大小
SQL> show parameter db_block_size
NAME TYPE VALUE
-------------------------------------------
db_block_size integer 8192

7、基础维护

7.1、取消180天密码过期限制

SQL> select * from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME';
PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
-----------------------------------------------------------------------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD 180

SQL> alter profile default limit password_life_time unlimited;

SQL> select * from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME';
PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
-----------------------------------------------------------------------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITED

7.2、关闭审计

SQL> show parameter audit_trail;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_trail string DB

SQL> alter system set audit_trail=none scope=spfile; (重启数据库生效)

7.3、修改最大进程数

SQL> show parameter processes;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 1
asm_io_processes integer 20
db_writer_processes integer 1
gcs_server_processes integer 0
global_txn_processes integer 1
job_queue_processes integer 4000
log_archive_max_processes integer 4
processes integer 300

SQL> alter system set processes=1000 scope=spfile; (重启数据库生效)

7.4、修改游标数

//将 open_cursors 改为和 processes 一样
SQL> show parameter open_cursors;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 300

SQL> alter system set open_cursors = 1100 scope=spfile; (重启数据库生效)

7.5、调整undo大小

SQL> select name from v$datafile;
NAME
-------------------------------------------------------------------------------
+DGSYSTEM/HELLODB/DATAFILE/system.262.1148218609
+DGSYSTEM/HELLODB/DATAFILE/sysaux.263.1148218613
+DGSYSTEM/HELLODB/DATAFILE/undotbs1.264.1148218613
+DGSYSTEM/HELLODB/DATAFILE/users.266.1148218619

SQL> alter database datafile '+DGSYSTEM/HELLODB/DATAFILE/undotbs1.264.1148218613' resize 30g;

7.6、调整db_files

SQL> show parameter db_files;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_files integer 200

SQL> alter system set db_files=1024 scope=spfile; (重启数据库生效)

六、Oracle Grid相关操作

1、添加环境变量

//查看ORACLE_HOME目录
[root@hellodba ~]# su - grid
[grid@hellodba ~]$ env | grep ORACLE
ORACLE_SID=+ASM
ORACLE_BASE=/oracle/app/grid
ORACLE_TERM=xterm
ORACLE_HOME=/oracle/app/12.2/grid

//添加到root下的环境变量
[root@hellodba ~]# vi ~/.bash_profile
PATH=$PATH:/oracle/app/12.2/grid/bin:$HOME/bin
[root@hellodba ~]# source ~/.bash_profile

2、查看服务状态

[root@hellodba ~]# crsctl check has
CRS-4638: Oracle High Availability Services is online

3、查看资源状态

[root@hellodba ~]# crsctl stat res -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DGDATA.dg
ONLINE ONLINE hellodba STABLE
ora.DGGRID.dg
ONLINE ONLINE hellodba STABLE
ora.DGRECOVERY.dg
ONLINE ONLINE hellodba STABLE
ora.DGSYSTEM.dg
ONLINE ONLINE hellodba STABLE
ora.LISTENER.lsnr
ONLINE ONLINE hellodba STABLE
ora.asm
ONLINE ONLINE hellodba Started,STABLE
ora.ons
OFFLINE OFFLINE hellodba STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE hellodba STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE hellodba STABLE
ora.hellodb.db
1 ONLINE ONLINE hellodba Open,HOME=/oracle/ap
p/oracle/product/12.
2/dbhome_1,STABLE
--------------------------------------------------------------------------------

4、启动、停止服务

4.1、启动服务

[root@hellodba ~]# crsctl start has
CRS-4123: Oracle High Availability Services has been started.

4.2、停止服务

[root@hellodba ~]# crsctl stop has
CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'hellodba'
CRS-2673: Attempting to stop 'ora.DGGRID.dg' on 'hellodba'
CRS-2673: Attempting to stop 'ora.DGRECOVERY.dg' on 'hellodba'
CRS-2673: Attempting to stop 'ora.DGDATA.dg' on 'hellodba'
CRS-2673: Attempting to stop 'ora.DGSYSTEM.dg' on 'hellodba'
CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'hellodba'
CRS-2677: Stop of 'ora.DGGRID.dg' on 'hellodba' succeeded
CRS-2677: Stop of 'ora.DGSYSTEM.dg' on 'hellodba' succeeded
CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'hellodba' succeeded
CRS-2677: Stop of 'ora.DGDATA.dg' on 'hellodba' succeeded
CRS-2677: Stop of 'ora.DGRECOVERY.dg' on 'hellodba' succeeded
CRS-2673: Attempting to stop 'ora.asm' on 'hellodba'
CRS-2677: Stop of 'ora.asm' on 'hellodba' succeeded
CRS-2673: Attempting to stop 'ora.evmd' on 'hellodba'
CRS-2677: Stop of 'ora.evmd' on 'hellodba' succeeded
CRS-2673: Attempting to stop 'ora.cssd' on 'hellodba'
CRS-2677: Stop of 'ora.cssd' on 'hellodba' succeeded
CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'hellodba' has completed
CRS-4133: Oracle High Availability Services has been stopped.

七、Oracle数据库的启停

1、启动

[root@hellodba ~]# crsctl start has
[root@hellodba ~]# crsctl check has
CRS-4638: Oracle High Availability Services is online
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> startup

2、停止

[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> shutdown immediate;
[root@hellodba ~]# crsctl stop has

八、总结

  到此Oracle Linux 7.9 + ASM安装Oracle 12CR2部署完毕,并进行了一些常规的设置。安装Oracle数据库需要有一定的专业知识和经验,在实际操作中,可能还会遇到其他问题和挑战,建议在进行安装之前详细阅读相关文档和指南,并确保有必要的技术支持和备份措施。希望通过本文对您搭建一套基于Oracle Linux 7.9 + ASM + Oracle 12CR2的数据库环境有一定帮助,祝顺利!

九、写在后面

由于本人有限的能力和知识储备,如有错误敬请批评指正!

公众号:Hello DBA
 

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论