Automate Oracle RAC Setup Prerequisites with This Script
This script automates all the necessary prerequisite steps for setting up Oracle RAC, saving you time and reducing the chance of manual errors.
Script involve all manual steps as prerequisite steps to reduce time described as follows:
- Disable Transparent HugePages: Disables Transparent HugePages by modifying the system settings and the GRUB configuration.
- Configure HugePages: Automatically calculates and configures the number of HugePages based on available system memory.
- Set Kernel Parameters: Configures the required kernel parameters for Oracle RAC by appending them to
/etc/sysctl.confand applying them withsysctl -p. - Set Shell Limits: Modifies the
/etc/security/limits.conffile to set the necessary shell limits for theoracleuser. - Disable Firewall and SELinux: Disables both the firewall and SELinux to allow communication between RAC nodes.
- Configure Hostname and DNS: Sets the hostname and updates the
/etc/hostsfile with the cluster node IPs. - Set Up SSH Passwordless Access: Sets up SSH passwordless authentication by generating an SSH key and copying it to the other nodes.
- Install Required Packages: Installs the necessary packages using the
oracle-rdbms-server-19c-preinstallpackage. - Configure Time Synchronization: Installs and configures
chronyfor time synchronization across the RAC nodes. - Create Oracle User and Groups: Creates the required Oracle user and groups.
- Configure ASMlib: Optionally configures ASMlib for Automatic Storage Management if needed.
Following is the script involve all prerequisite need to done before installing Oracle database on system:
Note: Save this file as rac_prereq.sh
#!/bin/bash
# Script to configure Oracle RAC prerequisites on Linux
echo "Starting Oracle RAC prerequisite configuration..."
# 1. Disable Transparent HugePages
echo "Disabling Transparent HugePages..."
echo "never" > /sys/kernel/mm/transparent_hugepage/enabled
echo "never" > /sys/kernel/mm/transparent_hugepage/defrag
# Disable Transparent HugePages permanently
if grep -q "transparent_hugepage" /etc/default/grub; then
echo "Transparent HugePages already disabled in GRUB"
else
echo "Adding Transparent HugePages to GRUB config..."
sed -i 's/GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="transparent_hugepage=never /' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
fi
# 2. Configure HugePages
echo "Configuring HugePages..."
HUGEPAGES=`awk '/Hugepagesize:/{print $2}' /proc/meminfo`
TOTAL_MEMORY=`free -m | awk '/Mem:/{print $2}'`
# Set the number of HugePages to be 75% of total memory
NUM_HUGEPAGES=$((($TOTAL_MEMORY * 75 / 100) * 1024 / $HUGEPAGES))
echo "vm.nr_hugepages = $NUM_HUGEPAGES" >> /etc/sysctl.conf
sysctl -p
# 3. Set Kernel Parameters
echo "Setting Kernel Parameters..."
cat >> /etc/sysctl.conf <<EOF
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 8589934592
kernel.shmmni = 4096
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 = 1048576
EOF
sysctl -p
# 4. Set Shell Limits for Oracle User
echo "Setting Shell Limits for Oracle User..."
cat >> /etc/security/limits.conf <<EOF
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
oracle soft memlock 134217728
oracle hard memlock 134217728
EOF
echo "session required pam_limits.so" >> /etc/pam.d/login
# 5. Disable Firewall
echo "Disabling Firewall..."
systemctl stop firewalld
systemctl disable firewalld
# 6. Disable SELinux
echo "Disabling SELinux..."
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
setenforce 0
# 7. Set Hostname and DNS
echo "Setting Hostname and DNS..."
hostnamectl set-hostname rac1
cat >> /etc/hosts <<EOF
192.168.0.101 rac1
192.168.0.102 rac2
EOF
# 8. Set up SSH Passwordless Access
echo "Setting up SSH Passwordless Access..."
ssh-keygen -t rsa -N "" -f ~/.ssh/id_rsa
for NODE in rac2; do
ssh-copy-id $NODE
done
# 9. Install Required Packages
echo "Installing Required OS Packages..."
yum install -y oracle-rdbms-server-19c-preinstall
# 10. Configure Chrony for Time Synchronization
echo "Configuring Chrony for Time Synchronization..."
yum install -y chrony
systemctl start chronyd
systemctl enable chronyd
# 11. Create Oracle User and Groups
echo "Creating Oracle User and Groups..."
groupadd oinstall
groupadd dba
groupadd asmadmin
useradd -g oinstall -G dba,asmadmin oracle
echo "oracle:oracle_password" | chpasswd
# 12. Configure ASMlib (Optional)
echo "Configuring ASMlib..."
yum install -y oracleasm-support oracleasmlib oracleasm
oracleasm configure -i
oracleasm init
echo "Oracle RAC prerequisite configuration complete."
Steps to Use the Script:
- Copy the Script to Your Linux System: Save the script to a file, e.g.,
rac_prereq.sh. - Make the Script Executable:
chmod +x rac_prereq.sh
Run the Script as Root or with Sudo:
sudo ./rac_prereq.sh
Reboot the System: Some changes (like Transparent HugePages and SELinux) require a reboot to take effect.
reboot