Presentation is loading. Please wait.

Presentation is loading. Please wait.

IT 21003 Database Administration SECTION 02. CREATING DATABASES Creating a Database: Overview 1. Plan the physical design and storage structures 2. Back.

Similar presentations


Presentation on theme: "IT 21003 Database Administration SECTION 02. CREATING DATABASES Creating a Database: Overview 1. Plan the physical design and storage structures 2. Back."— Presentation transcript:

1 IT 21003 Database Administration SECTION 02

2 CREATING DATABASES Creating a Database: Overview 1. Plan the physical design and storage structures 2. Back Up any existing databases 3. Set the instance indentifier 4. Connect to Enterprise Manager or other utility and startup an instance

3 CREATING DATABASES Creating a Database: Overview 5.Create the database using an appropriate facility 6. Run any required post-installation scripts 7. Back Up the new database

4 CREATING DATABASES Pre-Creation Activities: Planning – Plan the Tables and Indexes Estimate Sizes Estimate Sizes – Plan the Backup and Recovery strategy

5 CREATING DATABASES Pre-Creation Activities: Planning –Creating a Database can overwrite existing database files In practice a new init.ora file is often created by copying and editing an existing one In practice a new init.ora file is often created by copying and editing an existing one If the Control_Files parameter is not changed, existing files may be overwritten If the Control_Files parameter is not changed, existing files may be overwritten

6 CREATING DATABASES Pre-Creation Activities: Planning The Instance_Name and Database_Name also need changedThe Instance_Name and Database_Name also need changed Decide on New Database or Migration of old Database Decide on New Database or Migration of old Database

7 CREATING DATABASES Pre-Creation Activities: Parameter Files –Create and edit the required parameter file(s) The parameter file configures the instance that will be used to create the databaseThe parameter file configures the instance that will be used to create the database –Rename and edit a supplied init.ora file or utilize an existing file Make sure the name is changed, do not use the same parameter file for different databasesMake sure the name is changed, do not use the same parameter file for different databases initprod.ora for production instanceinitprod.ora for production instance initest.ora for test instanceinitest.ora for test instance

8 CREATING DATABASES Pre-Creation Activities: Parameter Files Cont’d –Examine the following parameters in your file (DB_NAME)(DB_NAME) (DB_BLOCK_SIZE)(DB_BLOCK_SIZE) (PROCESSES)(PROCESSES) (LICENSE_SESSION_WARNING)(LICENSE_SESSION_WARNING)

9 CREATING DATABASES Pre-Creation Activities: Parameter Files Cont’d –Examine the following parameters in your file (CONTROL_FILES)(CONTROL_FILES) (DB_BLOCK_BUFFERS)(DB_BLOCK_BUFFERS) (LICENSE_MAX_SESSIONS)(LICENSE_MAX_SESSIONS) (LICENSE_MAX_USERS)(LICENSE_MAX_USERS) –These MUST BE CHANGED

10 CREATING DATABASES DB_NAME –String of eight or fewer characters used to identify the local name component of the database name To avoid confusion, this should match the Oracle instance identifierTo avoid confusion, this should match the Oracle instance identifier –DB_NAME is stored in the datafile headers, redo log files, and control files –This parameter is not easy to change once the database has been created

11 CREATING DATABASES CONTROL_FILES –Control_Files can be specified within the parameter file as follows: CONTROL_FILES=/usr/oracle/home/con trol_file,CONTROL_FILES=/usr/oracle/home/con trol_file, /usr/oracle/home/control_file2 /usr/oracle/home/control_file2

12 CREATING DATABASES CONTROL_FILES –At least TWO FILES should be specified so that the loss of a control file is not critical –The control files should be placed on DIFFERENT DISKS

13 CREATING DATABASES CONTROL_FILES –If a name for the control file is not specified, an operating-system-dependent default file is created –Be careful on Create Database the control files are replaced, could cause old databases to not function

14 CREATING DATABASES DB_BLOCK_SIZE –DB_BLOCK_SIZE specifies the size of a database block and therefore the size of the database buffers in SGA

15 CREATING DATABASES DB_BLOCK_SIZE –Default size is operating-system dependent Usually set at either 2Kb or 4Kb or 2048 kb or 4096 kbUsually set at either 2Kb or 4Kb or 2048 kb or 4096 kb More realistic size is 16Kb or 32KbMore realistic size is 16Kb or 32Kb It should be an exact multiple of the OS block sizeIt should be an exact multiple of the OS block size

