建站不啰嗦,上手跟我做(七)oracle 数据库下载和安装

oracle 数据库下载和安装

下载

oracle 数据库需要在官网下载
图片.png

安装

以 linuxx64_12201_database.zip 为例

第一、依赖包安装

[root@localhost /]# yum install gcc gcc-c++ ksh libaio-devel libstdc++-devel compat-libstdc++-33 compat-libcap1 -y

Loaded plugins: fastestmirror

Determining fastest mirrors

* base: mirrors.huaweicloud.com

* extras: mirrors.huaweicloud.com

* updates: mirrors.aliyun.com

base | 3.6 kB 00:00

extras | 3.4 kB 00:00

updates | 3.4 kB 00:00

(1/4): base/7/x86_64/group_gz | 166 kB 00:00

(2/4): extras/7/x86_64/primary_db | 180 kB 00:00

(3/4): updates/7/x86_64/primary_db | 2.4 MB 00:00

(4/4): base/7/x86_64/primary_db
[oracle@localhost database]$  rpm -q binutils compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat
[root@localhost ~]# yum install binutils compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.huaweicloud.com

* extras: mirrors.huaweicloud.com

* updates: mirrors.aliyun.com

[root@localhost ~]# rpm -q binutils compat-libstdc++ gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXext libXtst libX11 libXau libXi make sysstat

binutils-2.27-34.base.el7.x86_64

package compat-libstdc++ is not installed

gcc-4.8.5-36.el7.x86_64

gcc-c++-4.8.5-36.el7.x86_64

glibc-2.17-260.el7_6.3.x86_64

glibc-devel-2.17-260.el7_6.3.x86_64

ksh-20120801-139.el7.x86_64

libaio-0.3.109-13.el7.x86_64

libaio-devel-0.3.109-13.el7.x86_64

libgcc-4.8.5-36.el7.x86_64

libstdc++-4.8.5-36.el7.x86_64

libstdc++-devel-4.8.5-36.el7.x86_64

libXext-1.3.3-3.el7.x86_64

libXtst-1.2.3-1.el7.x86_64

libX11-1.6.5-2.el7.x86_64

libXau-1.0.8-2.1.el7.x86_64

libXi-1.7.9-1.el7.x86_64

make-3.82-23.el7.x86_64

sysstat-10.1.5-17.el7.x86_64

第二、解压

[root@localhost /]# cd /opt

[root@localhost opt]# ls

linuxx64_12201_database.zip

[root@localhost opt]# unzip linuxx64_12201_database.zip

-bash: unzip: command not found

[root@localhost opt]# yum install -y unzip zip

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.huaweicloud.com

* extras: mirrors.huaweicloud.com

* updates: mirrors.aliyun.com

[root@localhost opt]# unzip linuxx64_12201_database.zip

creating: database/stage/globalvariables/

inflating: database/stage/globalvariables/variable.properties

inflating: database/stage/globalvariables/globalvar.xml

inflating: database/stage/install1.jar

inflating: database/runInstaller

[root@localhost opt]# ls

database linuxx64_12201_database.zip

第三、创建 oracle 用户和组

1、创建 oracle 用户

[root@localhost ~]# groupadd dba

[root@localhost ~]# groupadd oinstall

[root@localhost ~]# useradd -g oinstall -G dba oracle

[root@localhost ~]#  groups oracle

oracle : oinstall dba

2、修改 oracle 用户的密码

[root@localhost ~]# passwd oracle

Changing password for user oracle.

New password: 123456

BAD PASSWORD: The password is shorter than 8 characters

Retype new password:

passwd: all authentication tokens updated successfully.

3、修改目录所属用户

[root@localhost opt]# chown -R oracle.oinstall /opt/database

[root@localhost opt]# ll

total 3372752

drwxr-xr-x. 7 oracle oinstall 117 Jan 27 2017 database

-rw-r--r--. 1 root root 3453696911 Mar 1 18:09 linuxx64_12201_database.zip

4、配置内核参数

[root@localhost etc]# vim /etc/sysctl.conf

-bash: vim: command not found

[root@localhost etc]# yum install vim

Loaded plugins: fastestmirror

Loading mirror speeds from cached hostfile

* base: mirrors.huaweicloud.com

