C/C++教程

命令行安装 Oracle11g

本文主要是介绍命令行安装 Oracle11g,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

命令行安装11g

以下文件名、路径、配置信息都是前后一致的,如根据实际情况调整,需要注意前后的一致性!
安装时仅安装软件,不创建数据库。

一、创建目录

检查一下配置的路径

[oracle@oracledb ~]$ echo $ORACLE_BASE
/app/oracle
[oracle@oracledb ~]$ echo $ORACLE_HOME
/app/oracle/product/11.2.0/db_1
[oracle@oracledb ~]$ echo $ORACLE_SID
orcl

用oracle用户建立数据库所需目录

$ mkdir -p $ORACLE_BASE/admin/$ORACLE_SID
$ cd $ORACLE_BASE/admin/$ORACLE_SID
$ mkdir adump bdump cdump dpdump hdump pfile udump
$ mkdir -p /app/oracle/fast_recovery_area/orcl
$ mkdir -p /app/oracle/oradata/orcl

以下都用oracle用户

二、配置初始化文件

创建一个初始化文件

$ vim ORACLE_BASE/admin/$ORACLE_SID/pfile/init.ora

插入下面内容

注意:

undo表空间名和创建数据库脚本表空间名一定一致!!!

##############################################################################

# Copyright (c) 1991, 2001, 2002 by Oracle Corporation

##############################################################################

###########################################

# Cache and I/O

###########################################
db_block_size=8192

###########################################

# Cursors and Library Cache

###########################################
open_cursors=300

###########################################

# Database Identification

###########################################
db_domain=""
db_name="orcl"

###########################################

# File Configuration

###########################################
control_files=("/app/oracle/oradata/orcl/control01.ctl", "/app/oracle/fast_recovery_area/orcl/control02.ctl")
db_recovery_file_dest="/app/oracle/fast_recovery_area"
db_recovery_file_dest_size=4385144832

###########################################

# Miscellaneous

###########################################
compatible=11.2.0.4.0
diagnostic_dest=/app/oracle
memory_target=805306368

###########################################

# Processes and Sessions

###########################################
processes=150

###########################################

# Security and Auditing

###########################################
audit_file_dest="/app/oracle/admin/orcl/adump"
audit_trail=db
remote_login_passwordfile=EXCLUSIVE

###########################################

# Shared Server

###########################################
dispatchers="(PROTOCOL=TCP) (SERVICE=orclXDB)"

###########################################

# System Managed Undo and Rollback Segments

###########################################
undo_tablespace=UNDOTBS1


三、创建oracle密码文件

$ orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle

四、创建数据库

先登录sys 以DBA身份,用初始化参数文件将数据库启动到nomount状态。

$ sqlplus /nolog
SQL> conn / as sysdba;
SQL> startup nomount pfile="/app/oracle/admin/orcl/pfile/init.ora";

说明:

字符集:ZHS16GBK

sys和system密码:manager2021

数据库SID:orcl

创建数据库脚本如下:

CREATE DATABASE orcl
   MAXINSTANCES 8
   MAXLOGHISTORY 16
   MAXLOGFILES 16
   MAXLOGMEMBERS 3
   MAXDATAFILES 512
   DATAFILE '/app/oracle/oradata/orcl/system01.dbf' SIZE 2048M REUSE 
      AUTOEXTEND OFF
      EXTENT MANAGEMENT LOCAL
   SYSAUX DATAFILE '/app/oracle/oradata/orcl/sysaux01.dbf' SIZE 1024M REUSE 
      AUTOEXTEND OFF
   SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/app/oracle/oradata/orcl/temp01.dbf' SIZE 4096M REUSE 
      AUTOEXTEND OFF
   SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/app/oracle/oradata/orcl/UNDOTBS1.dbf' SIZE 8192M REUSE 
      AUTOEXTEND OFF
   CHARACTER SET ZHS16GBK
   NATIONAL CHARACTER SET AL16UTF16
   LOGFILE GROUP 1 ('/app/oracle/oradata/orcl/redo01.log') SIZE 102400K,
           GROUP 2 ('/app/oracle/oradata/orcl/redo02.log') SIZE 102400K,
           GROUP 3 ('/app/oracle/oradata/orcl/redo03.log') SIZE 102400K
   USER SYS IDENTIFIED BY "manager2021" 
   USER SYSTEM IDENTIFIED BY "manager2021";

/

五、执行数据字典脚本

用两个角色执行脚本:

SQL> conn sys/manager2021 as sysdba
SQL> @?/rdbms/admin/catalog
SQL> @?/rdbms/admin/catproc
SQL> conn system/manager2021 
SQL> @?/sqlplus/admin/pupbld

六、创建spfile

创建完spfile后,关闭数据库,然后就可以startup直接启动了。

SQL> create spfile from pfile='/app/oracle/admin/orcl/pfile/init.ora';
SQL> shutdown immediate;
SQL> startup

七、网络访问连接设置

1、配置文件

因为安装时仅安装软件,所以没有配置net 。

在$ORACLE_HOME/network/admin路径下,手工配置三个ora文件,需要注意的就是机器名一定正确,SID一定正确。

文件内容如下,直接复制粘贴即可:

(1) listener.ora

# listener.ora Network Configuration File: /app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = oracledb)(PORT = 1521))
    )
  )

ADR_BASE_LISTENER = /app/oracle

(2)tnsnames.ora

ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = oracledb)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

(3)sqlnet.ora

# sqlnet.ora Network Configuration File: /app/oracle/product/11.2.0/db_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES, EZCONNECT)

ADR_BASE = /app/oracle

2、启动监听

(1)用命令启动监听:lsnrctl start

[oracle@oracledb admin]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-SEP-2021 01:29:32

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

Starting /app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /app/oracle/diag/tnslsnr/oracledb/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracledb)(PORT=1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                28-SEP-2021 01:29:32
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /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)))
The listener supports no services
The command completed successfully
[oracle@oracledb admin]$ 

(2)检查监听状态:

[oracle@oracledb admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-SEP-2021 01:30:29

Copyright (c) 1991, 2013, 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.4.0 - Production
Start Date                28-SEP-2021 01:29:32
Uptime                    0 days 0 hr. 0 min. 57 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /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)))
The listener supports no services
The command completed successfully
[oracle@oracledb admin]$ 

(3)测试tns

[oracle@oracledb admin]$ tnsping orcl

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 28-SEP-2021 01:31:16

Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
/app/oracle/product/11.2.0/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = oracledb)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
OK (0 msec)
[oracle@oracledb admin]$ 

至此完成命令行方式安装!

这篇关于命令行安装 Oracle11g的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!