16 CREATING DATABASES DB_BLOCK_SIZE –The parameter should probably be increased, if: The Oracle host machine is very large, has lots of memory, and lots of fast storageThe Oracle host machine is very large, has lots of memory, and lots of fast storage If there are a relatively high number of large rowsIf there are a relatively high number of large rows Not many requests for small amounts of dataNot many requests for small amounts of data

17 CREATING DATABASES DB_BLOCK_SIZE –Oracle to 8i – block size cannot be changed once set without restructuring the database –Oracle 9i up – block size can be changed

18 CREATING DATABASES DB_BLOCK_BUFFERS –DB_BLOCK_BUFFERS is the total number of buffers(database blocks) in the buffer cache at one time

19 CREATING DATABASES DB_BLOCK_BUFFERS –Governs the size of the large portion of the SGA and can have profound effect on performance –Size of each buffer is determined by DB_BLOCK_SIZE

20 CREATING DATABASES DB_BLOCK_BUFFERS –Estimate the number of buffers by determining the number of blocks each application accesses at one time (include data, index, and rollback segment blocks) –High values enable larger cache, which may reduce I/O If set too high, the SGA may be larger than physical memory and lead to swapping, and reduction in system performanceIf set too high, the SGA may be larger than physical memory and lead to swapping, and reduction in system performance

21 CREATING DATABASES The PROCESSES Parameter –Determines the maximum number of users who can connect to the instance at any one time

22 CREATING DATABASES The PROCESSES Parameter –To estimate the number required: One for each Server ProcessOne for each Server Process Overhead of One Process required for each Background ProcessOverhead of One Process required for each Background Process

23 CREATING DATABASES The PROCESSES Parameter –Example: If the required maximum number of users connected to an instance at one time is 100, the setting of PROCESSES may need to be 107If the required maximum number of users connected to an instance at one time is 100, the setting of PROCESSES may need to be 107 PROCESSES = Background + UsersPROCESSES = Background + Users

24 CREATING DATABASES Listing Additional Parameters –To obtain a list of parameters and their current values for an instance Connect as a DBAConnect as a DBA SELECT *SELECT * FROM v$parameter;FROM v$parameter;

25 CREATING DATABASES Setting the Instance Identifier (SID) –The instance identifier is used by the operating system to determine the default instanced for database connections –The value is often the DB_NAME of the database –Setting the instance identifier is operating- system specific –Utilize SQL Plus Worksheet or Oracle Enterprise Manager

26 CREATING DATABASES Creating the Database –Syntax: –CREATE DATABASE [database_name] –[CONTROLFILE REUSE] –[LOGFILE {GROUP integer} filespec] –[MAXLOGFILES integer]

27 CREATING DATABASES Creating the Database –Syntax Cont’d: –[DATAFILE filespec, filespec] –[MAXDATAFILES integer] –[MAXINSTANCES integer] –[ARCHIVELOG | NOARCHIVELOG] –[CHARACTER SET charset]; –[NATIONAL CHARACTER SET charset];

28 CREATING DATABASES Creating the Database Example: CREATE DATABASE db1 DATAFILE ‘E:\production\system_dbf’ SIZE 50M LOGFILE GROUP 1 (‘E:\production\log01\dev_log1a.rdo’, ‘E:\production\log01\dev_log1b.rdo’, ‘E:\production\log01\dev_log1c.rdo’) SIZE 1M GROUP 2 (‘E:\production\log02\dev_log2a.rdo’, ‘E:\production\log01\dev_log2b.rdo’, ‘E:\production\log01\dev_log2c.rdo’) SIZE 1M;

29 CREATING DATABASES Creating the Database Example Results: Creates a database named db1Creates a database named db1 Creates two online redo log groups with three log files of 1mb eachCreates two online redo log groups with three log files of 1mb each Creates a SYSTEM tablespace with size of 50MBCreates a SYSTEM tablespace with size of 50MB Remember that other parameters will be loading default valuesRemember that other parameters will be loading default values Example: MAXDATAFILES will be set to 32Example: MAXDATAFILES will be set to 32

30 CREATING DATABASES Database Creation Parameters –database_name Name of the database being createdName of the database being created Character string of up to eight charactersCharacter string of up to eight characters Defaults to DB_NAME in the parameter file used at startup timeDefaults to DB_NAME in the parameter file used at startup time –Specify this parameter to ensure that the correct parameter file is used

31 CREATING DATABASES Database Creation Parameters –CONTROLFILE REUSE – (NEVER USE THIS) Specifies that the control files listed in the parameter file are to be overwritten (if they already exist)Specifies that the control files listed in the parameter file are to be overwritten (if they already exist)

