Oracle系列-02红帽rhel83安装oracle19c(19.7)数据库
vi /etc/hosts
dgedu 192.168.127.2
查看硬盘UUID,后续会用到
blkid
/dev/nvme0n1p1: UUID="b198e531-ad3d-4d45-9969-79a255ac653b" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="2ff71485-01"
/dev/nvme0n1p2: UUID="73f7760b-387b-498e-a4f5-ce1deeba48dc" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="2ff71485-02"
/dev/nvme0n1p3: UUID="b66546bc-0010-4cea-a74a-d23acf06164b" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="2ff71485-03"
#mount /dev/sr0 /mnt
echo "[EL8-1]" >> /etc/yum.repos.d/king.repo
echo "name =Linux-8-DVD1" >> /etc/yum.repos.d/king.repo
echo "baseurl=file:///mnt/AppStream" >> /etc/yum.repos.d/king.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/king.repo
echo "enabled=1" >> /etc/yum.repos.d/king.repo
echo "[EL8-2]" >> /etc/yum.repos.d/king.repo
echo "name =Linux-8-DVD2" >> /etc/yum.repos.d/king.repo
echo "baseurl=file:///mnt/BaseOS" >> /etc/yum.repos.d/king.repo
echo "gpgcheck=0" >> /etc/yum.repos.d/king.repo
echo "enabled=1" >> /etc/yum.repos.d/king.repo
cat /etc/yum.repos.d/king.repo
# From Public Yum or ULN
# New for OL8
dnf clean all
dnf makecache
dnf install -y net-tools
dnf install -y zip unzip
dnf install -y bc
dnf install -y autoconf
dnf install -y binutils
dnf install -y compat-libcap1
dnf install -y compat-libstdc++-33
dnf install -y elfutils-libelf
dnf install -y elfutils-libelf-devel
dnf install -y fontconfig-devel
dnf install -y glibc
dnf install -y glibc-devel
dnf install -y ksh
dnf install -y libaio
dnf install -y libaio-devel
dnf install -y libXrender
dnf install -y libXrender-devel
dnf install -y libX11
dnf install -y libXau
dnf install -y libXi
dnf install -y libXtst
dnf install -y libgcc
dnf install -y librdmacm-devel
dnf install -y libstdc++
dnf install -y libstdc++-devel
dnf install -y libxcb
dnf install -y make
dnf install -y libtool
dnf install -y net-tools
dnf install -y nfs-utils
dnf install -y targetcli
dnf install -y smartmontools
dnf install -y sysstat
dnf install -y unixODBC
dnf install -y libnsl2
dnf install -y libnsl2.i686
dnf install -y libnsl
dnf install -y libnsl.i686
dnf install -y *vnc*
------
错误:没有任何匹配: compat-libcap1
未找到匹配的参数: compat-libstdc++-33
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libcap1-1.10-7.el7.x86_64.rpm
[root@localhost backup]# rz
compat-libcap1-1.10-7.el7.x86_64.rpm
compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
[root@localhost backup]#rpv -vih *.rpm
--
vi /etc/security/limits.conf
#ORACLE SETTING
grid soft nproc 16384
grid hard nproc 16384
grid soft nofile 65536
grid hard nofile 65536
grid soft stack 32768
grid hard stack 32768
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft stack 32768
oracle hard stack 32768
oracle hard memlock 6000000
oracle soft memlock 6000000
echo "session required pam_limits.so" >> /etc/pam.d/login
cat /etc/pam.d/login
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 --system
查看透明页
cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never
cat /sys/kernel/mm/transparent_hugepage/enabled
[always] madvise never
--关闭透明页
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
chmod +x /etc/rc.d/rc.local
--关闭NUMA
yum install numactl -y
numactl --hardware
vi /etc/default/grub
numa=off
grub2-mkconfig -o /etc/grub2.cdg
numactl --show
numactl --hardware
--修改时区
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
hwclock
--设置内存的文件系统shm
systemctl set-default multi-user.target
vi /etc/fstab
none /dev/shm tmpfs defaults,size=6144m 0 0
mount -o remount /dev/shm
--设置防火墙和seLinux
echo "SELINUX=disabled" > /etc/selinux/config
echo "#SELINUXTYPE=targeted " >> /etc/selinux/config
setenforce 0
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
-----------
/usr/sbin/groupadd -g 60001 oinstall
/usr/sbin/groupadd -g 60002 dba
/usr/sbin/groupadd -g 60003 oper
/usr/sbin/useradd -u 61001 -g oinstall -G dba,oper oracle
echo "oracle" | passwd --stdin grid
echo "oracle" | passwd --stdin oracle
mkdir -p /oracle/app/oraInventory
mkdir -p /oracle/app/oracle/product/19c/db_1
chown -R oracle:oinstall /oracle
chown -R oracle:oinstall /oradata
chown -R oracle:dba /backup
chown -R oracle:dba /archive
chmod -R 775 /oracle
chmod -R 775 /oradata
chmod -R 775 /archive
chmod -R 775 /backup
su - oracle
vi ~/.bash_profile
PS1="[`whoami`@`hostname`:"'$PWD]$'
export PS1
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export ORACLE_UNQNAME=kingdb
ORACLE_BASE=/oracle/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/19c/db_1; export ORACLE_HOME
ORACLE_SID=kingdb; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANG
PATH=.:$PATH:$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
----
上传Oracle安装包
cd /oracle/app/oracle/product/19c/db_1
unzip -q /backup/LINUX.X64_193000_db_home.zip
cd /backup
unzip -q p30899722_190000_Linux-x86-64.zip
unzip -o /backup/p6880880_190000_Linux-x86-64.zip -d /oracle/app/oracle/product/19c/db_1
--安装配置vnc--注意8.3以后的VNC配置与之前版本相差巨大
-创建文件
vim /etc/tigervnc/vncserver.users
:1=root
:2=oracle
-修改vncserver-config-defaults , 如果添加一行localhost ,外部不能访问
vim /etc/tigervnc/vncserver-config-defaults
session=gnome
securitytypes=vncauth,tlsvnc
desktop=sandbox
geometry=2000x1200
alwaysshared
-修改vncserver-config-mandatory ,如果添加一行localhost ,外部不能访问
vim /etc/tigervnc/vncserver-config-mandatory
securitytypes=vncauth,tlsvnc
desktop=sandbox
geometry=2000x1200
alwaysshared
-创建config 文件
vim $HOME/.vnc/config
session=gnome
geometry=1000x1200
-创建vncserver.users
vim /etc/tigervnc/vncserver.users
:1=root
:2=oracle
-复制vncserver@x.service 文件
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
-设置vnc 密码
如果你想用oracle用户让外部连接,就用oracle用户执行,执行后会在$HOME/.vnc/ 下生成passwd 文件
vncpasswd
-启动vnc
其中的2 指的是/etc/tigervnc/vncserver.users 中对应的用户, 2就是oracle
systemctl daemon-reload
systemctl stop vncserver@:2
systemctl start vncserver@:2
systemctl status vncserver@:2
-check
如果vncserver-config-defaults 和vncserver-config-mandator 配置了localhost,下边红框中将显示为127.0.0.1:5903 ,导致外部不能访问
netstat -tnlp
--安装数据库软件
cd /oracle/app/oracle/product/19c/db_1
export CV_ASSUME_DISTID=RHEL7.6
./runInstaller -applyRU /backup/30899722/
cd /oracle/app/oracle/product/19c/db_1
--建监听
netca
--建库--创建PDB
dbca
--执行补丁
cd $ORACLE_HOME/OPatch
./datapatch -verbose
-------
select * from dba_registry_history;
--打开所有PDB数据库(使用触发器)
CREATE TRIGGER open_all_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'alter pluggable database all open';
END open_all_pdbs;
/
--日志查看与检查
select * from v$diag_info;
--单独打开和关闭数据库
show pdbs;
alter pluggable database dgedupdb close;
alter pluggable database dgedupdb open;
--切换pdb数据库
alter session set container=kingpdb;
--查看当前进入的数据库
show con_name;
--创建表空间
create tablespace king datafile '/oradata/kingDB/kingpdb/king01.dbf' size 20m;
create user king identified by king123 default tablespace king;
grant dba to king;
select name from v$datafile;
kingpdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgedu)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = kingpdb)
)
)
dgedupdb =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dgedu)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = dgedupdb)
)
)
tnsping kingpdb
tnsping dgedupdb
--180天密码过期问题
select * from dba_profiles where profile='DEFAULT' and resource_name='PASSWORD_LIFE_TIME';
alter profile default limit password_life_time unlimited;
--关闭审计
show parameter audit
alter system set audit_trail=none scope=spfile;
--相关参数更改
sga_max_size
sga_target
memory_max_target
memory_target
db_files
processes
open_cursors
alter system set processes=2000 scope=spfile;
alter system set open_cursors=2000 scope=spfile;
--EM管理器使用
select DBMS_XDB.gethttpport FROM dual;
select DBMS_XDB_CONFIG.gethttpsport FROM dual;
EXEC DBMS_XDM_CONFIG.sethttpsport(5500);
https://ip:port/em/
--归档与闪回配置
alter system set db_recovery_file_dest_size=10G;
alter system set db_recovery_file='/archive';
alter system switch logfile;
shutdown immediate;
startup mount
alter database archivelog;
--闪回配置
alter database falshback on;
shutdown immediate;
startup
archive log list;
alter system switch logfile;