Centos7之Oracle12c安装与远程连接配置

2024-02-14 12:36

本文主要是介绍Centos7之Oracle12c安装与远程连接配置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

Centos7之Oracle12c安装与远程连接配置

文章目录

  • Centos7之Oracle12c安装与远程连接配置
  • 1.Oracle官网
  • 2. Centos7中安装Oracle12c(12.2.0.1.0)
    • 2.1 Introduction (介绍)
    • 2.2 Prerequisites(先决条件)
    • 2.3 Installation Steps(安装步骤)
    • 2.4 Oracle Installer Screens(Oracle安装程序屏幕)
    • 2.5 Post Installation Tasks(安装后任务)
    • 2.6 Oracle Environment(Oracle环境变量)
    • 2.7 登录验证
    • 2.8 PL/SQL developer连接Oracle数据库
      • 2.8.1 配置Oracle监听
      • 2.8.2 使用Pl/SQL developer连接数据库服务器

1.Oracle官网

  1. 官网地址
  1. 官网文档地址:https://docs.oracle.com/en/database/oracle/oracle-database
  2. Oracle12c文档地址:https://docs.oracle.com/en/database/oracle/oracle-database/12.2/index.html

2. Centos7中安装Oracle12c(12.2.0.1.0)

2.1 Introduction (介绍)

本安装指南说明如何在Centos7中安装Oracle12c

Reference System:

[root@yuan ~]# hostnamectlStatic hostname: yuanIcon name: computer-laptopChassis: laptopMachine ID: 28ea7433e24341a892abab3fd175abc8Boot ID: 7f9eb0c180e14bd99d6db7b5ae6d1416Operating System: CentOS Linux 7 (Core)CPE OS Name: cpe:/o:centos:centos:7Kernel: Linux 3.10.0-957.10.1.el7.x86_64Architecture: x86-64

2.2 Prerequisites(先决条件)

  1. After a successful OS installation, verify the hostname and register it in your DNS. Alternatively add your hostname/IP to the /etc/hosts.

成功安装操作系统后,请验证主机名并将其注册到DNS中。或者将主机名/IP添加到/etc/hosts。

[root@yuan ~]# cat /etc/hostname
yuan
  1. Leave the SELinux in enforcing mode as well as the firewall enabled

使SELinux处于强制模式,并启用防火墙

[root@yuan ~]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   enforcing
Mode from config file:          enforcing
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      31
[root@yuan ~]# firewall-cmd --state
running
  1. Update the CentOS system with the latest packages

    使用最新的软件包更新CentOS系统

[root@yuan ~]# yum update -y
  1. 下载Oracle安装包

官网下载地址:https://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html

2.3 Installation Steps(安装步骤)

  1. Create required OS users and groups for Oracle Database.

    为Oracle数据库创建所需的操作系统用户和组

[root@yuan ~]# groupadd oinstall
[root@yuan ~]# groupadd dba
[root@yuan ~]# useradd -g oinstall -G dba oracle
[root@yuan ~]# passd oracle #回车后输入Oracle用户的密码,如myoracle
  1. Add the following kernel parameters to the */etc/sysctl.conf

    将以下内核参数添加到/etc/sysctl.conf文件中

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1987162112
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
  1. Check and apply the new values.(检查并应用新值)
[root@yuan ~]# sysctl -p
  1. Specify limits for oracle user in the /etc/security/limits.conf

    在/etc/security/limits.conf中指定Oracle用户的限制

[root@yuan ~]# vim /etc/security/limits.conf 然后在文件末尾添加如下代码oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
  1. 解压下载好的文件到/stage/目录下
[root@yuan ~]# yum install -y zip unzip # 最新版本已经内置安装了zip与unzip,这句可以不执行
# 解压
[root@yuan ~]# unzip linuxx64_12201_database.zip -d /stage/
  1. Modify permissions on /stage(修改stage的权限)
[root@yuan ~]# chown -R oracle:oinstall /stage/
  1. Create /u01 directory for Oracle software and /u02 for database files.

    为Oracle软件创建/u01目录,为数据库文件创建/u02目录。

[root@yuan ~]# mkdir /u01
[root@yuan ~]# mkdir /u02
[root@yuan ~]# chown -R oracle:oinstall /u01
[root@yuan ~]# chown -R oracle:oinstall /u02
[root@yuan ~]# chmod -R 775 /u01
[root@yuan ~]# chmod -R 775 /u02
[root@yuan ~]# chmod g+s /u01
[root@yuan ~]# chmod g+s /u02
  1. Install required packages(安装所需的包)
[root@yuan ~]# yum install -y binutils.x86_64 compat-libcap1.x86_64 gcc.x86_64 gcc-c++.x86_64 glibc.i686 glibc.x86_64 \
glibc-devel.i686 glibc-devel.x86_64 ksh compat-libstdc++-33 libaio.i686 libaio.x86_64 libaio-devel.i686 libaio-devel.x86_64 \
libgcc.i686 libgcc.x86_64 libstdc++.i686 libstdc++.x86_64 libstdc++-devel.i686 libstdc++-devel.x86_64 libXi.i686 libXi.x86_64 \
libXtst.i686 libXtst.x86_64 make.x86_64 sysstat.x86_64

2.4 Oracle Installer Screens(Oracle安装程序屏幕)

  1. 以“Oracle”用户身份登录并运行Oracle安装程序:
[oracle@yuan ~]$ /stage/database/runInstaller
Starting Oracle Universal Installer...
  1. Security Updates(配置安全更新)

​ 让你填写邮件信息的,直接点击下一步

  1. Installation Option(安装选项)

    创建和配置数据库©(默认选中的是此项)

  2. System Class(系统类)

    桌面类(D),默认此项即可

  3. Typical Installation(典型安装)

    On the Typical Install Configuration screen, specify the key features.

    Oracle base/u01/app/oracle
    Software location/u01/app/oracle/product/12.2.0/dbhome_1
    Database file location/u02
    Global database nameorcl
  4. Create Inventory(创建产品清单)

    Accept the default /u01/app/oraInventory and click Next.

  5. Prerequisite Checks(先决条件检查)

    The Installer automatically verifies all required OS packages and OS kernel settings.

  6. Summary(概要)

    Final chance to edit any installation features. Click Install.

  7. Execute Configuration Scripts(执行配置脚本)

  8. When a request window appears, login as root and execute two scripts:

    [root@yuan ~]# /u01/app/oraInventory/orainstRoot.sh
    Changing permissions of /u01/app/oraInventory.
    Adding read,write permissions for group.
    Removing read,write,execute permissions for world.
    Changing groupname of /u01/app/oraInventory to oinstall.
    The execution of the script is complete.
    
    [root@yuan ~]# /u01/app/oracle/product/12.2.0/dbhome_1/root.sh
    # 中途敲了两次回车
    Performing root user operation.
    The following environment variables are set as:ORACLE_OWNER= oracleORACLE_HOME=  /u01/app/oracle/product/12.1.0/dbhome_1
    Enter the full pathname of the local bin directory: [/usr/local/bin]: <PRESS ENTER>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.
    You can follow the installation in a separated window.
    
  9. Installation progress(安装进度)

    Another window opens to show you the installation progress. Do not close this window.

  10. Installation completed successfully

    The last screen inform that the installation is done and displays the Oracle Enterprise Manager URL.

    https://localhost:5500/em

    Click OK to close the Installer.

2.5 Post Installation Tasks(安装后任务)

  1. Login as root and verify the active zones

    以root用户登录并验证活动区域

    [root@yuan ~]# firewall-cmd --get-active-zones
    publicinterfaces: wlp2s0
    

    Open the related ports(打开相关端口)

    [root@yuan ~]# firewall-cmd --zone=public --add-port=1521/tcp --add-port=5500/tcp --add-port=5520/tcp --add-port=3938/tcp --permanent
    success
    
    [root@yuan ~]# firewall-cmd --reload
    success
    
    [root@yuan ~]# firewall-cmd --list-ports
    1521/tcp 5500/tcp 5520/tcp 3938/tcp
    [root@yuan ~]# 
    

2.6 Oracle Environment(Oracle环境变量)

Login as oracle user and add the following values to the /home/oracle/.bash_profile

#切换至Oracle用户
[root@yuan product]# su oracle 
#编辑/home/oracle/.bash_profile文件
[oracle@yuan product]$ vim /home/oracle/.bash_profile
#在文件末尾添加下面信息
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/12.2.0/dbhome_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
PATH=$ORACLE_HOME/bin:$PATH; export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/usr/lib64; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH

Reload the bash_profile to apply the new settings:

[oracle@yuan ~]$ cd /home/oracle
[oracle@yuan ~]$ . .bash_profile

2.7 登录验证

[oracle@yuan ~]$ sqlplus / as sysdbaSQL*Plus: Release 12.2.0.1.0 Production on Fri Apr 26 23:09:29 2019Copyright (c) 1982, 2016, Oracle.  All rights reserved.???: 
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>

查看实例状态

SQL> select status from v$instance;
STATUS
------------
OPEN

关闭数据库

SQL> shutdown immediate;

2.8 PL/SQL developer连接Oracle数据库

2.8.1 配置Oracle监听

如果不配监听:连接时会报:ora-12541:tns:无监听程序

  1. 查看监听状态
oracle@yuan ~]$ lsnrctl status#如果输出的倒数第二行有“The listener supports no service”则表示无监听,
#原因是:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)中的
#HSOT=localhost,将其改为Oracle宿主机自身的IP地址即可,如下:
#(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.31.126)
  1. 修改监听信息
  • 使用netmgr命令启动Net Manager图形管理界面,在listener中将localhost改为对应的IP地址即可。
  • 如果是远程该的话,则使用vim编辑器修改,如下:
[oracle@yuan ~]$ vim /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.LISTENER =(DESCRIPTION_LIST =(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)))(DESCRIPTION =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.126)(PORT = 1521))#这里改为IP即可))ADR_BASE_LISTENER = /u01/app/oracle
  1. 重启监听
[oracle@yuan ~]$ lsnrctl stop
[oracle@yuan ~]$ lsnrctl start

2.8.2 使用Pl/SQL developer连接数据库服务器

这里采用的是不安装Oracle客户端的情况下连接Oracle数据库服务器

  1. 下载instantclient-basic-windows.x64-12.2.0.1.0.zip文件解压到指定位置,如D盘
  2. 解压后,在instantclient_12_2 文件夹下新建 NETWORK\ADMIN 两个文件夹
  3. 在ADMIN文件夹下新建tnsnames.ora文件,内容如下:
ORCL =(DESCRIPTION =(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.31.126)(PORT = 1521))#数据库服务器IP配置)(CONNECT_DATA =(SERVICE_NAME = orcl)#sid))
  1. 配置环境变量
  • TNS_ADMIN配置,目的是打开pl/sql时自动识别要连接的DATABASE

在系统变量中新建TNS_ADMIN=D:\instantclient_12_2\NETWORK\ADMIN 环境变量

  • NLS_LANG配置,目的是解决pl/sql连接后数据显示乱码问题,即查询某个字段后中文显示成???的问题

在系统变量中新建NLS_LANG=SIMPLIFIED CHINESE_CHINA.ZHS16GBK 环境变量

  1. pl/sql developer配置
  • 打开pl/sql developer找到preferences–>Oracle–>Connecttion
  • 将Oracle Home的内容添加为D:\instantclient_12_2
  • 将OCI Library 内容改为D:\instantclient_12_2\oci.dll
  1. 重启Pl/SQL developer,然后连接Oracle数据库即可

这篇关于Centos7之Oracle12c安装与远程连接配置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/708508

相关文章

VScode连接远程Linux服务器环境配置图文教程

《VScode连接远程Linux服务器环境配置图文教程》:本文主要介绍如何安装和配置VSCode,包括安装步骤、环境配置(如汉化包、远程SSH连接)、语言包安装(如C/C++插件)等,文中给出了详... 目录一、安装vscode二、环境配置1.中文汉化包2.安装remote-ssh,用于远程连接2.1安装2

关于rpc长连接与短连接的思考记录

《关于rpc长连接与短连接的思考记录》文章总结了RPC项目中长连接和短连接的处理方式,包括RPC和HTTP的长连接与短连接的区别、TCP的保活机制、客户端与服务器的连接模式及其利弊分析,文章强调了在实... 目录rpc项目中的长连接与短连接的思考什么是rpc项目中的长连接和短连接与tcp和http的长连接短

Redis多种内存淘汰策略及配置技巧分享

《Redis多种内存淘汰策略及配置技巧分享》本文介绍了Redis内存满时的淘汰机制,包括内存淘汰机制的概念,Redis提供的8种淘汰策略(如noeviction、volatile-lru等)及其适用场... 目录前言一、什么是 Redis 的内存淘汰机制?二、Redis 内存淘汰策略1. pythonnoe

python管理工具之conda安装部署及使用详解

《python管理工具之conda安装部署及使用详解》这篇文章详细介绍了如何安装和使用conda来管理Python环境,它涵盖了从安装部署、镜像源配置到具体的conda使用方法,包括创建、激活、安装包... 目录pytpshheraerUhon管理工具:conda部署+使用一、安装部署1、 下载2、 安装3

windos server2022的配置故障转移服务的图文教程

《windosserver2022的配置故障转移服务的图文教程》本文主要介绍了windosserver2022的配置故障转移服务的图文教程,以确保服务和应用程序的连续性和可用性,文中通过图文介绍的非... 目录准备环境:步骤故障转移群集是 Windows Server 2022 中提供的一种功能,用于在多个

windos server2022里的DFS配置的实现

《windosserver2022里的DFS配置的实现》DFS是WindowsServer操作系统提供的一种功能,用于在多台服务器上集中管理共享文件夹和文件的分布式存储解决方案,本文就来介绍一下wi... 目录什么是DFS?优势:应用场景:DFS配置步骤什么是DFS?DFS指的是分布式文件系统(Distr

关于Maven中pom.xml文件配置详解

《关于Maven中pom.xml文件配置详解》pom.xml是Maven项目的核心配置文件,它描述了项目的结构、依赖关系、构建配置等信息,通过合理配置pom.xml,可以提高项目的可维护性和构建效率... 目录1. POM文件的基本结构1.1 项目基本信息2. 项目属性2.1 引用属性3. 项目依赖4. 构

龙蜥操作系统Anolis OS-23.x安装配置图解教程(保姆级)

《龙蜥操作系统AnolisOS-23.x安装配置图解教程(保姆级)》:本文主要介绍了安装和配置AnolisOS23.2系统,包括分区、软件选择、设置root密码、网络配置、主机名设置和禁用SELinux的步骤,详细内容请阅读本文,希望能对你有所帮助... ‌AnolisOS‌是由阿里云推出的开源操作系统,旨

Ubuntu系统怎么安装Warp? 新一代AI 终端神器安装使用方法

《Ubuntu系统怎么安装Warp?新一代AI终端神器安装使用方法》Warp是一款使用Rust开发的现代化AI终端工具,该怎么再Ubuntu系统中安装使用呢?下面我们就来看看详细教程... Warp Terminal 是一款使用 Rust 开发的现代化「AI 终端」工具。最初它只支持 MACOS,但在 20

mysql-8.0.30压缩包版安装和配置MySQL环境过程

《mysql-8.0.30压缩包版安装和配置MySQL环境过程》该文章介绍了如何在Windows系统中下载、安装和配置MySQL数据库,包括下载地址、解压文件、创建和配置my.ini文件、设置环境变量... 目录压缩包安装配置下载配置环境变量下载和初始化总结压缩包安装配置下载下载地址:https://d