基础环境配置
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 && 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
运行:
chmod +x oracle_install_lhr.sh
nsh oracle_install_lhr.sh &
静默安装软件和静默建库
oracle用户执行:
-- 解压
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
静默建库
-- 静默建库
-- 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、开机启动
vim /etc/oratab
LHR11G:/u01/app/oracle/product/11.2.0/dbhome_1:Y
cat >> /etc/rc.d/rc.local <<"EOF"
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
su oracle -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
EOF
chmod +x /etc/rc.d/rc.local
3、密码文件
orapwd file=orapworcl force=y password=oracle