* extras: mirrors.huaweicloud.com

* updates: mirrors.aliyun.com

[root@localhost etc]# vim /etc/sysctl.conf

  

# sysctl settings are defined through files in

# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.

#

# Vendors settings live in /usr/lib/sysctl.d/.

# To override a whole file, create a new file with the same in

# /etc/sysctl.d/ and put new settings there. To override

# only specific settings, add a file with a lexically later

# name in /etc/sysctl.d/ and put new settings there.

#

# For more information, see sysctl.conf(5) and sysctl.d(5).

fs.file-max = 6815744

kernel.sem = 250 32000 100 128

kernel.shmmni = 4096

kernel.shmall = 1073741824

kernel.shmmax = 4398046511104

kernel.panic_on_oops = 1

net.core.rmem_default = 262144

net.core.rmem_max = 4194304

net.core.wmem_default = 262144

net.core.wmem_max = 1048576

net.ipv4.conf.all.rp_filter = 2

net.ipv4.conf.default.rp_filter = 2

fs.aio-max-nr = 1048576

net.ipv4.ip_local_port_range = 9000 65500

5、更改当前内核参数

[root@localhost etc]# sysctl -p

6、修改设置 selinux

[root@localhost etc]# vim /etc/selinux/config

# This file controls the state of SELinux on the system.

# SELINUX= can take one of these three values:

# enforcing - SELinux security policy is enforced.

# permissive - SELinux prints warnings instead of enforcing.

# disabled - No SELinux policy is loaded.

SELINUX=permissive

# SELINUXTYPE= can take one of three values:

# targeted - Targeted processes are protected,

# minimum - Modification of targeted policy. Only selected processes are protected.

# mls - Multi Level Security protection.

SELINUXTYPE=targeted

  

[root@localhost etc]# setenforce Permissive

7、禁用防火墙

[root@localhost etc]# systemctl stop firewalld

[root@localhost etc]# systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.

Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

8、创建 oracle 安装目录

[root@localhost etc]# mkdir -p /usr/local/products/oracle12c

[root@localhost etc]# chown -R oracle:oinstall /usr/local

[root@localhost etc]# chmod -R 775 /usr/local/

9、配置主机名

[root@localhost ~]# vim /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.1.193 oraclehost

9、配置 oracle 环境变量

[root@localhost ~]# su - oracle

Last login: Fri Mar 1 20:00:21 CST 2019 on pts/0

[oracle@localhost ~]$ vim .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 TMP=/tmp

export TMPDIR=$TMP

  

export ORACLE_HOSTNAME=oraclehost

export ORACLE_UNQNAME=cdb1

export ORACLE_BASE=/usr/local/products

export ORACLE_HOME=$ORACLE_BASE/oracle12c

export ORACLE_SID=cdb1

  

export PATH=/usr/sbin:/usr/local/bin:$PATH

export PATH=$ORACLE_HOME/bin:$PATH

  

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib

export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

第四、安装 oracle

[oracle@localhost database]$ cd /opt/database/response

[oracle@localhost response]$ ls

dbca.rsp db_install.rsp netca.rsp


[root@oraclehost response]# vim db_install.rsp

oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall 
INVENTORY_LOCATION=/usr/local/oraInventory 
ORACLE_HOME=/usr/local/products/oracle12c 
ORACLE_BASE=/usr/local/products 
oracle.install.db.InstallEdition=EE 
oracle.install.db.OSDBA_GROUP=dba 
oracle.install.db.OSBACKUPDBA_GROUP=dba 
oracle.install.db.OSDGDBA_GROUP=dba 
oracle.install.db.OSKMDBA_GROUP=dba 
oracle.install.db.OSRACDBA_GROUP=dba

[root@oraclehost database]# ls

install response rpm runInstaller sshsetup stage welcome.html

[root@oraclehost database]# su - oracle

[oracle@oraclehost opt]$ cd /opt/database/
[oracle@oraclehost database]$ ./runInstaller -ignoreSysPrereqs -ignorePrereq -waitforcompletion \ -showProgress -silent -responseFile /opt/database/response/db_install.rsp

Starting Oracle Universal Installer...

  

Checking Temp space: must be greater than 500 MB. Actual 29448 MB Passed

