天天看點

Redhat6.6 圖形化安裝 oracle12c

環境說明

  1. 下載下傳好Redhat6.6,在VMware Station12安裝,選擇安裝圖形化界面。下載下傳oracle12c linuxamd64_12102_database.zip 并解壓到database
  2. 啟動Redhat6.6 64位,點選菜單 虛拟機->VMware-tools安裝。
  3. 在指令行中根使用者執行如下指令,進行VMware-tools安裝

    cd /media/VMware\ Tools/

    cp VMwareTools-10.0.0-*.tar.gz ~

    cd ~

    tar zxf VMwareTools-10.0.0-*.tar.gz

    rm VMwareTools-10.0.0-*.tar.gz

    cd vmware-tools-distrib/

    ./vmware-intall.pl

    之後一路回車即可

    這裡安裝這個工具主要是後面使用共享檔案夾
  4. 點選虛拟機設定->選項->共享檔案夾 共享database
  5. 回到指令行,cd /mnt/hgfs/database,這裡就是oracle12g的安裝檔案

配置安裝Oracle的系統環境

  1. uname -a 檢查linux版本,32 or 64
  2. 建立oracle使用者及管理組

    以root使用者登入linux,執行以下指令

    #groupadd dba 建立管理組      #groupadd oinstall 建立安裝組      #useradd oracle -g oinstall -G dba      #passwd oracle     oracle           
    檢查是否存在 nobody 使用者:idnobody ,沒有則添加: Useradd nobody
  3. 建立用于安裝 oracle 的目錄結構并賦權:
    #mkdir /opt/oracle/     #mkdir /opt/oracle/oradata     #mkdir /opt/oracle/product     #chown -R oracle.oinstall /opt/oracle     #mkdir /opt/oraInventory     #chown -R oracle.oinstall /opt/oraInventory/           
  4. 建立 oracle 環境變量:

    使用上面建立的 oracle 使用者登入:

    #su - oracle     $vi /home/oracle/.bash_profile     在檔案中添加如下:     umask 022     export ORACLE_BASE=/opt/oracle     export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/dbhome_1      export ORACLE_SID=orcl     export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin     export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib     儲存退出      --執行以下指令讓配置馬上生效或以 oracle 使用者登入使設定生效      $source $HOME/.bash_profile           
  5. 設定系統核心參數:

    切回root使用者:su root

    其中給出的是最小值,是以如果你的系統使用的值較大,則不要更改他

    #vi /etc/sysctl.conf

    fs.file-max=6815744

    fs.aio-max-nr= 1048576

    kernel.shmall= 2097152

    kernel.shmmax=2147483648

    kernel.shmmni=4096

    kernel.sem=25032000100128

    net.ipv4.ip_local_port_range= 900065500

    net.core.rmem_default=4194304

    net.core.rmem_max=4194304

    net.core.wmem_default= 262144

    net.core.wmem_max= 1048576

    修改後運作"/sbin/sysctl -p"指令使得核心改變立即生效

  6. 對oracle使用者進行限制配置:

    vi /etc/security/limits.conf

    oracle soft nproc 2047      oracle hard nproc 16384   //對 oracle 使用者的 process 最大 16384 個     oracle soft nofile 1024      oracle hard nofile 65536 //對 oracle 使用者檔案數量限制是 65535 個     編輯檔案:vi /etc/pam.d/login 加入以下語句(可能應該加在最後一條規則之前):     session required /lib64/security/pam_limits.so     session required pam_limits.so           

