redhat7.2靜默安裝Oracle11.2.0.4

大大的地雷發表於2018-03-27

redhat7.2靜默安裝Oracle11.2.0.4
我們將oracle安裝到/opt/oracle目錄下,後面的環境變數則以此為基礎。

一、設定主機hosts對映

vi /etc/hosts
[plain] view plain copy

    127.0.0.1       localhost  
    192.168.61.110  DB  

二、依賴庫安裝
[plain] view plain copy

    yum install -y compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel  
    yum install -y ksh libaio-devel numactl-devel  
    yum install -y unixODBC unixODBC-devel oracleasm oracleasmlib oracleasm-support  

關於依賴庫的安裝,說明一下,這裡可以使用安裝虛擬機器的映象來做本地yum源,這些依賴庫都在作業系統映象中。本地yum源的製作過程如下:

首先上傳映象到hadoop使用者的Downloads目錄下,然後掛載該映象。
[plain] view plain copy

    mkdir /media/cdrom  
    mount -o loop -t iso9660 /home/hadoop/Downloads/rhel-server-7.0-x86_64-dvd.iso /media/cdrom/  
    vi /etc/yum.repo.d/redhat-base.repo  

編輯本地yum源配置檔案
[plain] view plain copy

    [redhat-base]  
    name=redhat-base  
    baseurl=file:///media/cdrom  
    gpgcheck=0  
    enable=1  

然後執行 yum repolist,接下來就可以進行yum install各種依賴庫。

三、使用者和使用者組準備
[plain] view plain copy

    groupadd dba  
    groupadd oinstall  
    useradd -g oinstall -G dba oracle  

此外,需要用oracle使用者操作,需要為oracle使用者設定密碼,利用root使用者為oracle設定密碼
[plain] view plain copy

    passwd oracle  

出現輸入密碼提示,輸入兩次一致密碼即可。

四、系統引數調整

/etc/sysctl.conf
[plain] view plain copy

    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  

使用命令sysctl -p讓配置生效

/etc/security/limits.conf
[plain] view plain copy

    oracle   soft   nofile    1024  
    oracle   hard   nofile    65536  
    oracle   soft   nproc    16384  
    oracle   hard   nproc    16384  
    oracle   soft   stack    10240  
    oracle   hard   stack    32768  
    oracle   hard   memlock    134217728  
    oracle   soft   memlock    134217728  

五、安裝目錄設定
[plain] view plain copy

    mkdir -p /opt/oracle  
    mkdir -p /opt/database  
    mkdir -p /opt/oraInventory  
    chown -R oracle:oinstall /opt/app  
    chmod 755 /opt/app  

六、環境變數設定

修改oracle家目錄下的.bash_profile檔案,新增如下變數
[plain] view plain copy
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export ROACLE_PID=ora11g
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export ORACLE_SID=orcl11g

oracle使用者登入並執行 source ~/.bash_profile讓環境變數生效。

在環境準備的過程中,其實可以讓工具幫我們完成二三四步驟,安裝依賴,建立使用者和使用者組,修改系統引數。這裡介紹利用網路來安裝的一種辦法。

1、下載yum源的配置檔案
[plain] view plain copy

    wget http://public-yum.oracle.com/public-yum-ol7.repo -O /etc/yum.repos.d/  
    wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle  
    yum repolist  
    yum makecache  

我們可以通過命令看看已經有了oracle-rdbms-server-11gR2-preinstall的安裝包可以使用了。

2、通過yum安裝oracle_rdbms_server_11gR2_preinstall即可完成手動操作的二三四步。

解壓上傳的 p13390677_112040_Linux-x86-64_1of7.zip, p13390677_112040_Linux-x86-64_2of7.zip兩個檔案得到資料的安裝資料夾database(筆者的oracle的安裝檔案在下載並解壓在/home/oracle目錄下):
/home/oracle/database/response目錄下有幾個關於oracle的安裝檔案,這裡因為沒有圖形介面所以使用Oracle的靜默安裝方式:
 ./runInstaller -silent -debug -force
FROM_LOCATION=/home/oracle/database/stage/products.xml
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/opt/oraInventory
ORACLE_HOME=/opt/oracle/product/11.2.0/db_1
ORACLE_HOME_NAME=”Oracle111″
ORACLE_BASE=/opt/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
具體參見:http://blog.itpub.net/4227/viewspace-688497/
完成安裝:Successfully Setup Software.出此日誌則表示安裝完成。

6.另開視窗,用root使用者執行下面的指令碼

/opt/oracle/oraInventory/orainstRoot.sh
/opt/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh

7.配置監聽程式

netca /silent /responsefile /home/oracle/data/response/netca.rsp
成功執行後,在/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin目錄下生成sqlnet.ora和listener.ora兩個檔案。
通過 netstat -tlnp 命令,看到
tcp 0 0 0.0.0.0:1521 0.0.0.0:* LISTEN 22494/tnslsnr
說明監聽器已經在1521埠上開始工作了
檢視監聽:lsnrctl status

安裝oracle資料庫:

dbca -silent -responseFile /home/oracle/database/response/dbca.rsp

建庫後例項檢查:

ps -ef | grep ora_ | grep -v grep

參考:
https://blog.csdn.net/doegoo/article/details/53020892
https://blog.csdn.net/feinifi/article/details/78412954
http://blog.itpub.net/4227/viewspace-688497/
http://www.mamicode.com/info-detail-1462357.html

 

相關文章