• CentOS6.5下Oracle11G-R2安装、卸载


    CentOS6.5下Oracle11G-R2安装、卸载
    资源下载地址(包含本人全部安装过程中,系统备份文件):http://download.csdn.net/detail/attagain/7700437

    一、 硬件要求
    本部分内容命令。均以root用户运行。


    1、 内存
    建议内存应大于2G以上。1G能够执行,但比較吃力。
    内存查看命令:
    [root@tsp-rls-dbserver /]# cat /proc/meminfo

    [root@tsp-rls-dbserver /]# free -m
    total       used       free     shared    buffers     cached
    Mem:         32062       1301      30760          0         40        552
    -/+ buffers/cache:        708      31354
    Swap:        16095          0      16095
    2、 交换分区
    交换分区大小。通常设为内存的1.5倍以上。也能够依据实际情况进行调整。
    交换分区查看命令:
    [root@tsp-rls-dbserver /]# grep SwapTotal /proc/meminfo
    SwapTotal:      67682296 kB
    3、 硬盘空间
    建议数据使用独立的挂载分区。本文中採用/data作为数据分区。

    要求/tmp文件夹空间不小于400M。
    磁盘空间查看命令:
    [root@tsp-rls-dbserver /]# df -h
    Filesystem                             Size  Used Avail Use% Mounted on
    /dev/mapper/vg_tsprlsdbserver-lv_root   50G  4.3G   43G  10% /
    tmpfs                                   16G  348K   16G   1% /dev/shm
    /dev/sda1                              485M   39M  421M   9% /boot
    /dev/mapper/vg_tsprlsdbserver-lv_home  210G  190M  199G   1% /home
    /dev/sdb1                              1.1T  4.5G  1.1T   1% /data

      文件夹空间大小查看命令:
    [root@tsp-rls-dbserver tmp]# du -ch /tmp

    二、 软件要求
    1、 安装依赖包
    建议安装系统时,选择开发库。CentOS6.5(x64)安装开发库后。主要依赖包有:
    compat-libstdc++-33-3.2.3-61.i386.rpm(url: http://download.csdn.net/detail/attagain/7699569 )
    compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7699573 )
    libaio-0.3.105-2.i386.rpm(url: http://download.csdn.net/detail/attagain/7700213 )
    libaio-0.3.107-10.el6.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7699585 )
    libaio-devel-0.3.105-2.i386.rpm(url: http://download.csdn.net/detail/attagain/7700217 )
    libaio-devel-0.3.105-2.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7700247 )
    libgcc-3.4.6-3.i386.zip(url: http://download.csdn.net/detail/attagain/7699599  含有:libgcc-3.4.6-3.i386.rpm、libgcc_s-4.4.7-20120601.so.1、libgcc_s.so.1,安装本文件,首先要卸载libgcc-4.4.7-4.el6.x86_64.rpm 。so文件即为卸载前从/lib64中备份下来的,以备误删使用)
    libgcc-4.4.7-4.el6.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7700201 )
    libstdc++-3.4.6-11.i386.rpm(url: http://download.csdn.net/detail/attagain/7700169 )
    libstdc++-devel-3.4.6-3.1.i386.rpm(url: http://download.csdn.net/detail/attagain/7699847 )
    libstdc++-4.4.7-4.el6.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7699837 )
    pdksh-5.2.14-37.el5_8.1.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7700147 )
    unixODBC-2.2.11-7.1.i386.rpm(url: http://download.csdn.net/detail/attagain/7700007 )
    unixODBC-2.2.11-7.1.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7700021 )
    unixODBC-devel-2.2.11-7.1.i386.rpm(url: http://download.csdn.net/detail/attagain/7699903 )
    unixODBC-devel-2.2.11-7.1.x86_64.rpm(url: http://download.csdn.net/detail/attagain/7699907 )

     注:上述安装包,我搜索了好久才整理搜集全然。已经上传至csdn,不须要资源分。在64位CentOS6.5上安装上述资源包时,须要先卸载原64位安装包。成功安装后,再安装被卸载的64位安装包(上述的64位安装包,亦能够在安装光盘中找到)。卸载原64位依赖包时,建议使用參--nodeps。如:rpm –e libaio-0.3.107-10.el6.x86_64 –nodeps。另外,须要特别注意的,卸载libgcc-4.4.7-4.el6.x86_64时,同一时候会将/lib64文件夹中的libgcc_s.so.1卸载。卸载成功后,还要恢复该文件。上述依赖包libgcc-3.4.6-3.i386.zip中,包括有我的系统备份包。


     假设缺少依赖包。能够使用rpm命令查看、离线安装、在线安装对应的安装包。

    以gcc包为例:
    查看安装包。是否安装命令:
    [root@tsp-rls-dbserver tmp]# rpm -qa|grep gcc
     离线安装命令:
    [root@tsp-rls-dbserver tmp]# rpm –ivh gcc-***.rpm
     在线安装命令:
    [root@tsp-rls-dbserver tmp]# yum install gcc
     注:依据系统检查结果,确定自己的系统须要安装什么安装包。

    三、 环境配置
    1、 创建oracle安装用户
    A、 创建oinstall组
    [root@tsp-rls-dbserver tmp]# groupadd oinstall
    B、 创建dba组
    [root@tsp-rls-dbserver tmp]# groupadd dba
    C、 新建用户oracle,设定其主组为oinstall,副组为dba
    [root@tsp-rls-dbserver tmp]# useradd -g oinstall -G dba oracle
    D、 查看创建用户ID信息
    [root@tsp-rls-dbserver tmp]# id oracle
    E、 设置oracle用户password
    [root@tsp-rls-dbserver tmp]# passwd oracle

    2、 设置用户环境变量
    将使用oracle用户安装Oracle软件。主文件夹为/home/oracle;假设安装在自己定义路径,须要创建路径,并设置其执行权限。
    改动用户环境变量文件/home/oracle/.bash_profile,运行命令:
    [root@tsp-rls-dbserver oracle]# vi /home/oracle/.bash_profile
    文件尾部加入例如以下信息:
    export ORACLE_SID=ORATSP
    export ORACLE_BASE=/home/oracle/app
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
    export PATH=$PATH:$ORACLE_HOME/bin
     运行source命令,使得环境变量參数生效
    [root@tsp-rls-dbserver oracle]# source /home/oracle/.bash_profile
     查看环境变量參数命令:
    [root@tsp-rls-dbserver oracle]# env | more

    3、  改动系统内核及环境參数
    A、 改动内核參数
    运行例如以下命令,改动配置文件/etc/sysctl.conf
    [root@tsp-rls-dbserver oracle]# vi /etc/sysctl.conf
      在文件尾部加入例如以下信息:
    fs.file-max= 6815744
    fs.aio-max-nr=1048576
    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= 1048576
    kernel.sem= 250 32000 100 128

     说明:kernel.shmmax和kernel.shmmax參数,应保持系统不变,必要时。能够适当调大。
      运行命令sysctl。使内核參数生效:
    [root@tsp-rls-dbserver oracle]# sysctl –p

    B、 改动进程数和最大会话数
    运行例如以下命令。改动配置文件/etc/security/limits.conf
    [root@tsp-rls-dbserver oracle]# vi /etc/security/limits.conf
    在文件尾部加入例如以下信息:
    oracle soft nproc 2047
    oracle hard nproc 16384
    oracle soft nofile 1024
    oracle hard nofile 65536

    C、 设置关联信息
      运行例如以下命令。改动关联文件/etc/pam.d/login
    [root@tsp-rls-dbserver oracle]# vi /etc/pam.d/login
      在文件尾部加入例如以下信息:
    session required pam_limits.so

    D、 改动系统启动环境參数
    运行例如以下命令,改动系统启动环境參数文件/etc/ profile
    [root@tsp-rls-dbserver oracle]# vi /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
    E、 改动主机解析信息
    运行命令。改动/etc/hosts文件
    [root@tsp-rls-dbserver ~]# vi /etc/hosts
       在文件尾部加入例如以下信息:
    192.168.30.203   tsp-rls-dbserver

    F、 数据分区挂载
    本文中,介绍的数据库安装,数据文件系统採用独立的数据分区。因此。须要运行mount命令,加入分区挂载信息。
    人工方式挂载,须要运行例如以下命令:
     查看磁盘分区信息命令:
    [root@tsp-rls-dbserver oracle]# fdisk –l
     运行mount命令,挂在sdb1分区,到/data(须要预先创建该文件夹):
    [root@tsp-rls-dbserver oracle]# mount /dev/sdb1 /data
     运行umount命令,取消挂载分区:
    [root@tsp-rls-dbserver oracle]# umount /data
     查看挂载分区结果命令:
    [root@tsp-rls-dbserver oracle]# df -h
    Filesystem                             Size  Used Avail Use% Mounted on
    /dev/mapper/vg_tsprlsdbserver-lv_root   50G  4.3G   43G  10% /
    tmpfs                                   16G  348K   16G   1% /dev/shm
    /dev/sda1                              485M   39M  421M   9% /boot
    /dev/mapper/vg_tsprlsdbserver-lv_home  210G  190M  199G   1% /home
    /dev/sdb1                              1.1T  4.5G  1.1T   1% /data

     查看系统分区UUID方法:
    [root@tsp-rls-dbserver oracle]# blkid

    [root@tsp-rls-dbserver oracle]# ls -l /dev/disk/by-uuid
    总用量 0
    lrwxrwxrwx. 1 root root 10 7月  30 12:18 0a99941d-8caa-4e3a-9645-a0239dd385f1 -> ../../dm-0
    lrwxrwxrwx. 1 root root 10 7月  30 12:20 3d9b7f12-0690-48d2-ae9a-004956dc5072 -> ../../sdb1
    lrwxrwxrwx. 1 root root 10 7月  30 12:18 a292586a-9cfb-45c5-88f3-5c9530e65dae -> ../../dm-1
    lrwxrwxrwx. 1 root root 10 7月  30 12:18 a486566b-272d-4de7-a852-72fcfc6e7a1a -> ../../dm-2
    lrwxrwxrwx. 1 root root 10 7月  30 12:18 f4ab21a5-f068-428c-85ae-b9f2ec1ac640 -> ../../sda1

     运行例如以下命令,改动系统分区文件/etc/ fstab,使得系统启动时,自己主动挂载分区:
    [root@tsp-rls-dbserver oracle]# vi /etc/fstab
     在文件里加入例如以下信息(使用sdb1的UUID):
    UUID=3d9b7f12-0690-48d2-ae9a-004956dc5072 /data      ext4    defaults        1 2

    四、 Oracle安装过程
    在运行数据库安装前,最好重新启动系统,确保所设置參数所有生效。
    以oracle用户登录系统,须要图形界面支持,能够使用xhost、NoManchine等远程桌面工具,本文中使用NoMachine工具。

    (有须要,请自行下载安装)
    1、 官网下载Oracle11GR2安装文件,上传至server
    运行命令,解压文件,设置可运行权限:
    [oracle@tsp-rls-dbserver soft]$ unzip linux.x64_11gR2.zip
    [oracle@tsp-rls-dbserver soft]$ chmod 755 -R ./linux.x64_11gR2
    2、 以oracle用户登录
     

    3、 设置语言环境信息,执行Oracle安装向导
    因为,oracle安装向导无法识别中文字体。终端暂时设置语言环境变量,并执行runInstaller。
    [oracle@tsp-rls-dbserver linux.x64_11gR2]$ export LANG=en_US
    [oracle@tsp-rls-dbserver linux.x64_11gR2]$ export LC_ALL=en_US
    [oracle@tsp-rls-dbserver linux.x64_11gR2]$ ./runInstaller
     

    下述4-26的步骤截图省略。如有须要,请到资源中下载word版:

    http://download.csdn.net/detail/attagain/7700437


    4、 选择安装类型(创建数据库实例)
     
    5、 安装程序类型(server类)
     
    6、 安装实例选择(单数据库实例)
     
    7、 安装类型(自己定义安装)
     
    8、 选择支持语言(支持中文)
     
    9、 数据库类型(企业级数据库)
     
    10、 数据库安装路径(设置环境变量信息)
     
    11、 安装具体路径(默认)
     
    12、 数据库实例类型(数据仓库)
     
    13、 数据库实例服务名
     
    14、 内存配置(默认40%)
     
    15、 字符集设置(AL32UTF8)
     
    16、 安全设置(默认)
     
    17、 演示样例数据结构(默认)
     
    18、 数据库控制管理(默认)
     
    19、 数据库文件系统(独立数据分区:/data/oracle)
     
    20、 数据库自己主动备份(默认)
     
    21、 数据库管理用户password(统一password设置)
     
    22、 管理、操作账户分组设置(默认)
     
    23、 安装预检信息收集(须要所有通过。忽略选项,可能导致执行异常)
     
    24、 安装装过程
     
    25、 数据库配置汇总信息
    管理URL:https://tsp-rls-dbserver:1158/em
     
    26、 以root用户登录,执行配置脚本
     
    27、 运行脚本orainstRoot过程(/home/oracle/oraInventory/orainstRoot.sh)
    [root@tsp-rls-dbserver deps]# /home/oracle/oraInventory/orainstRoot.sh
    Changing permissions of /home/oracle/oraInventory.
    Adding read,write permissions for group.
    Removing read,write,execute permissions for world.

    Changing groupname of /home/oracle/oraInventory to oinstall.
    The execution of the script is complete.

    28、 运行脚本root过程(/home/oracle/app/product/11.2.0/dbhome_1/root.sh)
    [root@tsp-rls-dbserver deps]# /home/oracle/app/product/11.2.0/dbhome_1/root.sh
    Running Oracle 11g root.sh script...

    The following environment variables are set as:
        ORACLE_OWNER= oracle
        ORACLE_HOME=  /home/oracle/app/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.sh script.
    Now product-specific root actions will be performed.
    Finished product-specific root actions.

    29、 安装完毕
    管理URL:https://tsp-rls-dbserver:1158/em

    30、 开放防火墙port(1521、1158)
    运行命令:
    [root@tsp-rls-dbserver deps]# /sbin/iptables -I INPUT -p tcp --dport 1521 -j ACCEPT
    [root@tsp-rls-dbserver deps]# /sbin/iptables -I INPUT -p tcp --dport 1158 -j ACCEPT
    保存设置命令:
    [root@tsp-rls-dbserver deps]# /etc/rc.d/init.d/iptables save
    查看port打开情况命令:
    [root@tsp-rls-dbserver deps]# /etc/init.d/iptables status
    重新启动防火墙服务
    [root@tsp-rls-dbserver deps]# /etc/rc.d/init.d/iptables restart

    31、 开机自己主动启动Oracle服务配置
    A、 改动dbstart和dbshut脚本
    [oracle@tsp-rls-dbserver ~]$ vi $ORACLE_HOME/bin/dbstart
    [oracle@tsp-rls-dbserver ~]$ vi $ORACLE_HOME/bin/dbshut
      找到文件里的ORACLE_HOME_LISTNER=$1,改动为:ORACLE_HOME_LISTNER=$ORACLE_HOME
    B、 改动oratab文件
    [oracle@tsp-rls-dbserver ~]$ vi /etc/oratab

    将ORATSP:/home/oracle/app/product/11.2.0/dbhome_1:N
    改动为:ORATSP:/home/oracle/app/product/11.2.0/dbhome_1:Y

    C、 改动rc.local文件(root用户)
    [root@tsp-rls-dbserver deps]# vi /etc/rc.d/rc.local
      文件尾部加入例如以下信息:
    su oracle -lc "/home/oracle/app/product/11.2.0/dbhome_1/bin/emctl start dbconsole"
    su oracle -lc "/home/oracle/app/product/11.2.0/dbhome_1/bin/lsnrctl start"
    su oracle -lc "/home/oracle/app/product/11.2.0/dbhome_1/bin/dbstart"

    五、 Oracle卸载
    1、 停止监听服务(oracle用户登录)
    [oracle@tsp-rls-dbserver ~]$ lsnrctl stop
    2、 停止数据库

    3、 删除oracle安装路径(root用户登录)
    [root@tsp-rls-dbserver deps]# rm -rf /home/oracle/app
    [root@tsp-rls-dbserver deps]# rm -rf /home/oracle/oraInventory

    4、 删除系统路径文件(root用户登录)
    [root@tsp-rls-dbserver deps]# rm -rf /usr/local/bin/dbhome
    [root@tsp-rls-dbserver deps]# rm -rf /usr/local/bin/oraenv
    [root@tsp-rls-dbserver deps]# rm -rf /usr/local/bin/coraenv

    5、 删除数据库实例表(root用户登录)
    [root@tsp-rls-dbserver deps]# rm -rf /etc/oratab

    6、 删除数据库实例lock文件(root用户登录)
    [root@tsp-rls-dbserver deps]# rm -rf /etc/oraInst.loc

    7、 删除oracle用户及用户组(root用户登录)
    [root@tsp-rls-dbserver deps]# userdel -r oracle
    [root@tsp-rls-dbserver deps]# groupdel oinstall
    [root@tsp-rls-dbserver deps]# groupdel dba

  • 相关阅读:
    对生产稳定的一些思考
    tsar指标解释
    tsar采集nginx指标
    Nginx如何处理一个连接
    Java : 如何更优雅的设计异常
    MySql的索引实现
    IntelliJ Idea 常用配置
    ICSharpCode.SharpZipLib.dll 压缩、解压Zip文件 附源码
    Java BigDecimal使用
    社交系统中用户好友关系数据库设计
  • 原文地址:https://www.cnblogs.com/yangykaifa/p/6807595.html
Copyright © 2020-2023  润新知