Oracle靜默安裝

monkey6發表於2024-06-10

1.安裝前準備

1.1.關閉防火牆和SELINUX

systemctl stop firewalld
systemctl disable firewalld
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

1.2.修改主機名

vi /etc/hostname

1.3.新增hosts解析

vi /etc/hosts
#----------------------------------------------------------
192.168.3.100   oracletest
#----------------------------------------------------------

1.4.關閉透明大頁

cd /etc/default/
cp grub grub.bak
vi grub
#----------------------------------------------------------
GRUB_CMDLINE_LINUX="spectre_v2=retpoline rhgb quiet"
# 修改為
GRUB_CMDLINE_LINUX="spectre_v2=retpoline rhgb quiet transparent_hugepage=never"
#----------------------------------------------------------
# On BIOS-based machines(安裝系統時使用傳統 BIOS的改法):
grub2-mkconfig -o /boot/grub2/grub.cfg
# On UEFI-based machines(安裝系統時使用UEFI-BIOS時的改法):
grub2-mkconfig -o/boot/efi/EFI/redhat/grub.cfg

1.5.修改核心引數

cp /etc/sysctl.conf /etc/sysctl.conf.bak
echo "#oracle" >> /etc/sysctl.conf
echo "kernel.shmmni = 4096" >> /etc/sysctl.conf
echo "fs.aio-max-nr = 1048576" >> /etc/sysctl.conf
echo "fs.file-max = 6815744" >> /etc/sysctl.conf
echo "kernel.sem = 250 32000 100 128" >> /etc/sysctl.conf
echo "net.ipv4.ip_local_port_range = 9000 65500" >> /etc/sysctl.conf
echo "net.core.rmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.rmem_max = 4194304" >> /etc/sysctl.conf
echo "net.core.wmem_default = 262144" >> /etc/sysctl.conf
echo "net.core.wmem_max = 1048586" >> /etc/sysctl.conf
echo "vm.swappiness = 10" >> /etc/sysctl.conf
echo "kernel.shmmax= $(free|grep Mem |awk '{print int($2*1024*0.85)}')" >> /etc/sysctl.conf
echo "kernel.shmall = $(free|grep Mem |awk '{print int(($2*1024*0.85)/4096)}')" >> /etc/sysctl.conf
echo "vm.nr_hugepages = $(free -m|grep Mem |awk '{print int(($2*0.8*0.8)/2)}')" >> /etc/sysctl.conf
free -m
sysctl -p

1.6.修改使用者限制

echo "#oracle" >> /etc/security/limits.conf
echo "oracle soft nproc 2047" >> /etc/security/limits.conf
echo "oracle hard nproc 16384" >> /etc/security/limits.conf
echo "oracle soft nofile 1024" >> /etc/security/limits.conf
echo "oracle hard nofile 65536" >> /etc/security/limits.conf
echo "* soft memlock $(free |grep Mem|awk '{print int($2*0.90*1024)}')" >> /etc/security/limits.conf
echo "* hard memlock $(free |grep Mem|awk '{print int($2*0.90*1024)}')" >> /etc/security/limits.conf

1.7.新增oracle profile

cat >> /etc/profile <<EOF
if [ \$USER = "oracle" ]; then
    if [ \$SHELL = "/bin/ksh" ]; then
       ulimit -u 16384
       ulimit -n 65536
    else
       ulimit -u 16384 -n 65536
    fi
fi
EOF

1.8.建立使用者

#create user
/usr/sbin/groupadd oinstall
/usr/sbin/groupadd dba
/usr/sbin/useradd -g oinstall -G dba oracle
echo "oracle" | passwd --stdin oracle

1.9.配置yum源

# lsblk檢視掛在到伺服器的系統映象
lsblk
# 掛載
mount /dev/sr0 /mnt
cd /etc/yum.repos.d/
vi local.repo
#-------------------------------------------------
[base]
name = local
baseurl = file:///mnt
gpgcheck=0
enable = 1
#-------------------------------------------------

1.10.重啟主機

reboot

2.安裝

2.1.上傳軟體包

cd /data
mkdir soft
chmod 777 soft
# 以oracle使用者的身份把安裝檔案上傳到soft中

2.2.建立oracle_base,oracle_home

mkdir -p /oracle/11204
chown -R oracle.oinstall /oracle
chown -R oracle.oinstall /oradata

2.3.安裝依賴包

compat-libstdc++包在系統映象中不存在,無法使用yum安裝,可以去這裡下載,之後上傳到伺服器安裝。pdksh不是必須的,可以忽略。

cd /data/soft/
yum install compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
yum install -y unzip gcc libaio libaio-devel elfutils-libelf-devel glibc-devel glibc-headers gcc-c++ libstdc++-devel sysstat pdksh

2.3.配置環境變數

