• oracle安装备忘录


    --------------------- 
    作者:liang墨竹 
    来源:CSDN 
    原文:https://blog.csdn.net/oschina_41140683/article/details/81510709 
    版权声明:本文为博主原创文章,转载请附上博文链接!
    
    hostnamectl set-hostname oracle
    
    1、配置yum源:
    cd /etc
    mv yum.repos.d yum.repos.d.bak
    mkdir yum.repos.d
    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    yum clean all
    yum makecache
    
    2、安装依赖包:
    yum -y install binutils 
    compat-libstdc++-33 
    elfutils-libelf 
    elfutils-libelf-devel 
    expat 
    gcc 
    gcc-c++ 
    glibc 
    glibc-common 
    glibc-devel 
    glibc-headers 
    libaio 
    libaio-devel 
    libgcc 
    libstdc++ 
    libstdc++-devel 
    make 
    pdksh 
    sysstat 
    unixODBC 
    unixODBC-devel
    
    3、检查依赖是否安装完整:
    rpm -q 
    binutils 
    compat-libstdc++-33 
    elfutils-libelf 
    elfutils-libelf-devel 
    expat 
    gcc 
    gcc-c++ 
    glibc 
    glibc-common 
    glibc-devel 
    glibc-headers 
    libaio 
    libaio-devel 
    libgcc 
    libstdc++ 
    libstdc++-devel 
    make 
    pdksh 
    sysstat 
    unixODBC 
    unixODBC-devel | grep "not installed"
    
    通过yum install pdksh -y 安装缺少 package ;直接下载rpm进行安装
    wget -O /tmp/pdksh-5.2.14-37.el5_8.1.x86_64.rpm http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
    rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
    再次检查依赖包是否安装完整:
    rpm -q 
    binutils 
    compat-libstdc++-33 
    elfutils-libelf 
    elfutils-libelf-devel 
    expat 
    gcc 
    gcc-c++ 
    glibc 
    glibc-common 
    glibc-devel 
    glibc-headers 
    libaio 
    libaio-devel 
    libgcc 
    libstdc++ 
    libstdc++-devel 
    make 
    pdksh 
    sysstat 
    unixODBC 
    unixODBC-devel | grep "not installed"
    
    
    4、添加oracle用户组和用户:
    
    groupadd oinstall
    groupadd dba
    groupadd asmadmin
    groupadd asmdba
    useradd -g oinstall -G dba,asmdba oracle -d /home/oracle
    
    5、添加完成后,查看oracle用户:
    id oracle
    
    6、初始化oracle用户的密码:
    passwd oracle
    
    配置hostname(本机IP映射)
    vim /etc/hosts
      192.168.199.110 oracle
    # 测试hostname
      ping -c 3 oracle
      
     优化OS内核参数
    # kernel.shmmax 参数设置为物理内存的一半
    vim /etc/sysctl.conf
    fs.aio-max-nr=1048576
    fs.file-max=6815744
    kernel.shmall=2097152
    kernel.shmmni=4096
    kernel.shmmax = 536870912
    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
    
    使参数生效:
    sysctl -p
    
    限制oracle用户的shell权限:
    vim /etc/security/limits.conf
     
    #在末尾添加
    oracle	soft	nproc	2047
    oracle	hard	nproc	16384
    oracle	soft	nofile	1024
    oracle	hard	nofile	65536
    oracle	soft	stack	10240
    oracle	hard	stack	10240
     
    vim /etc/pam.d/login
     
    session  required   /lib64/security/pam_limits.so
    session  required   pam_limits.so
     
    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
    fi
     
     
    --------------------------------------------------------
    使之生效:
    source /etc/profile
    ============================================================================20190511
    创建oracle安装目录:
    mkdir -p /db/app/oracle/product/11.2.0
    mkdir /db/app/oracle/oradata
    mkdir /db/app/oracle/inventory
    mkdir /db/app/oracle/fast_recovery_area
    chown -R oracle:oinstall /db/app/oracle
    chmod -R 775 /db/app/oracle
    
    配置oracle用户环境变量:
    
    su - oracle  ## oracle用户登陆
     
    vim .bash_profile
     
    export ORACLE_HOSTNAME=oracle
    export ORACLE_BASE=/db/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
    export ORACLE_SID=ORCL
    export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
    export LC_ALL="en_US"
    export LANG="en_US"
    export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
    export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
     
    ## 以上配置完成后,建议重启系统
     
    reboot
    
    解压oracle压缩文件到 /db:
    
    cd /db/
     
    unzip linux.x64_11gR2_database_1of2.zip -d /db
    unzip linux.x64_11gR2_database_2of2.zip -d /db
     
    解压完成后
     
    mkdir /home/oracle/etc/
    cp /db/database/response/* /home/oracle/etc/
     
    vim /home/oracle/etc/db_install.rsp
     
    oracle.install.option=INSTALL_DB_SWONLY
    DECLINE_SECURITY_UPDATES=true
    UNIX_GROUP_NAME=oinstall
    INVENTORY_LOCATION=/db/app/oracle/inventory
    SELECTED_LANGUAGES=en,zh_CN
    ORACLE_HOSTNAME=oracle
    ORACLE_HOME=/db/app/oracle/product/11.2.0
    ORACLE_BASE=/db/app/oracle
    oracle.install.db.InstallEdition=EE
    oracle.install.db.isCustomInstall=true
    oracle.install.db.DBA_GROUP=dba
    oracle.install.db.OPER_GROUP=dba
    开始安装:
    
    su - oracle
     
    ./runInstaller -silent -ignorePrereq -responseFile /home/oracle/etc/db_install.rsp
     
    ## 安装期间可以使用tail命令监看oracle的安装日志
     
    tail -f /db/app/oracle/inventory/logs/installActions2018-08-11_12-48-29PM.log
    安装完成,提示Successfully Setup Software.
    
    
    
     使用root用户执行脚本:
    
    su - root
    /db/app/oracle/inventory/orainstRoot.sh
    /db/app/oracle/product/11.2.0/root.sh
    
     
    增加或修改oracle的环境变量:
    
    su  - oracle
     
    vim ~/.bash_profile
     
    #for oracle
    export ORACLE_BASE=/db/app/oracle
    export ORACLE_SID=orcl
    export ROACLE_PID=ora11g
    #export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
    export ORACLE_HOME=/db/app/oracle/product/11.2.0/db_1
    export PATH=$PATH:$ORACLE_HOME/bin
    export LANG="zh_CN.UTF-8"
    export NLS_LANG="SIMPLIFIED CHINESE_CHINA.AL32UTF8"
    export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
    配置监听程序:
    
    [oracle@oracle ~]$ netca /silent /responsefile /home/oracle/etc/netca.rsp
    Parsing command line arguments:
        Parameter "silent" = true
        Parameter "responsefile" = /home/oracle/etc/netca.rsp
    Done parsing command line arguments.
    Oracle Net Services Configuration:
    Profile configuration complete.
    Oracle Net Listener Startup:
        Running Listener Control: 
          /u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
        Listener Control complete.
        Listener started successfully.
    Listener configuration complete.
    Oracle Net Services configuration successful. The exit code is 0
    启动监控程序:
    
    [oracle@oracle ~]$ lsnrctl start
     
    LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 01-SEP-2016 11:23:31
     
    Copyright (c) 1991, 2009, Oracle.  All rights reserved.
     
    Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
     
    TNSLSNR for Linux: Version 11.2.0.1.0 - Production
    System parameter file is /db/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
    Log messages written to /db/app/oracle/diag/tnslsnr/docker/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=docker)(PORT=1521)))
     
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
    STATUS of the LISTENER
    ------------------------
    Alias                     LISTENER
    Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
    Start Date                01-SEP-2016 11:23:31
    Uptime                    0 days 0 hr. 0 min. 0 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /db/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
    Listener Log File         /db/app/oracle/diag/tnslsnr/docker/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=docker)(PORT=1521)))
    The listener supports no services
    The command completed successfully
    静默dbca建库
    
    编辑应答文件:
    
    [oracle@oracle ~]$ vi /etc/dbca.rsp
    [GENERAL]
    RESPONSEFILE_VERSION = "11.2.0"
    OPERATION_TYPE = "createDatabase"
    [CREATEDATABASE]
    GDBNAME = "orcl"
    SID = "orcl"
    TEMPLATENAME = "General_Purpose.dbc"
    CHARACTERSET = "AL32UTF8"
    建库:
    
    [oracle@oracle ~]$ dbca -silent -responseFile etc/dbca.rsp
     
    Enter SYS user password: oracle
      
    Enter SYSTEM user password: oracle
     
    Copying database files
    1% complete
    3% complete
    11% complete
    18% complete
    26% complete
    37% complete
    Creating and starting Oracle instance
    40% complete
    45% complete
    50% complete
    55% complete
    56% complete
    57% complete
    60% complete
    62% complete
    Completing Database Creation
    66% complete
    70% complete
    73% complete
    74% complete
    85% complete
    96% complete
    100% complete
    Look at the log file Look at the log file "/db/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
    查看输出日志:
    
    [oracle@oracle ~]$ cat /db/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log
    Copying database files
    DBCA_PROGRESS : 1%
    DBCA_PROGRESS : 3%
    DBCA_PROGRESS : 11%
    DBCA_PROGRESS : 18%
    DBCA_PROGRESS : 26%
    DBCA_PROGRESS : 37%
    Creating and starting Oracle instance
    DBCA_PROGRESS : 40%
    DBCA_PROGRESS : 45%
    DBCA_PROGRESS : 50%
    DBCA_PROGRESS : 55%
    DBCA_PROGRESS : 56%
    DBCA_PROGRESS : 60%
    DBCA_PROGRESS : 62%
    Completing Database Creation
    DBCA_PROGRESS : 66%
    DBCA_PROGRESS : 70%
    DBCA_PROGRESS : 73%
    DBCA_PROGRESS : 85%
    DBCA_PROGRESS : 96%
    DBCA_PROGRESS : 100%
    Database creation complete. For details check the logfiles at:
     /db/app/oracle/cfgtoollogs/dbca/orcl11g.
    Database Information:
    Global Database Name:orcl11g.us.oracle.com
    System Identifier(SID):orcl
    至此完成数据库实例的创建。
    
    删除实例:
    
    [oracle@oracle ~]$ dbca -silent -deleteDatabase -sourcedb orcl
    设置Oracle开机启动
    vi /db/app/oracle/product/11.2.0/bin/dbstart
    ORACLE_HOME_LISTNER=$ORACLE_HOME
     
    vi /db/app/oracle/product/11.2.0/bin/dbshut
     
    ORACLE_HOME_LISTNER=$ORACLE_HOME
     
    vi /etc/oratab
     
    orcl:/db/app/oracle/product/11.2.0:Y
     
    vi /etc/rc.d/init.d/oracle
     
    #! /bin/bash
    # oracle: Start/Stop Oracle Database 11g R2
    #
    # chkconfig: 345 90 10
    # description: The Oracle Database is an Object-Relational Database Management System.
    #
    # processname: oracle
    . /etc/rc.d/init.d/functions
    LOCKFILE=/var/lock/subsys/oracle
    ORACLE_HOME=/db/app/oracle/product/11.2.0
    ORACLE_USER=oracle
    case "$1" in
    'start')
       if [ -f $LOCKFILE ]; then
          echo $0 already running.
          exit 1
       fi
       echo -n $"Starting Oracle Database:"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl start"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl start dbconsole"
       touch $LOCKFILE
       ;;
    'stop')
       if [ ! -f $LOCKFILE ]; then
          echo $0 already stopping.
          exit 1
       fi
       echo -n $"Stopping Oracle Database:"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/lsnrctl stop"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/dbshut"
       su - $ORACLE_USER -c "$ORACLE_HOME/bin/emctl stop dbconsole"
       rm -f $LOCKFILE
       ;;
    'restart')
       $0 stop
       $0 start
       ;;
    'status')
       if [ -f $LOCKFILE ]; then
          echo $0 started.
          else
          echo $0 stopped.
       fi
       ;;
    *)
       echo "Usage: $0 [start|stop|status]"
       exit 1
    esac
    exit 0
    开机启动oracle
    
    systemctl enable oracle
    开机启动问题
    oracle ORA-12547: TNS:lost contact
     
    cd /db/app/oracle/product/11.2.0/bin/
     
    chmod 6751 oracle
     
    TNS-12555: TNS:permission denied
     
    cd /var/tmp
     
    chown -R oracle:oinstall .oracle
    
    sqlplus / as sysdba
    @$ORACLE_HOME/rdbms/admin/utlsampl.sql
    
    alter user scott account unlock;
    commit;
    
    
    systemctl stop firewalld.service
    systemctl stop firewalld
    
    alter user scott account unlock;
    alter user scott identified by tiger;
    grant connect to scott;
    View Code
  • 相关阅读:
    仿美团pc,koa+ssr(四)
    基本的数据库操作脚本
    jQuery选择器总结
    经常学习参考网站
    WebAPI
    Sqlserver 基本面试题
    truncate和delete的区别
    Webservice,WCF,WebAPI 之间的区别
    WCF 学习
    学习angularJs(1)--引用文件
  • 原文地址:https://www.cnblogs.com/xiaodebing/p/11274024.html
Copyright © 2020-2023  润新知