oracle 常用安装脚本以及步骤
oracle 常用脚本以及语句
一.19c单机安装:
#!/bin/bash
##需要7.0+ 版本的Linux
#关闭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
EOF
#编辑配置文件
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
EOF
#编辑配置文件
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=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
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
#为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-libstdc++ elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc glibc-common glibc-devel glibc-devel glibc-headers ksh libaio libaio libaio-devel libaio-devel libgcc libstdc++ libstdc++-devel make numactl-devel sysstat unixODBC
;;
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
###静默安装11.2.0.4单机:
oracle软件解压在/soft 目录
1.数据库软件的响应文件:
mkdir -p /u01/app/oracle/admin/ttfcdg/adump
mkdir -p /u01/app/oracle/archivelog
mkdir -p /u01/app/oracle/fast_recovery_area/ttfcdg
vi /home/oracle/db_install_11g.rsp
oracle.install.responseFileVersion=/soft/database/respons/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=ap-east-1.compute.internal
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.EEOptionsSelection=false
oracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
./runInstaller -silent -ignoreSysPrereqs -force -ignorePrereq -responseFile /home/oracle/db_install_11g.rsp -showProgress
2.安装数据库
vi /home/oracle/db_create.rsp
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "ttfc"
SID="ttfc"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "9000"
SYSPASSWORD = "Password1"
SYSTEMPASSWORD = "Password1"
DB_BLOCK_SIZE=8192
redoLogFileSize=256
dbca -silent -initParams log_archive_dest_1='location=/u01/app/oracle/archivelog' -responseFile /home/oracle/db_create.rsp
四、安装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