32 CREATING DATABASES Database Creation Parameters –LOGFILE Specifies one or more redo log filesSpecifies one or more redo log files Each filespec specifies one or more redo log groups, each of which contain more than one fileEach filespec specifies one or more redo log groups, each of which contain more than one file If the GROUP clause is omitted, a default group is createdIf the GROUP clause is omitted, a default group is created If omitted, two redo log file groups are created by defaultIf omitted, two redo log file groups are created by default

33 CREATING DATABASES Database Creation Parameters Cont’d –DATAFILE One or more files to be used for the SYSTEM tablespaceOne or more files to be used for the SYSTEM tablespace If omitted, Oracle creates an operating-system-dependent file in the default directoryIf omitted, Oracle creates an operating-system-dependent file in the default directory Files can be specified to extend automaticallyFiles can be specified to extend automatically

34 CREATING DATABASES Database Creation Parameters Cont’d –ARCHIVELOG | NOARCHIVELOG Specifies whether the database will be in ARCHIVELOG more or NOARCHIVELOG modeSpecifies whether the database will be in ARCHIVELOG more or NOARCHIVELOG mode

35 CREATING DATABASES Database Creation Parameters Cont’d –CHARACTER SET Specifies the character set that will be use for the databaseSpecifies the character set that will be use for the database –NATIONAL CHARACTER SET Specifies the national character set to be used for the databaseSpecifies the national character set to be used for the database –Defaults to CHARACTER SET

36 CREATING DATABASES Database Creation Parameters Cont’d - Limits –The MAX...parameters limit the size of the control file The control file has to reserve space for the file detailsThe control file has to reserve space for the file details –MAXLOGFILES Integer value specifying the maximum number of redo log file groups that the database will haveInteger value specifying the maximum number of redo log file groups that the database will have

37 CREATING DATABASES Database Creation Parameters Cont’d - Limits –MAXLOGMEMBERS Maximum number of log members (files) in a groupMaximum number of log members (files) in a group

38 CREATING DATABASES Database Creation Parameters Cont’d - Limits –MAXDATAFILES Integer value specifying the maximum number of datafiles that can make up the databaseInteger value specifying the maximum number of datafiles that can make up the database –Default value is 32, difficult to change after database creation depending on the Oracle version used DB_FILES in the parameter can be used to temporarily reduce the parameterDB_FILES in the parameter can be used to temporarily reduce the parameter

39 CREATING DATABASES CREATE DATABASE Operations –CREATE DATABASE automatically does the following: Creates (or overwrites) the Control FilesCreates (or overwrites) the Control Files Creates the Database FilesCreates the Database Files Creates the Redo Log FilesCreates the Redo Log Files Creates the SYSTEM rollback segment in the SYSTEM tablespaceCreates the SYSTEM rollback segment in the SYSTEM tablespace

40 CREATING DATABASES CREATE DATABASE Operations Creates and loads the Data Dictionary TablesCreates and loads the Data Dictionary Tables –A script called sql.bsq is run to create the tables –Change this file parameters before running CREATE DATABASE Mounts the DatabaseMounts the Database Opens the DatabaseOpens the Database Creates the SYS and SYSTEM UsersCreates the SYS and SYSTEM Users

41 CREATING DATABASES Post Creation Activities –The CREATE DATABASE statement builds the dictionary base tables These tables are extremely difficult to readThese tables are extremely difficult to read Their structure may change across releases of OracleTheir structure may change across releases of Oracle

42 CREATING DATABASES Post Creation Activities –Scripts need to be run to create views on the base tables Held in the ORACLE_HOME\rdbms\admin folderHeld in the ORACLE_HOME\rdbms\admin folder –catalog.sql Builds some basic views on the dictionary tablesBuilds some basic views on the dictionary tables –catproc.sql Builds the views for procedural objects (packages, procedures, etc)Builds the views for procedural objects (packages, procedures, etc)

43 CREATING DATABASES Post Creation Activities Cont’d –Change passwords for SYS and SYSTEM users Initially, password for SYS is set to change_on_install and SYSTEM password is managerInitially, password for SYS is set to change_on_install and SYSTEM password is manager –Create additional tablespaces, rollback segments, control files, and redo log files and backup the entire database –Create the user accounts –Create and populate the tables and other storage structures


Download ppt "IT 21003 Database Administration SECTION 02. CREATING DATABASES Creating a Database: Overview 1. Plan the physical design and storage structures 2. Back."

Similar presentations


Ads by Google