Checking swap space: must be greater than 150 MB. Actual 2047 MB Passed

Preparing to launch Oracle Universal Installer from /tmp/OraInstall2019-03-03_09-54-18AM. Please wait ...[WARNING] [INS-32016] The selected Oracle home contains directories or files.

ACTION: To start with an empty Oracle home, either remove its contents or choose another location.

You can find the log of this install session at:

/usr/local/oraInventory/logs/installActions2019-03-03_09-54-18AM.log

  

Prepare in progress.

.................................................. 8% Done.

  

Prepare successful.

  

Copy files in progress.

.................................................. 17% Done.

.................................................. 22% Done.

.................................................. 27% Done.

.................................................. 32% Done.

.................................................. 40% Done.

.................................................. 45% Done.

.................................................. 50% Done.

.................................................. 55% Done.

.................................................. 60% Done.

.................................................. 65% Done.

.................................................. 70% Done.

.................................................. 75% Done.

.................................................. 80% Done.

....................

Copy files successful.

  

Link binaries in progress.

..........

Link binaries successful.

  

Setup files in progress.

..............................

Setup files successful.

  

Setup Inventory in progress.

  

Setup Inventory successful.

  

Finish Setup successful.

The installation of Oracle Database 12c was successful.

Please check '/usr/local/oraInventory/logs/silentInstall2019-03-03_09-54-18AM.log' for more details.

  

Setup Oracle Base in progress.

  

Setup Oracle Base successful.

.................................................. 95% Done.

  

As a root user, execute the following script(s):

1. /usr/local/oraInventory/orainstRoot.sh

2. /usr/local/products/oracle12c/root.sh

  

  

  

.................................................. 100% Done.

Successfully Setup Software.
[oracle@oraclehost database]$ su - root

Password:

Last login: Sun Mar 3 09:35:29 CST 2019 from 192.168.1.192 on pts/0

[root@oraclehost ~]# /usr/local/oraInventory/orainstRoot.sh

Changing permissions of /usr/local/oraInventory.

Adding read,write permissions for group.

Removing read,write,execute permissions for world.

  

Changing groupname of /usr/local/oraInventory to oinstall.

The execution of the script is complete.

[root@oraclehost ~]# /usr/local/products/oracle12c/root.sh

Check /usr/local/products/oracle12c/install/root_oraclehost_2019-03-03_10-01-41-496169616.log for the output of root script
[root@oraclehost ~]# cat /usr/local/products/oracle12c/install/root_oraclehost_2019-03-03_10-01-41-496169616.log

Performing root user operation.

  

The following environment variables are set as:

ORACLE_OWNER= oracle

ORACLE_HOME= /usr/local/products/oracle12c

Copying dbhome to /usr/local/bin ...

Copying oraenv to /usr/local/bin ...

Copying coraenv to /usr/local/bin ...

  

  

Creating /etc/oratab file...

Entries will be added to the /etc/oratab file as needed by

Database Configuration Assistant when a database is created

Finished running generic part of root script.

Now product-specific root actions will be performed.

Oracle Trace File Analyzer (TFA) is available at : /usr/local/products/oracle12c/suptools/tfa/release/tfa_home/bin/tfactl
[root@oraclehost ~]# su - oracle

[oracle@oraclehost ~]$ sqlplus /nolog

  

SQL*Plus: Release 12.2.0.1.0 Production on Sun Mar 3 10:09:46 2019

  

Copyright (c) 1982, 2016, Oracle. All rights reserved.

  

SQL> conn /as sysdba

Connected to an idle instance.

SQL> select status from v$instance;

select status from v$instance

*

ERROR at line 1:

ORA-01034: ORACLE not available

Process ID: 0

Session ID: 0 Serial number: 0

[oracle@RAC1 ~]$ lsnrctl start

  

LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 25-SEP-2018 09:33:18

  

Copyright (c) 1991, 2011, Oracle. All rights reserved.

  

Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...

  

TNSLSNR for Linux: Version 11.2.0.3.0 - Production

System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Log messages written to /u01/app/oracle/diag/tnslsnr/RAC1/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RAC1)(PORT=1521)))

  

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production

Start Date 25-SEP-2018 09:33:20

Uptime 0 days 0 hr. 0 min. 0 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora

Listener Log File /u01/app/oracle/diag/tnslsnr/RAC1/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=RAC1)(PORT=1521)))

The listener supports no services

The command completed successfully
[oracle@RAC1 ~]$ sqlplus /nolog

  

SQL*Plus: Release 11.2.0.3.0 Production on Tue Sep 25 09:33:26 2018

  

Copyright (c) 1982, 2011, Oracle. All rights reserved.

  

SQL> connect /as sysdba

Connected to an idle instance.

SQL> startup

ORACLE instance started.

第五、创建容器数据库

createAsContainerDatabase

dbca -silent -createDatabase \ -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \ -gdbname cdb1 -sid cdb1 -responseFile /opt/database/response/dbca.rsp \ -characterSet AL32UTF8 \ -sysPassword OraPasswd1 \ -systemPassword OraPasswd1 \ -createAsContainerDatabase true \ -numberOfPDBs 1 \ -pdbName pdb1 \ -pdbAdminPassword OraPasswd1 \ -automaticMemoryManagement false \ -ignorePreReqs

容器数据库是 oracle12 新特性,非容器数据库和 oracle11、oracle10 兼容

[oracle@oraclehost ~]$ dbca -silent -createDatabase \

> -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \

> -gdbname cdb1 -sid cdb1 -responseFile /opt/database/response/dbca.rsp \

> -characterSet AL32UTF8 \

> -sysPassword OraPasswd1 \

> -systemPassword OraPasswd1 \

> -createAsContainerDatabase true \

> -numberOfPDBs 1 \

> -pdbName pdb1 \

> -pdbAdminPassword OraPasswd1 \

> -automaticMemoryManagement false \

> -ignorePreReqs

Copying database files

1% complete

13% complete

25% complete

Creating and starting Oracle instance

26% complete

30% complete

31% complete

35% complete

38% complete

39% complete

41% complete

Completing Database Creation

42% complete

43% complete

44% complete

46% complete

49% complete

50% complete

Creating Pluggable Databases

55% complete

75% complete

Executing Post Configuration Actions

100% complete

Look at the log file "/usr/local/products/cfgtoollogs/dbca/cdb1/cdb1.log" for further details.
[oracle@oraclehost ~]$ cat /usr/local/products/cfgtoollogs/dbca/cdb1/cdb1.log

[ 2019-03-03 10:15:17.079 CST ] Copying database files

DBCA_PROGRESS : 1%

DBCA_PROGRESS : 13%

DBCA_PROGRESS : 25%

[ 2019-03-03 10:17:17.390 CST ] Creating and starting Oracle instance

DBCA_PROGRESS : 26%

DBCA_PROGRESS : 30%

DBCA_PROGRESS : 31%

DBCA_PROGRESS : 35%

DBCA_PROGRESS : 38%

DBCA_PROGRESS : 39%

DBCA_PROGRESS : 41%

[ 2019-03-03 10:21:01.195 CST ] Completing Database Creation

DBCA_PROGRESS : 42%

DBCA_PROGRESS : 43%

DBCA_PROGRESS : 44%

DBCA_PROGRESS : 46%

DBCA_PROGRESS : 49%

DBCA_PROGRESS : 50%

[ 2019-03-03 10:26:21.743 CST ] Creating Pluggable Databases

DBCA_PROGRESS : 55%

DBCA_PROGRESS : 75%

[ 2019-03-03 10:27:08.868 CST ] Executing Post Configuration Actions

DBCA_PROGRESS : 100%

[ 2019-03-03 10:27:08.869 CST ] Database creation complete. For details check the logfiles at:

/usr/local/products/cfgtoollogs/dbca/cdb1.

Database Information:

Global Database Name:cdb1

System Identifier(SID):cdb1

第六、创建监听

[oracle@oraclehost ~]$ lsnrctl status

  

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 03-MAR-2019 10:34:16

  

Copyright (c) 1991, 2016, Oracle. All rights reserved.

  

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))

TNS-12541: TNS:no listener

TNS-12560: TNS:protocol adapter error

TNS-00511: No listener

Linux Error: 111: Connection refused
[oracle@oraclehost ~]$ netca -silent -responseFile /opt/database/response/netca.rsp

  

Parsing command line arguments:

