首页 > 数据库 >CentOS7_Oracle12C 安装非容器数据库

CentOS7_Oracle12C 安装非容器数据库

时间:2022-11-15 21:04:25浏览次数:62  
标签:java 数据库 CentOS7 Oracle12C yum install oracle net root

Oracle12C 安装非容器数据库

1.安装环境准备

1.1 条件准备

  • Oracle安装包:linuxx64_12201_database.zip

  • SSH远程工具:Mobax

  • VM ware虚拟机:centos7.6(内存:2G, Swap: 3G 磁盘: 40G)

  • 网路环境:内网

  • 其他软件包:rlwrap-0.37-1.el6.x86_64.rpm

1.2 配置安装环境

使用MobaX以root用户登录虚拟机进行以下操作

  • 修改主机名

    [root@localhost ~]# hostnamectl set-hostname oracle 
    
  • 修改本地dns文件

    填写真实ip和主机名

    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    192.168.100.66 oracle
    
  • 重新挂载系统光盘镜像

    img

  • 挂载光盘

    [root@oracle]# mount /dev/cdrom /mnt
    
    mount: /mnt: <u>WARNING</u>: device write-protected, mounted read-only.
    
  • 创建本地仓库

    [root@oracle]# mkdir /yums
    
  • 创建本地仓库

    
    [root@oracle mnt]# cp -r Packages /yums/
    [root@oracle mnt]# cp -r repodata /yums/
    [root@oracle /]# rm -rf /etc/yum.repos.d/*
    [root@oracle /]# vi /etc/yum.repos.d/BaseOS.repo
    [BaseOS]
    name=BaseOS
    baseurl=file:///yums
    gpgcheck=0
    enabled=1
    
    [root@oracle /]# yum makecache
    BaseOS                                          181 MB/s | 2.6 MB     00:00
    Metadata cache created.
    
* 安装ORACLE先决条件的软件包

  yum install -y bc
  yum install -y compat-libcap1*
  yum install -y compat-libcap*
  yum install -y binutils 
  yum install -y compat-libstdc++-33 
  yum install -y elfutils-libelf 
  yum install -y elfutils-libelf-devel 
  yum install -y gcc 
  yum install -y gcc-c++ 
  yum install -y glibc-2.5 
  yum install -y glibc-common 
  yum install -y glibc-devel 
  yum install -y glibc-headers 
  yum install -y ksh libaio 
  yum install -y libaio-devel 
  yum install -y libgcc 
  yum install -y libstdc++ 
  yum install -y libstdc++-devel 
  yum install -y make 
  yum install -y sysstat 
  yum install -y unixODBC 
  yum install -y unixODBC-devel
  yum install -y binutils*
  yum install -y compat-libstdc*
  yum install -y elfutils-libelf*
  yum install -y gcc*
  yum install -y glibc*
  yum install -y ksh*
  yum install -y libaio*
  yum install -y libgcc*
  yum install -y libstdc*
  yum install -y make*
  yum install -y sysstat*
  yum install -y libXp*
  yum install -y glibc-kernheaders
  yum install -y net-tools-*
  
  • 修改内核文件

    [root@oracle /]# vim /etc/sysctl.conf
    # sysctl settings are defined through files in
    # /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
    #
    # Vendors settings live in /usr/lib/sysctl.d/.
    # To override a whole file, create a new file with the same in
    # /etc/sysctl.d/ and put new settings there. To override
    # only specific settings, add a file with a lexically later
    # name in /etc/sysctl.d/ and put new settings there.
    #
    # For more information, see sysctl.conf(5) and sysctl.d(5).
    kernel.shmmax = 1073741823
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048586
    fs.file-max = 6815744
    kernel.shmall = 4294967296
    net.ipv4.tcp_max_tw_buckets = 6000
    net.ipv4.ip_local_port_range = 9000 65500
    net.ipv4.tcp_tw_recycle = 0
    net.ipv4.tcp_tw_reuse = 1
    #net.core.somaxconn = 262144
    net.core.netdev_max_backlog = 262144
    net.ipv4.tcp_max_orphans = 262144
    net.ipv4.tcp_max_syn_backlog = 262144
    net.ipv4.tcp_synack_retries = 2
    net.ipv4.tcp_syn_retries = 1
    net.ipv4.tcp_fin_timeout = 1
    net.ipv4.tcp_keepalive_time = 30
    net.ipv4.tcp_keepalive_probes = 6
    net.ipv4.tcp_keepalive_intvl = 5
    net.ipv4.tcp_timestamps = 0
    fs.aio-max-nr = 1048576
    net.ipv4.conf.all.rp_filter = 2
    
    [root@oracle /]# sysctl -p
    kernel.shmmax = 1073741823
    kernel.shmmni = 4096
    kernel.sem = 250 32000 100 128
    net.core.rmem_default = 262144
    net.core.rmem_max = 4194304
    net.core.wmem_default = 262144
    net.core.wmem_max = 1048586
    fs.file-max = 6815744
    kernel.shmall = 4294967296
    net.ipv4.tcp_max_tw_buckets = 6000
    net.ipv4.ip_local_port_range = 9000 65500
    net.ipv4.tcp_tw_recycle = 0
    net.ipv4.tcp_tw_reuse = 1
    net.core.netdev_max_backlog = 262144
    net.ipv4.tcp_max_orphans = 262144
    net.ipv4.tcp_max_syn_backlog = 262144
    net.ipv4.tcp_synack_retries = 2
    net.ipv4.tcp_syn_retries = 1
    net.ipv4.tcp_fin_timeout = 1
    net.ipv4.tcp_keepalive_time = 30
    net.ipv4.tcp_keepalive_probes = 6
    net.ipv4.tcp_keepalive_intvl = 5
    net.ipv4.tcp_timestamps = 0
    fs.aio-max-nr = 1048576
    net.ipv4.conf.all.rp_filter = 2
    
