New Oracle database instance without Linux interface

New Oracle database instance without Linux interface

according to https://blog.csdn.net/qq_24058757/article/details/88220437
Summarize and sort out your own new instance process after step operation

Memory check

Check the memory. There should be no problem. If the memory is small, pay attention to the mounting

[oracle@oracledb ~]$ grep -i memtotal /proc/meminfo
MemTotal:       16265868 kB

Switch to oracle user, and subsequent operations are carried out under oracle user

SID of ORACLE created

Set the SID of ORACLE to the instance we want to create

#Switch to oracle user environment
[root@oracledb ~]# su oracle

#The SID of the ORACLE created this time is tfcpzx
[oracle@oracledb ~]$ export ORACLE_SID=tfcpzx

#Print SID of current ORACLE
[oracle@oracledb ~]$ echo $ORACLE_SID
tfcpzx

If echo $Oracle_ The value found by SID is not the newly set SID
Can be modified bash_ SID in profile

#The above operation failed to perform this step
#Enter the root directory
[oracle@oracledb ~]$ cd ~  
#Edit bash_profile and modify the export ORACLE_SID=tfcpzx
[oracle@oracledb ~]$ vi .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

umask 022
export ORACLE_HOSTNAME=oracledb
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/
export ORACLE_SID=tfcpzx  #Change to the instance name you created
export PATH=.:$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$ORACLE_HOME/jdk/bin:$PATH
export LC_ALL="en_US"
export LANG="en_US"
export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"
export NLS_DATE_FORMAT="YYYY-MM-DD HH24:MI:SS"
".bash_profile" 24L, 556C

Press i to enter the editing mode. After modification, press ESC to exit editing. Enter: wq save and exit
Then reload the configuration

#Reload configuration
[oracle@oracledb ~]$ source .bash_profile 
#Select the new instance SID
[oracle@oracledb ~]$ export ORACLE_SID=tfcpzx
[oracle@oracledb ~]$ echo $ORACLE_SID
tfcpzx

Check for no error

Create the user corresponding to the instance

#Replace the ztfx SID with your own
[oracle@oracledb ~]$ mkdir -p $ORACLE_BASE/admin/tfcpzx/{a,b,c,u}dump
[oracle@oracledb ~]$ mkdir -p $ORACLE_BASE/admin/tfcpzx/pfile
[oracle@oracledb ~]$ mkdir -p $ORACLE_BASE/oradata/tfcpzx

Create initialization file

[oracle@oracledb ~]$ cd $ORACLE_HOME/dbs
[oracle@oracledb dbs]$ ll
total 57556
-rw-r--r-- 1 oracle oinstall     2851 May 15  2009 init.ora

#Copy the initialization file according to the naming rule init + instance name ora
[oracle@oracledb dbs]$ cp init.ora inittfcpzx.ora
[oracle@oracledb dbs]$ ls
init.ora         inittfcpzx.ora

#Edit and set < Oracle_ Replace base > with the corresponding absolute path. If you don't know, you can use echo $ORACLE_BASE command view
[oracle@oracledb dbs]$ vi inittfcpzx.ora
db_name='tfcpzx' #Change to your own SID
memory_target=1G
processes = 150
audit_file_dest='/u01/app/oracle/admin/tfcpzx/adump'#Replace with your own
audit_trail ='db'
db_block_size=8192
db_domain=''
db_recovery_file_dest='/u01/app/oracle/fash_recovery_area' #Replace with your own
db_recovery_file_dest_size=2G
diagnostic_dest='/u01/app/oracle' #Replace with your own
dispatchers='(PROTOCOL=TCP) (SERVICE=tfcpzxDB)'#tfcpzxDB will be replaced with its own SID+DB
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 = (ora_control3, ora_control4) #Change to $Oracle_ Those that do not exist in home / DBS are sufficient. If the generation fails, these two files will be generated. For the next generation, you need to delete the generated files or increase the value here (to prevent the files from existing)
compatible ='11.2.0'

Create password

Change the password of sys user to sys

#Change the tfcpzx of orapwtfcpzx to its own SID. password=123456 is the setting password. If the setting password is a character, double quotation marks shall be added, such as "password"
[oracle@oracledb dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwtfcpzx password=123456 entries=5 force=y

Create oracle database creation script

#Enter the instance of oradata
[oracle@oracledb dbs]$ cd $ORACLE_BASE/oradata/tfcpzx

#When creating a file, the path in the file information should be replaced with its own instance
#I'm here in the data under the root directory, usually in / u01/oracle/oradata / my own instance / directory
[oracle@oracledb dbs]$ vi createdb.sql
create database tfcpzx #replace
MAXINSTANCES 1
MAXLOGHISTORY 1
MAXLOGFILES 5
MAXLOGMEMBERS 5
MAXDATAFILES 100
DATAFILE
'/data/oracle/oradata/tfcpzx/system01.dbf' size 100m reuse autoextend on next 1m maxsize unlimited extent management local
sysaux datafile
'/data/oracle/oradata/tfcpzx/sysaux01.dbf' size 100m reuse autoextend on next 1m maxsize unlimited 
default temporary tablespace TEMP tempfile
'/data/oracle/oradata/tfcpzx/temp01.dbf' size 20m reuse autoextend on next 640k maxsize unlimited 
undo tablespace UNDOTBS1 datafile
'/data/oracle/oradata/tfcpzx/undo01.dbf' size 20m reuse autoextend on next 5M maxsize unlimited 
logfile
GROUP 1 ('/data/oracle/oradata/tfcpzx/redo1.dbf') size 10m, 
GROUP 2 ('/data/oracle/oradata/tfcpzx/redo2.dbf') size 10m, 
GROUP 3 ('/data/oracle/oradata/tfcpzx/redo3.dbf') size 10m  
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
;

Execute database building and data dictionary scripts

#Switch to the root directory of oracle
[oracle@oracledb ~]$ cd ~
#Print the SID of the current ORACLE. If it is not or not displayed, press the first step to select it under the new instance
[oracle@oracledb ~]$ echo $ORACLE_SID
tfcpzx

#Connect database
[oracle@oracledb ~]$ sqlplus / as sysdba

#The current database has not been established, so only the instance can be started through startup nomount
SQL> startup nomount
SQL> @$ORACLE_BASE/oradata/tfcpzx/createdb.sql#Replace with your own SID path
SQL> @?/rdbms/admin/catalog.sql;#It takes time to execute this sentence directly. Please wait for the end flag before operation
SQL> @?/rdbms/admin/catproc.sql;#It takes time to execute this sentence directly. Please wait for the end flag before operation
SQL> @?/rdbms/admin/catexp.sql;#It takes time to execute this sentence directly. Please wait for the end flag before operation

#After the above operations are completed, quit exits sqlplus

expand:
startup nomount starts the instance but not the database,
startup mount starts the instance and loads the database, but the database is not opened,
The most complete operations of startup, including instance, database loading and database opening, are completed

catalog.sql this script allows users to create oracle dynamic performance views, such as v s e s s i o n , v session,v session,vsession_wait,v$transactoin, etc. These performance views are mainly used to monitor the running status of oracle instances
Create objects for

  1. The basic PL/SQL environment includes PL/SQL statements 1) data types 2) predefined exceptions 3) built-in procedures and functions 4)SQL operations
  2. audit
  3. Import / export
  4. SQL*Loader
  5. Installed options

catproc.sql script establishes the use of PL/SQL functions. In addition, it creates several PL/SQL packages catproc. Which can be used to expand the functions of RDBMS The SQL script also creates additional packages and views for

  1. alert
  2. The Conduit
  3. Logminer
  4. Large object
  5. object
  6. Advanced queuing
  7. Copy options
  8. Other built-in items and options

catexp. The VIEW required by SQL EXPORT is generated by catexp SQL creation. These internal views are used to organize the data format in the DUMP file of EXPORT. Most of the views are used to collect data for creating DDL statements, while others are mainly used by ORACLE developers

Modify the listening configuration file

[oracle@oracledb ~]$ cd $ORACLE_HOME/network/admin
[oracle@oracledb admin]$ ls
listener.ora  samples  shrept.lst  sqlnet.ora  tnsnames.ora
[oracle@oracledb admin]$ vi tnsnames.ora 
[oracle@oracledb admin]$ vi 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 = /u01/app/oracle

#Replace tfcpzx with your own SID and HOST with your own IP. 1521 is the default oracle port. If you change it to your own port, the same below
tfcpzx =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      )
      (ADDRESS_LIST =
        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.5.50)(PORT = 1521))
      )
    )
  )

#Replace tfcpzx with your own SID, replace HOST with your own IP, and change the directory to your own oracle_ Home (Oracle installation directory)
SID_LIST_tfcpzx =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = tfcpzx)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0)
      (SID_NAME = tfcpzx)
    )
  )

#This is generally self-contained and does not need to be changed. HOST writes its own HOST ip
LISTENER_FATPASE =
  (ADDRESS = (PROTOCOL = TCP)(HOST = oracledb)(PORT = 1521))

lsnrctl start

#Here, you need to specify which database instance to start listening
[oracle@oracledb adminl start tfcpzx

#View listening status lsnrctl status
[oracle@oracledb admin]$ lsnrctl status       

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 18-MAY-2021 17:43:51

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                18-MAY-2021 14:21:58
Uptime                    0 days 3 hr. 21 min. 53 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File         /u01/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)))
Services Summary...
Service "tfcpzx" has 1 instance(s).
  Instance "tfcpzx", status READY, has 1 handler(s) for this service...
Service "tfcpzxDB" has 1 instance(s).
  Instance "tfcpzx", status READY, has 1 handler(s) for this service...
The command completed successfully


#Expand without operation
#Stop listening, all closed
[oracle@oracledb admin]$ lsnrctl stop
#Start listening, all start
[oracle@oracledb admin]$ lsnrctl start

Start database service

#Switch to the root directory of oracle
[oracle@oracledb ~]$ cd ~
#Print the SID of the current ORACLE. If it is not or not displayed, press the first step to select it under the new instance
[oracle@oracledb ~]$ echo $ORACLE_SID
tfcpzx

#Connect database
[oracle@oracledb ~]$ sqlplus / as sysdba
#Close the service. The instance was opened just now, and now all of them are closed here
SQL> shutdown

#Start service
SQL> startup 

Finished, PLSQL link

After starting the service, you can connect to PLSQL
The password we created is sys user, and the password is 123456 we set earlier

If the password is wrong
You can change the user password on the linux server

#Connect database
[oracle@oracledb ~]$ sqlplus / as sysdba
#To modify the password, double quotation marks should be added to the string. sys is a DBA user, and as sysdba should be added. Other users do not need it
SQL> alter user sys identified by 123456 as sysdba;

Keywords: Linux Database Oracle

Added by Flames on Wed, 09 Feb 2022 13:29:07 +0200