安裝oracle

  1. 解壓oracle:

    前面已經解壓設定成共享目錄,可以跳過解壓,但需要移動到根目錄改權限,如果沒有解壓直接上傳到伺服器的,可以執行如下指令:

    #unzip linux*_1of2.zip     #unzip linux*_2of2.zip     注意解壓好的目錄使用者oracle必須具有讀寫和執行的權限,可以将目錄的使用者和使用者組設定為oracle。也可以拷貝到$ORACLE_BASE或者oracle使用者的home下:     #chown -R oracle database     #chgrp -R oinstall database           
  2. reboot并以oracle登入,進入圖形界面
    #cd database     #./runInstaller           

    這裡會出現核心參數配置不對,可能是前面配置核心的參數是參考安裝oracle 11g的參數的問題,依賴包也缺少

    (1)解決依賴包

    因為這裡安裝Redhat6.6的時候沒有注冊,沒有線上源,這裡先說明一下如何配置本地源

    1)虛拟機挂在安裝Redhat6.6的鏡像

    2)添加本地源:

    # cd /etc/yum.repos.d/     # vi rhel-source.repo     最後添加:     [rhel_local_01]     name=Red Hat Enterprise Linux $releasever - $basearch - Source33333     baseurl=file:///media/"RHEL-6.6 Server.x86_64"     gpgcheck=1     # yum clean all     導入公鑰:     rpm --import /etc/pki/rpm-gpg/RPM*           
    3)安裝依賴
    [root@localhost ~]# yum install compat-libcap1 compat-libstdc++-33 libstdc++-devel gcc gcc-c++ ksh libaio-devel     依賴關系解決     ============================================ ============================================     軟體包                    架構         版本                  倉庫                 大小     ========================================================================================     正在安裝:     compat-libcap1            x86_64       1.10-1                rhel-local-01        17 k     compat-libstdc++-33       x86_64       3.2.3-69.el6          rhel-local-01       183 k     gcc                       x86_64       4.4.7-11.el6          rhel-local-01        10 M     gcc-c++                   x86_64       4.4.7-11.el6          rhel-local-01       4.7 M     ksh                       x86_64       20120801-21.el6       rhel-local-01       758 k     libaio-devel              x86_64       0.3.107-10.el6        rhel-local-01        13 k     libstdc++-devel           x86_64       4.4.7-11.el6          rhel-local-01       1.6 M     為依賴而安裝:     cloog-ppl                 x86_64       0.15.7-1.2.el6        rhel-local-01        93 k     cpp                       x86_64       4.4.7-11.el6          rhel-local-01       3.7 M     mpfr                      x86_64       2.4.1-6.el6           rhel-local-01       156 k     ppl                       x86_64       0.10.2-11.el6         rhel-local-01       1.3 M     事務概要     ========================================================================================     Install      11 Package(s)     總下載下傳量:23 M     Installed size: 56 M     确定嗎?[y/N]:y     已安裝:     compat-libcap1.x86_64 0:1.10-1           compat-libstdc++-33.x86_64 0:3.2.3-69.el6        gcc.x86_64 0:4.4.7-11.el6                gcc-c++.x86_64 0:4.4.7-11.el6                    ksh.x86_64 0:20120801-21.el6             libaio-devel.x86_64 0:0.3.107-10.el6             libstdc++-devel.x86_64 0:4.4.7-11.el6        作為依賴被安裝:     cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-11.el6 mpfr.x86_64 0:2.4.1-6.el6     ppl.x86_64 0:0.10.2-11.el6           

    (2)解決核心參數

    因為核心參數的問題是可修複的,點選修補并再次檢查

    這裡說明隻要根使用者執行指定腳本即可

[root@localhost ~]# /tmp/CVU_12.1.0.2.0_oracle/runfixup.sh           

核心參數變化如下:(通過/sbin/sysctl -p指令)