* 修改系统限制文件

```bash
[root@oracle /]# vi /etc/security/limits.conf
oracle   soft   nofile    1024
oracle   hard   nofile    65536
oracle   soft   nproc    16384
oracle   hard   nproc    16384
oracle   soft   stack    10240
oracle   hard   stack    32768
oracle   hard   memlock    134217728
oracle   soft   memlock    134217728
  • 限制使用进程数

    [root@oracle /]# vim /etc/pam.d/login
    session required /lib/security/pam_limits.so
    session required pam_limits.so
    
  • 修改环境变量

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

    [root@oracle /]# vim /etc/profile
    
    # By default, we want umask to get set. This sets it for login shell
    # Current threshold for system reserved uid/gids is 200
    # You could check uidgid reservation validity in
    # /usr/share/doc/setup-*/uidgid file
    if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then
        umask 002
    else
        umask 022
    fi
    
    for i in /etc/profile.d/*.sh /etc/profile.d/sh.local ; do
        if [ -r "$i" ]; then
            if [ "${-#*i}" != "$-" ]; then
                . "$i"
            else
                . "$i" >/dev/null
            fi
        fi
    done
    
    unset i
    unset -f pathmunge
    
    if [ -n "${BASH_VERSION-}" ] ; then
            if [ -f /etc/bashrc ] ; then
                    # Bash login shells run only /etc/profile
                    # Bash non-login shells run only /etc/bashrc
                    # Check for double sourcing is done in /etc/bashrc.
                    . /etc/bashrc
           fi
    fi
    if [ $USER = "oracle" ]; then
       if [ $SHELL = "/bin/ksh" ]; then
          ulimit -p 16384
          ulimit -n 65536
          else
          ulimit -u 16384 -n 65536
       fi
    fi
    
  • 创建用户和用户组

    groupadd oinstall

    groupadd dba

    groupadd oper

    useradd -g oinstall -G dba,oper oracle

    mkdir -p /u01/app/oracle

    mkdir -p /u01/oraInventory

    chown -R oracle.oinstall /u01

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

    chmod -R 775 /u01/app/oracle

    [root@oracle /]# groupadd oinstall
    [root@oracle /]# groupadd dba
    [root@oracle /]# groupadd oper
    [root@oracle /]# useradd -g oinstall -G dba,oper oracle
    [root@oracle /]# mkdir -p /u01/app/oracle
    [root@oracle /]# mkdir -p /u01/oraInventory
    [root@oracle /]# chown -R oracle.oinstall /u01
    [root@oracle /]# chown -R oracle:oinstall /u01/app/oracle
    [root@oracle /]# chmod -R 775 /u01/app/oracle
    
  • 修改oracle用户密码

    passwd oracle

    [root@oracle /]# passwd oracle
    Changing password for user oracle.
    New password:
    BAD PASSWORD: The password is a palindrome
    Retype new password:
    passwd: all authentication tokens updated successfully.
    
  • 配置Oracle用户环境变量

    [oracle@oracle ~]$ su - oracle
    [oracle@oracle ~]$ vim .bash_profile
    

    export EDITOR=vi

    export TMP=/tmp

    export TMPDIR=$TMP

    export ORACLE_SID=orcl

    export ORACLE_BASE=/u01/app/oracle

    export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1

    export INVENTORY_LOCATION=/u01/oraInventory

    export TNS_ADMIN=$ORACLE_HOME/network/admin

    export LD_LIBRARY_PATH=$ORACLE_HOME/lib

    export
    NLS_LANG="AMERICAN_AMERICA.AL32UTF8"
    export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"

    export PATH=ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:PATH:$HOME/bin
    umask 022、

    [oracle@oracle ~]$ vim .bash_profile
    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi
    
    # User specific environment and startup programs
    export EDITOR=vi
    export TMP=/tmp
    export TMPDIR=$TMP
    export ORACLE_SID=orcl
    export ORACLE_BASE=/u01/app/oracle
    export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
    export INVENTORY_LOCATION=/u01/oraInventory
    export TNS_ADMIN=$ORACLE_HOME/network/admin
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export NLS_LANG="American_america.zhs16gbk"
    export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
    export PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/bin:$PATH:$HOME/bin
    umask 022
    [oracle@oracle ~]$ source .bash_profile
    
  • 上传Oracle压缩包到/u01下

2. 安装Oracle数据软件

2.1 安装准备

  • 解压缩安装包

    [root@oracle u01]# unzip linuxx64_12201_database.zip
    
  • 修改database文件目录权限

    [root@oracle u01]# chown -R oracle:oinstall database/
    
  • 切换到oracle用户安装数据库软件

    [oracle@oracle ~]$ cd /u01/database/
    [oracle@oracle database]$ export DISPLAY=192.168.100.6:0.0 
    [oracle@oracle database]$ ./runInstaller
    

    注:如果报一下错误,尝试以root用户安装xdpyinfo

    [oracle@oracle database]$ ./runInstaller
    Starting Oracle Universal Installer...
    
    Checking Temp space: must be greater than 500 MB.   Actual 9210 MB    Passed
    Checking swap space: must be greater than 150 MB.   Actual 1978 MB    Passed
    Checking monitor: must be configured to display at least 256 colors
        >>> Could not execute auto check for display colors using command /usr/bin/xdpyinfo. Check if the DISPLAY variable is set.    Failed <<<<
    
    Some requirement checks failed. You must fulfill these requirements before
    
    continuing with the installation,
    

    注:如果报以下错误,日志显示为缺少 libnsl.so.1,需安装libnsl.so.1

    img

    [oracle@oracle database]$ cat /tmp/OraInstall2022-11-12_03-04-59PM/oraInstall2022-11-12_03-04-59PM.err
    java.lang.UnsatisfiedLinkError: /tmp/OraInstall2022-11-12_03-04-59PM/oui/lib/linux64/liboraInstaller.so: libnsl.so.1: cannot open shared object file: No such file or directory
            at java.lang.ClassLoader$NativeLibrary.load(Native Method)
            at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
            at java.lang.Runtime.load0(Runtime.java:809)
            at java.lang.System.load(System.java:1086)
            at oracle.sysman.oii.oiip.osd.unix.OiipuUnixOps.loadNativeLib(OiipuUnixOps.java:364)
            at oracle.sysman.oii.oiip.osd.unix.OiipuUnixOps.<clinit>(OiipuUnixOps.java:128)
            at oracle.sysman.oii.oiic.OiicPullSession.createDuplicateStreamsForLog(OiicPullSession.java:5382)
            at oracle.sysman.oii.oiic.OiicPullSession.createDuplicateStreams(OiicPullSession.java:5482)
            at oracle.sysman.oii.oiic.OiicAPIInstaller.initInstallEnvironment(OiicAPIInstaller.java:506)
            at oracle.install.driver.oui.OUIInstallDriver.load(OUIInstallDriver.java:422)
            at oracle.install.ivw.db.driver.DBSetupDriver.load(DBSetupDriver.java:289)
            at oracle.install.commons.base.driver.common.Installer.run(Installer.java:516)
            at oracle.install.ivw.common.util.OracleInstaller.run(OracleInstaller.java:133)
            at oracle.install.ivw.db.driver.DBInstaller.run(DBInstaller.java:139)
            at oracle.install.commons.util.Application.startup(Application.java:1072)
            at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
            at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:198)
            at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:566)
            at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:127)
            at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:165)
    ---# Begin Stacktrace #---------------------------
    ID: oracle.install.commons.util.exception.AbstractErrorAdvisor:8
    oracle.install.commons.base.driver.common.InstallerException: [INS-10102] Installer initialization failed.
            at oracle.install.commons.base.driver.common.Installer.run(Installer.java:534)
            at oracle.install.ivw.common.util.OracleInstaller.run(OracleInstaller.java:133)
            at oracle.install.ivw.db.driver.DBInstaller.run(DBInstaller.java:139)
            at oracle.install.commons.util.Application.startup(Application.java:1072)
            at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:181)
            at oracle.install.commons.flow.FlowApplication.startup(FlowApplication.java:198)
            at oracle.install.commons.base.driver.common.Installer.startup(Installer.java:566)
            at oracle.install.ivw.db.driver.DBInstaller.startup(DBInstaller.java:127)
            at oracle.install.ivw.db.driver.DBInstaller.main(DBInstaller.java:165)
    Caused by: oracle.install.commons.base.driver.common.SetupDriverException: [INS-10012] Setup driver initialization failed.
            at oracle.install.driver.oui.OUIInstallDriver.load(OUIInstallDriver.java:431)
            at oracle.install.ivw.db.driver.DBSetupDriver.load(DBSetupDriver.java:289)
            at oracle.install.commons.base.driver.common.Installer.run(Installer.java:516)
            ... 8 more
    Caused by: java.lang.UnsatisfiedLinkError: no oraInstaller in java.library.path
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
            at java.lang.Runtime.loadLibrary0(Runtime.java:870)
            at java.lang.System.loadLibrary(System.java:1122)
            at oracle.sysman.oii.oiip.osd.unix.OiipuUnixOps.loadNativeLib(OiipuUnixOps.java:380)
            at oracle.sysman.oii.oiip.osd.unix.OiipuUnixOps.<clinit>(OiipuUnixOps.java:128)
            at oracle.sysman.oii.oiic.OiicPullSession.createDuplicateStreamsForLog(OiicPullSession.java:5382)
            at oracle.sysman.oii.oiic.OiicPullSession.createDuplicateStreams(OiicPullSession.java:5482)
            at oracle.sysman.oii.oiic.OiicAPIInstaller.initInstallEnvironment(OiicAPIInstaller.java:506)
            at oracle.install.driver.oui.OUIInstallDriver.load(OUIInstallDriver.java:422)
            ... 10 more
    
    ---# End Stacktrace #-----------------------------
    

    安装方法:

    [root@oracle ~]# dnf install libnsl
    

2.2 安装软件过程

img

img

点击“Yes”继续

img

img

img

img

img

img

img

img

img

img

root用户先后执行这两个脚本

[root@oracle ~]# /u01/oraInventory/orainstRoot.sh
Changing permissions of /u01/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /u01/oraInventory to oinstall.
The execution of the script is complete.
[root@oracle ~]# /u01/app/oracle/product/12.2.0/db_1/root.sh
Performing root user operation.

The following environment variables are set as:
    ORACLE_OWNER= oracle
    ORACLE_HOME=  /u01/app/oracle/product/12.2.0/db_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.
Do you want to setup Oracle Trace File Analyzer (TFA) now ? yes|[no] :

Oracle Trace File Analyzer (TFA - User Mode) is available at :
    /u01/app/oracle/product/12.2.0/db_1/suptools/tfa/release/tfa_home/bin/tfactl

OR

Oracle Trace File Analyzer (TFA - Daemon Mode) can be installed by running this script :
    /u01/app/oracle/product/12.2.0/db_1/suptools/tfa/release/tfa_home/install/roottfa.sh

[root@oracle ~]#

脚本会等待用户输入,一路按回车即可

img

点击“OK”继续下一步

img

安装成功,点击“Close”关闭即可

3. 创建监听程序

3.1创建监听过程

  • 输入netca创建监听器
[oracle@oracle ~]$ export DISPLAY=192.168.100.6:0.0
[oracle@oracle ~]$ netca
  • 创建过程

    一路点击“Next”即可

img

img

选择“No”, 可以根据需求决定是否创建另一个监听器。

点击“Finish

3. 创建数据库实例

3.1 创建过程

[oracle@oracle ~]$ dbca

注:先不创建快速恢复区,安装成功后,也可以再配置快速恢复区。

先选择ASMM,这个同样也可以通过参数修改

注:如果练习的话,可以选择示例schema

点击“Finish

安装完毕,点击“Close”即可

[oracle@oracle ~]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 13-NOV-2022 21:33:48

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oracle)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                13-NOV-2022 20:33:34
Uptime                    0 days 1 hr. 0 min. 14 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
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

输入lsnrctl status,可以看到orcl实例已经注册到监听器上了。

切换root用户可以安装以下内容,解决在sqlplus中按上下键无法查看执行过的命令的问题

[root@oracle u01]$ yum -y install rlwrap-0.37-1.el6.x86_64.rpm

在oracle用户家目录中的.bash_profile中追加以下内容

[oracle@oracle ~]$ vim .bash_profile


alias sqlplus='rlwrap sqlplus'
alias rman='rlwrap rman'

4.安装完毕

标签:java,数据库,CentOS7,Oracle12C,yum,install,oracle,net,root
From: https://www.cnblogs.com/shiqiang-lee/p/16893725.html

相关文章

  • 8.0以上版本MySQL-Driver连接数据库
    一、URLURL解析变更`之前我的MySQL数据库驱动mysql-connector-java版本号为5.1.34,在升级成8.0.9-rc版本后,发现原来的连接方式报错了。故在这里记录一下新版本的MySQL......
  • 数据库锁
    加锁的目的对数据加锁是为了解决事务的隔离性问题,让事务之间相互不影响,每个事务进行操作的时候都必须先对数据加上一把锁,防止其他事务同时操作数据。提交或回滚事务会释......
  • 数据库事务相关
    1、数据库事务的基本概念数据库事务(transaction)是访问并可能操作各种数据项的一个数据库操作序列,这些操作要么全部执行,要么全部不执行,是一个不可分割的工作单位。事务......
  • mysql数据库的备份
    linux备份使用python脚本,要求有python3和mysqldump脚本中保留时间有点问题,不会自动删除,后期再看vim/usr/bin/mysql_bakup.py#!/usr/bin/python36#-*-coding:ut......
  • centos7磁盘空间扩容及挂载目录
    创建的虚拟机,包含两块虚拟硬盘,未分配空间和挂载,其中一块磁盘大小为200G,一块为500G测试环境需要:根目录增加100G,其余做预留   /data目录挂载并分配500G空间。一、根目......
  • 数据库独角兽SingleStore:没有HTAP,机器学习和人工智能都是不切实际的
    SingleStore(前身MemSQL)是一个为数据密集型应用设计的云原生数据库。它是一个分布式的关系型SQL数据库管理系统(RDBMS),具有ANSISQL支持,它以数据摄入、交易处理和查询处......
  • Centos7修改默认网卡名(改为eth0)
    有的时候安装好centos7系统后,发现默认的网卡名不是eth0,为了便于管理,可以手动修改。下面对centos7版本下网卡重命名操作做一记录:1)编辑网卡信息[root@linux~]#cd/etc/sysc......
  • Centos7安装MySQL8.0-操作手册
    一.Mysql8.0.31安装(YUM方式)1)首先删除系统默认或之前可能安装的其他版本的mysql或者mairadb[[email protected]~]#foriin$(rpm-qa|grep-E"mysql|mariadb");dor......
  • Sql Server 数据库导出一张表的数据,为脚本
    https://zhidao.baidu.com/question/1643403394551614060.html1、首先打开sqlserver,找到需要导出的数据库。2、单击右键,选择任务 -> 生成脚本,然后选择下一步。......
  • Linux安装ODBC连接SQLServer数据库
    操作系统:Centos7.21、下载ODBC安装包unixODBC-2.3.9.tar.gzfreetds-1.3.9.tar.gz下载这两个压缩包的地址:ftp://ftp.freetds.org/pub/freetds/stable/ftp://ftp.unixodb......