目录
- 一、前言
- 二、安装前准备
- 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、重启操作系统
- 三、安装Oracle数据库
- 1、下载Oracle数据库软件
- 2、安装Oracle数据库软件
- 2.1、上传Oracle数据库安装软件到服务器并解压
- 2.2、操作系统启动VNC服务
- 2.3、使用VNC客户端连接服务器
- 2.4、运行Oracle数据库安装向导以安装Oracle数据
- 3、创建监听
- 3.1、监听的启停与状态查看
- 4、创建数据库
- 四、Oracle数据库安装后的操作
- 1、登录数据库
- 2、数据库基础配置查看
- 2.1、查看数据库版本信息
- 2.2、查看数据库基础信息
- 2.3、查看数据库字符集
- 2.4、查看数据库块大小
- 2.5、查看SGA和PGA大小
- 2.6、查看进程数
- 2.7、查看游标数
- 3、数据库基础维护
- 3.1、取消180天密码过期限制
- 3.2、关闭审计
- 3.3、修改最大进程数
- 3.4、修改游标数
- 3.5、调整undo大小
- 3.6、调整db_files
- 五、Oracle数据库的启停
- 1、启动
- 2、停止
- 六、总结
- 七、写在后面
一、前言
欢迎阅读本篇技术文档,本文将为您提供关于在Red Hat Enterprise Linux 7.6操作系统上安装Oracle 12CR2数据库的详细过程。在开始之前,请确保您已经具备一定的Linux系统管理和Oracle数据库知识。本文档假设您对Linux操作系统和Oracle数据库有一定的了解,并已经熟悉基本的命令行操作。希望本文档能够为您提供有价值的信息,并使您能够成功安装和配置Oracle 12CR2数据库。
二、安装前准备
1、环境规划
欢迎阅读本篇技术文档,本文将为您提供关于在Red Hat Enterprise Linux 7.6操作系统上安装Oracle 12CR2数据库的详细过程。在开始之前,请确保您已经具备一定的Linux系统管理和Oracle数据库知识。本文档假设您对Linux操作系统和Oracle数据库有一定的了解,并已经熟悉基本的命令行操作。希望本文档能够为您提供有价值的信息,并使您能够成功安装和配置Oracle 12CR2数据库。
1、环境规划
2、Linux系统参数设置
2.1、hosts文件配置
[root@hellodba ~]# echo "192.168.0.57 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.57 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 54321 oinstall
[root@hellodba ~]# /usr/sbin/groupadd -g 54322 dba
[root@hellodba ~]# /usr/sbin/groupadd -g 54323 oper
[root@hellodba ~]# /usr/sbin/groupadd -g 54324 backupdba
[root@hellodba ~]# /usr/sbin/groupadd -g 54325 kmdba
[root@hellodba ~]# /usr/sbin/useradd -u 54321 -g oinstall -G dba,oper,backupdba,kmdba oracle
[root@hellodba ~]# echo "oracle" | passwd --stdin oracle
2.5、创建数据库安装目录并授权
[root@hellodba ~]# mkdir -p /oracle/app/oracle/product/12.2/dbhome_1
[root@hellodba ~]# mkdir -p /oracle/app/oraInventory
[root@hellodba ~]# mkdir -p /oradata
[root@hellodba ~]# mkdir -p /backup
[root@hellodba ~]# mkdir -p /archive
[root@hellodba ~]# chown -R oracle:oinstall /oracle
[root@hellodba ~]# chown -R oracle:dba /oradata
[root@hellodba ~]# chown -R oracle:dba /backup
[root@hellodba ~]# chown -R oracle:dba /archive
[root@hellodba ~]# chmod -R 775 /oracle
[root@hellodba ~]# chmod -R 775 /oradata
[root@hellodba ~]# chmod -R 775 /backup
[root@hellodba ~]# chmod -R 775 /archive
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.6 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
#打开文件描述符大小
oracle soft nproc 16384
oracle hard nproc 16384
#单个用户可用的进程数
oracle soft nofile 16384
oracle hard nofile 65536
#进程堆栈段的大小
oracle soft stack 10240
oracle hard stack 32768
#内存锁,略低于物理内存
oracle hard memlock 14000000
oracle soft memlock 14000000
[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 Mon 2023-09-18 22:55:16 CST; 4s ago
Docs: man:firewalld(1)
Process: 9986 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 9986 (code=exited, status=0/SUCCESS)
Sep 18 20:42:57 hellodba systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 18 20:42:57 hellodba systemd[1]: Started firewalld - dynamic firewall daemon.
Sep 18 22:55:15 hellodba systemd[1]: Stopping firewalld - dynamic firewall daemon...
Sep 18 22:55:16 hellodba systemd[1]: Stopped firewalld - dynamic firewall daemon.
//禁止开机启动防火墙
[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 TZ=Asia/Shanghai
export LANG=en_US.UTF8
export TMPDIR=$TMP
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_HOME/bin; export PATH
THREADS_FLAG=native; export THREADS_FLAG
umask=022
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -u 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
[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、重启操作系统
[root@hellodba ~]# reboot
三、安装Oracle数据库
1、下载Oracle数据库软件
https://edelivery.oracle.com/osdc/faces/SoftwareDelivery
2、安装Oracle数据库软件
2.1、上传Oracle数据库安装软件到服务器并解压
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ cd /backup
[oracle@hellodba backup]$ ll
-rw-r--r-- 1 oracle oinstall 3453696911 Sep 19 09:55 linuxx64_12201_database.zip
[oracle@hellodba backup]$ unzip -q linuxx64_12201_database.zip
[oracle@hellodba backup]$ ll
drwxr-xr-x 7 oracle oinstall 117 Jan 27 2017 database
-rw-r--r-- 1 oracle oinstall 3453696911 Sep 19 09:55 linuxx64_12201_database.zip
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ cd $ORACLE_HOME
[oracle@hellodba dbhome_1]$ unzip -q /backup/LINUX.X64_193000_db_home.zip
2.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:1 (oracle)' desktop is hellodba:1
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:1.log
2.3、使用VNC客户端连接服务器
2.4、运行Oracle数据库安装向导以安装Oracle数据
[oracle@hellodba ~]$ cd /backup/database/
[oracle@hellodba database]$ ./runInstaller
[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/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]:
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.
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
3、创建监听
[oracle@hellodba ~]$ netca
3.1、监听的启停与状态查看
//关闭监听
[oracle@hellodba ~]$ lsnrctl stop
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-SEP-2023 22:03:01
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hellodba)(PORT=1521)))
The command completed successfully
//启动监听
[oracle@hellodba ~]$ lsnrctl start
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-SEP-2023 22:03:06
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Starting /oracle/app/oracle/product/12.2/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /oracle/app/oracle/product/12.2/dbhome_1/network/admin/listener.ora
Log messages written to /oracle/app/oracle/diag/tnslsnr/hellodba/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hellodba)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hellodba)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 19-SEP-2023 22:03:06
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/oracle/product/12.2/dbhome_1/network/admin/listener.ora
Listener Log File /oracle/app/oracle/diag/tnslsnr/hellodba/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hellodba)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully
//监听状态查看
[oracle@hellodba ~]$ lsnrctl status
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-SEP-2023 22:03:55
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=hellodba)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 19-SEP-2023 22:03:06
Uptime 0 days 0 hr. 0 min. 49 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /oracle/app/oracle/product/12.2/dbhome_1/network/admin/listener.ora
Listener Log File /oracle/app/oracle/diag/tnslsnr/hellodba/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=hellodba)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "hellodb" has 1 instance(s).
Instance "hellodb", status READY, has 1 handler(s) for this service...
Service "hellodbXDB" has 1 instance(s).
Instance "hellodb", status READY, has 1 handler(s) for this service...
The command completed successfully
4、创建数据库
[oracle@hellodba ~]$ dbca
四、Oracle数据库安装后的操作
1、登录数据库
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> select open_mode from v$database;
OPEN_MODE
------------------------------------------------------------
READ WRITE
2、数据库基础配置查看
2.1、查看数据库版本信息
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
2.2、查看数据库基础信息
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
2.3、查看数据库字符集
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
2.4、查看数据库块大小
SQL> show parameter db_block_size;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_block_size integer 8192
2.5、查看SGA和PGA大小
SQL> show parameter sga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
allow_group_access_to_sga boolean FALSE
lock_sga boolean FALSE
pre_page_sga boolean TRUE
sga_max_size big integer 7872M
sga_min_size big integer 0
sga_target big integer 7872M
unified_audit_sga_queue_size integer 1048576
SQL> show parameter pga;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
pga_aggregate_limit big integer 3174M
pga_aggregate_target big integer 1587M
2.6、查看进程数
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 320
2.7、查看游标数
SQL> show parameter open_cursors;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 300
3、数据库基础维护
3.1、取消180天密码过期限制
SQL> select profile,resource_name,resource_type,limit 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 profile,resource_name,resource_type,limit from dba_profiles where profile='DEFAULT' and RESOURCE_NAME='PASSWORD_LIFE_TIME';
PROFILE RESOURCE_NAME RESOURCE_TYPE LIMIT
------------------------------------ ----------- ------------------------------
DEFAULT PASSWORD_LIFE_TIME PASSWORD UNLIMITED
3.2、关闭审计
SQL> show parameter audit_trail;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
audit_trail string DB
SQL> alter system set audit_trail=none scope=spfile; (重启数据库生效)
3.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 320
SQL> alter system set processes=1000 scope=spfile; (重启数据库生效)
3.4、修改游标数
//将 open_cursors 改为和 processes 一样
SQL> show parameter open_cursors;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
open_cursors integer 300
SQL> alter system set open_cursors = 1000 scope=spfile; (重启数据库生效)
3.5、调整undo大小
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oradata/hellodb/system01.dbf
/oradata/hellodb/sysaux01.dbf
/oradata/hellodb/undotbs01.dbf
/oradata/hellodb/users01.dbf
SQL> alter database datafile '/oradata/hellodb/undotbs01.dbf' resize 30g;
3.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数据库的启停
1、启动
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ lsnrctl start
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> startup
2、停止
[root@hellodba ~]# su - oracle
[oracle@hellodba ~]$ lsnrctl stop
[oracle@hellodba ~]$ sqlplus / as sysdba
SQL> shutdown immediate;
六、总结
到此Red Hat Enterprise Linux 7.6 + Oracle 12CR2单机部署完毕,并进行了一些常规的设置。安装Oracle数据库需要有一定的专业知识和经验,在实际操作中,可能还会遇到其他问题和挑战,建议在进行安装之前详细阅读相关文档和指南,并确保有必要的技术支持和备份措施。希望通过本文对您搭建一套基于Red Hat Enterprise Linux 7.6 + Oracle 12CR2的数据库环境有一定帮助,祝顺利!
七、写在后面
由于本人有限的能力和知识储备,如有错误敬请批评指正!
到此Red Hat Enterprise Linux 7.6 + Oracle 12CR2单机部署完毕,并进行了一些常规的设置。安装Oracle数据库需要有一定的专业知识和经验,在实际操作中,可能还会遇到其他问题和挑战,建议在进行安装之前详细阅读相关文档和指南,并确保有必要的技术支持和备份措施。希望通过本文对您搭建一套基于Red Hat Enterprise Linux 7.6 + Oracle 12CR2的数据库环境有一定帮助,祝顺利!
由于本人有限的能力和知识储备,如有错误敬请批评指正!
公众号:Hello DBA