安装数据库软件
安装依赖
libnsl
添加组和用户
groupadd -g 54321 oinstall
groupadd -g 54322 dba
groupadd -g 54323 oper
useradd -u 54321 -g oinstall -G dba,oper oracle
vi /etc/oraInst.loc
inventory_loc=/u01/app/oraInventory
inst_group=oinstall
静默安装
以下以oracle用户操作:
mkdir /u01/app
unzip linuxx64_12201_database.zip
cd database/
cp response/db_install.rsp inst.rsp
./runInstaller -showProgress -ignoreSysPrereqs -waitforcompletion -silent -responseFile /home/oracle/database/inst.rsp
inst.rsp文件中编辑如下
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.OSDBA_GROUP=dba
oracle.install.db.OSOPER_GROUP=oper
oracle.install.db.OSBACKUPDBA_GROUP=dba
oracle.install.db.OSDGDBA_GROUP=dba
oracle.install.db.OSKMDBA_GROUP=dba
oracle.install.db.OSRACDBA_GROUP=dba
创建实例:
1. 设置环境变量
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1
export ORACLE_SID=ORA12CR2
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
export PATH=$ORACLE_HOME/bin:$PATH
2. 创建初始化文件
文件$ORACLE_HOME/dbs/initORA12CR2.ora内容如下
db_name=ORA12CR2
db_domain=''
db_block_size=8192
memory_target=1G
memory_max_target=2G
processes=200
control_files=(/u01/app/oracle/oradata/ORA12CR2/control01.ctl,/u01/app/oracle/oradata/ORA12CR2/control02.ctl)
job_queue_processes=10
open_cursors=500
fast_start_mttr_target=500
undo_management=AUTO
undo_tablespace=UNDOTBS1
remote_login_passwordfile=EXCLUSIVE
3. 创建所需目录:
CDB数据文件地址:$ORACLE_BASE/oradata/<SID>/
PDB数据文件地址:$ORACLE_BASE/oradata/<SID>/<pdb>/
4. 创建数据库:
sqlplus / as sysdba
startup nomount;
CREATE DATABASE ORA12CR2
MAXLOGFILES 16
MAXLOGMEMBERS 4
MAXDATAFILES 1024
MAXINSTANCES 1
MAXLOGHISTORY 680
CHARACTER SET AL32UTF8
DATAFILE '/u01/app/oracle/oradata/ORA12CR2/system01.dbf' SIZE 500M REUSE EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/ORA12CR2/sysaux01.dbf' SIZE 500M
UNDO TABLESPACE UNDOTBS1 DATAFILE '/u01/app/oracle/oradata/ORA12CR2/undotbs01.dbf' SIZE 500M
DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/oracle/oradata/ORA12CR2/temp01.dbf' SIZE 500M
DEFAULT TABLESPACE USERS DATAFILE '/u01/app/oracle/oradata/ORA12CR2/users01.dbf' SIZE 200M
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/ORA12CR2/redo01a.dbf', '/u01/app/oracle/oradata/ORA12CR2/redo01b.dbf') SIZE 50M,
GROUP 2 ('/u01/app/oracle/oradata/ORA12CR2/redo02a.dbf', '/u01/app/oracle/oradata/ORA12CR2/redo02b.dbf') SIZE 50M,
GROUP 3 ('/u01/app/oracle/oradata/ORA12CR2/redo03a.dbf', '/u01/app/oracle/oradata/ORA12CR2/redo03b.dbf') SIZE 50M
USER sys IDENTIFIED BY oracle
USER system IDENTIFIED BY oracle;
5. 创建数据字典
SQL> spool create_dd.lis
SQL> @?/rdbms/admin/catalog.sql
SQL> @?/rdbms/admin/catproc.sql
SQL> connect system/oracle
SQL> @?/sqlplus/admin/pupbld
6. 创建监听
listener.ora文件:
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1521))
)
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=ORA12CR2.localdomain)
(ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/dbhome_1)
(SID_NAME=ORA12CR2)
)
)
7. 创建密码文件
cd $ORACLE_HOME/dbs
以下必须输入强密码:
orapwd file=orapw<ORACLE_SID> password=<sys password>
否则就得加上format=12
orapwd file=orapw<ORACLE_SID> password=<sys password> format=12