CentOS 7 静默安装 Oracle 11g 11.2.0.2 数据库系统(四)

Oracle DataBase 安装后的配置、建库与故障排查:

[root@oracle11g ~]# ls -F
anaconda-ks.cfg zabbix-release-3.4-1.el7.centos.noarch.rpm zabbix-release-4.0-1.el7.noarch.rpm
src/ zabbix-release-3.4-2.el7.noarch.rpm
[root@oracle11g ~]# cd /d
data/ dev/
[root@oracle11g ~]# cd /data/
[root@oracle11g data]# ls -F
app/ database/ etc/ log/ oracle/ oraInventory/
[root@oracle11g data]#
[root@oracle11g data]# cd ..
[root@oracle11g /]# ll
total 20
lrwxrwxrwx. 1 root root 7 Apr 23 2019 bin -> usr/bin
dr-xr-xr-x. 5 root root 4096 Apr 22 11:04 boot
drwxr-xr-x 8 root root 89 Apr 22 11:18 data
drwxr-xr-x 21 root root 3220 Apr 22 11:04 dev
drwxr-xr-x. 87 root root 8192 Apr 22 13:58 etc
drwxr-xr-x. 5 root root 59 Apr 22 09:34 home
lrwxrwxrwx. 1 root root 7 Apr 23 2019 lib -> usr/lib
lrwxrwxrwx. 1 root root 9 Apr 23 2019 lib64 -> usr/lib64
drwxr-xr-x. 2 root root 6 Apr 11 2018 media
drwxr-xr-x. 2 root root 6 Apr 11 2018 mnt
drwxr-xr-x. 2 root root 6 Apr 11 2018 opt
dr-xr-xr-x 171 root root 0 Apr 22 11:04 proc
dr-xr-x---. 5 root root 4096 Apr 22 10:58 root
drwxr-xr-x 29 root root 800 Apr 22 11:12 run
lrwxrwxrwx. 1 root root 8 Apr 23 2019 sbin -> usr/sbin
drwxr-xr-x. 2 root root 6 Apr 11 2018 srv
dr-xr-xr-x 13 root root 0 Apr 22 11:04 sys
drwxrwxrwt. 10 root root 207 Apr 22 13:41 tmp
drwxr-xr-x. 13 root root 155 Apr 23 2019 usr
drwxr-xr-x. 20 root root 278 Jul 23 2019 var
[root@oracle11g /]#
[root@oracle11g /]# /data/app/oracle/inventory/orainstRoot.sh
Changing permissions of /data/app/oracle/inventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.

Changing groupname of /data/app/oracle/inventory to oinstall.
The execution of the script is complete.
[root@oracle11g /]# /data/app/oracle/product/11.2.0/root.sh
Check /data/app/oracle/product/11.2.0/install/root_oracle11g_2020-04-22_14-06-28.log for the output of root script
[root@oracle11g /]#

配置监听程序
[root@oracle11g /]# su - oracle
Last login: Wed Apr 22 11:26:45 CST 2020 on pts/0
[oracle@oracle11g ~]$
[oracle@oracle11g ~]$ echo $ORACLE_HOME
/data/app/oracle/product/11.2.0/
[oracle@oracle11g ~]$ cd /data/app/oracle/product/11.2.0/
[oracle@oracle11g 11.2.0]$ ls -F
apex/ dbs/ inventory/ network/ owm/ srvm/
assistants/ dc_ocm/ j2ee/ nls/ perl/ sysman/
bin/ deinstall/ javavm/ oc4j/ plsql/ timingframework/
ccr/ demo/ jdbc/ odbc/ precomp/ ucp/
cdata/ diagnostics/ jdev/ olap/ racg/ uix/
cfgtoollogs/ dv/ jdk/ ons/ rdbms/ utl/
clone/ emcli/ jlib/ OPatch/ relnotes/ wwg/
config/ has/ ldap/ opmn/ root.sh* xdk/
crs/ hs/ lib/ oracore/ scheduler/
csmig/ ide/ log/ oraInst.loc slax/
css/ install/ md/ ord/ sqldeveloper/
ctx/ install.platform mesg/ oui/ sqlj/
cv/ instantclient/ mgw/ owb/ sqlplus/
[oracle@oracle11g 11.2.0]$ netca /silent /responsefile /data/etc/netca.rsp

Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /data/etc/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/data/app/oracle/product/11.2.0/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
[oracle@oracle11g 11.2.0]$
[oracle@oracle11g 11.2.0]$ netstat -tnpl | grep 1521
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 :::1521 :::* LISTEN 30130/tnslsnr
[oracle@oracle11g 11.2.0]$

