Thursday, December 3, 2020

Preparing Linux to install Oracle Products

# ---------------------------------------------------------------------
# Setup the ROOT Environment
# ---------------------------------------------------------------------
#

cat > /root/.bash_profile <<EOF
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
      . ~/.bashrc
fi

# User specific environment and startup programs
export PS1=\$'[ \${LOGNAME}@\h:\`pwd\`: ]\$ '
export GRID_VERSION=19.3.0.1
export ORACLE_BASE=/u01/app/grid
export GRID_HOME=/u01/app/\${GRID_VERSION}/grid
export ORACLE_HOME=\${GRID_HOME}
export OPATCH=\${ORACLE_HOME}/OPatch
export JAVA_HOME=\${ORACLE_HOME}/jdk
export PATH=\${PATH}:\${HOME}/bin:\${GRID_HOME}/bin:\${OPATCH}:\${JAVA_HOME}/bin
EOF

. .bash_profile

# ---------------------------------------------------------------------
# OEL 7 and 8
# ---------------------------------------------------------------------
hostnamectl set hostname srv01.dbnitro.net --stats

# ---------------------------------------------------------------------
# OR
# ---------------------------------------------------------------------

vim /etc/hosts

# OR

echo "192.168.56.10   srv01.dbnitro.net   srv01"  >> /etc/hosts

# ---------------------------------------------------------------------
# OEL 7 and 8
# ---------------------------------------------------------------------systemctl stop firewalld
systemctl disable firewalld

# ---------------------------------------------------------------------
# yum -y install chrony
# ---------------------------------------------------------------------
systemctl enable chronyd.service
systemctl status chronyd.service
systemctl start chronyd.service
systemctl restart chronyd.service
systemctl status chronyd.service

# ---------------------------------------------------------------------
# Install EPEL for OL7
# ---------------------------------------------------------------------
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# ---------------------------------------------------------------------
# Install EPEL for OL8
# ---------------------------------------------------------------------
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm

# ---------------------------------------------------------------------# JAVA
# ---------------------------------------------------------------------
yum -y install java-1.8.0-openjdk-devel.x86_64 java-1.8.0-openjdk.x86_64

# ---------------------------------------------------------------------
dnf -y install java-1.8.0-openjdk-devel.x86_64 java-1.8.0-openjdk.x86_64

# ---------------------------------------------------------------------
# Update the Linux and Kernel
# ---------------------------------------------------------------------
yum -y upgrade

# ---------------------------------------------------------------------
# OEL 7 ---> https://yum.oracle.com/repo/OracleLinux/OL7/baseos/latest/x86_64/index.html

# ---------------------------------------------------------------------
# Verify Installed Packages
# ---------------------------------------------------------------------
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' atop bc.x86_64 beakerlib-vim-syntax binutils bind-utils bzip2-devel.x86_64 bzip2-libs.x86_64 bzip2.x86_64 chrony cpp compat-libstdc++-33 compat-libcap1 dialog elinks elfutils-libelf elfutils-libelf-devel epel-release.noarch firefox gcc gcc-c++ glances glibc glibc-common glibc-devel glibc-headers htop iotop iptraf-ng iscsi-initiator-utils iscsi-initiator-utils-iscsiuio lsscsi libiscsi netbsd-iscsi targetcli ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libiscsi libXtst libXtst-devel lm_sensors lsof make mlocate nawk.x86_64 net-tools ntp nfs-utils nmap perl perl-DBI perl-TermReadKey perl-ExtUtils-MakeMaker perl-CPAN perl-CGI perl-URI.noarch psmisc readline-devel rlwrap smartmontools sos cockpit sysstat telnet tuned tuned-utils unixODBC unixODBC-devel unzip vim-X11 vim-common vim-enhanced vim-filesystem vim-minimal wget xorg-x11-server-Xorg xorg-x11-server-common xorg-x11-utils xorg-x11-apps xorg-x11-xauth xterm.x86_64 whois | egrep "is not installed"
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' kmod-oracleasm.x86_64      --->   NOT NECESSARY FOR AFD/ACFS
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracleasm-support.x86_64   --->   NOT NECESSARY FOR AFD/ACFS
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracleasmlib.x86_64        --->   NOT NECESSARY FOR AFD/ACFS
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' ocfs2-tools.x86_64
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracle-rdbms-server-11gR2-preinstall.x86_64
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracle-rdbms-server-12cR1-preinstall.x86_64
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracle-database-server-12cR2-preinstall.x86_64
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracle-database-preinstall-18c.x86_64
rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' oracle-database-preinstall-19c.x86_64

# ---------------------------------------------------------------------
# Install Packages
# ---------------------------------------------------------------------
yum -y install atop bc.x86_64 beakerlib-vim-syntax binutils bind-utils bzip2-devel.x86_64 bzip2-libs.x86_64 bzip2.x86_64 chrony cpp compat-libstdc++-33 compat-libcap1 dialog elinks elfutils-libelf elfutils-libelf-devel epel-release.noarch firefox gcc gcc-c++ glances glibc glibc-common glibc-devel glibc-headers htop iotop iptraf-ng iscsi-initiator-utils iscsi-initiator-utils-iscsiuio lsscsi libiscsi netbsd-iscsi targetcli ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libiscsi libXtst libXtst-devel lm_sensors lsof make mlocate nawk.x86_64 net-tools ntp nfs-utils nmap perl perl-DBI perl-TermReadKey perl-ExtUtils-MakeMaker perl-CPAN perl-CGI perl-URI.noarch psmisc readline-devel rlwrap smartmontools sos cockpit sysstat telnet tuned tuned-utils unixODBC unixODBC-devel unzip vim-X11 vim-common vim-enhanced vim-filesystem vim-minimal wget xorg-x11-server-Xorg xorg-x11-server-common xorg-x11-utils xorg-x11-apps xorg-x11-xauth xterm.x86_64 whois
yum -y install kmod-oracleasm.x86_64      --->   NOT NECESSARY FOR AFD/ACFS
yum -y install oracleasm-support.x86_64   --->   NOT NECESSARY FOR AFD/ACFS
yum -y install oracleasmlib.x86_64        --->   NOT NECESSARY FOR AFD/ACFS
yum -y install ocfs2-tools.x86_64
yum -y install oracle-rdbms-server-11gR2-preinstall.x86_64
yum -y install oracle-rdbms-server-12cR1-preinstall.x86_64
yum -y install oracle-database-server-12cR2-preinstall.x86_64
yum -y install oracle-database-preinstall-18c.x86_64
yum -y install oracle-database-preinstall-19c.x86_64


