oracle 常用安裝腳本以及步驟


oracle 常用腳本以及語句

一.19c單機安裝:

#!/bin/bash

##需要7.0+ 版本的Linux
chown -R oracle:oinstall /oracle
echo 'oracle' | passwd oracle --stdin

#關閉selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
systemctl stop firewalld
systemctl disable firewalld

#禁用avahi-daemon
systemctl stop avahi-daemon
systemctl disable avahi-daemon
systemctl status avahi-daemon

#關閉 NetworkManager

systemctl stop NetworkManager
systemctl disable NetworkManager


#設置RemoveIPC=false
echo "RemoveIPC=no" >> /etc/systemd/logind.conf


#配置/etc/hosts文件 添加
cat >> /etc/hosts<<EOF

192.168.10.30 19c

EOF

#增大共享內存
#mount -t tmpfs shmfs -o size=7g /dev/shm
#echo 'shmfs /dev/shm tmpfs size=24g' >> /etc/fstab


#添加組
groupadd -g 1200 oinstall
groupadd -g 1201 dba
groupadd -g 1202 oper
groupadd -g 1203 backupdba
groupadd -g 1204 dgdba
groupadd -g 1205 kmdba


#添加用戶

useradd -m -d /home/oracle -u 1101 -g oinstall -G dba,oper,backupdba,dgdba,kmdba oracle
echo 'oracle' | passwd --stdin oracle


#創建安裝目錄

mkdir -p /u01/app/oracle/product/19c/dbhome_1
mkdir -p /u01/app/oraInventory

#更改目錄權限
chown -R oracle:oinstall /u01/app/oracle
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 775 /u01

#改變內核參數
cat >> /etc/sysctl.conf<<EOF

#Kernel for Oracle 19c

fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 4294967295
kernel.shmall = 16097152
kernel.shmmax = 128849018880
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

#添加用戶資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
oracle hard stack 32768
oracle  hard  memlock  3145728
oracle  soft  memlock  3145728

 

#編輯配置文件
cat >> /etc/profile<<EOF