静默创建数据库
【切换到root用户做备份】
[root@oracle11g ~]# cp /data/etc/dbca.rsp{,.original}
[root@oracle11g ~]# ls /data/etc/ | grep dbca.rsp
dbca.rsp
dbca.rsp.original
[root@oracle11g ~]#

静默创建数据库应答文件
[root@oracle11g ~]# cat >> /data/etc/dbca.rsp << EOF

[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/data/app/oracle/oradata
RECOVERYAREADESTINATION=/data/app/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
EOF
[root@oracle11g ~]#

[oracle@oracle11g 11.2.0]$ cat -n /data/etc/dbca.rsp
1046 #----------------------- End of DELETEINSTANCE section ------------------------
1047 [GENERAL]
1048 RESPONSEFILE_VERSION = "11.2.0"
1049 OPERATION_TYPE = "createDatabase"
1050 [CREATEDATABASE]
1051 GDBNAME = "orcl"
1052 SID = "orcl"
1053 SYSPASSWORD = "oracle"
1054 SYSTEMPASSWORD = "oracle"
1055 SYSMANPASSWORD = "oracle"
1056 DBSNMPPASSWORD = "oracle"
1057 DATAFILEDESTINATION =/data/app/oracle/oradata
1058 RECOVERYAREADESTINATION=/data/app/oracle/fast_recovery_area
1059 CHARACTERSET = "AL32UTF8"
1060 TOTALMEMORY = "1638"
[oracle@oracle11g 11.2.0]$

静默创建数据库
[oracle@oracle11g 11.2.0]$ dbca -silent -responseFile /data/etc/dbca.rsp
Enter SYS user password: 【shujuzhilitest】

Enter SYSTEM user password: 【shujuzhilitest】

Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/data/app/oracle/cfgtoollogs/dbca/orcl11g/orcl11g.log" for further details.
[oracle@oracle11g 11.2.0]$
[oracle@oracle11g 11.2.0]$ ps -ef | grep ora_ | grep -v grep
oracle 32157 1 0 15:01 ? 00:00:00 ora_pmon_orcl11g
oracle 32159 1 0 15:01 ? 00:00:00 ora_vktm_orcl11g
oracle 32163 1 0 15:01 ? 00:00:00 ora_gen0_orcl11g
oracle 32165 1 0 15:01 ? 00:00:00 ora_diag_orcl11g
oracle 32167 1 0 15:01 ? 00:00:00 ora_dbrm_orcl11g
oracle 32169 1 0 15:01 ? 00:00:00 ora_psp0_orcl11g
oracle 32171 1 0 15:01 ? 00:00:00 ora_dia0_orcl11g
oracle 32173 1 0 15:01 ? 00:00:00 ora_mman_orcl11g
oracle 32175 1 0 15:01 ? 00:00:00 ora_dbw0_orcl11g
oracle 32177 1 0 15:01 ? 00:00:00 ora_lgwr_orcl11g
oracle 32179 1 0 15:01 ? 00:00:00 ora_ckpt_orcl11g
oracle 32181 1 0 15:01 ? 00:00:00 ora_smon_orcl11g
oracle 32183 1 0 15:01 ? 00:00:00 ora_reco_orcl11g
oracle 32185 1 0 15:01 ? 00:00:00 ora_mmon_orcl11g
oracle 32187 1 0 15:01 ? 00:00:00 ora_mmnl_orcl11g
oracle 32189 1 0 15:01 ? 00:00:00 ora_d000_orcl11g
oracle 32191 1 0 15:01 ? 00:00:00 ora_s000_orcl11g
oracle 32239 1 0 15:01 ? 00:00:00 ora_qmnc_orcl11g
oracle 32256 1 0 15:01 ? 00:00:00 ora_cjq0_orcl11g
oracle 32268 1 0 15:01 ? 00:00:00 ora_q000_orcl11g
oracle 32270 1 0 15:01 ? 00:00:00 ora_q001_orcl11g
[oracle@oracle11g 11.2.0]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 22-APR-2020 15:04:27

Copyright (c) 1991, 2009, 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.1.0 - Production
Start Date 22-APR-2020 14:38:10
Uptime 0 days 0 hr. 26 min. 19 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /data/app/oracle/product/11.2.0/network/admin/listener.ora
Listener Log File /data/app/oracle/diag/tnslsnr/oracle11g/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle11g)(PORT=1521)))
Services Summary...
Service "orcl11g.us.oracle.com" has 1 instance(s).
Instance "orcl11g", status READY, has 1 handler(s) for this service...
Service "orcl11gXDB.us.oracle.com" has 1 instance(s).
Instance "orcl11g", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@oracle11g 11.2.0]$
[oracle@oracle11g 11.2.0]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 22 15:06:35 2020

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

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

