一、前期環境准備
1.硬件信息
(1)主機版本
[root@localhost ~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.7 (Maipo)
[root@localhost ~]#
(2)CPU
[oracle@localhost soft19]$ cat /proc/cpuinfo | grep "physical id" | uniq |wc -l
8
[root@localhost ~]# cat /proc/cpuinfo | grep "cpu cores" | uniq
cpu cores : 1
(3)內存大小
[root@localhost ~]# cat /proc/meminfo | grep MemTotal
MemTotal: 16413444 kB
2.介質信息
[oracle@localhost ~]$ pwd
/home/oracle
[oracle@localhost ~]$ ls -lrt LINUX.X64_193000_db_home.zip
-rw-r--r-- 1 oracle oinstall 3059705302 Jun 30 2020 LINUX.X64_193000_db_home.zip
[oracle@localhost ~]$
unzip LINUX.X64_193000_db_home.zip -d $ORACLE_HOME
3.環境准備
(1)檢查依賴包
rpm -qa binutils compat-libcap1 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
##如果缺少依賴包,並且服務器已配置了 yum,可采用如下方式進行安裝
yum install bc \
gcc \
gcc-c++ \
binutils \
compat-libcap1 \
compat-libstdc++ \
dtrace-modules \
dtrace-modules-headers \
dtrace-modules-provider-headers \
dtrace-utils \
elfutils-libelf \
elfutils-libelf-devel \
fontconfig-devel \
glibc \
glibc-devel \
ksh \
libaio \
libaio-devel \
libdtrace-ctf-devel \
libX11 \
libXau \
libXi \
libXtst \
libXrender \
libXrender-devel \
libgcc \
librdmacm-devel \
libstdc++ \
libstdc++-devel \
libxcb \
make \
smartmontools \
sysstat
(2)修改內核參數
cp /etc/sysctl.conf /etc/sysctl.conf_bak_20200327
vi /etc/sysctl.conf ##添加如下內容
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 33554432
kernel.shmmax = 137438953471
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
修改后執行 sysctl -p
(3)禁用防火牆和 selinux
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl status firewalld.service
systemctl status NetworkManager.service
##從 RHEL7 開始,使用 systemctl 工具來管理服務程序,包括了 service 和 chkconfig
以下是一些常用命令
systemctl list-unit-files|grep enabled
啟動一個服務:systemctl start firewalld.service
關閉一個服務:systemctl stop firewalld.service
重啟一個服務:systemctl restart firewalld.service
顯示一個服務的狀態:systemctl status firewalld.service
在開機時啟用一個服務:systemctl enable firewalld.service
在開機時禁用一個服務:systemctl disable firewalld.service
查看服務是否開機啟動:systemctl is-enabled firewalld.service;echo $?
查看已啟動的服務列表:systemctl list-unit-files|grep enabled
[oracle@localhost ~]$ cat /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=disabled
# 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
[oracle@localhost ~]$
(4)配置 host
vi /etc/hosts
10.135.102.133 localhost
(5)創建用戶、組
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
useradd -u 501 -g oinstall -G dba,oper oracle
passwd oracle
(6)創建目錄並設置權限
mkdir -p /u01/app/oracle/product/19.3/db_1
chown -R oracle:oinstall /u01/
chmod -R 775 /u01/
(7)修改用戶安全限制
vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
##在/etc/pam.d/login 文件添加如下內容
session required pam_limits.so
(8)設置用戶環境變量
su - oracle
vi .bash_profile
export ORACLE_SID=ecis
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/19.3/db_1
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH:$JAVA_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
source .bash_profile
二、正式安裝
##由於當前環境無法使用圖形化進行安裝,這里將采用靜默安裝 Oracle 19c 數據庫
1.靜默安裝數據庫軟件
(1)修改響應文件
cd /u01/app/oracle/product/19.3/db_1/install/response
cat db_install.rsp|grep -v "^#"|grep -v "^$"
mv db_install.rsp db_install.rsp.bak
vi db_install.rsp
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v19.0.0
oracle.install.option=INSTALL_DB_SWONLY
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/19.3/db_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
oracle.install.db.rootconfig.executeRootScript=false
oracle.install.db.rootconfig.configMethod=ROOT
(2)安裝數據庫軟件
/u01/app/oracle/product/19.3/db_1/runInstaller -force -silent -noconfig -ignorePrereq -responseFile /u01/app/oracle/product/19.3/db_1/install/response/db_install.rsp
(3)根據安裝提示查看安裝日志
tail -200f /u01/app/oraInventory/logs/InstallActions2020-03-31_04-49-29PM/installActions2020-03-31_04-49-29PM.log
(4)執行腳本
su - root
[root@localhost ~]# /u01/app/oracle/product/19.3/db_1/root.sh
Check /u01/app/oracle/product/19.3/db_1/install/root_localhost_2020-03-31_17-00-53-190777891.log for the output of root script
2.靜默安裝數據庫
(1)修改響應文件
cd /u01/app/oracle/product/19.3/db_1/assistants/dbca
cat dbca.rsp |grep -v "^#"|grep -v "^$"
mv dbca.rsp dbca.rsp.bak
vi dbca.rsp
gdbName=zjipnm
sid=zjipnm
createAsContainerDatabase=true
numberOfPDBs=1
pdbName=zjipnmpdb
pdbAdminPassword=Gzb$akptY
templateName=General_Purpose.dbc
sysPassword=Gzb$akptY
systemPassword=Gzb$akptY
emExpressPort=5500
datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/
characterSet=ZHS16GBK
nationalCharacterSet=AL16UTF16
memoryPercentage=40
automaticMemoryManagement=false
totalMemory=12288
(2)安裝數據庫
dbca -silent -createDatabase -responseFile /u01/app/oracle/product/19.3/db_1/assistants/dbca/dbca.rsp
Prepare for db operation
8% complete
Copying database files
31% complete
Creating and starting Oracle instance
32% complete
36% complete
40% complete
43% complete
46% complete
Completing Database Creation
51% complete
53% complete
54% complete
Creating Pluggable Databases
58% complete
77% complete
Executing Post Configuration Actions
100% complete
Database creation complete. For details check the logfiles at:
/u01/app/oracle/cfgtoollogs/dbca/ECIS.
Database Information:
Global Database Name:ECIS
System Identifier(SID):zjipnmpdb
Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/PROD/PROD.log" for
further details.
3.創建監聽
(1)響應文件
cd /u01/app/oracle/product/19.3/db_1/assistants/netca
cat netca.rsp|grep -v "^#"|grep -v "^$"
mv netca.rsp netca.rspbak
[GENERAL]
RESPONSEFILE_VERSION="19.0"
CREATE_TYPE="CUSTOM"
[oracle.net.ca]
INSTALLED_COMPONENTS={"server","net8","javavm"}
INSTALL_TYPE=""typical""
LISTENER_NUMBER=1
LISTENER_NAMES={"LISTENER"}
LISTENER_PROTOCOLS={"TCP;1521"}
LISTENER_START=""LISTENER""
NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"}
NSN_NUMBER=1
NSN_NAMES={"EXTPROC_CONNECTION_DATA"}
NSN_SERVICE={"PLSExtProc"}
NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
netca -silent -responsefile /u01/app/oracle/product/19.3/db_1/assistants/netca/netca.rsp
[oracle@localhost ~]$ lsnrctl status
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 13-JAN-2021 17:37:44
Copyright (c) 1991, 2019, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 13-JAN-2021 13:39:31
Uptime 0 days 3 hr. 58 min. 12 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.3/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
Instance "ecis", status READY, has 1 handler(s) for this service...
Service "b8c10d35dc4e8f1ee055000000000001" has 1 instance(s).
Instance "ecis", status READY, has 1 handler(s) for this service...
Service "zjipnm" has 1 instance(s).
Instance "ecis", status READY, has 1 handler(s) for this service...
Service "zjipnmXDB" has 1 instance(s).
Instance "ecis", status READY, has 1 handler(s) for this service...
Service "zjipnmpdb" has 1 instance(s).
Instance "ecis", status READY, has 1 handler(s) for this service...
The command completed successfully
問題1
[oracle@localhost ~]$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.3.0 - Production on Wed Dec 15 10:54:03 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/app/oracle/product/11.2.0/db_1/dbs/initicare1.ora'
沒有initicare1.ora文件
解決此問題的方法就是到cd /u01/app/oracle/admin/zjipnm/pfile/目錄下,將init.ora.0132021114328復制到dbs目錄下:
cp init.ora.0132021114328 /u01/app/oracle/product/19.3/db_1/dbs/initicare1.ora
問題2
ORA-01102: cannot mount database in EXCLUSIVE mode
1、重啟服務器可解決
2、查$ORACLE_HOME/dbs目錄:
$ cd $ORACLE_HOME/dbs
$ ls sgadef*
sgadef* not found
$ ls lk*
/opt/oracle/product/ 10.2.0/db_1/dbs/lkSIMPLY
lkSIMPLY
果然,lk<sid>文件沒有被刪除。將它刪除掉
$ rm lk*
再次啟動時又遇到下面的錯誤
ORA-00205: error in identifying control file, check alert log for more info : (
查看共享內存段
[root@simply bdump]# ipcs -map
------ Shared Memory Creator/Last-op --------
shmid owner cpid lpid
786444 root 6490 6438
819213 root 6549 6438
1409040 oracle 31502 16728
根據ID號清楚共享內存段
ipcrm –m 1409040
我這里操作是沒有成功的,不過執行了下面的操作就ok了!
查看信號量
[root@simply bdump]# ipcs -s
key semid owner perms nsems
0x17ff6454 360448 oracle 640 154
清除oracle的信號量
[root@simply bdump]# ipcrm -s 360448
再次查詢確認
[root@simply bdump]# ipcs -s
------ Semaphore Arrays --------
key semid owner perms nsems
再查詢共享內存段也ok了!
[root@simply bdump]# ipcs -m
如果是Oracle進程沒有關閉,
$kill -9 <PID>
安裝oracle后實例不存在:Oracle報錯 ORA-01078
報錯:
在啟動Oracle數據庫時報錯,如下:
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Sat Feb 16 19:43:43 2013
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/initorcl.ora'
原因分析:
這是因為在oracle10g和oracle11g中,數據庫默認將使用spfile啟動數據庫,如果spfile不存在,則就會出現上述錯誤。
解決一:
用find /u01 -name pfile命令查找pfile文件的位置,/u01/app/oracle/admin/orcl/pfile/
將$ORACLE_BASE/admin/orcl/pfile目錄下的init.ora.2212013132036形式的文件copy 到$ORACLE_HOME/dbs目錄下命名為initorcl.ora即可。
(注:initorcl.ora中的orcl為你的實例名 ORACLE_SID,這里我的SID為:center)
方法二:
將$ORACLE_HOME/dbs目錄下spflieorcl.ora改名為spfilecenter.ora即可。(注:spfilecenter.ora中的center為環境變量中設置的SID,我的是center)
方法三:
拷貝pfile文件下的init.ora.61420130339到dbs下,並重命名成init+實例名.ora即可
{{{
[oracle@localhost oracle]$ find /u01 -name pfile
/u01/app/admin/orcl/pfile
[oracle@localhost oracle]$ cd /u01/app/admin/orcl/pfile
[oracle@localhost pfile]$ ls
init.ora.61420130339
[oracle@localhost pfile]$ cp init.ora.61420130339 /u01/app/oracle/dbs/initdevdb.ora
}}}