Oracle 基础知识

Oracle 基础

Disk Layout

$ORACLE_BASE

Before we can install any Oracle software, we need to have a base location. This location is called the Oracle Base, and many times on Unix and Linux environments, the $ORACLE_BASE environment variable is explicitly defined to this location. The OFA guidelines suggests that ORACLE_BASE be located at /u01/app/oracle on Unix and Linux machines. On Windows, ORACLE_BASE is often located in the C:\oracle directory.

The Oracle Base is the root of the Oracle software and its log files. The Oracle database software will be installed in a subdirectory of the base. Oracle keeps an internal inventory of the Oracle software and its patches in $ORACLE_BASE/oraInventory. Oracle database files can be a subdirectory of the base as well.

$ORACLE_HOME

It is possible to have more than one Oracle database on a single server, each with a different Oracle version. The biggest, but not sole, benefit of OFA today is to help facilitate different Oracle versions on the same server. With OFA, you can easily install the Oracle 11.2.0.4, 12.1.0.2, and 12.2.0.1 versions and have no conflicts.

Oracle handles each version independently by installing it in its own home directory, called $ORACLE_HOME (%ORACLE_HOME% on Windows). The OFA guidelines place $ORACLE_HOME in a folder with a naming scheme similar to $ORACLE_BASE/product/version/type, where version denotes the Oracle version installed and where type is typically dbhome_X for database software, client_X for Oracle Client software, or grid_X for Oracle’s Grid Infrastructure. Here are some examples of ORACLE_HOME directories:

  • /u01/app/oracle/product/11.2.0/dbhome_1
  • /u01/app/oracle/product/11.2.0/dbhome_2
  • /u01/app/oracle/product/12.1.0/dbhome_1
  • /u01/app/oracle/product/12.1.0/dbhome_2

Database Files

The OFA guidelines suggest that we store database files in $ORACLE_BASE/oradata/db_name as a starting point. If your database is for anything other than a testbed, the disk for ORACLE_BASE may not be large enough to store all of the files. It is very common for the DBA to separate database files to different disk locations, for a number of reasons. They may need multiple disk units because one disk unit is not large enough. They may want multiple disk units so that highly active database files can be segregated to reduce disk contention.

If more than one disk is being used, they are typically mounted to the Unix or Linux server similar to the following example:

  • /u01/app/oracle/oradata/orcl/data01
  • /u01/app/oracle/oradata/orcl/data02

The database name is orcl in the example above. It should be noted that data01 and data02 are different disk units with different mount points. On Unix/Linux, they look to be subdirectories off the same disk, but they are not. Your organization may use a different directory structure for the Oracle disk, which is perfectly acceptable. Again, just be consistent across the enterprise.

There is one more OFA guideline pertaining to database files, and that addresses the name of the file itself. The OFA guideline suggests that we name control files controlXX.ctl, name online redo logs redoXX.log, and name database files tablespace_nameXX.dbf, where XX is a sequential number. So, for example, I might have three control files with names control01.ctl, control02.ctl, and control03.ctl. Online redo logs would be named redo01.log, redo02.log, and redo03.log. Database files for the SYSTEM and SYSAUX tablespaces are usually named system01.dbf and sysaux01.dbf respectively. An application data tablespace with multiple files might have files named app_data01.dbf and app_data02.dbf as an example.

Directory PathContents
/u01/app/oracleORACLE_BASE
/u01/app/oracle/oralnventoryOracle Inventory
/u01/app/oracle/product/12.2.0.1ORACLE_HOME
/u01/app/oracle/adminAdmin files
/u01/app/oracle/diag/rdbms/orcl/orclDiagnostic files
/u01/app/oracle/oradata/orclDatabase files

基本使用

命令行配置

[root@node01 ~]# yum install -y rlwrap

[oracle@node01 ~]$ alias sqlplus='rlwrap sqlplus'

如何启动数据库:

第一步启动监听:

# 1. 启动监听
[oracle@node01 ~]$ lsnrctl start

第二步登录到数据库:

# 2. 登录数据库
[oracle@node01 ~]$ sqlplus /nolog

第三步:

SQL*Plus: Release 19.0.0.0.0 - Production on Wed Jul 10 10:15:48 2024
Version 19.3.0.0.0

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

-- 连接到 sysdba
SQL> conn / as sysdba
Connected to an idle instance.

-- 执行 startup 命令
SQL>startup 
ORACLE instance started.

Total System Global Area 1845491624 bytes
Fixed Size		            9136040 bytes
Variable Size		      436207616 bytes
Database Buffers	     1392508928 bytes
Redo Buffers		        7639040 bytes
Database mounted.
Database opened.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

LavenLiu

常言道:投资效率是最大的投资。

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

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

打赏作者

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

抵扣说明:

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

余额充值