# ------------------------------------------------------------------------
# Set parameters on /etc/hosts on Single Instance
# ------------------------------------------------------------------------
#
echo "#"                                                                                                                     >> /etc/hosts
echo "`ifconfig -a | grep inet | awk '{ print $2 }' | head -2 | grep -v 127.0.0.1 | head -1`   `hostname`   `hostname -s`"   >> /etc/hosts

# ------------------------------------------------------------------------
# Disable SELINUX
# ------------------------------------------------------------------------
#

cat > /etc/sysconfig/selinux <<EOF
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted
EOF

# ------------------------------------------------------------------------
# Configure limits.conf
# ------------------------------------------------------------------------
#

cat >> /etc/security/limits.conf <<EOF
#
# Oracle Limits Configuration
#
* soft nproc 2047
* hard nproc 16384
* soft nofile 65536
* hard nofile 65536
* soft stack 10240
* hard stack 32768
* soft memlock 60397977
* hard memlock 60397977
EOF

# ------------------------------------------------------------------------
# Create the Groups and Users
# ------------------------------------------------------------------------
# ODA Environment
#

----------------------------------------------------------------------------------------------------------------------
Groups      Group Name      Group ID   Grid is a member           Oracle is a member       Agent is a member
----------- --------------- ---------- -----------------------    ---------------------    -----------------------
oinstall    oinstall        54321      yes (primary group)        yes (primary group)      yes (primary group)
osdba       dba             54322      yes                        yes                      yes
osdba       oper            54323      no                         yes                      yes
osbkpdba    backupdba       54324      no                         yes                      yes
osdba       asmdba          54325      yes                        yes                      yes
osdgdba     dgdba           54326      no                         yes                      yes
osdba       kmdba           54327      no                         yes                      yes
osasm       asmadmin        54328      yes                        no                       no
osoper      asmoper         54329      yes                        no                       yes
osracdba    racdba          54330      yes                        yes                      no
osoper      racoper         54331      yes                        yes                      yes

--------------------------------------------------------------------------------------------------------------------

# ------------------------------------------------------------------------
# Groups ( yum -y install system-config-users )
# ------------------------------------------------------------------------
#
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54324 backupdba
/usr/sbin/groupadd -g 54325 asmdba
/usr/sbin/groupadd -g 54326 dgdba
/usr/sbin/groupadd -g 54327 kmdba
/usr/sbin/groupadd -g 54328 asmadmin
/usr/sbin/groupadd -g 54329 asmoper
/usr/sbin/groupadd -g 54330 racdba
/usr/sbin/groupadd -g 54331 racoper

/usr/sbin/useradd -u 54321 -g oinstall -G dba,oper,backupdba,asmdba,dgdba,kmdba,racdba,racoper oracle
/usr/sbin/useradd -u 54322 -g oinstall -G dba,asmdba,asmadmin,asmoper,racdba,racoper grid

# ------------------------------------------------------------------------
# Create Users Password
# ------------------------------------------------------------------------
# Password
#

passwd grid
passwd oracle

# OR

echo 'oracle:oracle' | chpasswd
echo 'grid:grid' | chpasswd

# ------------------------------------------------------------------------
# Install the Pre-Install Package for Databases
yum -y install oracle-database-preinstall-19c.x86_64


# ------------------------------------------------------------------------
# Validate the Kernel Parameters
sysctl -p

# ------------------------------------------------------------------------
# Creating Directories to Grid and Database Installation
# ------------------------------------------------------------------------
# General Folders
# ------------------------------------------------------------------------

mkdir -p /u01/app/oraInventory
#
mkdir -p /u01/app/grid
mkdir -p /u01/app/grid/diag
#
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/diag
#
chown -R grid.oinstall /u01
chown -R grid.oinstall /u01/app/grid
chown -R grid.oinstall /u01/app/grid/diag
#
chown -R oracle.oinstall /u01/app/oracle
chown -R oracle.oinstall /u01/app/oracle/diag
#
chmod -R 775 /u01/

 ------------------------------------------------------------------------
# Mount tmpfs automatically on Linux
# ------------------------------------------------------------------------
# Create the folders to Grid and Database
# Change the permission to GRID (verify if is necessary re-run this part of the script after Grid installation)
# ------------------------------------------------------------------------
# Grid (Verify this configuration before the Grid Installation)
# ------------------------------------------------------------------------
# Used to Manage Auto Memory

# mount -t tmpfs shmfs -o size=16g /dev/shm

#

echo "shmfs                                     /dev/shm                tmpfs   size=16g        0 0" >> /etc/fstab

#

mount -a


No comments:

Post a Comment