修改前:     net.ipv4.ip_forward = 0     net.ipv4.conf.default.rp_filter = 1     net.ipv4.conf.default.accept_source_route = 0     kernel.sysrq = 0     kernel.core_uses_pid = 1     net.ipv4.tcp_syncookies = 1     error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key     error: "net.bridge.bridge-nf-call-iptables" is an unknown key     error: "net.bridge.bridge-nf-call-arptables" is an unknown key     kernel.msgmnb = 65536     kernel.msgmax = 65536     kernel.shmmax = 68719476736     kernel.shmall = 4294967296     fs.file-max = 6815744     fs.aio-max-nr = 1048576     kernel.shmmni = 4096     kernel.sem = 25032000100128     error: "Invalid argument" setting key "net.ipv4.ip_local_port_range"     net.core.rmem_default = 4194304     net.core.rmem_max = 4194304     net.core.wmem_default = 262144     net.core.wmem_max = 1048576     修改後:     net.ipv4.ip_forward = 0     net.ipv4.conf.default.rp_filter = 1     net.ipv4.conf.default.accept_source_route = 0     kernel.sysrq = 0     kernel.core_uses_pid = 1     net.ipv4.tcp_syncookies = 1     error: "net.bridge.bridge-nf-call-ip6tables" is an unknown key     error: "net.bridge.bridge-nf-call-iptables" is an unknown key     error: "net.bridge.bridge-nf-call-arptables" is an unknown key     kernel.msgmnb = 65536     kernel.msgmax = 65536     kernel.shmmax = 68719476736     kernel.shmall = 4294967296     fs.file-max = 6815744     fs.aio-max-nr = 1048576     kernel.shmmni = 4096     kernel.sem = 930699040  32000   100 128     net.ipv4.ip_local_port_range = 9000   65535     net.core.rmem_default = 4194304     net.core.rmem_max = 4194304     net.core.wmem_default = 262144     net.core.wmem_max = 1048576           

确定即可

儲存響應檔案,以備以後靜默安裝oralce使用

之後等待即可

執行配置腳本:     [root@localhost ~]# /opt/oraInventory/orainstRoot.sh      更改權限/opt/oraInventory.     添加組的讀取和寫入權限。     删除全局的讀取, 寫入和執行權限。     更改組名/opt/oraInventory 到 oinstall.     腳本的執行已完成。     [root@localhost ~]# /opt/oracle/product/12.1.0/dbhome_1/root.sh      Performing root user operation.     The following environment variables are set as:         ORACLE_OWNER= oracle         ORACLE_HOME=  /opt/oracle/product/12.1.0/dbhome_1     Enter the full pathname of the local bin directory: [/usr/local/bin]: /usr/local/bin        Copying dbhome to /usr/local/bin ...        Copying oraenv to /usr/local/bin ...        Copying coraenv to /usr/local/bin ...     Creating /etc/oratab file...     Entries will be added to the /etc/oratab file as needed by     Database Configuration Assistant when a database is created     Finished running generic part of root script.     Now product-specific root actions will be performed.           
指令行顯示此次安裝日志的位置:     .[oracle@localhost database]$      [oracle@localhost database]$ 可以在以下位置找到本次安裝會話的日志:      /opt/oraInventory/logs/installActions2015-12-14_12-39-07PM.log           

安裝資料庫

執行指令

$dbca

安裝監聽

$netca

進入圖形化配置,直接預設下一步,到最後完成,其中你也可以修改監聽器的名稱,協定,端口

指令行顯示     Oracle Net Services 配置:     正在配置監聽程式:LISTENER     監聽程式配置完成。     Oracle Net 監聽程式啟動:         正在運作監聽程式控制:            /opt/oracle/product/12.1.0/dbhome_1/bin/lsnrctl start LISTENER         監聽程式控制完成。         監聽程式已成功啟動。     成功完成 Oracle Net Services 配置。退出代碼是0           

安裝完畢後的一些測試、配置及檢查

  1. 配置oracle随機啟動

    (1)修改/etc/oratab檔案,需要将orcl:/opt/oracle/product/12.1.0/dbhome_1:N最後的N改成Y(如果/etc/oratab檔案不存在,則需要使用root使用者執行$ORACLE_HOME/root.sh檔案)

    #cat /etc/oratab     orcl:/opt/oracle/product/12.1.0/dbhome_1:Y           
    (2)使用oracle的安裝使用者(oracle)修改$ORACLE_HOME/bin/dbstart檔案,修改之前最好備份一下,使用如下指令
    #cp $ORACLE_HOME/bin/dbstart $ORACLE_HOME/bin/dbstart.bak     找到     ORACLE_HOME_LISTNER=...,     修改成     ORACLE_HOME_LISTNER=/opt/oracle/product/12.1.0/dbhome_1     或者直接修改成:     ORACLE_HOME_LISTNER=$ORACLE_HOME           

    (3)測試運作dbshut, dbstart

    1)修改dbstart和dbshut的日志檔案的權限(如果這兩個檔案不存在,先手工touch):

    root使用者先建立這兩個檔案,不建立也可以,系統會自動建立在$ORACLE_HOME下。

    #cd $ORACLE_HOME/bin     #touch startup.log     #chown oracle.oinstall startup.log     #chmod 755 startup.log     #touch shutdown.log     #chown oracle.oinstall shutdown.log     #chmod 755 shutdown.log     #ls -l startup.log shutdown.log           
    2)執行相應的腳本進行測試
    #su - oracle     $cd $ORACLE_HOME     $dbshut (or dbstart)           
    3)建立oracle服務啟動腳本oradb(使用root使用者),建立後可以使用oradb start|stop 指令。
    #touch /home/oracle/oradb     #chown oracle.oinstall /home/oracle/oradb     #chmod 775 /home/oracle/oradb     腳本内容如下:     #!/bin/sh     # description: Oracle auto start-stop script.      # chkconfig: - 20 80     #     # Set ORA_HOME to be equivalent to the $ORACLE_HOME     # from which you wish to execute dbstart and dbshut;     #     # Set ORA_OWNER to the user id of the owner of the     # Oracle database in ORA_HOME.     ORA_HOME=/opt/oracle/product/12.1.0/dbhome_1/     ORA_OWNER=oracle     if [ ! -f $ORA_HOME/bin/dbstart ]     then     echo "Oracle startup: cannot start"     exit     fi     case "$1" in     'start')     # Start the Oracle databases:     # The following command assumes that the oracle login     # will not prompt the user for any values     su - $ORA_OWNER -c $ORA_HOME/bin/dbstart     su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start"     ;;     'stop')     # Stop the Oracle databases:     # The following command assumes that the oracle login     # will not prompt the user for any values     su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop"     su - $ORA_OWNER -c $ORA_HOME/bin/dbshut     ;;     'restart')     $0 stop     $0 start     ;;     esac           
    把該腳本copy到/etc/init.d/目錄下     #cp /home/oracle/oradb /etc/init.d/oradb     将oradb加入到系統啟動清單中     #chkconfig --add /home/oracle/oradb 注:一定要在/etc/init.d/目錄下執行     #chkconfig --list oradb           
    測試快速啟動指令:
    #/etc/init.d/oradb stop     #/etc/init.d/oradb start           
    重新開機linux #reboot 在linux啟動的時候,會偏慢
    # su - oracle     # ps -ef | grep ora           

    (4)測試連接配接資料庫

    用oracle使用者遠端登陸,然後

[oracle@localhost ~]$ sqlplus /nolog     SQL*Plus: Release 12.1.0.2.0 Production on Mon Dec 14 23:30:15 2015     Copyright (c) 1982, 2014, Oracle.  All rights reserved.     SQL> conn / as sysdba     Connected.      SQL> create table testUser(id integer, name char(10));     Table created.     SQL> insert into testUser values(0, 'Jack');     1 row created.     SQL> commit;     Commit complete.     SQL> select * from testUser;         ID NAME     ---------- ----------          0 Jack     SQL> shutdown immediate     Database closed.     Database dismounted.     ORACLE instance shut down.     SQL> quit     Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production     With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options           

到此,oracle安裝完畢

參考

oracle自啟動腳本

安裝Linux版本的oracle11g單機版.PDF

Oracle Enterprise Manager 12c 安裝過程