Euler 21.10安装oracle 19.22单机安装
1.虚拟机安装
服务器的名称和hosts文件名称要一样
hostnamectl set-hostname hfdb95 && bash
查看系统版本:
uname -a cat /etc/redhat-release
2.IP地址配置
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=enp0s3
UUID=17494451-7a44-426b-ad78-63089e920b2f
DEVICE=enp0s3
ONBOOT=yes
IPADDR=192.168.40.31
PREFIX=24
GATEWAY=192.168.40.1
IPV6_PRIVACY=no
重启systemctl restart network
3.磁盘分区配置
fdisk -lfdisk /dev/sdb (n\p\1\回车\回车\w)mkfs.xfs /dev/sdb1mkdir /oracle mount /dev/sdb1 /oraclevi /etc/fstab 加入 /dev/sdb1 /oracle xfs defaults 0 0
mkdir /oradatamkdir /backupmkdir /archive
4.环境变量配置
host文件配置
cat >> /etc/hosts << EOF
192.168.40.95 hfdb95
EOF
cat /etc/hosts
cat >> ~/.bash_profile << EOF
export LANG=en_US.UTF8
EOF
cat ~/.bash_profilesource ~/.bash_profile
创建用户、组、目录
/usr/sbin/groupadd -g 60001 oinstall
/usr/sbin/groupadd -g 60002 dba
/usr/sbin/groupadd -g 60003 oper
useradd -u 61001 -g oinstall -G dba,oper oracle
mkdir -p /oracle
mkdir -p /oracle/app/oracle/product/19c/db_1
mkdir -p /oracle/app/oraInventory
chown -R oracle:oinstall /oracle
chown -R oracle:oinstall /oradata
chown -R oracle:oinstall /backup
chown -R oracle:oinstall /archive
chmod -R 775 /oracle
chmod -R 775 /oradata
chmod -R 775 /backup
chmod -R 775 /archive
echo "oracle" | passwd --stdin oracle
配置yum源
mount /dev/cdrom /mnt
cd /etc/yum.repos.d
mkdir bk
mv *.repo bk/
echo "[EL]" >> /etc/yum.repos.d/itpux.repo
echo "name =Linux 7.x DVD" >> /etc/yum.repos.d/itpux.repo
echo "baseurl=file:///mnt" >> /etc/yum.repos.d/itpux.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/itpux.repo
echo "enabled=1" >> /etc/yum.repos.d/itpux.repo
cat /etc/yum.repos.d/itpux.repo
安装相关软件
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 ftp
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 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 -y
yum -y install sysstat -y
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 unzip
yum -y install *vnc*
--下面这个提示没有安装包,后面缺少什么环境就补什么
yum -y install libnsl2
yum -y install libnsl2.i686
yum -y install libnsl
yum -y install libnsl.i686
修改资源限制参数
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 8000000
oracle soft memlock 8000000
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 4000000 --锁定内存大小(memlock单位KB,略低于物理内存)oracle soft memlock 4000000
控制给用户分配的资源
vi /etc/security/limits.d/20-nproc.conf将注释掉#* soft nproc 4096 #root soft nproc unlimited追加:* soft nproc 16384
修改内核参数
vi /etc/sysctl.conf
#ORACLE SETTING
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
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 = 5033164800
kernel.shmall = 1228800
kernel.shmmni = 4096
vm.nr_hugepages = 2500
sysctl -p #生效
闭透明页,开大内存页面要关闭
cat /sys/kernel/mm/transparent_hugepage/defrag[always] madvise nevercat /sys/kernel/mm/transparent_hugepage/enabled[always] madvise never这个状态说明是启用的
cat >> /etc/rc.d/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
禁用NUMA
sed -ie 's/rhgb quiet/rhgb quiet numa=off/g' /etc/default/grub
cat /etc/default/grub然后执行:
grub2-mkconfig -o /etc/grub2.cfg
用这个命令执行看下是不是一个cpu可以识别到所有的内存numactl --show
修改时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtimehwclock
配置安全
echo "SELINUX=disabled" > /etc/selinux/config
echo "#SELINUXTYPE=targeted " >> /etc/selinux/config
cat /etc/selinux/config
重启生效setenforce 0
设置内存的文件系统shm
(一半的物理内存给oracle用,一定要改 128G内存改到100G)#/dev/shm共享内存不足的处理解决方法:例如:为了将/dev/shm的大小增加到1GB,修改/etc/fstab的这行:默认的:none /dev/shm tmpfs defaults 0 0 改成:
none /dev/shm tmpfs defaults,size=4096m 0 0
size参数也可以用G作单位:size=2G。重新mount/dev/shm使之生效:
#mount -o remount /dev/shm
关闭防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
到这里可以重启下系统,检查下系统是否可以启动,为了后期的操作,停机后可以给虚拟机打个快照,也可以备份一份虚拟机系统。
配置Oracle环境变量
su - oracle
vi ~/.bash_profile
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
export LANG=en_US.UTF8
export TMPDIR=$TMP
export ORACLE_UNQNAME=hfdb95
ORACLE_SID=hfdb40; export ORACLE_SID
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/19c/db_1; export ORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
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
5.文件上传和数据库安装
安装数据库软件
[oracle@hfdb40:/home/oracle]$cd /oracle/app/oracle/product/19c/db_1/
[oracle@hfdb40:/oracle/app/oracle/product/19c/db_1]$unzip /backup/LINUX.X64_193000_db_home.zip
安装vnc(yum install vnc),登录安装oracle软件 --oracle用户登录,启动vncserver
使用 vnc 打开是黑屏,没有办法,只能使用 x display 安装。
启动 xhost + , DISPLAY=192.168.40.3:0.0 这个 IP 地址需要根据你环境修改
[oracle@hfdb95:/home/oracle]$export DISPLAY=192.168.40.3:0.0
[oracle@hfdb95:/home/oracle]$xhost +
[oracle@hfdb95:/oracle/app/oracle/product/19c/db_1]$./runInstaller
ERROR: Unable to verify the graphical display setup. This application requires X display. Make sure that xdpyinfo exist under PATH variable.
/oracle/app/oracle/product/19c/db_1/perl/bin/perl: error while loading shared libraries: libnsl.so.1: cannot open shared object file: No such file or directory
[root@hfdb96 yum.repos.d]# yum -y install xdpyinfo
[root@hfdb95 backup]# ldd /oracle/app/oracle/product/19c/db_1/perl/bin/perl
linux-vdso.so.1 (0x00007ffff290a000)
libpthread.so.0 => /usr/lib64/libpthread.so.0 (0x00007f3b01e10000)
libnsl.so.1 => not found
libdl.so.2 => /usr/lib64/libdl.so.2 (0x00007f3b01e0b000)
libm.so.6 => /usr/lib64/libm.so.6 (0x00007f3b01c88000)
libcrypt.so.1 => /usr/lib64/libcrypt.so.1 (0x00007f3b01c4d000)
libutil.so.1 => /usr/lib64/libutil.so.1 (0x00007f3b01c48000)
libc.so.6 => /usr/lib64/libc.so.6 (0x00007f3b01a8e000)
libgcc_s.so.1 => /usr/lib64/libgcc_s.so.1 (0x00007f3b01a75000)
/lib64/ld-linux-x86-64.so.2 (0x00007f3b01e4d000)
[root@hfdb95 backup]# ls -rtl /usr/lib64/libnsl*
-rwxr-xr-x. 1 root root 96368 6月 24 2021 /usr/lib64/libnsl.so.2.0.1
lrwxrwxrwx. 1 root root 15 6月 24 2021 /usr/lib64/libnsl.so.2 -> libnsl.so.2.0.1
[root@hfdb95 backup]# cd /usr/lib64/
[root@hfdb95 lib64]# cp /backup/libnsl-2.17.so .
[root@hfdb95 lib64]# ln -s libnsl-2.17.so /usr/lib64/libnsl.so.1
[root@hfdb95 lib64]# ls -rtl /usr/lib64/libnsl*
-rwxr-xr-x. 1 root root 96368 6月 24 2021 /usr/lib64/libnsl.so.2.0.1
lrwxrwxrwx. 1 root root 15 6月 24 2021 /usr/lib64/libnsl.so.2 -> libnsl.so.2.0.1
-rw-r--r-- 1 root root 113152 1月 9 16:58 /usr/lib64/libnsl-2.17.so
lrwxrwxrwx 1 root root 14 1月 9 16:58 /usr/lib64/libnsl.so.1 -> libnsl-2.17.so
更新 OPatch 工具
[oracle@hfdb95:/oracle/app/oracle/product/19c/db_1]$mv OPatch/ OPatch.bak
[oracle@hfdb95:/oracle/app/oracle/product/19c/db_1]$unzip -q /backup/p6880880_190000_Linux-x86-64.zip
解压补丁
[root@hfdb95 backup]# unzip -q p35943157_190000_Linux-x86-64.zip
[root@hfdb95 backup]# chown -R oracle:oinstall /backup/
打补丁和数据库软件安装
[oracle@hfdb95 ~]$ cd $ORACLE_HOME
[oracle@hfdb95:/oracle/app/oracle/product/19c/db_1]$./runInstaller -applyRU /backup/35943157
--补丁应用的 log 日志目录:/oracle/app/oracle/product/19c/db_1/cfgtoollogs/opatchauto
[oracle@hfdb95:/oracle/app/oracle/product/19c/db_1]$./runInstaller -applyRU /backup/35943157
ERROR: The home is not clean. This home cannot be used since there was a failed OPatch execution in this home. Use a different home to proceed.
解决:
[oracle@hfdb95:/oracle/app/oracle/product/19c/db_1/install]$mv patch patch.bak
数据库安装
该问题显示无法识别该系统的id,在oracle安装包解压后产生文件。
vi $ORACLE_HOME/cv/admin/cvu_config中添加以下语句并保存
[root@hfdb95 opatchauto]# su - oracle
上一次登录: 四 1月 9 16:54:18 CST 2025 pts/1 上
[oracle@hfdb95:/home/oracle]$vi $ORACLE_HOME/cv/admin/cvu_config
添加:
CV_ASSUME_DISTID=bclinux 21.10
后面都是选择默认即可,到验证这步骤
使用root用户执行安装。
使用root用户依次执行这两条sql。
数据库软件安装完成了,基本上数据库安装都没有问题了。
安装中主要出现最多的问题,可能就是目录权限的问题。所以前期的步骤要认真执行,用root用户执行。
配置监听
[oracle@hfdb40 db_1]$netca
查看监听状态:lsnrctl status
启动监听:lsnrctl start
安装数据库
[oracle@hfdb40 db_1] dbca
设置你的数据库全局名,默认是orcl,最好修改掉。
设置数据文件的目录位置。
数据库的块大小,默认是8K就可以。
字符类型需要问业务或者研发那边,一般是16GBK。
设置sys的密码,最好要记下,不记得也没有关系,后期可以登录到数据库服务器上面,再修改。
安装业务需求进行修改,也可以安装完成后再配置,问题都不大。
后期维护
login.sql --【定义提示符】
glogin.sql 脚本 vi $ORACLE_HOME/sqlplus/admin/glogin.sql
SET TERMOUT OFF
DEFINE sqlprompt=HFSQL
COLUMN sqlprompt NEW_VALUE sqlprompt
SELECT USER || '@' || NVL('&_CONNECT_IDENTIFIER', global_name )
sqlprompt
FROM global_name;
SET SQLPROMPT '&sqlprompt> '
UNDEFINE sqlprompt
SET TERMOUT ON
col NAME format a40
col VALUE format a60
col VALUE format 99999999999
set linesize 200
set pagesize 500
column plan_plus_exp format a80
set serveroutput on size 1000000
define_editor=vi
使用rlwrap工具实现sqlplus便捷操作
mount /dev/cdrom /mnt
yum install -y readline*
[root@hfdb40 oracle]# tar zxvf rlwrap-0.42.tar.gz
tar zxvf rlwrap-0.45.2.tar.gz
[root@hfdb40 rlwrap-0.42]# ./configure
./configure
make
make install
.bash_profile/.profile
vi ~/.bash_profile
alias sqlplus="rlwrap sqlplus"
alias rman="rlwrap rman"
alias log='tail -200f /oracle/app/oracle/diag/rdbms/hfdb/hfdb/trace/alert_hfdb.log'
oracle 19c的启动与停止
Isnrctl stop
sqlplus"/as sysdba"
shutdown immediate;
exit
reboot
su-oracle
sqlplus"/as sysdba"
startup;
exit
Isnrctl start
相关参数
sga_max_size
sga_target
db_files
Processes
open_cursors
alter system set db files=8192 scope=spfile;
alter system set processes=2000 scope=spfile;
alter system set open_cursors=2000 scope=spfile;
oracle 19cEM管理器使用
SELECT DBMS_XDB.gethttpport FROM dual;
SELECT DBMS_XDB_CONFIG.gethttpsport FROM dual;
EXEC DBMS_XDB_CONFIG.sethttpsport(5500);
https://<hostname>:<port>/em/
oracle 19c数据库归档与闪回设置
--配归档
alter system set db_recovery_file_dest_size=100g;
alter system set db_recovery_file_dest='/archive';
shutdown immediate;
startup mount
alter database archivelog;
--启动闪回#alter database flashback ON;
shutdown immediate;
startup
archive log list;
alter system switch logfile;