Parameter "silent" = true

Parameter "responsefile" = /opt/database/response/netca.rsp

Done parsing command line arguments.

Oracle Net Services Configuration:

Profile configuration complete.

Oracle Net Listener Startup:

Running Listener Control:

/usr/local/products/oracle12c/bin/lsnrctl start LISTENER

Listener Control complete.

Listener started successfully.

Listener configuration complete.

Oracle Net Services configuration successful. The exit code is 0
[oracle@oraclehost ~]$ vim /usr/local/products/oracle12c/network/admin/listener.ora

  

# listener.ora Network Configuration File: /usr/local/products/oracle12c/network/admin/listener.ora

# Generated by Oracle configuration tools.

SID_LIST_LISTENER =

(SID_LIST =

(SID_DESC =

(SID_NAME =PLSExtProc)

(ORACLE_HOME = /usr/local/products/oracle12c)

(PROGRAM = extproc)

)

)

LISTENER =

(DESCRIPTION_LIST =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP)(HOST =oraclehost)(PORT = 1521))

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))

)

)
在Oracle用户(不是grid用户)下,将$ORACLE_HOME/network/admin/sqlnet.ora文件原来的SQLNET.ALLOWED_LOGON_VERSION=8注释掉(如果没有sqlnet.ora文件,那么就创建一个),修改为如下的行:


SQLNET.ALLOWED_LOGON_VERSION_SERVER=8

SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8
[oracle@oraclehost /]$ sqlplus /nolog

  

SQL*Plus: Release 12.2.0.1.0 Production on Sun Mar 3 11:52:33 2019

  

Copyright (c) 1982, 2016, Oracle. All rights reserved.

  

SQL> conn /as sysdba

Connected.

SQL> select username from dba_users;

  

USERNAME

--------------------------------------------------------------------------------

SYS

SYSTEM

XS$NULL

OJVMSYS

LBACSYS

OUTLN

SYS$UMF

DBSNMP

APPQOSSYS

DBSFWUSER

GGSYS

SQL> alter user SYSTEM identified by 123456;

  

User altered.

38EDA7E8622C4E38B21492E094E40B27.jpg

重启后启动数据库

[oracle@oraclehost ~]$ su - oracle

[oracle@oraclehost ~]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 03-MAR-2019 12:01:19

Copyright (c) 1991, 2016, Oracle. All rights reserved.

  

Starting /usr/local/products/oracle12c/bin/tnslsnr: please wait...

  

TNSLSNR for Linux: Version 12.2.0.1.0 - Production

System parameter file is /usr/local/products/oracle12c/network/admin/listener.ora

Log messages written to /usr/local/products/diag/tnslsnr/oraclehost/listener/alert/log.xml

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraclehost)(PORT=1521)))

Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

  

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraclehost)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production

Start Date 03-MAR-2019 12:01:19

Uptime 0 days 0 hr. 0 min. 0 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /usr/local/products/oracle12c/network/admin/listener.ora

Listener Log File /usr/local/products/diag/tnslsnr/oraclehost/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraclehost)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Services Summary...

Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully
[oracle@oraclehost ~]$ sqlplus /nolog

 
SQL*Plus: Release 12.2.0.1.0 Production on Sun Mar 3 12:03:09 2019

  

Copyright (c) 1982, 2016, Oracle. All rights reserved.

  

SQL> connect /as sysdba;

Connected to an idle instance.

SQL> startup

ORACLE instance started.

  

Total System Global Area 578813952 bytes

Fixed Size 8795328 bytes

Variable Size 301992768 bytes

Database Buffers 264241152 bytes

Redo Buffers 3784704 bytes

Database mounted.

Database opened.

SQL>

55BDA2028FB947D18DCCA1F0DD92D349.jpg

开机启动

[root@oraclehost ~]# vim /etc/oratab

  

#

  

  

  

# This file is used by ORACLE utilities. It is created by root.sh

# and updated by either Database Configuration Assistant while creating

# a database or ASM Configuration Assistant while creating ASM instance.

  

# A colon, ':', is used as the field terminator. A new line terminates

# the entry. Lines beginning with a pound sign, '#', are comments.

#

# Entries are of the form:

# $ORACLE_SID:$ORACLE_HOME:<N|Y>:


