首页 > 数据库 >CentOS7.9部署Oracle

CentOS7.9部署Oracle

时间:2023-10-16 11:14:14浏览次数:63  
标签:00 部署 ORACLE CentOS7.9 orcl oracle Oracle ora

CentOS7.9部署Oracle整体思路

  1. 准备好CentOS7.9系统和Oracle安装包。Oracle下载链接:https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
    系统配置最低要求:1c,2G
    可用内存需要交换空间
    介于1 GB和2 GB之间 RAM大小的1.5倍
    介于2 GB和16 GB之间 等于RAM的大小
    超过16 GB 16 GB
  2. 导入安装包
  3. 检查软件环境依赖包
  4. Oracle前系统配置(Oracle部署前准备)
  5. 重启系统
  6. 部署Oracle
  7. 执行
  8. 配置监听程序
  9. 静默创建数据库
  10. 设置Oracle开机启动
  11. 启动文件提权
  12. 防火墙放通Oracle的端口或关闭防火墙

Oracle部署

系统环境准备

  1. 手动添加swap分区(若有swap分区可忽略)
    dd if=/dev/zero of=/swap bs=1024 count=2048000
    mkswap /swap
    chmod 600 /swap
    swapon /swap
    echo "/swap swap swap default 0 0">>/etc/fstab  #设置成自动挂载
    

     

  2. 配置hostname
    hostnamectl set-hostname oracledb
    echo "127.0.0.1     oracledb" >>/etc/hosts
    

     

  3. 关闭selinux
    sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config  
    setenforce 0
    

     

     

  4. 安装Oracle安装依赖环境

     安装命令:

    yum -y install binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
    yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*i686 compat-libstdc++-33*.devel compat-libstdc++-33 compat-libstdc++-33*.devel gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc++ libstdc++*.i686 libstdc++-devel libstdc++-devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686

     
    检查依赖包安装是否成功:

    rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel | grep "not installed"
    rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel | wc -l

     

  5. 创建用户组和用户
    groupadd oinstall
    groupadd dba
    groupadd oper
    useradd -g oinstall -G dba oracle

    #Oracle inventory组(通常为 oinstall)

    #OSDBA组 (通常为 dba)

    #OSOPER组 (通常为 oper)

    #Oracle软件所有者(通常为 oracle)

     
    修改Oracle用户的密码:

    passwd oracle
    

     

     

  6. 配置内核参数和资源限制
    /etc/sysctl.conf添加如下参数,如果系统中某个参数高于下面的参数的值 ,保留较大的值,下面的数值只是官方要求的最小值,可以根据系统调整数值,以优化系统性能
    fs.aio-max-nr = 1048576
    fs.file-max = 6815744
    kernel.shmall = 2097152
    kernel.shmmax = 536870912
    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 = 1048576
    

     
    使内核参数生效:

    sysctl -p
    

     
    /etc/security/limits.conf中添加如下参数:

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

     


    在/etc/pam.d/login文件中,添加下面内容:

    session required /lib64/security/pam_limits.so
    session required 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
    

     
    使用/etc/profile文件生效:

    source /etc/profile
    

    禁用使用Transparent HugePages(启用Transparent HugePages,可能会导致造成内存在运行时的延迟分配,Oracle官方建议使用标准的HugePages):

    查看是否启用 如果显示 [always]说明启用了:
    cat /sys/kernel/mm/transparent_hugepage/enabled
    

    禁用Transparent HugePages,在/etc/grub.conf添加如下内容:

    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    

     
    重新启动系统更改成为永久更改

  7. 创建Oracle安装目录
    mkdir -p /data/app/
    chown -R oracle:oinstall /data/app/
    chmod -R 775 /data/app/
    

     

     

  8. 配置Oracle用户环境变量
    在文件/home/oracle/.bash_profile里添加下面内容(具体值根据实际情况修改):
    umask 022
    export ORACLE_HOSTNAME=oracledb
    export ORACLE_BASE=/data/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"
    

     

     

     

  9. 重启系统
    reboot
    

     

  10. 安装Oracle
    安装rpm安装包
    rpm -ivh oracle-database-free-23c-1.0-1.el8.x86_64.rpm --force --nodeps
    

     

  11. 配置监听配置
    su - oracle
    netca /silent /responsefile /data/etc/netca.rsp
    
    #输出结果
    [oracle@oracledb ~]$ netca /silent /responsefile /data/etc/netca.rsp
    
    Parsing command line arguments:
        Parameter "silent" = true
        Parameter "responsefile" = /data/etc/netca.rsp
    Done parsing command line arguments.
    Oracle Net Services Configuration:
    Profile configuration complete.
    Oracle Net Listener Startup:
        Running Listener Control:
          /data/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
        Listener Control complete.
        Listener started successfully.
    Listener configuration complete.
    Oracle Net Services configuration successful. The exit code is 0
    

    查看监听

    netstat -tnpl | grep 1521
    

     

  12. 创建数据库
    编辑应答文件/data/etc/dbca.rsp
    [GENERAL]
    RESPONSEFILE_VERSION = "11.2.0"
    OPERATION_TYPE = "createDatabase"
    [CREATEDATABASE]
    GDBNAME = "orcl"
    SID = "orcl"
    SYSPASSWORD = "oracle"
    SYSTEMPASSWORD = "oracle"
    SYSMANPASSWORD = "oracle"
    DBSNMPPASSWORD = "oracle"
    DATAFILEDESTINATION =/data/app/oracle/oradata
    RECOVERYAREADESTINATION=/data/app/oracle/fast_recovery_area
    CHARACTERSET = "AL32UTF8"
    TOTALMEMORY = "1638"
    

    执行静默建库:

    su - oracle
    dbca -silent -responseFile /data/etc/dbca.rsp
    

    执行过程如下:

    [oracle@oracledb ~]$ dbca -silent -responseFile /data/etc/dbca.rsp
    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
    60% complete
    62% complete
    Completing Database Creation
    66% complete
    70% complete
    73% complete
    85% complete
    96% complete
    100% complete
    Look at the log file "/data/app/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
    

     查看进程:

    ps -ef | grep ora_ | grep -v grep
    
    # 执行结果
    [oracle@oracledb ~]$ ps -ef | grep ora_ | grep -v grep
    oracle   19304     1  0 18:33 ?        00:00:00 ora_pmon_orcl
    oracle   19306     1  0 18:33 ?        00:00:00 ora_vktm_orcl
    oracle   19310     1  0 18:33 ?        00:00:00 ora_gen0_orcl
    oracle   19312     1  0 18:33 ?        00:00:00 ora_diag_orcl
    oracle   19314     1  0 18:33 ?        00:00:00 ora_dbrm_orcl
    oracle   19316     1  0 18:33 ?        00:00:00 ora_psp0_orcl
    oracle   19318     1  0 18:33 ?        00:00:00 ora_dia0_orcl
    oracle   19320     1  0 18:33 ?        00:00:00 ora_mman_orcl
    oracle   19322     1  0 18:33 ?        00:00:00 ora_dbw0_orcl
    oracle   19324     1  0 18:33 ?        00:00:00 ora_lgwr_orcl
    oracle   19326     1  0 18:33 ?        00:00:00 ora_ckpt_orcl
    oracle   19328     1  0 18:33 ?        00:00:00 ora_smon_orcl
    oracle   19330     1  0 18:33 ?        00:00:00 ora_reco_orcl
    oracle   19332     1  0 18:33 ?        00:00:00 ora_mmon_orcl
    oracle   19334     1  0 18:33 ?        00:00:00 ora_mmnl_orcl
    oracle   19336     1  0 18:33 ?        00:00:00 ora_d000_orcl
    oracle   19338     1  0 18:33 ?        00:00:00 ora_s000_orcl
    oracle   19361     1  0 18:34 ?        00:00:00 ora_qmnc_orcl
    oracle   19376     1  0 18:34 ?        00:00:00 ora_cjq0_orcl
    oracle   19396     1  0 18:34 ?        00:00:00 ora_q000_orcl
    oracle   19398     1  0 18:34 ?        00:00:00 ora_q001_orcl
    

    查看监听状态:

    $ lsnrctl status
    
    #结果
    [oracle@oracledb ~]$ lsnrctl status
    
    LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 02-JAN-2019 18:36:15
    
    Copyright (c) 1991, 2009, Oracle.  All rights reserved.
    
    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                02-JAN-2019 18:20:21
    Uptime                    0 days 0 hr. 15 min. 54 sec
    Trace Level               off
    Security                  ON: Local OS Authentication
    SNMP                      OFF
    Listener Parameter File   /data/app/oracle/product/11.2.0/network/admin/listener.ora
    Listener Log File         /data/app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
    Listening Endpoints Summary...
      (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
      (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))
    Services Summary...
    Service "orcl" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    Service "orclXDB" has 1 instance(s).
      Instance "orcl", status READY, has 1 handler(s) for this service...
    The command completed successfully
    [oracle@oracledb ~]$
    

     

  13. 登录数据库
    su - oracle
    sqlplus / as sysdba
    select status from v$instance;
    

     

  14. 执行select时异常状态:
    SQL> select status from v$instance;
    select status from v$instance
    *
    ERROR at line 1:
    ORA-01034: ORACLE not available
    Process ID: 0
    Session ID: 0 Serial number: 0
    

     

  15. 执行select时异常处理方法:
    输入startup
    #startup的输出提示:
    SQL> statup
    SP2-0042: unknown command "statup" - rest of line ignored.
    SQL> startup
    ORA-01078: failure in processing system parameters
    LRM-00109: could not open parameter file '/data/app/oracle/product/11.2.0/dbs/initORCL.ora'
    

    根据提示,将 O R A C L E B A S E / a d m i n / 数 据 库 名 称 / p f i l e 目 录 下 的 i n i t . o r a . x x x 形 式 的 文 件 c o p y 到 ORACLE_BASE/admin/数据库名称/pfile目录下的init.ora.xxx形式的文件copy到 ORACLEB​ASE/admin/数据库名称/pfile目录下的init.ora.xxx形式的文件copy到ORACLE_HOME/dbs目录下initOracle.ora(根据startup提示)即可

    cp /data/app/oracle/admin/orcl/pfile/init.ora.022019183329 initORCL.ora
    

     查看数据库编码:

    select * from v$version;
    
    #结果
    SQL> select * from v$version;
    
    BANNER
    --------------------------------------------------------------------------------
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE	11.2.0.1.0	Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    

     激活scott用户

    alter user scott account unlock;
    alter user scott identified by tiger;
    select username,account_status from dba_users;
    

     

  16. 设置Oracle开机自启动
    修改/data/app/oracle/product/11.2.0/bin/dbstart
    ORACLE_HOME_LISTNER=$ORACLE_HOME
    

    修改/data/app/oracle/product/11.2.0/bin/dbshut

    ORACLE_HOME_LISTNER=$ORACLE_HOME
    

    修改vi /etc/oratab

    orcl:/data/app/oracle/product/11.2.0:Y
    

    新建文件/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=/data/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
    

    /etc/init.d/oracle添加执行权限:

    chmod +x /etc/init.d/oracle
    

    开机启动oracle

    systemctl enable oracle
    或
    chkconfig oracle on
    

    给启动文件加权限

    cd /data/app/oracle/product/11.2.0/bin/
    chmod 6751 oracle
    cd /var/tmp
    chown -R oracle:oinstall .oracle
    

     

  17. 防火墙端口开放Oracle使用的端口或关闭防火墙
    #关闭Oracle使用的端口
    firewall-cmd --zone=public --add-port=1521/tcp --permanent firewall-cmd --reload
    #关闭防火墙
    systemctl stop firewalld
    systemctl disable firewalld
    systemctl status firewalld

     

     

 