SQL> startup
ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/data/app/oracle/product/11.2.0/dbs/initORCL.ora'
SQL>
【这个报错是因为 文件 initORCL.ora 不存在,该文件的模板是 init.ora。新开一个tty窗口做如下操作:】

[root@oracle11g ~]# cd /data/app/oracle/product/11.2.0/dbs/
[root@oracle11g dbs]# ls -F
hc_DBUA0.dat hc_orcl11g.dat init.ora lkORCL11G orapworcl11g spfileorcl11g.ora
[root@oracle11g dbs]# su - oracle
Last login: Wed Apr 22 14:24:05 CST 2020 on pts/1
[oracle@oracle11g ~]$ ls -F
[oracle@oracle11g ~]$ pwd -P
/home/oracle
[oracle@oracle11g ~]$ cd /data/app/oracle/product/11.2.0/dbs/
[oracle@oracle11g dbs]$ ls -F
hc_DBUA0.dat hc_orcl11g.dat init.ora lkORCL11G orapworcl11g spfileorcl11g.ora
[oracle@oracle11g dbs]$ cp init.ora initORCL.ora
[oracle@oracle11g dbs]$ ls -F
hc_DBUA0.dat hc_orcl11g.dat init.ora initORCL.ora lkORCL11G orapworcl11g spfileorcl11g.ora
[oracle@oracle11g dbs]$

【将文件initORCL.ora中的 ORACLE_BASE 换成 $ORACLE_BASE 的值,我执行 echo $ORACLE_BASE 后得到的是 /data/app/oracle 。因此我将 ORACLE_BASE 替换成了 /data/app/oracle 】

[oracle@oracle11g dbs]$ cat -n initORCL.ora
1 #
2 # $Header: rdbms/admin/init.ora /main/23 2009/05/15 13:35:38 ysarig Exp $
3 #
4 # Copyright (c) 1991, 1997, 1998 by Oracle Corporation
5 # NAME
6 # init.ora
7 # FUNCTION
8 # NOTES
9 # MODIFIED
10 # ysarig 05/14/09 - Updating compatible to 11.2
11 # ysarig 08/13/07 - Fixing the sample for 11g
12 # atsukerm 08/06/98 - fix for 8.1.
13 # hpiao 06/05/97 - fix for 803
14 # glavash 05/12/97 - add oracle_trace_enable comment
15 # hpiao 04/22/97 - remove ifile=, events=, etc.
16 # alingelb 09/19/94 - remove vms-specific stuff
17 # dpawson 07/07/93 - add more comments regarded archive start
18 # maporter 10/29/92 - Add vms_sga_use_gblpagfile=TRUE
19 # jloaiza 03/07/92 - change ALPHA to BETA
20 # danderso 02/26/92 - change db_block_cache_protect to _db_block_cache_p
21 # ghallmar 02/03/92 - db_directory -> db_domain
22 # maporter 01/12/92 - merge changes from branch 1.8.308.1
23 # maporter 12/21/91 - bug 76493: Add control_files parameter
24 # wbridge 12/03/91 - use of %c in archive format is discouraged
25 # ghallmar 12/02/91 - add global_names=true, db_directory=us.acme.com
26 # thayes 11/27/91 - Change default for cache_clone
27 # jloaiza 08/13/91 - merge changes from branch 1.7.100.1
28 # jloaiza 07/31/91 - add debug stuff
29 # rlim 04/29/91 - removal of char_is_varchar2
30 # Bridge 03/12/91 - log_allocation no longer exists
31 # Wijaya 02/05/91 - remove obsolete parameters
32 #
33 ##############################################################################
34 # Example INIT.ORA file
35 #
36 # This file is provided by Oracle Corporation to help you start by providing
37 # a starting point to customize your RDBMS installation for your site.
38 #
39 # NOTE: The values that are used in this file are only intended to be used
40 # as a starting point. You may want to adjust/tune those values to your
41 # specific hardware and needs. You may also consider using Database
42 # Configuration Assistant tool (DBCA) to create INIT file and to size your
43 # initial set of tablespaces based on the user input.
44 ###############################################################################
45
46 # Change '<ORACLE_BASE>' to point to the oracle base (the one you specify at
47 # install time)
48
49 db_name='ORCL'
50 memory_target=1G
51 processes = 150
52 audit_file_dest='/data/app/oracle/admin/orcl/adump'
53 audit_trail ='db'
54 db_block_size=8192
55 db_domain=''
56 db_recovery_file_dest='/data/app/oracle/flash_recovery_area'
57 db_recovery_file_dest_size=2G
58 diagnostic_dest='/data/app/oracle'
59 dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
60 open_cursors=300
61 remote_login_passwordfile='EXCLUSIVE'
62 undo_tablespace='UNDOTBS1'
63 # You may want to ensure that control files are created on separate physical
64 # devices
65 control_files = (ora_control1, ora_control2)
66 compatible ='11.2.0'
[oracle@oracle11g dbs]$ mkdir -p /data/app/oracle/admin/orcl/adump