# This file is used by ORACLE utilities. It is created by root.sh

# and updated by either Database Configuration Assistant while creating

# a database or ASM Configuration Assistant while creating ASM instance.


# A colon, ':', is used as the field terminator. A new line terminates

# the entry. Lines beginning with a pound sign, '#', are comments.

#

# Entries are of the form:

# $ORACLE_SID:$ORACLE_HOME:<N|Y>:

#

# The first and second fields are the system identifier and home

# directory of the database respectively. The third field indicates

# to the dbstart utility that the database should , "Y", or should not,

# "N", be brought up at system boot time.

#

# Multiple entries with the same $ORACLE_SID are not allowed.


cdb1:/usr/local/products/oracle12c:Y
[root@oraclehost ~]# vim /etc/rc.d/rc.local

  

#!/bin/bash

#!/bin/bash

# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES

#

# It is highly advisable to create own systemd services or udev rules

# to run scripts during boot instead of using this file.

#

# In contrast to previous versions due to parallel execution during boot

# this script will NOT be run after all other services.

#

# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure

# that this script will be executed during boot.

  

touch /var/lock/subsys/local


##用oracle用户登录,运行lsnrctl start 脚本启用监听。

su - oracle -c "/usr/local/products/oracle12c/bin/lsnrctl start"

##用oracle用户登录,运行dbstart启动数据库

su - oracle -c "/usr/local/products/oracle12c/bin/dbstart"
[root@oraclehost ~]# cd /etc/rc.d

[root@oraclehost rc.d]# ls

init.d rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rc6.d rc.local

[root@oraclehost rc.d]# ll

total 4

drwxr-xr-x. 2 root root 70 Mar 1 17:51 init.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc0.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc1.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc2.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc3.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc4.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc5.d

drwxr-xr-x. 2 root root 45 Mar 1 17:51 rc6.d

-rw-r--r--. 1 root root 720 Mar 3 12:22 rc.local

[root@oraclehost rc.d]# chmod +x rc.local

重启后连接数据库

597FDFE791DA402DBF5EE7DDF47125CF.jpg

第七、创建非容器数据库

dbca -silent -createDatabase \ -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \ -gdbname orcl -sid orcl -responseFile /opt/database/response/dbca.rsp \ -characterSet AL32UTF8 \ -sysPassword OraPasswd1 \ -systemPassword OraPasswd1 \ -createAsContainerDatabase false \ -numberOfPDBs 1 \ -pdbName pdb2 \ -pdbAdminPassword OraPasswd1 \ -automaticMemoryManagement false \ -ignorePreReqs

容器数据库是 oracle12 新特性,非容器数据库和 oracle11、oracle10 兼容

[oracle@oraclehost ~]$ dbca -silent -createDatabase \

> -templateName /usr/local/products/oracle12c/assistants/dbca/templates/General_Purpose.dbc \

> -gdbname orcl -sid orcl -responseFile /opt/database/response/dbca.rsp \

> -characterSet AL32UTF8 \

> -sysPassword OraPasswd1 \

> -systemPassword OraPasswd1 \

> -createAsContainerDatabase false \

> -numberOfPDBs 1 \

> -pdbName pdb2 \

> -pdbAdminPassword OraPasswd1 \

> -automaticMemoryManagement false \

> -ignorePreReqs

Copying database files

1% complete

2% complete

18% complete

33% complete

Creating and starting Oracle instance

35% complete

40% complete

44% complete

49% complete

50% complete

53% complete

55% complete

Completing Database Creation

56% complete

57% complete

58% complete

62% complete

65% complete

66% complete

Executing Post Configuration Actions

100% complete

Look at the log file "/usr/local/products/cfgtoollogs/dbca/orcl/orcl.log" for further details.
[oracle@oraclehost ~]$ cat /usr/local/products/cfgtoollogs/dbca/orcl/orcl.log

[ 2019-03-04 18:05:36.102 CST ] Copying database files

DBCA_PROGRESS : 1%

DBCA_PROGRESS : 2%

DBCA_PROGRESS : 18%

DBCA_PROGRESS : 33%

[ 2019-03-04 18:09:38.464 CST ] Creating and starting Oracle instance

DBCA_PROGRESS : 35%

