Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build Library manually instead of CDB and CDB by Oracle 12c

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article is about how Oracle 12c can build libraries manually instead of CDB and CDB. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

I believe everyone should know that for the creation of Oracle database, Oracle not only supports dbca (GUI interface), but also supports manual creation of the database, even if using CREATE DATABASE statements to create the database. One advantage of using this statement pair to use DBCA is that you can create a database from within a script.

Non-CDB databases prior to 12c as well as CDB container databases are supported in Oracle 12c version. So it is created in a slightly different way. This paper also describes the manual creation methods of two different databases. There is no more to say below, let's take a look at the detailed introduction.

I. 12c manually create non-CDB databases

Step 1: specify the instance identifier (SID)

The environment variable for ORACLE_SID is used to distinguish this instance from other Oracle Database instances that may be created later and running on the same host computer at the same time.

$export ORACLE_SID=nocdb$ export ORACLE_UNQNAME=nocdb

Step 2: make sure to set the required environment variables

Depending on your platform, you may have to set environment variables, or at least verify that they are set correctly, before starting SQL * Plus (as required by the next steps). Check the currently set environment variable below. If it is not set, use the export command to set it.

$env | grep ORAORACLE_UNQNAME=nocdbORACLE_SID=nocdbORACLE_BASE=/app/oracle/ora12cORACLE_HOSTNAME=ydq05.ydq.comORACLE_HOME=/app/oracle/ora12c/db_1

Step 3: select the database administrator authentication method

You must authenticate and grant the appropriate system permissions to create the database.

Typically, an administrator with the required permissions is authenticated in the following ways:

Use password files

Have operating system authentication (operating system authentication is used in this demonstration)

$id oracleuid=54321 (oracle) gid=54321 (oinstall) groups=54321 (oinstall), 54322 (dba)

Step 4: create an initialization parameter file

When the Oracle instance starts, it reads an initialization parameter file. The file can be a text file, which can be created and modified using a text editor or binary file, which is created and modified dynamically by the database. The preferred binaries are called server parameter files. In this step, you will create a text initialization parameter file. In later steps, you can create a server parameter file from a text file.

$mkdir-pv / app/oracle/ora12c/oradata/nocdb # create a directory for data files $vi $ORACLE_HOME/dbs/initnocdb.oraDB_NAME=nocdbCONTROL_FILES='/app/oracle/ora12c/oradata/nocdb/contorl01.ctl'MEMORY_TARGET=380m

Step 5: (Windows only) create an instance

On Windows platforms, before connecting to an instance, you must manually create it if it does not exist. The ORADIM command creates an Oracle database instance by creating a new Windows service.

Oradim-NEW-SID sid-STARTMODE MANUAL-PFILE file

Step 6: connect to the instance

Start SQL * Plus and connect to the Oracle database instance SYSDBA with administrative privileges.

$sqlplus / as sysdba-the demo environment is version 12.1 SQL*Plus: Release 12.1.0.1.0 Production on Wed May 31 10:44:41 2017Copyright (c) 1982, 2013, Oracle. All rights reserved.Connected to an idle instance.SQL >

Step 7: create a server parameter file

The server parameter file allows you to use this ALTER SYSTEM command to change initialization parameters and retain the changes when the database is shut down and started. You can create server parameter files from edited text initialization files.

SQL > create spfile from pfile='/app/oracle/ora12c/db_1/dbs/initnocdb.ora'

Step 8: start the instance

Start the instance without installing the database.

SQL > startup nomount;ORACLE instance started.Total System Global Area 1068937216 bytesFixed Size 2296576 bytesVariable Size 641729792 bytesDatabase Buffers 419430400 bytesRedo Buffers 5480448 bytes

Step 9: issue the CREATE DATABASE statement

To create a new database, use the CREATE DATABASE statement.

SQL > CREATE DATABASE nocdb USER SYS IDENTIFIED BY pass USER SYSTEM IDENTIFIED BY pass LOGFILE GROUP 1 ('/ app/oracle/ora12c/oradata/nocdb/redo01a.log','/app/oracle/ora12c/oradata/nocdb/redo01b.log') SIZE 100m BLOCKSIZE 512, GROUP 2 ('/ app/oracle/ora12c/oradata/nocdb/redo02a.log') '/ app/oracle/ora12c/oradata/nocdb/redo02b.log') SIZE 100m BLOCKSIZE 512 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 1024 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 EXTENT MANAGEMENT LOCAL DATAFILE' / app/oracle/ora12c/oradata/nocdb/system01.dbf' SIZE 700m SYSAUX DATAFILE'/ app/oracle/ora12c/oradata/nocdb/sysaux01.dbf' SIZE 550m DEFAULT TABLESPACE users DATAFILE'/ app/oracle/ora12c/oradata/nocdb/users01.dbf' SIZE 500m DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE'/ app/oracle/ora12c/oradata/nocdb/temp01.dbf 'SIZE 20m UNDO TABLESPACE undotbs1 DATAFILE'/ app/oracle/ora12c/oradata/nocdb/undotbs01.dbf' SIZE 200m USER_DATA TABLESPACE usertbs DATAFILE'/ app/oracle/ora12c/oradata/nocdb/usertbs01.dbf' SIZE 200m