#this is for oracle user
if [ \$USER = "oracle" ]; then
if [ \$SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
EOF


#編輯登陸配置文件
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF


#為oracle用戶添加環境變量
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=19c
export ORACLE_HOME=/u01/app/oracle/product/19c/dbhome_1
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
EOF
source /home/oracle/.bash_profile

#關閉ntpd服務
/sbin/service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.org

systemctl stop chronyd
systemctl disable chrnyd

version=`cat /etc/redhat-release | cut -d ' ' -f 7 | cut -d . -f 1`

#配置yum倉庫
mount /dev/cdrom /mnt

rm -f /etc/yum.repos.d/*
if [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi


#安裝oracle所需要的包
yum clean all

yum install -y gcc bc binutils compat-libcap1 compat-libstdc++ elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libX11 libXau libXi libXtst libXrender libXrender-devel libgcc libstdc++ libstdc++-devel libxcb make net-tools nfs-utils python python-configshell python-rtslib python-six targetcli smartmontools sysstat

二、oracle 安裝10G 單機初始化環境:

#!/bin/bash

#關閉selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
service iptables stop
chkconfig iptables off


#配置/etc/hosts文件 添加
cat >> /etc/hosts<<EOF


172.16.0.191 rhel


EOF

#增大共享內存
mount -t tmpfs shmfs -o size=7g /dev/shm
echo 'shmfs /dev/shm tmpfs size=24g' >> /etc/fstab


#添加組
groupadd -g 1001 oinstall
groupadd -g 1002 dba


#添加用戶


useradd -u 1003 -g oinstall -G dba oracle
echo 'oracle' | passwd --stdin oracle


#創建安裝目錄

mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
mkdir -p /u01/app/oraInventory


#更改目錄權限

chown -R oracle:oinstall /u01/app/oraInventory/
chown -R oracle:oinstall /u01/app/oracle/
chmod -R 775 /u01

#改變內核參數
cat >> /etc/sysctl.conf<<EOF

#Kernel for Oracle 10g R2
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 1048576
net.core.rmem_max = 1048576
net.core.wmem_default = 262144
net.core.wmem_max = 262144

EOF

#使內核參數立即生效
sysctl -p

#添加用戶資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536

 


#編輯配置文件
cat >> /etc/profile<<EOF

#this is for oracle user
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
EOF


#編輯登陸配置文件
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF


#為oracle用戶添加環境變量
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
EOF
source /home/oracle/.bash_profile

#關閉ntpd服務

chkconfig ntpd off

service ntpd stop

mv /etc/ntp.conf /etc/ntp.conf.bak

version=`cat /etc/redhat-release | cut -d ' ' -f 7 | cut -d . -f 1`

#配置yum倉庫
mount /dev/cdrom /mnt

rm -f /etc/yum.repos.d/*
if [ $version=6 ] || [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi

if [ $version=5 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
EOF
fi

#安裝oracle所需要的包
yum clean all

 

case $version in
7)
echo "the linux version is 7"

yum -y install binutils compat-libcap1 compat-libstdc++ gcc- gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++- libstdc++-devel libXi libXtst make sysstat


;;
6)
echo "the linux version is 6"
yum -y install compat-libcap1-1.10-1 binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc libstdc++ make sysstat unixODBC unixODBC-devel
;;
5)
echo "the linux version is 5"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc libstdc++ make sysstat unixODBC unixODBC-devel
;;
4)
echo "the linux version is 4"
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio-devel libaio libgcc libstdc++ libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel esac

 

三、oracle 安裝11G單機初始化環境腳本:

 

#!/bin/bash

#關閉selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
service iptables stop
chkconfig iptables off


#配置/etc/hosts文件 添加
cat >> /etc/hosts<<EOF


172.16.0.191 rhel


EOF

#增大共享內存
mount -t tmpfs shmfs -o size=7g /dev/shm
echo 'shmfs /dev/shm tmpfs size=24g' >> /etc/fstab


#添加組
groupadd -g 1001 oinstall
groupadd -g 1002 asmdba
groupadd -g 1003 asmadmin
groupadd -g 1004 asmoper
groupadd -g 1005 dba
groupadd -g 1006 oper


#添加用戶


useradd -u 1002 -g oinstall -G dba,asmdba,oper oracle
echo 'oracle' | passwd --stdin oracle


#創建安裝目錄

mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1
mkdir -p /u01/app/oraInventory


#更改目錄權限

chown -R oracle:oinstall /u01/app/oraInventory/
chown -R oracle:oinstall /u01/app/oracle/
chmod -R 775 /u01

#改變內核參數
cat >> /etc/sysctl.conf<<EOF

#Kernel for Oracle 11g R2
fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 4294967295
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

#添加用戶資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

 

#編輯配置文件
cat >> /etc/profile<<EOF

#this is for oracle user
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
EOF


#編輯登陸配置文件
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF


#為oracle用戶添加環境變量
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
EOF
source /home/oracle/.bash_profile

#關閉ntpd服務

chkconfig ntpd off

service ntpd stop

mv /etc/ntp.conf /etc/ntp.conf.bak

version=`cat /etc/redhat-release | cut -d ' ' -f 7 | cut -d . -f 1`

#配置yum倉庫
mount /dev/cdrom /mnt

rm -f /etc/yum.repos.d/*
if [ $version=6 ] || [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi

if [ $version=5 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
EOF
fi

#安裝oracle所需要的包
yum clean all

 

case $version in
7)
echo "the linux version is 7"
;;
6)
echo "the linux version is 6"
yum -y install compat-libcap1-1.10-1 binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc libstdc++ make sysstat unixODBC unixODBC-devel
;;
5)
echo "the linux version is 5"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc libstdc++ make sysstat unixODBC unixODBC-devel
;;
4)
echo "the linux version is 4"
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio-devel libaio libgcc libstdc++ libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel
esac

 

四、安裝oracle 11g(11.2.0.4) rac 初始化腳本

 

#!/bin/bash

#關閉selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
service iptables stop
chkconfig iptables off


#配置/etc/hosts文件 添加
cat >> /etc/hosts<<EOF

# rac1
172.16.0.191 rac1
172.16.0.193 rac1-vip
192.168.94.11 rac1-priv
# rac2
172.16.0.192 rac2
172.16.0.194 rac2-vip
192.168.94.12 rac2-priv
# scan-ip
172.16.0.203 scan-vip

EOF

#增大共享內存
mount -t tmpfs shmfs -o size=7g /dev/shm
echo 'shmfs /dev/shm tmpfs size=7g' >> /etc/fstab


#添加組
groupadd -g 1001 oinstall
groupadd -g 1002 asmdba
groupadd -g 1003 asmadmin
groupadd -g 1004 asmoper
groupadd -g 1005 dba
groupadd -g 1006 oper


#添加用戶
useradd -u 1001 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
echo 'oracle' | passwd --stdin grid

useradd -u 1002 -g oinstall -G dba,asmdba,oper oracle
echo 'oracle' | passwd --stdin oracle


#創建安裝目錄
mkdir -p /u01/app/grid/
mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1

#更改目錄權限
chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle/
chmod -R 775 /u01

#改變內核參數
cat >> /etc/sysctl.conf<<EOF

#Kernel for Oracle 11g R2
fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 4294967295
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

#添加用戶資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
EOF

 

#編輯配置文件
cat >> /etc/profile<<EOF

#this is for oracle user
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
EOF


#編輯登陸配置文件
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF

#為grid用戶添加環境變量
cat >> /home/grid/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/grid
export ORACLE_SID=+ASM1
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
EOF
source /home/grid/.bash_profile

#為oracle用戶添加環境變量
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=racdb1
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
EOF
source /home/oracle/.bash_profile

#關閉ntpd服務

chkconfig ntpd off

service ntpd stop

mv /etc/ntp.conf /etc/ntp.conf.bak

version=`cat /etc/redhat-release | cut -d ' ' -f 7 | cut -d . -f 1`

#配置yum倉庫
mount /dev/cdrom /mnt

rm -f /etc/yum.repos.d/*
if [ $version=6 ] || [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi


if [ $version=5 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
EOF
fi

#安裝oracle所需要的包
yum clean all

 

case $version in
7)
echo "the linux version is 7"
;;
6)
echo "the linux version is 6"
yum -y install compat-libcap1-1.10-1 binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc libstdc++ make sysstat unixODBC unixODBC-devel
;;
5)
echo "the linux version is 5"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc libstdc++ make sysstat unixODBC unixODBC-devel
;;
4)
echo "the linux version is 4"
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio-devel libaio libgcc libstdc++ libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel
esac

 

五、單機無rehat 7grid 12c

#!/bin/bash

#關閉selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
systemctl stop firewalld
systemctl disable firewalld

 

#配置/etc/hosts文件 添加
cat >> /etc/hosts<<EOF


172.16.0.191 rhel


EOF

#關閉 NetworkManager

systemctl stop NetworkManager
systemctl disable NetworkManager

 


#添加組
/usr/sbin/groupadd -g 54321 oinstall
/usr/sbin/groupadd -g 54322 dba
/usr/sbin/groupadd -g 54323 oper
/usr/sbin/groupadd -g 54327 asmdba
/usr/sbin/groupadd -g 54328 asmoper
/usr/sbin/groupadd -g 54329 asmadmin

 


#添加用戶

/usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,oper oracle
echo 'oracle' | passwd --stdin oracle


#創建安裝目錄

mkdir -p /u01/app/oracle/product/12.2.0/db_1
mkdir -p /u01/app/oraInventory


#更改目錄權限

chown -R oracle:oinstall /u01/app/oraInventory/
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01

#改變內核參數

cat >> /etc/sysctl.conf<<EOF


#Kernel for Oracle 12c R2
fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 4294967295
kernel.shmall = 16097152
kernel.shmmax = 128849018880
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

#添加用戶資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240

 

#編輯配置文件
cat >> /etc/profile<<EOF

#this is for oracle user
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
EOF


#編輯登陸配置文件
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF


#為oracle用戶添加環境變量
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
export PATH=\$ORACLE_HOME/OPatch:\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

stty erase ^H
EOF
source /home/oracle/.bash_profile

#關閉ntpd服務

chkconfig ntpd off

service ntpd stop

mv /etc/ntp.conf /etc/ntp.conf.bak

version=`cat /etc/redhat-release | awk '{print $4}'| cut -d . -f 1`

#配置yum倉庫


#安裝oracle所需要的包
yum clean all

case $version in
7)
echo "the linux version is Enterprise 7"
yum -y install binutils \
compat-libcap1 \
compat-libstdc++-33 \
compat-libstdc++-33.i686 \
e2fsprogs \
e2fsprogs-libs \
gcc \
gcc-c++ \
glibc.i686 \
glibc \
glibc-devel.i686 \
glibc-devel \
ksh \
libaio \
libaio.i686 \
libaio-devel \
libaio-devel.i686 \
libX11.i686 \
libX11 \
libXau.i686 \
libXau \
libXi.i686 \
libXi \
libXtst.i686 \
libXtst \
libgcc.i686 \
libgcc \
libstdc++.i686 \
libstdc++ \
libstdc++-devel.i686 \
libstdc++-devel \
libxcb.i686 \
libxcb \
make \
net-tools \
nfs-utils \
smartmontools \
sysstat \
unixODBC.i686 \
unixODBC \
unixODBC-devel.i686 \
unixODBC-devel \
java-1.8.0-openjdk

;;
6)
echo "the linux version is Enterprise 6"
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33 compat-libstdc++-33.i686 gcc gcc-c++ \
elfutils-libelf elfutils-libelf-devel glibc.i686 glibc glibc-devel.i686 glibc-devel libgcc.i686 libgcc libstdc++.i686 libstdc++ \
libstdc++-devel.i686 libstdc++-devel libaio.i686 libaio libaio-devel.i686 libaio-devel make \
sysstat unixODBC.i686 unixODBC unixODBC-devel.i686 unixODBC-devel
;;
5)
echo "the linux version is Enterprise 5"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc \
gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc \
libstdc++ make sysstat unixODBC unixODBC-devel
;;
4)
echo "the linux version is Enterprise 4"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel \
gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio-devel libaio libgcc libstdc++ \
libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel
;;
*)
echo "Too old Version !"

esac

 

六、rhel7安裝12cR2 RAC(其實有各種坑)

#!/bin/bash

#配置hosts表
cat >> /etc/hosts<<EOF

#rac1
192.168.211.151 node1
192.168.211.153 node1-vip
192.168.137.151 node1-priv


#rac2
192.168.211.152 node2
192.168.211.154 node2-vip
192.168.137.152 node2-priv


#scan-ip
192.168.211.155 scan-cluster
EOF

#關閉selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0

#關閉防火牆
service iptables stop
chkconfig iptables off
service ip6tables stop
chkconfig ip6tables off

systemctl disable firewalld
systemctl stop firewalld

#關閉 NetworkManager

systemctl stop NetworkManager
systemctl disable NetworkManager

/sbin/service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.org

systemctl stop chronyd
systemctl disable chrnyd

#添加組
groupadd -g 54221 oinstall
groupadd -g 54222 asmdba
groupadd -g 54223 asmadmin
groupadd -g 54224 asmoper
groupadd -g 54225 dba
groupadd -g 54226 oper

#avahi-daemon服務

systemctl stop avahi-dnsconfd
systemctl stop avahi-daemon
systemctl disable avahi-dnsconfd
systemctl disable avahi-daemon

#禁止NTP

/sbin/service ntpd stop
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.org
rm /var/run/ntpd.pid


#添加用戶
useradd -u 54321 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
echo 'oracle' | passwd --stdin grid

useradd -u 54322 -g oinstall -G dba,asmdba,oper oracle
echo 'oracle' | passwd --stdin oracle

 

#創建安裝目錄
mkdir -p /u01/app/grid
mkdir -p /u01/app/12.2.0/grid
mkdir -p /u01/app/oracle/product/12.2.0/db_1

#更改目錄權限

chown -R grid:oinstall /u01
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01


#改變內核參數
cat >> /etc/sysctl.conf<<EOF

#Kernel for Oracle 12C
fs.aio-max-nr = 1048576
fs.file-max = 6815744
#kernel.shmall = 2097152
#kernel.shmmax = 4294967295
kernel.shmall = 16097152
kernel.shmmax = 128849018880
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

#添加用戶資源限制
cat >> /etc/security/limits.conf<<EOF

#limits for Oracle users
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF

 

#編輯配置文件
cat >> /etc/profile<<EOF

#this is for oracle user
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
EOF

 

#編輯登陸配置文件
cat >> /etc/pam.d/login<<EOF
#this is for oracle user
session required pam_limits.so
EOF

#為grid用戶添加環境變量
cat >> /home/grid/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/grid
export ORACLE_SID=+ASM1
export ORACLE_HOME=/u01/app/12.2.0/grid
export PATH=\$ORACLE_HOME/OPatch:\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH

stty erase ^H

EOF
source /home/oracle/.bash_profile


#為oracle用戶添加環境變量
cat >> /home/oracle/.bash_profile<<EOF
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=orcl
export ORACLE_HOME=\$ORACLE_BASE/product/12.2.0/db_1
export PATH=\$ORACLE_HOME/OPatch:\$ORACLE_HOME/bin:\$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib:\$LD_LIBRARY_PATH
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

stty erase ^H
EOF
source /home/oracle/.bash_profile

version=`cat /etc/redhat-release | awk '{print $4}'| cut -d . -f 1`
#version=`cat /etc/redhat-release | awk '{print $7}' | awk -F . '{print $1}'`

#配置yum倉庫
#mount /dev/cdrom /mnt

#mv -f /etc/yum.repos.d/* /tmp

if [ "$version" -eq 6 ] || [ "$version" -eq 7 ] ; then
cat > /etc/yum.repos.d/rhel-dvd.repo<<EOF
[rhel-debuginfo]
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi

#if [ "$version" -eq 5 ] ; then
#cat > /etc/yum.repos.d/rhel-dvd.repo<<EOF
#[rhel]
#name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
#baseurl=file:///mnt/Server
#enabled=1
#gpgcheck=0
#EOF
#fi


#安裝oracle所需要的包
yum clean all

case $version in
7)
echo "the linux version is Enterprise 7"
yum -y install binutils \
compat-libcap1 \
compat-libstdc++-33 \
compat-libstdc++-33.i686 \
e2fsprogs \
e2fsprogs-libs \
gcc \
gcc-c++ \
glibc.i686 \
glibc \
glibc-devel.i686 \
glibc-devel \
ksh \
libaio \
libaio.i686 \
libaio-devel \
libaio-devel.i686 \
libX11.i686 \
libX11 \
libXau.i686 \
libXau \
libXi.i686 \
libXi \
libXtst.i686 \
libXtst \
libgcc.i686 \
libgcc \
libstdc++.i686 \
libstdc++ \
libstdc++-devel.i686 \
libstdc++-devel \
libxcb.i686 \
libxcb \
make \
net-tools \
nfs-utils \
smartmontools \
sysstat \
unixODBC.i686 \
unixODBC \
unixODBC-devel.i686 \
unixODBC-devel \
java-1.8.0-openjdk \
psmisc

;;
6)
echo "the linux version is Enterprise 6"
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33 compat-libstdc++-33.i686 gcc gcc-c++ \
elfutils-libelf elfutils-libelf-devel glibc.i686 glibc glibc-devel.i686 glibc-devel libgcc.i686 libgcc libstdc++.i686 libstdc++ \
libstdc++-devel.i686 libstdc++-devel libaio.i686 libaio libaio-devel.i686 libaio-devel make \
sysstat unixODBC.i686 unixODBC unixODBC-devel.i686 unixODBC-devel
;;
5)
echo "the linux version is Enterprise 5"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel gcc \
gcc-c++ glibc glibc-devel glibc-common glibc-headers ksh libaio libaio-devel libgcc \
libstdc++ make sysstat unixODBC unixODBC-devel
;;
4)
echo "the linux version is Enterprise 4"
yum -y install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel \
gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio-devel libaio libgcc libstdc++ \
libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel
;;
*)
echo "Too old Version !"
esac

 

# 16.配置NOZEROCONF
#How To Prevent Bogus Entry 169.254.0.0/255.255.0.0 Automatically Added To Routing Table (文檔 ID 1161144.1)

cat >>/etc/sysconfig/network<<EOF
NOZEROCONF=yes

EOF

#選擇deadline IO調度


cat > /etc/udev/rules.d/60-oracle-schedulers.rules<<EOF

ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"

EOF

udevadm control --reload-rules

oracle 12c r2 asm  配置

for i in b c d e
do
echo "KERNEL==\"sd?\",SUBSYSTEM==\"block\",PROGRAM==\"/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\",RESULT==\"`/usr/lib/udev/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\",SYMLINK+=\"asm-disk$i\",OWNER=\"grid\",GROUP=\"asmadmin\",MODE=\"0660\""
done > /etc/udev/rules.d/99-oracle-asmdevices.rules

udevadm trigger
udevadm control -R
systemctl restart systemd-udevd.service

 透明大頁:

1.查看透明大頁是否啟用

RHEL 6:

# cat /sys/kernel/mm/redhat_transparent_hugepage/enabled

[oracle@rhel 6 ~]$ cat /sys/kernel/mm/redhat_transparent_hugepage/enabled
[always] madvise never

 

RHEL 7:

# cat /sys/kernel/mm/transparent_hugepage/enabled
[root@rhel 7 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled

[always] madvise never

 

2.禁用透明大頁

RHEL 6:

(1).編輯
/etc/grub.conf 文件,在kernel 那一行后面追加
transparent_hugepage=never

例如:
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux 6 (2.6.32-642.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-642.el6.x86_64 ro root=/dev/mapper/rootvg-lvroot rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_LVM_LV=rootvg/lvswap rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=rootvg/lvroot rd_NO_DM rhgb quiet transparent_hugepage=never
initrd /initramfs-2.6.32-642.el6.x86_64.img

(2).重啟系統生效。


RHEL 7:
(1).編輯/etc/sysconfig/grub 文件,在 GRUB_CMDLINE_LINUX 那一行后面追加 transparent_hugepage=never

例如:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rootvg/root rd.lvm.lv=rootvg/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"

(2).再使用
grub2-mkconfig 生成grub.cfg配置文件。
# grub2-mkconfig -o /boot/grub2/grub.cfg
(3).重啟系統使配置生效。

網卡綁定:

建議em1,em3綁定到bond0, em1,em3綁定到bond0, em2,em4綁定到bond1。

em1參數配置:
#vi ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
BOOTPROTO=none

em3參數配置:
#vi ifcfg-eth3
DEVICE=eth3
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
BOOTPROTO=none

em2參數配置:

#vi ifcfg-eth2
DEVICE=eth2
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
BOOTPROTO=none


em4參數配置:

#vi ifcfg-eth4
DEVICE=eth4
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
BOOTPROTO=none


bond0 參數配置:

DEVICE=bond0
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=10.1.20.1
BOOTPROTO=static
NETMASK=255.255.255.0
GATEWAY=10.1.20.254
IPV6INIT=no
USERCTL=no
IPV4_FAILURE_FATAL=yes
NAME="System bond0"
BONDING_OPTS="mode=1 miimon=100"

bond1 參數配置:

DEVICE=bond1
NM_CONTROLLED=no
ONBOOT=yes
IPADDR=10.1.20.2
BOOTPROTO=static
NETMASK=255.255.255.0
GATEWAY=10.1.20.254
IPV6INIT=no
USERCTL=no
IPV4_FAILURE_FATAL=yes
NAME="System bond1"
BONDING_OPTS="mode=1 miimon=100"

rac 安裝環境預檢查:

 

./runcluvfy.sh  stage -pre crsinst -fixup -n tzjydb1,tzjydb2 -verbose

 

DD磁盤:

+mv /etc/udev/rules.d/99-oracle-asmdevices.rules.bak /etc/udev/rules.d/99-oracle-asmdevices.rules


注意 dd 使用過的為(一個節點就可以):

dd if=/dev/zero of=/dev/asm-diskb bs=1024k count=10
dd if=/dev/zero of=/dev/asm-diskc bs=1024k count=10
dd if=/dev/zero of=/dev/asm-diskd bs=1024k count=10
dd if=/dev/zero of=/dev/asm-diske bs=1024k count=10
dd if=/dev/zero of=/dev/asm-diskf bs=1024k count=10

dd if=/dev/zero of=/dev/emcpowera1 bs=1024k count=10
dd if=/dev/zero of=/dev/emcpowerb1 bs=1024k count=10
dd if=/dev/zero of=/dev/emcpowere1 bs=1024k count=10


dd if=/dev/zero of=/dev/dm-0 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-1 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-2 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-3 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-4 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-5 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-6 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-7 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-8 bs=1024k count=10
dd if=/dev/zero of=/dev/dm-9 bs=1024k count=10

 

rehat/centos 7 修改主機名:

systemctl restart systemd-hostnamed
systemctl restart node1

重啟網絡

systemctl restart network

 

 

vi /etc/sysconfig/network
# Created by anaconda
NOZEROCONF=yes
HOSTNAME=node1

hostnamectl status


用redhat 7新增的hostnamectl命令獲取的名稱信息則如下:

[root@node1 ~]# vi /etc/hostname
node2

hostnamectl

hostnamectl set-hostname node1

[root@node2 ~]# hostnamectl status
[root@node2 ~]# hostnamectl status
Static hostname: node1
Icon name: computer-vm
Chassis: vm
Machine ID: 3bdde3d59641468ba47d63105d5017a3
Boot ID: d22652483d264394b8dfac6b51b5eaf2
Virtualization: kvm
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
CPE OS Name: cpe:/o:redhat:enterprise_linux:7.2:GA:server
Kernel: Linux 3.10.0-327.el7.x86_64
Architecture: x86-64


重啟生效

 

asm 磁盤設置:

vi /etc/udev/rules.d/99-oracle-asmdevices.rules
KERNEL=="/dev/mapper/mpathe", NAME="asmocr01",OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="/dev/mapper/mpathg", NAME="asmocr02",OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="/dev/mapper/mpathh", NAME="asmocr03",OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="/dev/mapper/mpathk", NAME="asmocr04",OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="/dev/mapper/mpathi", NAME="asmocr05",OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="/dev/mapper/mpathb", NAME="asmdata01",OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="/dev/mapper/mpathc", NAME="asmlog01",OWNER="grid", GROUP="asmadmin", MODE="0660"

asm配置另一種磁盤:
for i in b c d e f g h i j k l m n o;
do
echo "KERNEL==\"sd*\", BUS==\"scsi\", PROGRAM==\"/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/\$name\", RESULT==\"`/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/sd$i`\", NAME=\"asm-disk$i\", OWNER=\"grid\", GROUP=\"asmadmin\", MODE=\"0660\""
done > /etc/udev/rules.d/99-oracle-asmdevices.rules

KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000f6c674da4408e611", NAME="asm-diskb", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb040008a1824c24408e611", NAME="asm-diskc", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000d62f92e84408e611", NAME="asm-diskd", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb040002f583fce4408e611", NAME="asm-diske", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000d5b1a3f64408e611", NAME="asm-diskf", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb040002c8ed9714408e611", NAME="asm-diskg", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000448e487a4408e611", NAME="asm-diskh", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000d8f6e1864408e611", NAME="asm-diski", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000f6c674da4408e611", NAME="asm-diskj", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb040008a1824c24408e611", NAME="asm-diskk", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000d62f92e84408e611", NAME="asm-diskl", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb040002f583fce4408e611", NAME="asm-diskm", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb04000d5b1a3f64408e611", NAME="asm-diskn", OWNER="grid", GROUP="asmadmin", MODE="0660"
KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id --whitelisted --replace-whitespace --device=/dev/$name", RESULT=="3600601603eb040002c8ed9714408e611", NAME="asm-disko", OWNER="grid", GROUP="asmadmin", MODE="0660"

 

或者sd換成mpath 如果是EMC存儲

六、最后附帶一個我同事靜默安裝oracle 11g  步驟:


1.linux check package

rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \
compat-libstdc++-33 compat-db control-center elfutils-libelf elfutils-libelf-devel gcc \
gcc-c++ glibc glibc-common glibc-devel libaio libaio-devel libgcc libstdc++ \
libstdc++-devel make sysstat unixODBC glibc-headers unixODBC-devel \
pdksh sysstat xscreensaver | grep not | grep -v grep | awk '{print "yum install -y " $2 }'


rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \
compat-libcap1 \
compat-libstdc++-33 \
gcc \
gcc-c++ \
glibc \
glibc-devel \
ksh \
pdksh \
libgcc \
libstdc++ \
libstdc++-devel \
libaio \
libaio-devel \
sysstat \
make

 

rehat7:

yum -y install binutils compat-libcap1 compat-libstdc++ gcc- gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++- libstdc++-devel libXi libXtst make sysstat


RedHat 6.5離線安裝GCC方法

rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm
rpm -ivh ppl-0.10.2-11.el6.x86_64.rpm
rpm -ivh cpp-4.4.7-4.el6.x86_64.rpm
rpm -ivh cloog-ppl-0.15.7-1.2.el6.x86_64.rpm
rpm -ivh gcc-4.4.7-4.el6.x86_64.rpm

 

==========================================
************hosts************
10.12.140.240 $hstname" >> /etc/hosts
vi /etc/hosts
==========================================

************stop firewall************
service iptables stop
chkconfig iptables off
chkconfig --list iptables
setenforce 0
vi /etc/sysconfig/selinux
==========================================

************fstab************
vi /etc/fstab
mount -o remount /dev/shm
free -m

==========================================


2.MODIFY OS PARAMETER

a ************/etc/sysctl.conf ************:

vi /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 48719476736
kernel.shmmni = 4096
kernel.sem = 500 64000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
net.core.rmem_max = 4194304

/sbin/sysctl -p

b ************/etc/security/limits.conf ************:
vi /etc/security/limits.conf

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240


c ************ /etc/pam.d/login ************:
vi /etc/pam.d/login

session required pam_limits.so

 

d ************ /etc/profile

if [ $USER = "oracle" ] ; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi

 

3 ************create oracle group & oracle user************
/usr/sbin/groupadd -g 600 oinstall
/usr/sbin/groupadd -g 601 dba

/usr/sbin/useradd -u 600 -g oinstall -G oinstall,dba oracle

echo oracle | passwd --stdin oracle

id oracle


************create oracle rdbms location************

mkdir -p /oracle/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /oracle/app/oracle
chmod -R 775 /oracle/app/oracle

mkdir -p /oracle/app/oraInventory
chown -R oracle:oinstall /oracle/app/oraInventory
chmod -R 775 /oracle/app/oraInventory
ls -l /oracle/app


4 Oracle BINARY
vi /home/oracle/.bash_profile

export ORACLE_SID=orcl
export ORACLE_BASE=/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$ORACLE_HOME/lib32:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
export TNS_ADMIN=$ORACLE_HOME/network/admin
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export NLS_DATE_FORMAT=\"YYYY-MM-DD HH24:MI:SS\"
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH
export ORACLE_TERM=xterm
export EDITOR=vi
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp


二 安裝

1 此步驟很重要,如果忽略1 ,最終會提示inventory 文件目錄非空 導致靜默安裝失敗 文章末尾會加以說明
vim /etc/oraInst.loc

inventory_loc=/oracle/app/oraInventory
inst_group=oinstall


2 靜默安裝 11.2.0.4 采用 debug模式安裝 ,如果有異常則更容易發現錯誤原因。

./runInstaller -ignorePrereq -ignoreSysPrereqs -silent -debug -force -noconfig -IgnoreSysPreReqs \
FROM_LOCATION=/soft/database/stage/products.xml \
oracle.install.option=INSTALL_DB_SWONLY \
DECLINE_SECURITY_UPDATES=true \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oracle/oraInventory \
SELECTED_LANGUAGES=en,zh_CN,zh_TW \
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 \
ORACLE_BASE=/u01/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.isCustomInstall=false \
oracle.install.db.DBA_GROUP=dba \
oracle.install.db.isRACOneInstall=false \
oracle.install.db.OPER_GROUP=dba


源文:
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 \


MOS 參考
=========================================================================
./runInstaller -ignorePrereq -ignoreSysPrereqs -silent -debug -waitforcompletion -nowait -force \
FROM_LOCATION=/soft/database/stage/products.xml \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u01/app/oracle/oraInventory \
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 \
ORACLE_HOME_NAME="OraDb11g_Home1" \
ORACLE_BASE=/u01/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.isCustomInstall=false \
oracle.install.db.DBA_GROUP=dba \
oracle.install.db.OPER_GROUP=dba \
DECLINE_SECURITY_UPDATES=true
=========================================================================

 

安裝完成之后 系統會提示我們用root用戶運行如下兩個腳本 。

As a root user, execute the following script(s):
1. /oracle/app/oracle/product/11.2.0/db_1/root.sh

Successfully Setup Software.

 

sh /oracle/app/oracle/product/11.2.0/db_1/root.sh


附上oracle軟件靜默安裝的參數含義如下:
-silent 表示以靜默方式安裝,不會有任何提示
-force 表示允許安裝到一個非空目錄
-noconfig 表示不運行配置助手netca
-responseFile 表示使用哪個響應文件,必需使用絕對路徑
oracle.install.responseFileVersion 響應文件模板的版本,該參數不要更改
oracle.install.option 安裝模式選項,本例只安裝oracle軟件,該參數不要更改
DECLINE_SECURITY_UPDATES 是否需要在線安全更新,設置為false,該參數不要更改
UNIX_GROUP_NAME oracle 用戶用於安裝軟件的組名
INVENTORY_LOCATION oracle 產品清單目錄
SELECTED_LANGUAGES oracle 運行語言環境,一般包括引文和簡繁體中文
ORACLE_HOME oracle安裝目錄
ORACLE_BASE oracle基礎目錄
oracle.install.db.InstallEdition 安裝版本類型,一般是企業版
oracle.install.db.isCustomInstall 是否定制安裝,默認Partitioning,OLAP,RAT都選上。根據自己的需要選擇組件。
oracle.install.db.customComponents 定制安裝組件列表:除了以上默認的,可加上Label Security和Database Vault
oracle.install.db.DBA_GROUP oracle 用戶用於授予osdba權限的組名
oracle.install.db.OPER_GROUP oracle 用戶用於授予osoper權限的組名


3 靜默安裝db
安裝完成oracle軟件之后還沒創建db,我們可以繼續使用靜默方式創建數據庫。

dbca -silent -responseFile /home/oracle/dbca.rsp

dbca.rsp 文件內容如下:根據自己的場景進行修改。

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "New_Database.dbt"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION ="/oracle/app/oracle/oradata"
STORAGETYPE=FS
CHARACTERSET = "ZHS16GBK"
DATABASETYPE = "MULTIPURPOSE"
AUTOMATICMEMORYMANAGEMENT = "FALSE"
TOTALMEMORY = 8192

源文:
CHARACTERSET = "AL32UTF8"

參考其它:小麥苗
================================================================================
dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname ora11g -sid ora11gsid -sysPassword oracle -systemPassword oracle -responseFile NO_VALUE -datafileDestination /oracle/app/oracle/oradata/ora11g -redoLogFileSize 60 -recoveryAreaDestination /oracle/app/oracle/oradata/ora11g/flash_recovery_area -storageType FS -characterSet ZHS16GBK -nationalCharacterSet AL16UTF16 -sampleSchema true -memoryPercentage 30 -totalMemory 1024 -databaseType OLTP -emConfiguration NONE
================================================================================


4 配置網絡監聽
這一步我使用netca的默認方式,而是直接編輯了$ORACLE_HOME/network/admin/ 下的*.ora 文件。
根據需求編輯好了之后啟動監聽。

lsnrctl start

 

[oracle@localhost admin]$ cat tnsnames.ora
TTFC =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.16.182)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = TTFC)
)
)


