#!/bin/bash
hostnamectl set-hostname xxx-uat-db && bash
groupadd oinstall
groupadd dba
useradd oracle -g oinstall -G dba
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
iptables -F
iptables -L
mkdir -p /data/oracle/product/19.3.0
chown -R oracle:oinstall /data/oracle
yum install -y binutils*
yum install -y compat-libcap*
yum install -y compat-libstdc++*
yum install -y gcc-4.8*
yum install -y gcc-c++*
yum install -y glibc*
yum install -y ksh
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y libXi*
yum install -y libXtst*
yum install -y make*
yum install -y sysstat*
yum install -y xorg-x11-xauth install bc binutils compat-libcap1 compat-libstdc+±33 elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libXrender libXrender-devel libX11 libXau libXi libXtst libgcc libstdc++ libstdc+±devel libxcb make policycoreutils policycoreutils-python smartmontools sysstat
cat >> /home/oracle/.bash_profile <<EOF
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=/data/oracle/product/19.3.0
export PATH=$PATH:$ORACLE_HOME/bin:/usr/local/bin
export ORACLE_HOSTNAME=xx-prod-db
export ORACLE_SID=wind
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/rdbms/lib:$ORACLE_HOME/network/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
EOF
cat >> /etc/security/limits.conf <<EOF
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
cat >> /etc/pam.d/login <<EOF
session required pam_limits.so
EOF
cat >> /etc/sysctl.conf <<EOF
fs.file-max = 6815744
kernel.sem = 250 32000 100 128
kernel.shmmni = 4096
kernel.shmall = 1073741824
kernel.shmmax = 4398046511104
kernel.panic_on_oops = 1
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
net.ipv4.ip_local_port_range = 9000 65500
EOF
cd /data/software
unzip LINUX.X64_193000_db_home.zip -d /data/oracle/product/19.3.0
chown oracle:oinstall /data/oracle -R
DISPLAY=xxxx:0.0; export DISPLAY
cd /data/oracle/product/19.3.0