标签:00,部署,ORACLE,CentOS7.9,orcl,oracle,Oracle,ora
From: https://www.cnblogs.com/sawyerhan/p/17734714.html

相关文章

  • 自动化环境部署后银河麒麟开始速度变慢
    问题刚刚装好的银河麒麟V10Sp1系统正常开机20s左右,但是部署完自动化环境(python+pytest+dogtail+opencv+allure)之后开机速度变慢了增加到了58s。解决办法排查后发现是exportQT_LINUX_ACCESSIBILITY_ALWAYS_ON=1>>/etc/profile导致的麒麟默认是关闭了该配置=0该环境变量......
  • 部署项目 Failure obtaining db row lock: Table ‘XXX.qrtz_LOCKS‘ doesn‘t exist
    系统环境centos7MySQL5.7原因:mysql对表大小写有要求,但是当时创建表的时候都是小写,所以说就查不到qrtz_LOCKS这张表,所以就报错了解决办法:找到mysql的配置文件my.cnf路径在etc/my.cnfcdetcvimmy.cnf此时点击A键触发编辑命令然后找到位置输入lower_case_table_names......
  • 部署 Docker 容器
    一.基于centos的rpm方式部署docker1)添加docker的软件源[root@docker~]#curl-s-o/etc/yum.repos.d/docker-ce.repohttps://download.docker.com/linux/centos/docker-ce.repo2)查看现有的docker版本[root@docker~]#yumlistdocker-ce--showduplicates|sort......
  • docker安装配置oracle19c
    1.拉取oracle19c镜像,我这边使用的是:registry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle2.创建Oracle容器: dockerrun-d-p1521:1521--nameoracle19c-dregistry.cn-hangzhou.aliyuncs.com/zhuyijun/oracle:19c  可以看到状态是Starting,具体日志可以查看 dock......
  • LINUX部署服务
    后端服务路径/opt/server前端服务路径/usr/local/nginxMYSQL更换触发器source/usr/t_user_alpha.sqlmysql重启servicemysqldrestart修改文件名mv文件名修改后的文件名进入mysqlmysql-uroot-p添加字段ALTERTABLEstudentADDageINT(4)进入窗口screen-rruoyi查看java进......
  • Oracle分区表技术详解
    Oracle是如何存储数据的?逻辑存储与物理存储在国企或者一线大厂,一般都会选择使用Oracle数据库,程序通过mybatis等持久层框架访问Oracle数据库,指定表空间,表空间内包含若干张表,表中存有行数据,行数据以行片段的形式存储在数据库块中,①当插入的行太大,无法装入单个块时;②或因为更新的......
  • 使用GitHub Actions自动部署Hexo博客
    准备两个仓库源码库:hexo源码仓库网页库:{username}.github.io目标在源码库编写博客,推送到远端后,触发GithubActions。Actions配置hexo环境,生成hexo文件后,推送到网页库。推送网页到网页库的权限问题,通过Github的accesstoken解决(https://github.com/settings/token......
  • Django 代码部署运行(Windows)
     安装git 准备好文件夹E:\_prjct\boshi_xinxi_caiji\codes2 启动gitbash$pwd/E/_prjct/boshi_xinxi_caiji/codes2$gitclonehttps://gitee.com/xautstar/doctoral-dissertation-collection.git   创建数据库collection,修改用户和密码  在sqlyog......
  • Oracle的存储过程
    Oracle存储过程简介什么是存储过程在oracle中,存储过程是为了完成特定功能的SQL语句集,编译后存储在数据库中,用户通过指定存储过程名字并给出参数(如果该存储过程带有参数)来调用存储过程。存储过程有什么优点效率高:存储过程编译一次后,就会存到数据库,每次调用时都直接执行,而如果......
  • Oracle重新编译视图
    当表名、列名、列类型等底层表的信息发生改变的时候,就会使得视图无法使用,其时就需要对视图进行重新的编译。第一步,查找失效的视图。可以使用数据字典中的user_objects来查找出失效的视图名,还可以利用user_views来查找出相应视图的代码信息。基本的代码如下:----------------查......