• 1. Oracle安装部署文档


    一. 部署环境步骤

    1.1 软件环境

    操作系统:CentOS release 6.5
    oracle安装包:linux.x64_11gR2_database_1of1.zip;linux.x64_11gR2_database_1of2.zip

    1.2 配置主机名

    # vim /etc/sysconfig/network
    HOSTNAME= oracle235
    # 或者执行 hostname oracle235

    1.3 配置网络

    # vim /etc/hosts
    192.168.1.235 oracle235

    1.4 配置系统内核参数

      配置 /etc/sysctl.conf :添加如下内容:

    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.ipv4.ip_local_port_range = 9000 65500
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048586

      注意上述参数中,需要根据实际情况修改 kernel.shmmax 参数的值,可以直接设置为物理内存大小。
      执行命令使之生效: 

    # /sbin/sysctl -p

    1.5 设置 Shell对Oracle用户的限制

      配置 /etc/security/limits.conf 文件:增加如下内容

    oracle      soft  nproc  2047
    oracle      hard  nproc  16384
    oracle      soft  nofile 2047
    oracle      hard  nofile 65536

      接着,修改 /etc/pam.d/login,在文件最后添加如下内容:

    session required /lib64/security/pam_limits.so

      最后,修改 /etc/profile,在文件最后添加如下内容

    if [ $USER = "oracle" ]; then
        if [ $SHELL = "/bin/ksh" ]; then
           ulimit -p 16384
           ulimit -n 65536
        else
           ulimit -u 16384 -n 65536
        fi
    fi

      所有修改完毕,重启所有 Linux 系统

    1.6 创建grid/Oracle用户和组

    # /usr/sbin/groupadd oinstall
    # /usr/sbin/groupadd dba
    # /usr/sbin/groupadd oper
    # /usr/sbin/useradd -g oinstall -G dba,oper oracle
    # passwd oracle

      创建 oracle 软件安装目录

    # mkdir -p /u01/oraInventory
    # chown -R oracle:oinstall /u01/
    # chmod -R 775 /u01/

      配置 oracle 用户的环境变量

    export ORACLE_BASE=/u01/app
    export ORACLE_HOME=$ORACLE_BASE/oracle
    export ORACLE_SID=orcl
    export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
    export NLS_LANG=AMERICAN_AMERICA.UTF8
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:$LD_LIBRARY_PATH
    alias sqlplus='rlwrap sqlplus'

    1.7 安装 oracle 安装包的依赖

    binutils-2.17.50.0.6
    compat-libstdc++-33-3.2.3
    compat-libcap1
    elfutils-libelf-0.125
    elfutils-libelf-devel-0.125
    elfutils-libelf-devel-static-0.125
    gcc-4.1.2
    gcc-c++-4.1.2
    glibc-2.5-24
    glibc-common-2.5
    glibc-devel-2.5
    glibc-headers-2.5
    kernel-headers-2.6.18
    ksh-20060214
    libaio-0.3.106
    libaio-devel-0.3.106 
    libgcc-4.1.2
    libgomp-4.1.2
    libstdc++-4.1.2 
    libstdc++-devel-4.1.2
    make-3.81
    sysstat-7.0.2
    unixODBC-2.2.11
    unixODBC-devel-2.2.11

      执行命令 查看是否遗漏包;

    rpm -q binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

      安装依赖包

    yum install -y binutils compat-libstdc++-33 compat-libcap1 elfutils-libelf elfutils-libelf-devel gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers kernel-headers ksh libaio libaio-devel libgcc libgomp libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel

    二. 用xshell打开图形界面

      可以采用 VNC 或者 xshell 软件登录 linux 界面去安装 Oracle Grid Infrastructure 软件。本例采用 xshell 软件

    2.1 安装与下载图形界面GNOME

    yum groupinstall "Desktop"
    yum groupinstall "X Window System"

    2.2 修改 /etc/gdm/custom.conf

    [daemon]
    [security]
    AllowRemoteRoot=true  
    [xdmcp]
    Port=177
    Enable=true    
    [gui]
    [greeter]
    [chooser]
    [debug]

    2.3 启动xshell工具

    三. 安装Oracle数据库图解

    3.1 安装 Oracle 软件

      进入 linux 桌面;打开终端;用 oracle 用户登录。进入 oracle 安装包目录;执行命令

    ./runInstaller

      下面是每一步都图解演示:点击 next 按钮

      跳过软件更新;点击next按钮

      选择只安装数据库软件

      选择单实例安装

      选择Languages

      选择"Enterprise Edition"

      选择oracle软件安装路径

      安装前环境监测

      安装Oracle软件

      接下来的时间慢慢等待 Oracle 软件安装;在安装过程中要用 root 用户执行两个脚本;如下截图

    3.2 配置Oracle数据库

      Oracle服务器软件已经安装完成;接下来需要配置Oracle数据库;在终端下执行命令

    dbca

      执行dbca之后;会弹出数据库配置助手;如下图所示:

      跳过软件更新;点击 next 按钮

      选择定制;可以根据业务定制

      经过漫长的等待;Oracle安装就完成

    四. Oracle网络配置

      数据库启动之后,要想提供对外服务。还需要配置 Oracle 的监听器配置文件 listener.ora(可以使用 netca 命令创建);而远程客户端则需要配置 tnsnames.ora 文件。与服务器建立网络连接。

    4.1 服务器监听文件 listener.ora

      我们先看下数据库SID和SERVICE_NAME。 

    SQL> show parameter instance_name;
    NAME            TYPE       VALUE
    --------------  ---------  ---------------
    service_names   string     ora235
    SQL> alter system set service_names='lottu' scope=both;
    System altered.
    SQL> show parameter service_name;
    NAME            TYPE       VALUE
    --------------  ---------  ---------------
    service_names   string     lottu

      一般 Oracle 的实例名跟 SERVICE_NAME 是一致的

      在目录 $ORACLE_HOME/network/admin/ 目录下;配置监听文件 listener.ora

    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
           (ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.235)(PORT = 1521)(IP = FIRST)))
           (ADDRESS_LIST =
             (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC))
           )
         )
      )
    
    SID_LIST_LISTENER =
      (SID_LIST =
       (SID_DESC =
         (SID_NAME = ora235)
         (GLOBAL_DBNAME = lottu)
         (ORACLE_HOME =/u01/app/oracle)
       )
      )

      再启动监听

    lsnrctl start

    4.2 客户端网络服务文件 tnsnames.ora

      在客户端的 $ORACLE_HOME/network/admin/ 目录下;配置如下:

    T235=
      (DESCRIPTION =
          (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.235)(PORT = 1521))
        (CONNECT_DATA =
          (SID = ora235)
        )
     (HS = OK)
      )
    # 或者用 (SERVICE_NAME = lottu) 替换 (SID = ora235)

      测试是否配置OK?

    [oracle@oracle235 admin]$ tnsping T235
    
    TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 03-AUG-2018 23:48:59
    
    Copyright (c) 1997, 2013, Oracle.  All rights reserved.
    
    Used parameter files:
    
    
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.235)(PORT = 1521)) (CONNECT_DATA = (SID = ora235)) (HS = OK))
    OK (0 msec)

      这样就可以通过客户端连接 Oracle 服务器

    五. Oracle开机自启动

      默认 Oracle 数据库是不会随着机器重启或者开机启动 Oracle 服务。

    5.1 修改Oracle系统配置文件

      用 root 用户修改文件 /etc/oratab ;将 N 改成 Y;本例如下

    $ORACLE_SID:$ORACLE_HOME:<N|Y>:
    ora235:/u01/app/oracle:Y

    5.2 在 /etc/init.d/ 下创建文件oracle

    #!/bin/bash
    #chkconfig:345 61 61 
    #description:oracle
    #
    # 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=/u01/app/oracle
    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:
    echo "Starting Oracle Databases ... "
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Starting Oracle Databases as part of system up." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbstart" >>/var/log/oracle
    echo "Done"
    
    # Start the Listener:
    echo "Starting Oracle Listeners ... "
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Starting Oracle Listeners as part of system up." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl start" >>/var/log/oracle
    echo "Done."
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Finished." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    touch /var/lock/subsys/oracle
    ;;
    
    'stop')
    # Stop the Oracle Listener:
    echo "Stoping Oracle Listeners ... "
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Stoping Oracle Listener as part of system down." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    su - $ORA_OWNER -c "$ORA_HOME/bin/lsnrctl stop" >>/var/log/oracle
    echo "Done."
    rm -f /var/lock/subsys/oracle
    
    # Stop the Oracle Database:
    echo "Stoping Oracle Databases ... "
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Stoping Oracle Databases as part of system down." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    su - $ORA_OWNER -c "$ORA_HOME/bin/dbshut" >>/var/log/oracle
    echo "Done."
    echo ""
    echo "-------------------------------------------------" >> /var/log/oracle
    date +" %T %a %D : Finished." >> /var/log/oracle
    echo "-------------------------------------------------" >> /var/log/oracle
    ;;
    
    'restart')
    $0 stop
    $0 start
    ;;
    esac

    5.3 添加服务

    # chmod 755 /etc/init.d/oracle
    # chkconfig --level 35 oracle on
    # ln -s /etc/init.d/oracle /etc/rc0.d/K01oracle
    # ln -s /etc/init.d/oracle /etc/rc6.d/K01oracle

    5.4 测试启动和关闭 Oracle

    [root@oracle235 ~]# service oracle stop
    Stoping Oracle Listeners ... 
    Done.
    Stoping Oracle Databases ... 
    Done.
    
    [root@oracle235 ~]# service oracle start
    Starting Oracle Databases ... 
    Done
    Starting Oracle Listeners ... 
    Done.

      本课程总共有 12 课;是给公司员工培训所编辑。未完待续...

  • 相关阅读:
    js代码中引入其他js文件
    SQL Server 创建跨库查詢、修改、增加、删除
    将SQL Server查询导出本地excel(mail发送)
    SQL Server2008 xp_cmdshell啟用
    SQL Server存储过程邮件发送以表格方式发送
    SQL Server2008进程堵塞处理方法
    sql 上舍下舍運用
    怎樣添加設置GridView,CheckBox全選功能
    点击 Button触发事件将GridView1 CheckBox勾选的行添加到GridView2中
    ES6-Proxy,代理
  • 原文地址:https://www.cnblogs.com/lottu/p/9522702.html
Copyright © 2020-2023  润新知