【切换到Oracle 的SQL执行 tty,做如下操作】
SQL> startup
ORA-00845: MEMORY_TARGET not supported on this system
SQL> startup nomount
ORA-00845: MEMORY_TARGET not supported on this system
SQL>

【出现这个报错是因为 共享文件系统 /dev/shm 比 MEMORY_TARGET 小,建议调整共享文件系统 /dev/shm 的大小。另开一个root用户的tty,做如下操作:】
[root@oracle11g ~]# pwd -P
/root
[root@oracle11g ~]# ls -F
anaconda-ks.cfg zabbix-release-3.4-1.el7.centos.noarch.rpm zabbix-release-4.0-1.el7.noarch.rpm
src/ zabbix-release-3.4-2.el7.noarch.rpm
[root@oracle11g ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 20G 31G 39% /
devtmpfs 1.9G 0 1.9G 0% /dev
tmpfs 1.9G 909M 987M 48% /dev/shm
tmpfs 1.9G 8.7M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 186M 829M 19% /boot
/dev/mapper/centos-home 47G 2.1G 45G 5% /home
tmpfs 379M 0 379M 0% /run/user/0
[root@oracle11g ~]# cat /etc/fstab | grep tmpfs
[root@oracle11g ~]# cat -n /etc/fstab
1
2 #
3 # /etc/fstab
4 # Created by anaconda on Tue Apr 23 13:58:21 2019
5 #
6 # Accessible filesystems, by reference, are maintained under '/dev/disk'
7 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
8 #
9 /dev/mapper/centos-root / xfs defaults 0 0
10 UUID=1a215e90-5d25-43c2-b781-6524a7d04705 /boot xfs defaults 0 0
11 /dev/mapper/centos-home /home xfs defaults 0 0
12 /dev/mapper/centos-swap swap swap defaults 0 0
[root@oracle11g ~]#
[root@oracle11g ~]# mount -t tmpfs shmfs -o size=4096M /dev/shm/
[root@oracle11g ~]# df -h | grep shm
shmfs 4.0G 0 4.0G 0% /dev/shm
[root@oracle11g ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 50G 20G 31G 39% /
devtmpfs 1.9G 0 1.9G 0% /dev
shmfs 4.0G 0 4.0G 0% /dev/shm
tmpfs 1.9G 8.7M 1.9G 1% /run
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup
/dev/vda1 1014M 186M 829M 19% /boot
/dev/mapper/centos-home 47G 2.1G 45G 5% /home
tmpfs 379M 0 379M 0% /run/user/0
[root@oracle11g ~]# cp /etc/fstab{,.original}
[root@oracle11g ~]# ls /etc/ | grep fstab
fstab
fstab.original
[root@oracle11g ~]# cat >> /etc/fstab << EOF

tmpfs /dev/shm tmpfs defaults,size=4096M 0 0
EOF
[root@oracle11g ~]# cat -n /etc/fstab
1
2 #
3 # /etc/fstab
4 # Created by anaconda on Tue Apr 23 13:58:21 2019
5 #
6 # Accessible filesystems, by reference, are maintained under '/dev/disk'
7 # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
8 #
9 /dev/mapper/centos-root / xfs defaults 0 0
10 UUID=1a215e90-5d25-43c2-b781-6524a7d04705 /boot xfs defaults 0 0
11 /dev/mapper/centos-home /home xfs defaults 0 0
12 /dev/mapper/centos-swap swap swap defaults 0 0
13 tmpfs /dev/shm tmpfs defaults,size=4096M 0 0
[root@oracle11g ~]#

[oracle@oracle11g orcl]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Apr 22 16:18:06 2020
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> startup
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown immediate
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 1068937216 bytes
Fixed Size 2220200 bytes
Variable Size 616566616 bytes
Database Buffers 444596224 bytes
Redo Buffers 5554176 bytes
SQL> quit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
[oracle@oracle11g orcl]$

孟伯 ,20200426

交流联系:微信 1807479153 ,QQ 1807479153

猜你喜欢

转载自blog.51cto.com/6286393/2490681
今日推荐