合 快速静默安装配置Oracle 11g单机环境脚本集合
Tags: Oracle安装部署单机DBA脚本静默安装静默建库脚本集合11gR2shell脚本
基础环境配置
root用户执行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | cat > oracle_install_lhr.sh <<"EOF00" #!/bin/bash #Author: dbaup.com #install package function install_package() { yum install -y openssh-clients openssh-server initscripts net-tools telnet which wget \ passwd e4fsprogs lrzsz sudo unzip lvm2 tree traceroute lsof file tar systemd \ bridge-utils mlocate mailx strace less mmv stress stress-ng iotop htop atop nmon \ dstat bcc-tools bcc yum-utils yum install -y dos2unix rlwrap xdpyinfo xorg-x11-apps nmap numactl numactl-devel \ iproute rsyslog bash-completion tmux sysbench vim redhat-lsb smartmontools xinetd \ gcc make sysstat ksh binutils socat cmake automake autoconf bzr bison libtool deltarpm \ rsync libev pv subversion gnuplot jq oniguruma yum-fastestmirror net-snmp net-snmp-utils \ nfs-utils rpcbind postfix dovecot bind-utils bind bind-chroot dnsmasq haproxy keepalived bzr \ fio bzip2 ntp flex lftp targetd targetcli iscsi-initiator-utils siege aria2 \ nethogs vnstat nload iptraf bmon bwm-ng trafshow collectl yum install -y ncurses-devel libgcrypt-devel libaio libaio-devel \ perl perl-Env perl-devel perl-Time-HiRes perl-DBD-MySQL perl-ExtUtils-MakeMaker perl-TermReadKey \ perl-Config-Tiny perl-Email-Date-Format perl-Log-Dispatch perl-Mail-Sender perl-Mail-Sendmail \ perl-MIME-Lite perl-Parallel-ForkManager perl-Digest-MD5 perl-ExtUtils-CBuilder perl-IO-Socket-SSL \ perl-JSON openssl-devel libverto-devel libsepol-devel libselinux-devel libkadm5 keyutils-libs-devel \ krb5-devel libcom_err-devel cyrus-sasl* perl-DBD-Pg perf slang perl-DBI perl-CPAN \ perl-ExtUtils-eBuilder cpan perl-tests yum install -y compat-libstdc++-33 gcc-c++ glibc glibc-common glibc.i686 glibc-devel glibc-devel.i686 \ libgcc libgcc.i686 libstdc++ libstdc++-devel libaio.i686 libaio-devel.i686 \ libXext libXext.i686 libXtst libXtst.i686 libX11 libX11.i686 libXau libXau.i686 \ libxcb libxcb.i686 libXi libXi.i686 unixODBC unixODBC-devel zlib-devel zlib-devel.i686 \ compat-libcap1 libXp libXp-devel libXp.i686 elfutils-libelf elfutils-libelf-devel compat-db \ gnome-libs pdksh xscreensaver fontconfig-devel libXrender-devel yum install -y git firefox python3 python-setuptools java-1.8.0-openjdk* golang \ tomcat tomcat-webapps tomcat-admin-webapps xorg-x11-apps wget http://repos.fedorapeople.org/repos/dchen/apache-maven/epel-apache-maven.repo -O /etc/yum.repos.d/epel-apache-maven.repo yum -y install apache-maven groupinstall Fonts cjkuni-ukai-fonts ibus.x86_64 ibus-libpinyin.x86_64 \ xorg-x11-xauth wqy-zenhei-fonts* libXfont xorg-x11-fonts* wqy* yum -y install xrdp && yum groupinstall -y Xfce } #base_config function base_config() { #hostname hostnamectl set-hostname oraclelhr #close selinux sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config setenforce 0 #close firewalld systemctl stop firewalld && systemctl disable firewalld #add user and group groupadd oinstall && groupadd dba && groupadd oper && useradd -g oinstall -G dba,oper oracle \ && echo "lhr" | passwd oracle --stdin #mkdir oracle need directory ORACLE_BASE='/u01/app/oracle' mkdir -p ${ORACLE_BASE}/product/11.2.0/dbhome_1 && chmod -R 775 ${ORACLE_BASE} \ && chown -R oracle:oinstall ${ORACLE_BASE} ORACLE_INVENTORY='/u01/app/oraInventory' mkdir -p ${ORACLE_INVENTORY} && chmod -R 775 ${ORACLE_INVENTORY} \ && chown -R oracle:oinstall ${ORACLE_INVENTORY} echo "export CATALINA_HOME=/usr/share/tomcat" >> /root/.bashrc echo "export PATH=$PATH:/usr/share/bcc/tools">> /etc/profile source /root/.bashrc cat >> /root/.bashrc <<"EOF" alias ll='ls -l --color=never' alias ls='ls --color=never' alias vi='vim' EOF mkdir /soft chmod 777 /soft mkdir -p ~/.pip cat > ~/.pip/pip.conf << EOF [global] index-url = https://pypi.douban.com/simple/ EOF sed -i 's/max_bpp=32/max_bpp=24/g' /etc/xrdp/xrdp.ini echo xfce4-session > /root/.xsession chmod +x /root/.xsession echo xfce4-session > /home/oracle/.xsession chmod +x /home/oracle/.xsession systemctl restart xrdp && systemctl enable xrdp #modify some file echo 'fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmmni = 4096 kernel.shmall = 1073741824 kernel.shmmax = 4398046511104 kernel.panic_on_oops = 1 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 net.ipv4.conf.all.rp_filter = 2 net.ipv4.conf.default.rp_filter = 2 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500 ' >> /etc/sysctl.conf && sysctl -p echo 'oracle soft nofile 1024 oracle hard nofile 65536 oracle soft nproc 16384 oracle hard nproc 16384 oracle soft stack 10240 oracle hard stack 32768 ' >> /etc/security/limits.conf echo 'session required /lib64/security/pam_limits.so session required pam_limits.so ' >> /etc/pam.d/login echo 'if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi fi ' >> /etc/profile #add oracle environmental variable cat >> /home/oracle/.bash_profile <<"EOF" export TMP=/tmp export TMPDIR=$TMP export ORACLE_SID=lhrdb export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1 export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib export NLS_DATE_FORMAT='YYYY-MM-DD HH24:mi:ss' alias sqlplus='rlwrap sqlplus' alias rman='rlwrap rman' alias sas='sqlplus / as sysdba' EOF } function main() { install_package && \ base_config } #run script main EOF00 |
运行:
1 2 | chmod +x oracle_install_lhr.sh nsh oracle_install_lhr.sh & |
静默安装软件和静默建库
oracle用户执行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | -- 解压 unzip p13390677_112040_Linux-x86-64_1of7.zip -d /tmp > /dev/null && unzip p13390677_112040_Linux-x86-64_2of7.zip -d /tmp > /dev/null -- 静默安装软件 /tmp/database/runInstaller -silent -force -noconfig -IgnoreSysPreReqs -ignorePrereq -showProgress \ oracle.install.option=INSTALL_DB_SWONLY \ DECLINE_SECURITY_UPDATES=true \ UNIX_GROUP_NAME=oinstall \ INVENTORY_LOCATION=/u01/app/oraInventory \ SELECTED_LANGUAGES=en \ 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.OPER_GROUP=dba \ oracle.install.db.isRACOneInstall=false \ oracle.install.db.config.starterdb.type=GENERAL_PURPOSE \ SECURITY_UPDATES_VIA_MYORACLESUPPORT=false \ oracle.installer.autoupdates.option=SKIP_UPDATES -- root用户执行 /u01/app/oraInventory/orainstRoot.sh /u01/app/oracle/product/11.2.0/dbhome_1/root.sh -- 响应文件配置 vi /tmp/database/response/db_install.rsp ORACLE_HOSTNAME=192.168.59.129 UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u02/app/oracle/oraInventory SELECTED_LANGUAGES=en,zh_CN ORACLE_HOME=/u02/app/oracle/product/11.2.0/dbhome_1 ORACLE_BASE=/u02/app/oracle oracle.install.db.InstallEdition=EE oracle.install.db.EEOptionsSelection=false oracle.install.db.DBA_GROUP=dba oracle.install.db.OPER_GROUP=oper oracle.install.db.isRACOneInstall=false oracle.install.db.config.starterdb.type=GENERAL_PURPOSE SECURITY_UPDATES_VIA_MYORACLESUPPORT=false oracle.installer.autoupdates.option=SKIP_UPDATES ----软件安装 ./runInstaller -silent -noconfig -responseFile /tmp/database/response/db_install.rsp -ignoreSysPrereqs -ignorePrereq -- 调试 ./runInstaller -debug -logLevel finest strace ./runInstaller |