静默安装Oracle 12c单机环境软件

简介: 静默安装Oracle 12c单机环境软件

基础环境配置

root用户执行:

cat > oracle_install_lhr.sh <<"EOF00"
#!/bin/bash
#Author: xmmup.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 && groupadd backupdba && groupadd dgdba && \
  groupadd kmdba && useradd -g oinstall -G dba,oper,backupdba,dgdba,kmdba oracle \
  && echo "lhr" | passwd oracle --stdin

  #mkdir oracle need directory
  ORACLE_BASE='/u01/app/oracle'
  mkdir -p ${ORACLE_BASE}/product/12.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/12.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

运行:

chmod +x oracle_install_lhr.sh 
sh oracle_install_lhr.sh &

静默安装软件和静默建库

静默安装软件

oracle用户执行:

-- 解压
unzip /soft/linuxx64_12201_database.zip -d /tmp >  /dev/null

-- 静默12c安装软件
/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/12.2.0/dbhome_1 \
ORACLE_BASE=/u01/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.isCustomInstall=false \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=oper \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_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


-- 静默安装18c数据库单机软件
/u08/app/oracle/product/18.0.0/dbhome_1/runInstaller -silent  -force -noconfig  -ignorePrereq \
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v18.0.0 \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u00/app/oraInventory \
ORACLE_BASE=/u08/app/oracle \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=oper \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=dba \
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE




-- 静默安装 19c 数据库单机软件
/u19/app/oracle/product/19.2.0/dbhome_1/runInstaller -silent  -force -noconfig  -ignorePrereq \
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0 \
oracle.install.option=INSTALL_DB_SWONLY \
UNIX_GROUP_NAME=oinstall \
INVENTORY_LOCATION=/u19/app/oraInventory \
ORACLE_BASE=/u19/app/oracle \
ORACLE_HOME=/u19/app/oracle/product/19.2.0/dbhome_1 \
oracle.install.db.InstallEdition=EE \
oracle.install.db.OSDBA_GROUP=dba \
oracle.install.db.OSOPER_GROUP=oper \
oracle.install.db.OSBACKUPDBA_GROUP=backupdba \
oracle.install.db.OSDGDBA_GROUP=dgdba \
oracle.install.db.OSKMDBA_GROUP=kmdba \
oracle.install.db.OSRACDBA_GROUP=racdba \
oracle.install.db.rootconfig.executeRootScript=true \
oracle.install.db.rootconfig.configMethod=ROOT
  
  
-- root用户执行
/u01/app/oraInventory/orainstRoot.sh
/u01/app/oracle/product/12.2.0/dbhome_1/root.sh

静默建库


-- 静默建库
-- dbca -silent -deleteDatabase -sourceDB lhrdb
dbca -silent -createDatabase -templateName General_Purpose.dbc -responseFile NO_VALUE \
-gdbname lhrdb  -sid lhrdb \
-sysPassword lhr -systemPassword lhr \
-datafileDestination '/u01/app/oracle/oradata' \
-recoveryAreaDestination '/u01/app/oracle/flash_recovery_area' \
-redoLogFileSize 50 \
-storageType FS \
-characterset AL32UTF8 -nationalCharacterSet AL16UTF16 \
-sampleSchema true \
-memoryPercentage 10 \
-databaseType OLTP  \
-emConfiguration NONE



监听

-- 监听
netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp
lsnrctl status


----监听配置
$ORACLE_HOME/bin/netca /silent /responsefile /u01/database/netca.rsp
netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp

$ORACLE_HOME/bin/netca /silent /responsefile /u01/database/netca.rsp
netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp
netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp -instype custom -listener LISTENER -lisport 1521
netca -silent -responsefile $ORACLE_HOME/assistants/netca/netca.rsp -instype custom -listener LISTENER_LHR -lisport 1522
crsctl delete resource ora.LISTENER.lsnr -f
rm $ORACLE_HOME/network/admin/listener.ora

其它配置

1、大页

配置大页:https://www.xmmup.com/oracleshujukupeizhidaye.html

cat >> /etc/security/limits.conf <<"EOF"