DBCA_PROGRESS : 40%

DBCA_PROGRESS : 44%

DBCA_PROGRESS : 49%

DBCA_PROGRESS : 50%

DBCA_PROGRESS : 53%

DBCA_PROGRESS : 55%

[ 2019-03-04 18:11:55.039 CST ] Completing Database Creation

DBCA_PROGRESS : 56%

DBCA_PROGRESS : 57%

DBCA_PROGRESS : 58%

DBCA_PROGRESS : 62%

DBCA_PROGRESS : 65%

DBCA_PROGRESS : 66%

[ 2019-03-04 18:14:19.878 CST ] Executing Post Configuration Actions

DBCA_PROGRESS : 100%

[ 2019-03-04 18:14:19.889 CST ] Database creation complete. For details check the logfiles at:

/usr/local/products/cfgtoollogs/dbca/orcl.

Database Information:

Global Database Name:orcl

System Identifier(SID):orcl

8FAA035B3C1245C4A4FE2AFBD69EF696.jpg

配置 orcl 实例监听

[oracle@oraclehost ~]$ netca -silent -responseFile /opt/database/response/netca.rsp

Parsing command line arguments:

Parameter "silent" = true

Parameter "responsefile" = /opt/database/response/netca.rsp

Done parsing command line arguments.

Oracle Net Services Configuration:

Profile configuration complete.

Oracle Net Listener Startup:

Running Listener Control:

/usr/local/products/oracle12c/bin/lsnrctl start LISTENER

Listener Control complete.

Listener started successfully.

Listener configuration complete.

Oracle Net Services configuration successful. The exit code is 0

设置 orcl 实例开机启动

[root@oraclehost ~]# vim /etc/oratab

  

#

  

  

  

# This file is used by ORACLE utilities. It is created by root.sh

# and updated by either Database Configuration Assistant while creating

# a database or ASM Configuration Assistant while creating ASM instance.

  

# A colon, ':', is used as the field terminator. A new line terminates

# the entry. Lines beginning with a pound sign, '#', are comments.

#

# Entries are of the form:

# $ORACLE_SID:$ORACLE_HOME:<N|Y>:

#

# The first and second fields are the system identifier and home

# directory of the database respectively. The third field indicates

# to the dbstart utility that the database should , "Y", or should not,

# "N", be brought up at system boot time.

#

# Multiple entries with the same $ORACLE_SID are not allowed.

#

#

cdb1:/usr/local/products/oracle12c:Y

orcl:/usr/local/products/oracle12c:Y
[oracle@oraclehost ~]$  lsnrctl status

  

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 05-MAR-2019 10:20:46

  

Copyright (c) 1991, 2016, Oracle. All rights reserved.

  

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=oraclehost)(PORT=1521)))

STATUS of the LISTENER

------------------------

Alias LISTENER

Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production

Start Date 05-MAR-2019 10:18:11

Uptime 0 days 0 hr. 2 min. 34 sec

Trace Level off

Security ON: Local OS Authentication

SNMP OFF

Listener Parameter File /usr/local/products/oracle12c/network/admin/listener.ora

Listener Log File /usr/local/products/diag/tnslsnr/oraclehost/listener/alert/log.xml

Listening Endpoints Summary...

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oraclehost)(PORT=1521)))

(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Services Summary...

Service "83285daeda985e67e053c101a8c0bc45" has 1 instance(s).

Instance "cdb1", status READY, has 1 handler(s) for this service...

Service "PLSExtProc" has 1 instance(s).

Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...

Service "cdb1" has 1 instance(s).

Instance "cdb1", status READY, has 1 handler(s) for this service...

Service "cdb1XDB" has 1 instance(s).

Instance "cdb1", status READY, has 1 handler(s) for this service...

Service "orcl" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

Service "orclXDB" has 1 instance(s).

Instance "orcl", status READY, has 1 handler(s) for this service...

Service "pdb1" has 1 instance(s).

Instance "cdb1", status READY, has 1 handler(s) for this service...

The command completed successfully

使用 docker 安装 Oracle
docker 安装 oracle19c

上一篇 建站不啰嗦,上手跟我做(六)mysql 数据库下载和安装
目录
下一篇 建站不啰嗦,上手跟我做(八)redis 下载和安装