oracle 常用脚本以及语句
一、oracle 安装10G 单机初始化环境:
#!/bin/bash
#关闭selinux
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0
#关闭防火墙
service iptables stop
chkconfig iptables off
#增大共享内存 mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1 chown -R oracle:oinstall /u01/app/oraInventory/ #改变内核参数 #Kernel for Oracle 10g R2 EOF #使内核参数立即生效 #添加用户资源限制 #limits for Oracle users oracle soft nproc 2047 #this is for oracle user #关闭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仓库 rm -f /etc/yum.repos.d/* if [ $version=5 ] ; then #安装oracle所需要的包 case $version in 二、oracle 安装11G单机初始化环境脚本: #!/bin/bash #关闭selinux #关闭防火墙 #增大共享内存 mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1 chown -R oracle:oinstall /u01/app/oraInventory/ #改变内核参数 #Kernel for Oracle 11g R2 #使内核参数立即生效 #添加用户资源限制 #limits for Oracle users #编辑配置文件 #this is for oracle user #关闭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仓库 rm -f /etc/yum.repos.d/* if [ $version=5 ] ; then #安装oracle所需要的包 case $version in 三、安装oracle 11g(11.2.0.4) rac 初始化脚本 #!/bin/bash #关闭selinux #关闭防火墙 # rac1 EOF #增大共享内存 useradd -u 1002 -g oinstall -G dba,asmdba,oper oracle #更改目录权限 #改变内核参数 #Kernel for Oracle 11g R2 #使内核参数立即生效 #添加用户资源限制 #limits for Oracle users grid soft nproc 2047 #编辑配置文件 #this is for oracle user #为grid用户添加环境变量 #为oracle用户添加环境变量 #关闭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仓库 rm -f /etc/yum.repos.d/* #安装oracle所需要的包 case $version in 四、单机无rehat 7grid 12c #!/bin/bash #关闭selinux #关闭防火墙 #配置/etc/hosts文件 添加 #关闭 NetworkManager systemctl stop NetworkManager /usr/sbin/useradd -u 54321 -g oinstall -G dba,asmdba,oper oracle mkdir -p /u01/app/oracle/product/12.2.0/db_1 chown -R oracle:oinstall /u01/app/oraInventory/ #改变内核参数 cat >> /etc/sysctl.conf< #使内核参数立即生效 #添加用户资源限制 #limits for Oracle users #编辑配置文件 #this is for oracle user stty erase ^H #关闭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仓库 case $version in ;; esac 五、rhel7安装12cR2 RAC(其实有各种坑) #!/bin/bash #配置hosts表 #rac1 #关闭selinux #关闭防火墙 systemctl disable firewalld #关闭 NetworkManager systemctl stop NetworkManager /sbin/service ntpd stop systemctl stop chronyd #添加组 #avahi-daemon服务 systemctl stop avahi-dnsconfd #禁止NTP /sbin/service ntpd stop useradd -u 54322 -g oinstall -G dba,asmdba,oper oracle #创建安装目录 #更改目录权限 chown -R grid:oinstall /u01 #Kernel for Oracle 12C #使内核参数立即生效 #添加用户资源限制 #limits for Oracle users oracle soft nproc 2047 #编辑配置文件 #this is for oracle user #编辑登陆配置文件 #为grid用户添加环境变量 stty erase ^H EOF stty erase ^H version=`cat /etc/redhat-release | awk '{print $4}'| cut -d . -f 1` #配置yum仓库 #mv -f /etc/yum.repos.d/* /tmp if [ "$version" -eq 6 ] || [ "$version" -eq 7 ] ; then #if [ "$version" -eq 5 ] ; then case $version in ;; # 16.配置NOZEROCONF cat >>/etc/sysconfig/network< EOF #选择deadline IO调度 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 udevadm trigger 透明大页: 1.查看透明大页是否启用 RHEL 6: # cat /sys/kernel/mm/redhat_transparent_hugepage/enabled [oracle@rhel 6 ~]$ cat /sys/kernel/mm/redhat_transparent_hugepage/enabled RHEL 7: # cat /sys/kernel/mm/transparent_hugepage/enabled [always] madvise never 2.禁用透明大页 RHEL 6: (1).编辑 例如: (2).重启系统生效。 例如: (2).再使用 网卡绑定: 建议em1,em3绑定到bond0, em1,em3绑定到bond0, em2,em4绑定到bond1。 em1参数配置: em3参数配置: em2参数配置: #vi ifcfg-eth2 #vi ifcfg-eth4 DEVICE=bond0 bond1 参数配置: DEVICE=bond1 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 if=/dev/zero of=/dev/asm-diskb bs=1024k count=10 dd if=/dev/zero of=/dev/emcpowera1 bs=1024k count=10 rehat/centos 7 修改主机名: systemctl restart systemd-hostnamed 重启网络 systemctl restart network vi /etc/sysconfig/network hostnamectl status [root@node1 ~]# vi /etc/hostname hostnamectl hostnamectl set-hostname node1 [root@node2 ~]# hostnamectl status asm 磁盘设置: vi /etc/udev/rules.d/99-oracle-asmdevices.rules asm配置另一种磁盘: 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" 或者sd换成mpath 如果是EMC存储 六、最后附带一个我同事静默安装oracle 11g 步骤: rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' binutils \ rpm -ivh mpfr-2.4.1-6.el6.x86_64.rpm ========================================== ************stop firewall************ ************fstab************ ========================================== a ************/etc/sysctl.conf ************: vi /etc/sysctl.conf fs.aio-max-nr = 1048576 /sbin/sysctl -p b ************/etc/security/limits.conf ************: oracle soft nproc 2047 session required pam_limits.so d ************ /etc/profile if [ $USER = "oracle" ] ; then 3 ************create oracle group & oracle user************ /usr/sbin/useradd -u 600 -g oinstall -G oinstall,dba oracle echo oracle | passwd --stdin oracle id oracle mkdir -p /oracle/app/oracle/product/11.2.0/db_1 mkdir -p /oracle/app/oraInventory export ORACLE_SID=orcl 1 此步骤很重要,如果忽略1 ,最终会提示inventory 文件目录非空 导致静默安装失败 文章末尾会加以说明 inventory_loc=/oracle/app/oraInventory ./runInstaller -ignorePrereq -ignoreSysPrereqs -silent -debug -force -noconfig -IgnoreSysPreReqs \ 安装完成之后 系统会提示我们用root用户运行如下两个脚本 。 As a root user, execute the following script(s): Successfully Setup Software. sh /oracle/app/oracle/product/11.2.0/db_1/root.sh dbca -silent -responseFile /home/oracle/dbca.rsp dbca.rsp 文件内容如下:根据自己的场景进行修改。 [GENERAL] 源文: 参考其它:小麦苗 lsnrctl start 三 遇到的问题 [FATAL] [INS-32035] Unable to create a new central inventory at the specified location. 解决方法: inventory_loc=/u01/app/oraInventory 问题二 [WARNING] [INS-32055] The Central Inventory is located in the Oracle base. 解决方法: oraInventory 存放Oracle软件安装的目录信息,Oralce的安装和升级都需要用到这个目录,删除或丢失oraInventory目录的内容就会导致安装/升级失败。 All Oracle software installations rely on this directory. oraInventory 目录的位置是由oraInst.loc 文件决定的: [oracle@veridata ~]$ /u01/app/oracle/product/11.2.0/dbhome_1/bin/dbca -silent -responseFile /home/oracle/dbca.rsp ================================================================================= Create a database by specifying the following parameters: Configure a database by specifying the following parameters: Generate scripts to create database by specifying the following parameters: Delete a database by specifying the following parameters:
#配置/etc/hosts文件 添加
cat >> /etc/hosts<
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/oraInventory
#更改目录权限
chown -R oracle:oinstall /u01/app/oracle/
chmod -R 775 /u01
cat >> /etc/sysctl.conf<
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
sysctl -p
cat >> /etc/security/limits.conf<
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
#编辑配置文件
cat >> /etc/profile<
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<
session required pam_limits.so
EOF
#为oracle用户添加环境变量
cat >> /home/oracle/.bash_profile<
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
mount /dev/cdrom /mnt
if [ $version=6 ] || [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi
cat > /etc/yum.repos.d/rhel-debuginfo.repo<
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
EOF
fi
yum clean all
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
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0
service iptables stop
chkconfig iptables off
#配置/etc/hosts文件 添加
cat >> /etc/hosts<
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/oraInventory
#更改目录权限
chown -R oracle:oinstall /u01/app/oracle/
chmod -R 775 /u01
cat >> /etc/sysctl.conf<
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<
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
cat >> /etc/profile<
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<
session required pam_limits.so
EOF
#为oracle用户添加环境变量
cat >> /home/oracle/.bash_profile<
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
mount /dev/cdrom /mnt
if [ $version=6 ] || [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi
cat > /etc/yum.repos.d/rhel-debuginfo.repo<
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
EOF
fi
yum clean all
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
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0
service iptables stop
chkconfig iptables off
#配置/etc/hosts文件 添加
cat >> /etc/hosts<
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
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
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<
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<
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
EOF
cat >> /etc/profile<
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<
session required pam_limits.so
EOF
cat >> /home/grid/.bash_profile<
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
cat >> /home/oracle/.bash_profile<
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
mount /dev/cdrom /mnt
if [ $version=6 ] || [ $version=7 ] ; then
cat > /etc/yum.repos.d/rhel-debuginfo.repo<
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<
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/Server
enabled=1
gpgcheck=0
EOF
fi
yum clean all
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
sed -i 's\SELINUX=enforcing\SELINUX=disabled\' /etc/selinux/config
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
cat >> /etc/hosts<
172.16.0.191 rhel
EOF
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
#添加用户
echo 'oracle' | passwd --stdin oracle
#创建安装目录
mkdir -p /u01/app/oraInventory
#更改目录权限
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
#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<
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
cat >> /etc/profile<
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<
session required pam_limits.so
EOF
#为oracle用户添加环境变量
cat >> /home/oracle/.bash_profile<
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
EOF
source /home/oracle/.bash_profile
#安装oracle所需要的包
yum clean all
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 !"
cat >> /etc/hosts<
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
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 stop firewalld
systemctl disable NetworkManager
chkconfig ntpd off
mv /etc/ntp.conf /etc/ntp.conf.org
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
systemctl stop avahi-daemon
systemctl disable avahi-dnsconfd
systemctl disable avahi-daemon
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
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 oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
#改变内核参数
cat >> /etc/sysctl.conf<
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<
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 10240
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
EOF
cat >> /etc/profile<
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<
session required pam_limits.so
EOF
cat >> /home/grid/.bash_profile<
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
source /home/oracle/.bash_profile
#为oracle用户添加环境变量
cat >> /home/oracle/.bash_profile<
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
EOF
source /home/oracle/.bash_profile
#version=`cat /etc/redhat-release | awk '{print $7}' | awk -F . '{print $1}'`
#mount /dev/cdrom /mnt
cat > /etc/yum.repos.d/rhel-dvd.repo<
name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
baseurl=file:///mnt/
enabled=1
gpgcheck=0
EOF
fi
#cat > /etc/yum.repos.d/rhel-dvd.repo<
#name=Red Hat Enterprise Linux \$releasever - \$basearch - Debug
#baseurl=file:///mnt/Server
#enabled=1
#gpgcheck=0
#EOF
#fi
#安装oracle所需要的包
yum clean all
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
#How To Prevent Bogus Entry 169.254.0.0/255.255.0.0 Automatically Added To Routing Table (文档 ID 1161144.1)
cat > /etc/udev/rules.d/60-oracle-schedulers.rules<
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 control -R
systemctl restart systemd-udevd.service
[always] madvise never
[root@rhel 7 ~]# cat /sys/kernel/mm/transparent_hugepage/enabled
/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
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"
grub2-mkconfig 生成grub.cfg配置文件。
# grub2-mkconfig -o /boot/grub2/grub.cfg
(3).重启系统使配置生效。
#vi ifcfg-eth1
DEVICE=eth1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
BOOTPROTO=none
#vi ifcfg-eth3
DEVICE=eth3
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
BOOTPROTO=none
DEVICE=eth2
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
BOOTPROTO=none
em4参数配置:
DEVICE=eth4
ONBOOT=yes
MASTER=bond1
SLAVE=yes
USERCTL=no
BOOTPROTO=none
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"
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"
注意 dd 使用过的为(一个节点就可以):
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/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
systemctl restart node1
# Created by anaconda
NOZEROCONF=yes
HOSTNAME=node1
用redhat 7新增的hostnamectl命令获取的名称信息则如下:
node2
[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
重启生效
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"
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=="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"
1.linux check package
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
RedHat 6.5离线安装GCC方法
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
==========================================
service iptables stop
chkconfig iptables off
chkconfig --list iptables
setenforce 0
vi /etc/sysconfig/selinux
==========================================
vi /etc/fstab
mount -o remount /dev/shm
free -m
2.MODIFY OS PARAMETER
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
vi /etc/security/limits.conf
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
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
umask 022
fi
/usr/sbin/groupadd -g 600 oinstall
/usr/sbin/groupadd -g 601 dba
************create oracle rdbms location************
chown -R oracle:oinstall /oracle/app/oracle
chmod -R 775 /oracle/app/oracle
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_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
二 安装
vim /etc/oraInst.loc
inst_group=oinstall
2 静默安装 11.2.0.4 采用 debug模式安装 ,如果有异常则更容易发现错误原因。
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
=========================================================================
1. /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,我们可以继续使用静默方式创建数据库。
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 文件。
根据需求编辑好了之后启动监听。
5 登陆数据库
sqlplus / as sysdba
select flashback_on from V$database;
SELECT * FROM NLS_DATABASE_PARAMETERS;
问题一 相信这个问题也是很多人也会遇到
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 加入
inst_group=oinstall
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 目录下,即可解决问题。
Oracle官方文档对oraInventory的说明:
Ensure that you back it up regularly.
Do not delete this directory unless you have completely removed
all Oracle software from the system.
/etc/oraInst.loc (AIX and Linux Platform)
/var/opt/oracle/OraInst.loc (Solaris and HP-UX platform)
问题三:
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.
at oracle.sysman.assistants.util.NetworkUtils.
at oracle.sysman.assistants.util.step.StepContext.
at oracle.sysman.assistants.dbca.backend.Host.
at oracle.sysman.assistants.dbca.backend.SilentHost.
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] {
Please refer to the manual for details.
You can enter one of the following command:
-createDatabase
-templateName
[-cloneTemplate]
-gdbName
[-sid
[-sysPassword
[-systemPassword
[-emConfiguration
-dbsnmpPassword
-sysmanPassword
[-hostUserName
-hostUserPassword
-backupSchedule
[-centralAgent
[-disableSecurityConfiguration
[-datafileDestination
[-redoLogFileSize
[-recoveryAreaDestination
[-datafileJarLocation
[-storageType < FS | ASM >
[-asmsnmpPassword
-diskGroupName
-recoveryGroupName
[-characterSet
[-nationalCharacterSet
[-registerWithDirService
-dirServiceUserName
-dirServicePassword
-walletPassword
[-listeners ]
[-variablesFile
[-variables
[-initParams
[-sampleSchema
[-memoryPercentage
[-automaticMemoryManagement ]
[-totalMemory
[-databaseType
-configureDatabase
-sourceDB
Create a template from an existing database by specifying the following parameters:
-createTemplateFromDB
-sourceDB
-templateName
-sysDBAUserName
-sysDBAPassword
[-maintainFileLocations
Create a clone template from an existing database by specifying the following parameters:
-createCloneTemplate
-sourceSID
-generateScripts
-templateName
-gdbName
[-scriptDest
-deleteDatabase
-sourceDB