cat >> /home/oracle/.bash_profile <<EOF
export TMP=/tmp
export LANG=en_US
export TMPDIR=$TMP
export ORACLE_UNQNAME=oracle
export ORACLE_SID=orcl
export ORACLE_BASE=/oracle
export ORACLE_HOME=/oracle/11204
export ORACLE_TERM=xterm
export NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export PATH=\$PATH:\$ORACLE_HOME/bin:\$ORACLE_HOME/OPatch
export THREADS_FLAG=native
umask=022
EOF
source .bash_profile

2.4.安裝軟體

2.4.1.自定義db_install.rsp
# 解壓安裝介質
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
cd database/response
# 下面的dbca.rsp  db_install.rsp  netca.rsp就是靜默安裝的模板檔案
# 自定義的db_install.rsp檔案
cat >> db_install.rsp <<EOF
#軟體版本資訊
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
#安裝選項-僅安裝資料庫軟體
oracle.install.option=INSTALL_DB_SWONLY
#主機名稱
ORACLE_HOSTNAME=oracle
#oracle使用者用於安裝軟體的組名
UNIX_GROUP_NAME=oinstall
#oracle產品清單目錄
INVENTORY_LOCATION=/oracle/oraInventory
#oracle執行語言環境
SELECTED_LANGUAGES=en
#oracle家目錄
ORACLE_HOME=/oracle/11204
#oracle基礎目錄
ORACLE_BASE=/oracle
#安裝版本型別:企業版
oracle.install.db.InstallEdition=EE
#不手動指定企業安裝元件
oracle.install.db.EEOptionsSelection=false
#當EEOptionsSelection=false時,該引數不用填寫
oracle.install.db.optionalComponents=
#指定擁有DBA組
oracle.install.db.DBA_GROUP=dba
#指定oper使用者組
oracle.install.db.OPER_GROUP=oinstall
#不配置安全更新
DECLINE_SECURITY_UPDATES=true
#跳過更新
oracle.installer.autoupdates.option=SKIP_UPDATES
EOF
2.4.2.靜默安裝
cd /data/soft/database/
# 注意db_install.rsp不能是相對路徑,noconfig意思是不配置資料庫,ignoreprereq忽略oracle安裝要求檢查
./runInstaller -silent -noconfig -ignorePrereq -responseFile /data/soft/db_install.rsp

image-20240610165756119

# root使用者執行
sh /oracle/oraInventory/orainstRoot.sh
sh /oracle/11204/root.sh

image-20240610165905048

2.5.靜默配置監聽

cp /data/soft/database/response/netca.rsp /data/soft/
netca -silent -responsefile /data/soft/netca.rsp

2.6.建立資料庫

2.6.1.自定義dbca.rsp
cat >> dbca.rsp <<EOF
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"

[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
TEMPLATENAME = "General_Purpose.dbc"
SYSPASSWORD = "monkey"
SYSTEMPASSWORD = "monkey"
#是否配置EM
EMCONFIGURATION = "NONE"
#資料檔案路徑
DATAFILEDESTINATION = "/oradata"
#資料庫字符集
CHARACTERSET = "AL32UTF8"
#覆蓋預設初始化引數
INITPARAMS = "processes=500"
#是否使用AMM(我一般使用ASMM,根據自己的需求設定)
AUTOMATICMEMORYMANAGEMENT = "false"
EOF
2.6.2.靜默安裝
dbca -silent -responseFile /data/soft/dbca.rsp

image-20240610170847599

2.6.3.調整引數檔案

根據需要調整引數檔案,例如db_files,control_files,sga_target,pga_aggregate_target等

3.圖形化安裝過程

3.1.軟體安裝

image-20240610111238159

image-20240610111256149

image-20240610111313687

image-20240610111330505

image-20240610111347332

image-20240610111447060

image-20240610111514154

image-20240610111729648

image-20240610111747149

安裝過程如果報錯:

Error in invoking target 'agent nmhs' of makefile '/oracle/11204/sysman/lib/ins_emagent.mk'. See '/oracle/oraInventory/logs/installActions2024-06-10_07-12-06PM.log' for details.

vi $ORACLE_HOME/sysman/lib/ins_emagent.mk

#===========================
# emdctl
#===========================

$(SYSMANBIN)emdctl:
 $(MK_EMAGENT_NMECTL)

修改為

#===========================
# emdctl
#===========================

$(SYSMANBIN)emdctl:
 $(MK_EMAGENT_NMECTL) -lnnz11

image-20240610114157356

3.2.安裝資料庫

image-20240610114451717

image-20240610114504255

image-20240610114540457

image-20240610114601341

image-20240610114615928

image-20240610114631932

image-20240610114743031

image-20240610114801285

image-20240610114822685

image-20240610115014947

image-20240610115027679

image-20240610115053261

image-20240610115108664

image-20240610115135801

image-20240610115209697

相關文章