*   soft   memlock   -1
*   hard   memlock   -1

EOF


alter system set MEMORY_TARGET=0 scope=spfile sid='*';
alter system set MEMORY_MAX_TARGET=0 scope=spfile sid='*';

alter system reset memory_target  scope=spfile ;
alter system reset memory_max_target  scope=spfile ;


echo -e 'vm.nr_hugepages=88850' >> /etc/sysctl.conf 
echo 88850 > /proc/sys/vm/nr_hugepages

2、ORA-28040: No matching authentication protocol

cat >> $ORACLE_HOME/network/admin/sqlnet.ora <<"EOF"
SQLNET.ALLOWED_LOGON_VERSION_SERVER=10
SQLNET.ALLOWED_LOGON_VERSION_CLIENT=10
EOF

3、开机启动

vim /etc/oratab
LHR11G:/u01/app/oracle/product/12.2.0/dbhome_1:Y

cat >> /etc/rc.d/rc.local <<"EOF"

export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
su oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
EOF

chmod +x /etc/rc.d/rc.local

4、密码文件

orapwd file=orapworcl force=y  password=oracle format=12
目录
相关文章
|
3月前
|
机器学习/深度学习 Oracle 关系型数据库
Oracle 19c单机一键安装脚本分享
Oracle 19c单机一键安装脚本分享
194 2
|
4月前
|
存储 Oracle 关系型数据库
|
4月前
|
SQL Oracle 关系型数据库
关系型数据库Oracle设置 RMAN 环境:
【7月更文挑战第25天】
69 2
|
4月前
|
存储 Oracle 关系型数据库
Oracle 12c支持哪些数据类型?
【7月更文挑战第20天】Oracle 12c支持哪些数据类型?
84 2
|
4月前
|
SQL Oracle 关系型数据库
Oracle 12c有哪些新特性?
【7月更文挑战第20天】Oracle 12c有哪些新特性?
67 2
|
6月前
|
SQL Oracle 关系型数据库
实时计算 Flink版产品使用合集之在oracle cdc2.3 + flink1.7环境下只能初始化同步数据,但后续Oracle的增删改查无法同步出去,是什么导致的
实时计算Flink版作为一种强大的流处理和批处理统一的计算框架,广泛应用于各种需要实时数据处理和分析的场景。实时计算Flink版通常结合SQL接口、DataStream API、以及与上下游数据源和存储系统的丰富连接器,提供了一套全面的解决方案,以应对各种实时计算需求。其低延迟、高吞吐、容错性强的特点,使其成为众多企业和组织实时数据处理首选的技术平台。以下是实时计算Flink版的一些典型使用合集。
|
6月前
|
SQL Oracle 关系型数据库
Oracle 12c的TOP N语句:数据排名的“快速通道”
【4月更文挑战第19天】Oracle 12c的TOP N语句是用于快速获取数据集排名前N的记录的SQL查询方法,特别适合寻找最具代表性的数据。通过指定排序条件和数量,TOP N能高效筛选出所需信息,例如最高销售额产品或最大访问量网页。在Oracle 12c中,查询优化器对TOP N查询进行了优化,保证快速返回结果,并提供丰富的排序和过滤选项。基本用法如`SELECT ... ORDER BY ... FETCH FIRST N ROWS ONLY`,还可结合`OFFSET`进行分页查询或用`WITH TIES`保持结果完整性。掌握TOP N语句能提升数据分析效率,助力企业决策。
|
6月前
|
存储 Oracle 关系型数据库
Oracle 12c的临时UNDO:数据的“临时保镖”
【4月更文挑战第19天】Oracle 12c引入的临时UNDO为数据安全提供新保障。它为临时操作和特定事务提供独立UNDO空间,避免共享UNDO带来的性能瓶颈和管理复杂性。临时UNDO随事务开始分配,记录修改历史,事务结束后自动释放。优点包括提高性能、简化管理及保证数据一致性。但需注意手动配置、监控和优化,以防长时间占用资源。了解其工作原理和最佳实践是提升数据库性能的关键。

推荐镜像

更多