Step 10: create additional tablespaces

For the database to work, additional tablespaces must be created for the application data.

SQL > CREATE TABLESPACE apps_tbs LOGGING DATAFILE'/ app/oracle/ora12c/oradata/nocdb/apps01.dbf' SIZE 500m REUSE AUTOEXTEND ON NEXT 1280K MAXSIZE UNLIMITED EXTENT MANAGEMENT LOCAL

Step 11: run the script to build the data dictionary view

Run the scripts necessary to build data dictionary views, synonyms, and PL / SQL packages, and support the normal operation of SQL * Plus.

Execute the following script with sysdba permissions

SQL > @? / rdbms/admin/catalog.sql-- database dictionary, dynamic view creation, etc. SQL > @? / rdbms/admin/catproc.sql-- PL/SQL saved process-related code SQL > @? / rdbms/admin/utlrp.sql-- compilation

Use the SYSTEM user to execute the following script

SQL > @? / sqlplus/admin/pupbld.sql-- SQL*Plus correlation-- Verification result SQL > SELECT name, 2 DECODE (cdb, 3 'YES',' Multitenant Option enabled', 4 'Regular 12c Database:') 5 "Multitenant Option", 6 open_mode, 7 con_id 8 FROM v$database NAME Multitenant Option OPEN_MODE CON_ID--NOCDB Regular 12c Database: READ WRITE 0

Step 12: (optional) run the script to install additional options (omitted here)

You may need to run other scripts. The script you run is determined by the features and options you choose to use or install.

Step 13: back up the database to the database (here)

Make a full backup to ensure that you have a complete set of files from which you can recover in the event of a media failure.

Step 14: (optional) enable automatic instance startup (here)

You may want to configure the Oracle instance to start automatically when its host is restarted.

Second, create CDB database manually under 12c

1. CDB creation instructions

Creating a CDB using a CREATE DATABASESQL statement is very similar to creating a non-CDB. When you create a CDB using the CREATE DATABASESQL statement, you must enable PDB and specify the name and location of the root and seed files.

To create a CDB,CREATE DATABASE statement, you must include an ENABLE PLUGGABLE DATABASE clause. When this clause is included, the statement uses the root and seed to create the CDB. If the ENABLE PLUGGABLE DATABASE clause is not specified, the newly created database is non-CDB. This statement does not create roots and seeds, and non-CDB will never contain PDB.

Here are several major differences

1. When creating a CDB database, you should specify the ENABLE PLUGGABLE DATABASE clause

2. The CDB database should specify the name and location of the root file and seed file

The    CREATE DATABASE statement uses a root file, such as a data file, to generate the name of the seed file. You must specify the name and location of the root and seed files.

After the    CREATE DATABASE statement completes successfully, you can create a new PDB using the seed and its files. The seed cannot be modified after it is created.

   can specify the name and location of the seed file in one of the following ways

     uses the seed FILE_NAME_CONVERT clause

    , such as SEED FILE_NAME_CONVERT = ('/ app/oracle/ora12c/oradata/cdb1/','/app/oracle/ora12c/oradata/pdbseed/'), means to convert the files in the cdb1 directory to the pdbseed directory

     is based on oracle file hosting (OMF)

     uses PDB_FILE_NAME_CONVERT to initialize parameters

3. Different attributes can be made for PDB seed database.

The attributes of the data files for the    root SYSTEM and SYSAUX tablespaces may not be suitable for the seed. In this case, you can use a clause to specify a different property tablespace_datafile for the seed's data file. Use these clauses to specify the seeds in the SYSTEM and SYSAUX tablespaces that all data files contain. The value inherited from the root is used for any property whose value has not been provided.

The following example