5 登陸數據庫
sqlplus / as sysdba
select flashback_on from V$database;
SELECT * FROM NLS_DATABASE_PARAMETERS;

三 遇到的問題
問題一 相信這個問題也是很多人也會遇到

[FATAL] [INS-32035] Unable to create a new central inventory at the specified location.
CAUSE: The central inventory location provided is not empty.
ACTION: Please provide another location for the inventory, or clean up the current location.

解決方法:
使用root vim /etc/oraInst.doc 加入

inventory_loc=/u01/app/oraInventory
inst_group=oinstall

問題二

[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.

解決方法:
如提示所言 Inventory 目錄安裝在了$ORACLE_BASE 目錄下了,所以調整Inventory 目錄不在$ORACLE_BASE 目錄下,即可解決問題。

oraInventory 存放Oracle軟件安裝的目錄信息,Oralce的安裝和升級都需要用到這個目錄,刪除或丟失oraInventory目錄的內容就會導致安裝/升級失敗。
Oracle官方文檔對oraInventory的說明:

All Oracle software installations rely on this directory.
Ensure that you back it up regularly.
Do not delete this directory unless you have completely removed
all Oracle software from the system.

oraInventory 目錄的位置是由oraInst.loc 文件決定的:
/etc/oraInst.loc (AIX and Linux Platform)
/var/opt/oracle/OraInst.loc (Solaris and HP-UX platform)


問題三:

[oracle@veridata ~]$ /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbca -silent -responseFile /home/oracle/dbca.rsp
UnsatisfiedLinkError exception loading native library: njni11
java.lang.UnsatisfiedLinkError: /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnjni11.so: libclntsh.so.11.1: cannot open shared object file: No such file or directory
Exception in thread "main" java.lang.UnsatisfiedLinkError: get
at oracle.net.common.NetGetEnv.get(Native Method)
at oracle.net.config.Config.getNetDir(Unknown Source)
at oracle.net.config.Config.initConfig(Unknown Source)
at oracle.net.config.Config.<init>(Unknown Source)
at oracle.sysman.assistants.util.NetworkUtils.<init>(NetworkUtils.java:292)
at oracle.sysman.assistants.util.step.StepContext.<init>(StepContext.java:336)
at oracle.sysman.assistants.dbca.backend.Host.<init>(Host.java:828)
at oracle.sysman.assistants.dbca.backend.SilentHost.<init>(SilentHost.java:154)
at oracle.sysman.assistants.dbca.Dbca.getHost(Dbca.java:163)
at oracle.sysman.assistants.dbca.Dbca.execute(Dbca.java:113)
at oracle.sysman.assistants.dbca.Dbca.main(Dbca.java:189)

=================================================================================
解決方案:
[oracle@veridata ~]$ cd /u01/app/oracle/product/11.2.0/dbhome_1/inventory/Scripts/ext/lib/
[oracle@veridata lib]$ cp libclntsh.so.11.1 /u01/app/oracle/product/11.2.0/dbhome_1/lib/
[oracle@veridata lib]$ dbca
可以彈出圖形界面


[oracle@centos ~]$ dbca -help
dbca [-silent | -progressOnly | -customCreate] {<command> <options> } | { [<command> [options] ] -responseFile <response file > } [-continueOnNonFatalErrors <true | false>]
Please refer to the manual for details.
You can enter one of the following command:

Create a database by specifying the following parameters:
-createDatabase
-templateName <name of an existing template in default location or the complete template path>
[-cloneTemplate]
-gdbName <global database name>
[-sid <database system identifier>]
[-sysPassword <SYS user password>]
[-systemPassword <SYSTEM user password>]
[-emConfiguration <CENTRAL|LOCAL|ALL|NONE>
-dbsnmpPassword <DBSNMP user password>
-sysmanPassword <SYSMAN user password>
[-hostUserName <Host user name for EM backup job>
-hostUserPassword <Host user password for EM backup job>
-backupSchedule <Daily backup schedule in the form of hh:mm>]
[-centralAgent <Enterprise Manager central agent home>]]
[-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>
[-datafileDestination <destination directory for all database files> | -datafileNames <a text file containing database objects such as controlfiles, tablespaces, redo log files and spfile to their corresponding raw device file names mappings in name=value format.>]
[-redoLogFileSize <size of each redo log file in megabytes>]
[-recoveryAreaDestination <destination directory for all recovery files>]
[-datafileJarLocation <location of the data file jar, used only for clone database creation>]
[-storageType < FS | ASM >
[-asmsnmpPassword <ASMSNMP password for ASM monitoring>]
-diskGroupName <database area disk group name>
-recoveryGroupName <recovery area disk group name>
[-characterSet <character set for the database>]
[-nationalCharacterSet <national character set for the database>]
[-registerWithDirService <true | false>
-dirServiceUserName <user name for directory service>
-dirServicePassword <password for directory service >
-walletPassword <password for database wallet >]
[-listeners <list of listeners to configure the database with>]
[-variablesFile <file name for the variable-value pair for variables in the template>]]
[-variables <comma separated list of name=value pairs>]
[-initParams <comma separated list of name=value pairs>]
[-sampleSchema <true | false> ]
[-memoryPercentage <percentage of physical memory for Oracle>]
[-automaticMemoryManagement ]
[-totalMemory <memory allocated for Oracle in MB>]
[-databaseType <MULTIPURPOSE|DATA_WAREHOUSING|OLTP>]]

Configure a database by specifying the following parameters:
-configureDatabase
-sourceDB <source database sid>
[-sysDBAUserName <user name with SYSDBA privileges>
-sysDBAPassword <password for sysDBAUserName user name>]
[-registerWithDirService|-unregisterWithDirService|-regenerateDBPassword <true | false>
-dirServiceUserName <user name for directory service>
-dirServicePassword <password for directory service >
-walletPassword <password for database wallet >]
[-disableSecurityConfiguration <ALL|AUDIT|PASSWORD_PROFILE|NONE>
[-enableSecurityConfiguration <true|false>
[-emConfiguration <CENTRAL|LOCAL|ALL|NONE>
-dbsnmpPassword <DBSNMP user password>
-sysmanPassword <SYSMAN user password>
[-hostUserName <Host user name for EM backup job>
-hostUserPassword <Host user password for EM backup job>
-backupSchedule <Daily backup schedule in the form of hh:mm>]
[-centralAgent <Enterprise Manager central agent home>]]


Create a template from an existing database by specifying the following parameters:
-createTemplateFromDB
-sourceDB <service in the form of <host>:<port>:<sid>>
-templateName <new template name>
-sysDBAUserName <user name with SYSDBA privileges>
-sysDBAPassword <password for sysDBAUserName user name>
[-maintainFileLocations <true | false>]


Create a clone template from an existing database by specifying the following parameters:
-createCloneTemplate
-sourceSID <source database sid>
-templateName <new template name>
[-sysDBAUserName <user name with SYSDBA privileges>
-sysDBAPassword <password for sysDBAUserName user name>]
[-maintainFileLocations <true | false>]
[-datafileJarLocation <directory to place the datafiles in a compressed format>]

Generate scripts to create database by specifying the following parameters:
-generateScripts
-templateName <name of an existing template in default location or the complete template path>
-gdbName <global database name>
[-scriptDest <destination for all the scriptfiles>]

Delete a database by specifying the following parameters:
-deleteDatabase
-sourceDB <source database sid>
[-sysDBAUserName <user name with SYSDBA privileges>
-sysDBAPassword <password for sysDBAUserName user name>]
Query for help by specifying the following options: -h | -help


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM