oracle單機數據庫搭建巨詳細文檔


規划

 

環境:redhat6.9

安裝包:p13390677_112040_Linux-x86-64_1of7.zip

p13390677_112040_Linux-x86-64_2of7.zip

 

數據庫配置

ORACLE_SID=csk;

ORACLE_BASE=/home/app/oracle;

ORACLE_HOME= $ORACLE_BASE/product/11.2.0/dbhome_1;

ORACLE IP = 192.168.17.133

ORACLE 端口= 1521、1158

具體過程

 

配置網卡

 

       [root@database ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

       添加如下內容:

        +++++++++++++++ETH0++++++++++++++++++++++

        DEVICE=eth0

        HWADDR=00:0C:29:0C:1F:38

        TYPE=Ethernet

        UUID=3e6bd021-df81-40e1-a4c5-e8215fa9ec95

        ONBOOT=yes

        NM_CONTROLLED=no

        BOOTPROTO=static

        IPADDR=192.168.17.133

        NETMASK=255.255.255.0

        GATEWAY=192.168.17.2

        ++++++++++++++++++++++++++++++++++++++++

關閉selinux

   [root@database ~]# vim /etc/sysconfig/selinux

   修改如下內容:

   SELINUX=disabled

 開放防火牆1521、1158端口

      配置防火牆

        [root@database ~]# vim /etc/sysconfig/iptables

        在端口號22后添加如下內容:

        -A INPUT -m state --state NEW -m tcp -p tcp --dport 1521 -j ACCEPT

        -A INPUT -m state --state NEW -m tcp -p tcp --dport 1158 -j ACCEPT

          ##1521是Oracle默認開放的遠程端口;1158則是OME端口。##

      重啟防火牆

        [root@database ~]# service iptables restart

        iptables:將鏈設置為政策 ACCEPT:filter                    [確定]

       iptables:清除防火牆規則:                                 [確定]

       iptables:正在卸載模塊:                                  [確定]

       iptables:應用防火牆規則:                                [確定]

      查看防火牆狀態

        [root@database ~]# service iptables status

        表格:filter

        Chain INPUT (policy ACCEPT)

        num  target    prot opt source              destination        

        1    ACCEPT    all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED

        2    ACCEPT    icmp --  0.0.0.0/0            0.0.0.0/0           

        3    ACCEPT    all  --  0.0.0.0/0            0.0.0.0/0          

        4    ACCEPT    tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22

        5    ACCEPT    tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:1521

        6    ACCEPT    tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:1158

        7    REJECT    all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

        Chain FORWARD (policy ACCEPT)

       num  target    prot opt source               destination        

        1    REJECT    all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

         Chain OUTPUT (policy ACCEPT)

        num  target    prot opt source              destination        

  修改hosts文件

        [root@database ~]# vim /etc/hosts

        添加如下內容:

        192.168.17.133  database

  添加YUM源

      1、掛載ISO鏡像

        [root@database ~]# mount /dev/sr0 /media

      2、配置repo文件

        [root@database ~]# vim /etc/yum.repos.d/rhel-source.repo

        添加如下內容:

        [rhel-source]

        name=rhel-source

        baseurl=file:///media

        enabled=1

       gpgcheck=0

      3、更新yum源

        [root@database ~]# yum  clean all

        [root@database ~]# yum  list

 安裝數據庫所需依賴軟件包

      1、檢查還有哪些依賴包沒有安裝

 [root@database ~]# rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH}) \n' binutils \compat-libstdc++ \elfutils-libelf \elfutils-libelf-devel \gcc \gcc-c++  \glibc \glibc-common \glibc-devel \glibc-headers \ksh \libaio \libaio-devel \libgcc \libstdc++ \libstdc++-devel \make\sysstat \unixODBC \unixODBC-devel

        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

               binutils-2.20.51.0.2-5.36.el6 (x86_64)

               package compat-libstdc++ is not installed

               elfutils-libelf-0.152-1.el6 (x86_64)

               package elfutils-libelf-devel is not installed

               package gcc is not installed

               package gcc-c++ is not installed

               glibc-2.12-1.132.el6 (x86_64)

               glibc-common-2.12-1.132.el6 (x86_64)

               glibc-devel-2.12-1.132.el6 (x86_64)

               glibc-headers-2.12-1.132.el6 (x86_64)

               package ksh is not installed

               libaio-0.3.107-10.el6 (x86_64)

               package libaio-devel is not installed

               libgcc-4.4.7-4.el6 (x86_64)

               libstdc++-4.4.7-4.el6 (x86_64)

               package libstdc++-devel is not installed

               package makesysstat is not installed

               package unixODBC is not installed

               package unixODBC-devel is not installed

        ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

      2、安裝

   [root@database ~]# yum install -y  compat-libstdc++* elfutils-libelf-devel* gcc* gcc-c++* ksh* libaio-devel* libstdc++-devel* libstdc++-devel* makesysstat*      unixODBC* unixODBC-devel* 

 修改內核參數

        [root@database ~]# vim /etc/sysctl.conf

        添加如下內容:

        kernel.sem = 250 32000 100 128

        kernel.shmall = 2097152

        kernel.shmmax =   1073741824

        kernel.shmmni = 4096

        fs.aio-max-nr = 1048576

        fs.file-max = 6815744

        net.core.rmem_default = 4194304

        net.core.rmem_max = 4194304

        net.core.wmem_default = 262144

        net.core.wmem_max = 1048576

        net.ipv4.ip_local_port_range = 9000   65500   

 ##########################################################################

        注意: kernel.shmmax 的值是物理內存的一半。 我的是2G內存,所以是1073741824。

        參數說明: kernel.shmmni:整個系統共享內存段的最大數目

        fs.file-max:系統中所允許的文件句柄最大數目

        net.core.rmem_default:套接字接收緩沖區大小的缺省值

        net.core.rmem_max:套接字接收緩沖區大小的最大值

        net.core.wmem_default:套接字發送緩沖區大小的缺省值

        net.core.wmem_max:套接字發送緩沖區大小的最大值

        net.ipv4.ip_local_port_range:應用程序可使用的IPv4端口范圍

  使內核參數立即生效

        [root@database ~]# 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.sem = 250 32000 100 128

        kernel.shmall = 2097152

        kernel.shmmax = 1073741824

        kernel.shmmni = 4096

        fs.aio-max-nr = 1048576

        fs.file-max = 6815744

        net.core.rmem_default = 4194304

        net.core.rmem_max = 4194304

        net.core.wmem_default = 262144

        net.core.wmem_max = 1048576

        net.ipv4.ip_local_port_range = 9000   65500

 修改/etc/security/limits.conf文件

 限制Oracle用戶資源

        [root@database ~]# vim /etc/security/limits.conf

        添加如下內容:

        oracle soft nproc 2047  #oracle用戶進程告警值

        oracle hard nproc 16384 #oracle用戶進程最大閾值

        oracle soft nofile 1024 #oracle用戶文件使用量告警值

        oracle hard nofile 65536 #oracle用戶文件使用量最大閾值

 修改/etc/pam.d/login文件

將配置文件加入到登錄驗證模塊中

       [root@database ~]# vim /etc/pam.d/login

       添加如下內容:

       session required pam_limits.so   #調用pam_limits.so模塊 

修改/etc/profile文件

限制oracle用戶使用的系統資源

       [root@database ~]# vim /etc/profile

       if [ $USER = "oracle" ]; then

             if [ $SHELL = "/bin/ksh" ]; then

                 ulimit -p 16384

                 ulimit -n 65536

             else

                 ulimit -u 16384 -n 65536

             fi

             umask 022

         fi

創建用戶和用戶組

       groupadd dba 

       groupadd oinstall

       useradd -g oinstall -G dba oracle

       passwd oracle

       查看是否創建成功

       [root@database ~]# id oracle

       uid=500(oracle) gid=502(oinstall) 組=502(oinstall),501(dba)

新建安裝目錄並設置目錄所有者和權限

       mkdir -p /home/app/oracle 

       mkdir -p /home/app/oraInventory

       mkdir -p /home/app/oracle/product/11.2.0/dbhome_1

       chown -R oracle:oinstall /home/app/oracle/

       chown -R oracle:oinstall /home/app/oraInventory/

       chown -R oracle:oinstall /home/app/oracle/product/11.2.0/dbhome_1

       chmod -R 775 /home/app/

修改oracle用戶環境變量,並限制Oracle用戶系統資源使用

       [root@database ~]# su - oracle

       [root@database ~]# vim .bash_profile

       添加如下內容:

       export TMP=/tmp;

       export TMPDIR=$TMP;

       export LANG=en_us;

       export ORACLE_BASE=/home/app/oracle;

       export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1;

       export ORACLE_SID=orcl;

       export ORACLE_TERM=xterm;

       export PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH;

       export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib;

       export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib;

         if [ $USER = "oracle" ]; then

             if [ $SHELL = "/bin/ksh" ]; then

                 ulimit -p 16384

                 ulimit -n 65536

             else

                 ulimit -u 16384 -n 65536

             fi

         fi

         umask 022

       使Oracle用戶下的環境變量文件立即生效

       [oracle@database ~]$ source .bash_profile

上傳Oracle單機安裝包

補丁集1和2 

     解壓並修改權限 

       [root@database oracle_rj]# unzip p13390677_112040_Linux-x86-64_1of7.zip && unzip p13390677_112040_Linux-x86-64_2of7.zip 

       [root@database oracle_rj]# chmod 775 -R database/

Oracle用戶下運行runInstaller開始安裝Oracle

       [oracle@database ~]$ /oracle_rj/database/runInstaller

       Starting Oracle Universal Installer...

       Checking Temp space: must be greater than 120 MB.  Actual 25657 MB    Passed

       Checking swap space: must be greater than 150 MB.  Actual 3999 MB    Passed

       Checking monitor: must be configured to display at least 256 colors.    Actual 16777216    Passed

       Preparing to launch Oracle Universal Installer from /tmp/OraInstall2020-01-20_04-10-49AM. Please wait ...

Step01.配置安全更新

取消勾選,不接收安全更新,然后點擊【Next】,彈出提示窗口,選擇【Yes】

 

step02.選擇跳過更新

tep03.選擇安裝選項

包含3個安裝選項:

1.    創建和配置數據庫

2.    僅安裝數據庫軟件

3.    升級現有數據庫

這里我們選擇【僅安裝數據庫軟件】,然后點擊【Next】:

Step04.節點選擇

包含3個選項:

1.    單實例數據庫安裝

2.    Real Application Clusters數據庫安裝

3.    ORACLE RAC 單節點安裝

選擇【單實例數據庫安裝】,然后點擊【Next】:

Step05.選擇產品語言

默認已添加了【English】,在左側語言列表中找到簡體中文【Simplified Chinese】,並添加到右側,然后點擊【Next】:

Step06.選擇數據庫版本

包含3個選項:

1.    企業版:具有可伸縮性、高性能、高可用性和安全功能的自行管理的數據庫,能夠滿足大多數高標准的關鍵任務應用程序的需求。

2.    標准版:標准版是尋求低成本解決方案的工作組、部門和中小企業的理想選擇。

3.    標准版1:標准版1是尋求低成本解決方案的工作組、部門和中小企業的理想選擇。

選擇【企業版】,然后點擊【Next】:

 

Step07.指定安裝位置

設置Oracle基目錄為新建的目錄:/home/app/oracle,則軟件位置會自動為:/home/app/oracle/product/11.2.0/dbhome_1,然后點擊【Next】:

 

Step08.創建產品清單

設置Oracle清單目錄為新建的目錄:/home/app/ oraInventory,選擇組"oinstall",然后點擊【Next】:

Step09.特權操作系統組

設置數據庫管理員組為【dba】,數據庫操作者組為【oinstall】。然后點擊【Next】:

Step10.執行先決條件檢查

若提示有程序包不存在,是因為Linux6之后,pdksh依賴包被ksh包替代,所有可選擇【忽略全部】,然后點擊【Next】:

 

 

 

 

 

 

 

Step12.運行配置腳本

軟件及數據庫配置完成后,需要運行配置腳本:

打開命令終端,切換到root用戶,並執行腳本:

 

 

 

按照提示運行這兩腳本

[root@database oraInventory]# ./orainstRoot.sh

Changing permissions of /home/app/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world. 

Changing groupname of /home/app/oraInventory to oinstall.

The execution of the script is complete.

 

[root@database oraInventory]# cd /home/app/oracle/product/11.2.0/dbhome_1/

[root@database dbhome_1]# ./root.sh

Performing root user operation for Oracle 11g

The following environment variables are set as:

    ORACLE_OWNER= oracle

    ORACLE_HOME=  /home/app/oracle/product/11.2.0/dbhome_1

Enter the full pathname of the local bin directory: [/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.

Finished product-specific root actions.

 

創建監聽

netca

 

 

 

 

 

 

 

 

  點擊 Finish,完成創建。

 

創建數據庫

dbca

 

  

選擇數據庫模板

選擇定制數據庫

 

 

 

 

 

 

 

 

 

 

 詢問數據庫創建后有沒有SQL腳本運行,選擇不運行。

 

 

 

 

 

 

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM