oracle数据库_安装

一、下载地址

请点击 这里 下载,这里我下载的是 Linux x86-64 19.3。

环境:
oracle version: oracle 19.3.0
操作系统版本: Centos 8
主机ip: 192.168.1.105
主机hostname : oracle-db.hk.com

二、安装前配置

2.1、 使用 oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm 配置

该 rpm会创建oracle用户、相关用户组、以及配置系统的参数,如 /etc/security/limits.d/oracle-database-preinstall-19c.conf

[root@oracle-db kevin]# curl -o oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm
[root@oracle-db kevin]# yum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm 
Last metadata expiration check: 0:13:49 ago on Wed 29 Jul 2020 09:45:57 PM CST.
Error: 
 Problem: conflicting requests
  - nothing provides compat-libcap1 needed by oracle-database-preinstall-19c-1.0-1.el7.x86_64
  - nothing provides compat-libstdc++-33 needed by oracle-database-preinstall-19c-1.0-1.el7.x86_64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

### 当出现上面的依赖包找不到时,执行以下命令
[root@oracle-db kevin]# dnf -y install wget
[root@oracle-db kevin]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
[root@oracle-db kevin]# wget http://mirror.centos.org/centos/7/os/x86_64/Packages/compat-libcap1-1.10-7.el7.x86_64.rpm
[root@oracle-db kevin]# yum localinstall compat-libstdc++-33-3.2.3-72.el7.x86_64.rpm
[root@oracle-db kevin]# yum localinstall compat-libcap1-1.10-7.el7.x86_64.rpm
### 再执行安装
[root@oracle-db kevin]# yum -y localinstall oracle-database-preinstall-19c-1.0-1.el7.x86_64.rpm

2.2、安装依赖包

[root@oracle-db kevin]# yum install bc binutils elfutils-libelf elfutils-libelf-devel fontconfig-devel glibc glibc-devel ksh libaio libaio-devel libgcc libnsl librdmacm-devel libstdc++ libstdc++-devel libX11 libXau libxcb libXi libXrender libXrender-devel libXtst make net-tools nfs-utils python3 python3-configshell python3-rtslib python3-six smartmontools sysstat targetcli unzip

[root@oracle-db ~]# dnf install xterm -y

2.3、配置 network

配置 hostname,在该文件中添加如下内容:

[root@oracle-db ~]#  vim /etc/hosts
192.168.1.105	oracle-db.hk.com

2.4、配置环境变量

切换到 oracle 用户,在这之前,可以为oracle 用户设置一个密码:

[oracle@oracle-db ~]$ passwd oracle # 为oracle用户设置新密码
###配置环境变量
[oracle@oracle-db ~]$ vim .bash_profile
export TMP=/tmp
export TEMPDIR=$TMP
export ORACLE_HOSTNAME=oracle-db.hk.com
export ORACLE_UNQNAME=ORCL
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19c/dbhome_1
export ORA_INVENTORY=/u01/app/oraInventory
export ORACLE_SID=ORCL
export PDB_NAME=pdb 	##这个配置好像没有生效,在使用可插拔数据库时,没有读取到这个配置
export DATA_DIR=/u02/oradata  ##这个配置好像没有生效,还是在 /u01/app/oracle/oradata 目录下
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
[oracle@oracle-db ~]$ source .bash_profile
## 创建相关目录
[root@oracle-db ~]# mkdir /u01/app/oracle/product/19c/dbhome_1 -p
[root@oracle-db ~]# mkdir /u02/oradata -p
[root@oracle-db ~]# chown oracle:oinstall /u01 /u02/ -R

2.5、安装 Server with GUI

如果系统是以图形化界面启动的,此步骤可以省略。

1.查看目前默认的启动默认
[root@oracle-db ~]# systemctl get-default
# 安装图形模式
[root@oracle-db ~]# dnf groupinstall "Server with GUI" -y

启用图形模式:
[root@centos8 ~]# systemctl set-default graphical

2.6、其它配置:

## 1.配置hugepage
[root@oracle-db kevin]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

配置好之后 ,将下载的 oracle安装文件上传到服务器,并解压到 $ORACLE_HOME目录下,重启服务器

2.7、安装 Xstart

这个在 windows 上安装即可 ,在安装 oracle 数据库时,会以图形化界面连接到服务器,可以在360软件管家中搜索安装即可。

三、安装

3.1、修改配置

解压oracle 安装文件到 $ORACLE_HOME 目录后,修改如下配置:

[root@oracle-db ~]# vim $ORACLE_HOME/cv/admin/cvu_config
将  CV_ASSUME_DISTID这一行注释打开,并修改值为 OEL8
否则,在安装 oracle 时会出现 
[WARNING] [INS-08101] Unexpected error while executing the action at state: 'supportedOSCheck' 19c on Oracle Linux 8 这样的错

3.2、使用 Xstart 连接到服务器进行安装

打开windows 安装的 XStart,输入相关信息,点击 Run 会启动 连接服务器的ssh 对话框,注意: 这里的用户名要为 安装 oracle 数据库的用户名.


进入 ssh对话框后,执行如下操作

[oracle@oracle-db dbhome_1]$ who am i ##查询当前用户的 pts,这里为 1
oracle   pts/1        2020-07-30 12:17 (localhost:11.0)
[oracle@oracle-db dbhome_1]$ export DISPLAY=192.168.1.99:1.0  ## DISPLAY的格式为 IP:tps:0  这里的 tps要和 who as i 的一样,不然在执行安装的时候会报错如下
[oracle@oracle-db dbhome_1]$ ./runInstaller 
ERROR: Unable to verify the graphical display setup. This application requires X display. Make sure that xdpyinfo exist under PATH variable.

Can't connect to X11 window server using '192.168.1.99:0.0' as the value of the DISPLAY variable.
如果你看到 oracle安装向导出现在你的面前,恭喜你,以上的配置都成功了。

3.3、根据向导安装数据库

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-zJbUo8Pz-1651643196841)(http://119.23.31.32/resources/blog/oracle/oracle_3.png)]

四、启动、关闭数据库

方式一、 使用命令启动

1、启动监听/停止监听/查看状态:

[oracle@oracle-db bin]$ lsnrctl start | stop | status 

2、启动实例:

[oracle@oracle-db bin]$ sqlplus / as sysdba
SQL > shutdown  ## 停止
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL > startup  ## 启动
ORACLE instance started.

Total System Global Area 2449473096 bytes
Fixed Size		    9137736 bytes
Variable Size		  536870912 bytes
Database Buffers	 1895825408 bytes
Redo Buffers		    7639040 bytes
Database mounted.
Database opened.
SQL> 

方式二、使用 oracle 内置脚本启动

1、修改配置

[oracle@oracle-db ~]$ vim /etc/oratab
 将该文件中的  orcl:/u01/app/oracle/product/19c/dbhome_1:N 改为 orcl:/u01/app/oracle/product/19c/dbhome_1:Y

2 、修改 dbstart 与 dbshut 文件

[oracle@oracle-db ~]$ whereis dbstart
dbstart: /u01/app/oracle/product/19c/dbhome_1/bin/dbstart
[oracle@oracle-db ~]$ cd /u01/app/oracle/product/19c/dbhome_1/bin/
[oracle@oracle-db bin]$ vim dbstart
ORACLE_HOME_LISTNER=$ORACLE_HOME  ## 将文件中的  ORACLE_HOME_LISTNER 改为 $ORACLE_HOME
[oracle@oracle-db bin]$ vim dbshut
ORACLE_HOME_LISTNER=$ORACLE_HOME  ## 将文件中的  ORACLE_HOME_LISTNER 改为 $ORACLE_HOME

启动服务 : dbstart ,会启动数据库 Listener 和 数据库实例,PDB 会被 Mounted,不会被 open ,如果要 open PDB 服务,可按如下方式:

[oracle@oracle-db bin]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jul 31 22:18:15 2020
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
SQL > show con_name;  ## 查看当前的 con_name ,为 CDB

CON_NAME
------------------------------
CDB$ROOT
SQL >

SQL> show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB				  MOUNTED    ## 状态只是 Mounted.

SQL > alter pluggable database PDB open;  ## 打开指定的 PDB服务 ,这里的PDB 是指 CON_NAME,这里只是刚好这个CON_NAME为 PDB而已。

Pluggable database altered.

SQL > show pdbs;

    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 PDB				  READ WRITE NO
SQL >

关闭服务 dbshut,会关闭数据库Listener和 数据库实例。

五、配置数据库/PDB

按照上面的使用 Xstart 连接到服务器后,在 ssh 中输入 dbca 会弹出 创建/配置数据库向导,按照步骤操作即可。

六、CDB 与PDB 操作

参考文档:
https://www.linuxidc.com/Linux/2019-02/156932.htm

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hellowordx007

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值