Oracle manually create database? Stable article

1. Description

        A new disk has been added to create the data file directory oradata of the database manually;

        There is a stand-alone asm database on this server. I don’t have enough memory and closed it first.

2. Manually create oracle database

1. Set ORACLE_SID

[oracle@oomcserver ~]$ cp .bash_profile .bash_profile_omccdb
[oracle@oomcserver ~]$ vim .bash_profile
[oracle@oomcserver ~]$ cat .bash_profile 
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export ORACLE_SID=mandb
export PATH=$PATH:$ORACLE_HOME/bin
NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"
export NLS_DATE_FORMAT

        Back up the environment variable configuration file first, mainly modify ORACLE_SID to mandb 

2. Set environment variable information such as ORACL_HOME

        No changes will be made here, just omit

3. Create the initialization parameter file pfile

[oracle@oomcserver dbs]$ vim initmandb.ora
[oracle@oomcserver dbs]$ cat initmandb.ora 
db_name='mandb'
memory_target=1G
processes = 150
audit_file_dest='<ORACLE_BASE>/admin/mandb/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/oradata/mandb/recovery'
db_recovery_file_dest_size=2G
diagnostic_dest='/oradata/mandb/diag'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300 
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = (/oradata/mandb/control01.ctl,/oradata/mandb/control02.ctl)
compatible ='11.2.0'


        If the directory defined by the initialization parameter file does not exist, it needs to be created manually.

mkdir -p /u01/app/oracle/admin/mandb/adump
mkdir -p /oradata/mandb/recovery
#防止adr报错
mkdir -p /oradata/mandb/diag

Important note: If it is a Windows platform, you need to register the instance as a service first when booting to NOMOUNT. The command is as follows

oradim -NEW -SID oracleSID -STARTMODE manual [replace oracleSID with the instance name you want to register]

4. Start the database to NOMOUNT state

startup nomount

5. Run the create database script to create the database.

CREATE DATABASE mandb
USER SYS IDENTIFIED BY sys
USER SYSTEM IDENTIFIED BY system
LOGFILE GROUP 1 ('/oradata/mandb/redo01a.log') SIZE 50M ,
GROUP 2 ('/oradata/mandb/redo02a.log') SIZE 50M ,
GROUP 3 ('/oradata/mandb/redo03a.log') SIZE 50M 
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 8192
Character set UTF8
EXTENT MANAGEMENT LOCAL
DATAFILE '/oradata/mandb/system01.dbf'
SIZE 700M AUTOEXTEND ON MAXSIZE 10G
SYSAUX DATAFILE '/oradata/mandb/sysaux01.dbf'
SIZE 550M AUTOEXTEND ON MAXSIZE 10G
DEFAULT TABLESPACE users
DATAFILE '/oradata/mandb/users01.dbf'
SIZE 100M AUTOEXTEND ON MAXSIZE 10G
DEFAULT TEMPORARY TABLESPACE temp
TEMPFILE '/oradata/mandb/temp01.dbf'
SIZE 200M AUTOEXTEND ON MAXSIZE 10G
UNDO TABLESPACE undotbs1
DATAFILE '/oradata/mandb/undotbs01.dbf'
SIZE 200M AUTOEXTEND ON MAXSIZE 10G;

--创建完成后查看数据库状态
 select dbid,name,open_mode from v$database;

        ​​ ​ Check the database status according to the path (data file) we built, the read and write status

6. Create dynamic parameter file

Create spfile from pfile;


7. Create other table spaces (omitted)

create tablespace users datafile '/oradata/mandb/mantest.dbf' size 100M;

8. Create data dictionary

su - oracle
cd /u01/app/oracle/product/11.2.0/db_1/rdbms/admin
sqlplus / as sysdba
@catalog.sql
@catproc.sql
@pupbld.sql

        The execution process is abbreviated, and you may have to wait for a few minutes. 

9. Check whether there are invalid components or objects

select comp_id,version,status from dba_registry;

select owner,object_name,object_type from all_objects where status<>'VALID';

If there are invalid components, run the utlrp.sql script

The script is located in $ORACLE_HOME/rdbms/admin/utlrp.sql, the same operation as above

10. Start the database

--重新启动
shutdown immediate
startup

        ​ ​ ​ ​ ok, yeah ​​just start the monitoring

Guess you like

Origin blog.csdn.net/qq_63693805/article/details/133637100