DATAFILE'/ u01 seed seed under sysaux01.dbf' SIZE 325m REUSE-- uses a configuration different from that of the above root container, such as the size of the system data file here is 125m, while automatic extension is enabled for 352M--seed in the root container, and sysaux also uses some properties different from those specified in the root container-- for attributes that are not specified in oracle.oradata Inherits the root container data file property SEEDSYSTEM DATAFILES SIZE 125m AUTOEXTEND ON NEXT 10m MAXSIZE UNLIMITEDSYSAUX DATAFILES SIZE 100m

2. Create a cdb database

For detailed steps, refer to the manual creation of a non-cdb database under 12c. The following section omits the detailed description of each step, and the differences are listed later.

-- set the environment variable $export ORACLE_SID=cdb1 $export ORACLE_UNQNAME=cdb1-- to create the corresponding directory $mkdir-pv / app/oracle/ora12c/oradata/cdb1 $mkdir-pv / app/oracle/ora12c/oradata/pdbseed-- generation parameter file $vi $ORACLE_HOME/dbs/initcdb1.oraDB_NAME=cdb1CONTROL_FILES='/app/oracle/ora12c/oradata/cdb1/contorl01.ctl'MEMORY_TARGET=380mENABLE_PLUGGABLE_DATABASE=true-- to start building the library $sqlplus / as sysdbaSQL > create spfile from pfile='$ORACLE_HOME/dbs/initcdb1.ora';SQL > startup nomount SQL > CREATE DATABASE cdb1 USER SYS IDENTIFIED BY pass USER SYSTEM IDENTIFIED BY pass LOGFILE GROUP 1 ('/ app/oracle/ora12c/oradata/cdb1/redo01a.log','/app/oracle/ora12c/oradata/cdb1/redo01b.log') SIZE 100m BLOCKSIZE 512, GROUP 2 ('/ app/oracle/ora12c/oradata/cdb1/redo02a.log') '/ app/oracle/ora12c/oradata/cdb1/redo02b.log') SIZE 100m BLOCKSIZE 512 MAXLOGHISTORY 1 MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 1024 CHARACTER SET AL32UTF8 NATIONAL CHARACTER SET AL16UTF16 EXTENT MANAGEMENT LOCAL DATAFILE' / app/oracle/ora12c/oradata/cdb1/system01.dbf' SIZE 700m SYSAUX DATAFILE'/ app/oracle/ora12c/oradata/cdb1/sysaux01.dbf' SIZE 550m DEFAULT TABLESPACE deftbs DATAFILE'/ app/oracle/ora12c/oradata/cdb1/deftbs01.dbf' SIZE 500m DEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE'/ app/oracle/ora12c/oradata/cdb1/temp01 .dbf 'SIZE 20m UNDO TABLESPACE undotbs1 DATAFILE' / app/oracle/ora12c/oradata/cdb1/undotbs01.dbf' SIZE 200m ENABLE PLUGGABLE DATABASE SEED FILE_NAME_CONVERT = ('/ app/oracle/ora12c/oradata/cdb1/' '/ app/oracle/ora12c/oradata/pdbseed/') SYSTEM DATAFILES SIZE 125m AUTOEXTEND ON NEXT 10m MAXSIZE UNLIMITED SYSAUX DATAFILES SIZE 100m USER_DATA TABLESPACE usertbs DATAFILE' / app/oracle/ora12c/oradata/pdbseed/usertbs01.dbf' SIZE 200m -- populate the data dictionary, and if it is the 12cR2 version, execute catcdb.sql directly instead of the following script-- execute the following script SQL > @? / rdbms/admin/catalog.sql-- Database Dictionary with sysdba privileges Dynamic view creation, etc. SQL > @? / rdbms/admin/catproc.sql-- PL/SQL saved process-related code SQL > @? / rdbms/admin/utlrp.sql-- compile-- use the SYSTEM user to execute the following script SQL > @? / sqlplus/admin/pupbld.sql # SQL*Plus related SQL > select 'Leshami' Author,' http://blog.csdn.net/leshami' Blog, 2' 645746311' QQ from dual AUTHOR BLOG QQ--Leshami http://blog.csdn.net/leshami 645746311 SQL > SELECT name, 2 DECODE (cdb, 3 'YES',' Multitenant Option enabled', 4 'Regular 12c Database:') 5 "Multitenant Option", 6 open_mode, 7 con_id 8 FROM v$database NAME Multitenant Option OPEN_MODE CON_ID--CDB1 Multitenant Option enabled READ WRITE 0 Thank you for your reading! On "Oracle 12c how to build a library by hand instead of CDB and CDB" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, you can share it out for more people to see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report