在部署goldengate过程中发现如下错误:
[oracle@localhost OGG]$ ggsci
ggsci: error while loading shared libraries: /opt/oracle/product/10.2.0/db_1/lib/libclntsh.so.10.1: cannot restore segment prot after reloc: Permission denied
查找资料,没有专门说ogg安装这个错误,是SELinux启用导致,但是有很多其他程序执行过程中报类此错误是有此导致,那么我抱着尝试的态度实验看看:
1、查看SELinux是否被关闭
[oracle@localhost tmp]$ more /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 – SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted – Only targeted network daemons are protected.
# strict – Full SELinux protection.
SELINUXTYPE=targeted
说明已经关闭。那就奇怪了,既然已经闭关了那为什么还不行?于是我怀疑,是不是有人只是修改了SELINUX=disabled,没有重启系统或者使用命令使其生效导致。
2、查看SELINUX修改是否生效
[root@localhost ~]# getenforce
Enforcing
果然修改没有生效
3、使SELINUX生效
[root@localhost ~]# setenforce 0
再次查询,现在已经生效
[root@localhost ~]# getenforce
Permissive
4、然后启动ggsci
[oracle@localhost ~]$ ggsci
Oracle GoldenGate Command Interpreter for Oracle
Version 11.1.1.1.1 OGGCORE_11.1.1.1.1_PLATFORMS_110729.1700
Linux, x64, 64bit (optimized), Oracle 10g on Jul 29 2011 19:43:29
Copyright (C) 1995, 2011, Oracle and/or its affiliates. All rights reserved.
数据文件重命名
最近一段时间,发现不少pub上不少新手都因为一时大意,添加数据文件名称不规范,然后想重命名该数据文件(或者想删除该数据文件然后重建),处理思路有些不妥,导致一些悲剧的发现,我这里通过实验提供一个自认为比较合理的处理思路:处理思路是数据文件离线重命名
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/test/archivelog
Oldest online log sequence 210
Next log sequence to archive 212
Current log sequence 212
--确认数据库是归档模式,使得数据库离线后,可以有归档日志恢复到在线状态
SQL> col name for a50
SQL> select name,file# from v$datafile;
NAME FILE#
-------------------------------------------------- ----------
/opt/oracle/oradata/test/system01.dbf 1
/opt/oracle/oradata/test/undotbs01.dbf 2
/opt/oracle/oradata/test/sysaux01.dbf 3
/opt/oracle/oradata/test/users01.dbf 4
/opt/oracle/oradata/test/user32g.dbf 5
/opt/oracle/oradata/test/xifenfei01.dbf 6
/opt/oracle/oradata/test/user02.dbf 7
/opt/oracle/oradata/test/odu02.dbf 8
/opt/oracle/oradata/test/odu01.dbf 9
/opt/oracle/oradata/test/odu03.dbf 10
10 rows selected.
SQL> alter tablespace xff add datafile '/opt/oracle/oradata/test/xifenfei02.chf'
2 size 10m autoextend off;
Tablespace altered.
SQL> select name,file# from v$datafile;
NAME FILE#
-------------------------------------------------- ----------
/opt/oracle/oradata/test/system01.dbf 1
/opt/oracle/oradata/test/undotbs01.dbf 2
/opt/oracle/oradata/test/sysaux01.dbf 3
/opt/oracle/oradata/test/users01.dbf 4
/opt/oracle/oradata/test/user32g.dbf 5
/opt/oracle/oradata/test/xifenfei01.dbf 6
/opt/oracle/oradata/test/user02.dbf 7
/opt/oracle/oradata/test/odu02.dbf 8
/opt/oracle/oradata/test/odu01.dbf 9
/opt/oracle/oradata/test/odu03.dbf 10
/opt/oracle/oradata/test/xifenfei02.chf 11
11 rows selected.
SQL> create table chf.xff_test tablespace xff
2 as
3 select * from dba_objects;
select * from dba_objects
*
ERROR at line 3:
ORA-01536: space quota exceeded for tablespace 'XFF'
SQL> alter user chf quota 100m on xff;
User altered.
SQL> create table chf.xff_test tablespace xff
2 as
3 select * from dba_objects;
Table created.
--需要重命名的数据文件内有数据,模拟数据库在生产环境中工作
SQL> alter database datafile 11 offline drop ;
Database altered.
--数据文件离线处理
SQL> !mv /opt/oracle/oradata/test/xifenfei02.chf /opt/oracle/oradata/test/xifenfei02.dbf
--系统级别把数据文件修改为正确名称
SQL> alter database rename file '/opt/oracle/oradata/test/xifenfei02.chf'
2 to '/opt/oracle/oradata/test/xifenfei02.dbf';
Database altered.
--修改控制文件中数据文件名称
SQL> recover datafile 11;
Media recovery complete.
SQL> alter database datafile 11 online;
Database altered.
--恢复数据文件,并使其online
SQL> select name,file# from v$datafile;
NAME FILE#
-------------------------------------------------- ----------
/opt/oracle/oradata/test/system01.dbf 1
/opt/oracle/oradata/test/undotbs01.dbf 2
/opt/oracle/oradata/test/sysaux01.dbf 3
/opt/oracle/oradata/test/users01.dbf 4
/opt/oracle/oradata/test/user32g.dbf 5
/opt/oracle/oradata/test/xifenfei01.dbf 6
/opt/oracle/oradata/test/user02.dbf 7
/opt/oracle/oradata/test/odu02.dbf 8
/opt/oracle/oradata/test/odu01.dbf 9
/opt/oracle/oradata/test/odu03.dbf 10
/opt/oracle/oradata/test/xifenfei02.dbf 11
11 rows selected.
如果数据库满足以下条件,可以删除数据文件,重新添加:
1、The database must be open.
2、If a datafile is not empty, it cannot be dropped. If you must remove a datafile that is not empty and that cannot be made empty by dropping schema objects, you must drop the tablespace that contains the datafile.
3、You cannot drop the first or only datafile in a tablespace. This means that DROP DATAFILE cannot be used with a bigfile tablespace.
4、You cannot drop datafiles in a read-only tablespace.
5、You cannot drop datafiles in the SYSTEM tablespace.
6、If a datafile in a locally managed tablespace is offline, it cannot be dropped.
7、db version >= 10g R2
SQL> alter tablespace xff drop datafile 11; alter tablespace xff drop datafile 11 * ERROR at line 1: ORA-03262: the file is non-empty SQL> alter tablespace xff add datafile '/opt/oracle/oradata/test/xifenfei03.chf' size 10m autoextend off; Tablespace altered. SQL> alter tablespace xff drop datafile '/opt/oracle/oradata/test/xifenfei03.chf'; Tablespace altered.
清除离线数据文件记录
测试前提:数据文件离线,系统上删除了该文件,需要删除在数据字典中,关于这条离线数据文件记录
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /opt/oracle/oradata/test/archivelog
Oldest online log sequence 210
Next log sequence to archive 212
Current log sequence 212
--数据库是归档模式
SQL> col file_name for a40
SQL> select file_id,file_name,bytes from dba_data_files order by 1;
FILE_ID FILE_NAME BYTES
---------- ---------------------------------------- ----------
1 /opt/oracle/oradata/test/system01.dbf 524288000
2 /opt/oracle/oradata/test/undotbs01.dbf 1289748480
3 /opt/oracle/oradata/test/sysaux01.dbf 377487360
4 /opt/oracle/oradata/test/users01.dbf 5242880
5 /opt/oracle/oradata/test/user32g.dbf 10485760
6 /opt/oracle/oradata/test/xifenfei01.dbf 20971520
7 /opt/oracle/oradata/test/user02.dbf 10485760
8 /opt/oracle/oradata/test/odu02.dbf 1.1283E+10
9 /opt/oracle/oradata/test/odu01.dbf 104857600
10 /opt/oracle/oradata/test/odu03.chf
10 rows selected.
SQL> col error for a20
SQL> select file#,ONLINE_STATUS,ERROR,CHANGE# from V$RECOVER_FILE order by 1;
FILE# ONLINE_ ERROR CHANGE#
---------- ------- -------------------- ----------
10 OFFLINE FILE NOT FOUND 0
SQL> !ls /opt/oracle/oradata/test/odu03.chf
ls: /opt/oracle/oradata/test/odu03.chf: No such file or directory
--说明该数据文件已经从硬盘上删除
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2082784 bytes
Variable Size 130025504 bytes
Database Buffers 71303168 bytes
Redo Buffers 6303744 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/opt/oracle/oradata/test/redo01.log' SIZE 50M,
9 GROUP 2 '/opt/oracle/oradata/test/redo02.log' SIZE 50M,
10 GROUP 3 '/opt/oracle/oradata/test/redo03.log' SIZE 50M
11 DATAFILE
12 '/opt/oracle/oradata/test/system01.dbf',
13 '/opt/oracle/oradata/test/undotbs01.dbf',
14 '/opt/oracle/oradata/test/sysaux01.dbf',
15 '/opt/oracle/oradata/test/users01.dbf',
16 '/opt/oracle/oradata/test/user32g.dbf',
17 '/opt/oracle/oradata/test/xifenfei01.dbf',
18 '/opt/oracle/oradata/test/user02.dbf',
19 '/opt/oracle/oradata/test/odu02.dbf',
20 '/opt/oracle/oradata/test/odu01.dbf'
,'/opt/oracle/oradata/test/odu03.chf' --文件不存在,创建控制文件这条记录需要除掉
21 CHARACTER SET ZHS16GBK
22 ;
Control file created.
SQL> alter database open;
Database altered.
SQL> select file_id,file_name,bytes from dba_data_files order by 1;
FILE_ID FILE_NAME BYTES
---------- ---------------------------------------- ----------
1 /opt/oracle/oradata/test/system01.dbf 524288000
2 /opt/oracle/oradata/test/undotbs01.dbf 1289748480
3 /opt/oracle/oradata/test/sysaux01.dbf 377487360
4 /opt/oracle/oradata/test/users01.dbf 5242880
5 /opt/oracle/oradata/test/user32g.dbf 10485760
6 /opt/oracle/oradata/test/xifenfei01.dbf 20971520
7 /opt/oracle/oradata/test/user02.dbf 10485760
8 /opt/oracle/oradata/test/odu02.dbf 1.1283E+10
9 /opt/oracle/oradata/test/odu01.dbf 104857600
10 /opt/oracle/product/10.2.0/db_1/dbs/MISSING00010 --系统默认创建了自定义的数据文件名称
10 rows selected.
SQL> select file#,ONLINE_STATUS,ERROR,CHANGE# from V$RECOVER_FILE order by 1;
FILE# ONLINE_ ERROR CHANGE#
---------- ------- -------------------- ----------
10 OFFLINE FILE MISSING 0
--提示该文件是离线状态,需要恢复,结果同开始时候状态
SQL> select file#,STATUS$,TS#,RELFILE# from file$ order by 1;
FILE# STATUS$ TS# RELFILE#
---------- ---------- ---------- ----------
1 2 0 1
2 2 1 2
3 2 2 3
4 2 4 4
5 2 4 5
6 2 6 6
7 2 4 7
8 2 7 9
9 2 7 6
10 2 7 10
11 1
11 rows selected.
SQL> delete from file$ where file#=10; ---重要的就是这个操作
1 row deleted.
SQL> select file#,STATUS$,TS#,RELFILE# from file$ order by 1;
FILE# STATUS$ TS# RELFILE#
---------- ---------- ---------- ----------
1 2 0 1
2 2 1 2
3 2 2 3
4 2 4 4
5 2 4 5
6 2 6 6
7 2 4 7
8 2 7 9
9 2 7 6
11 1
10 rows selected.
SQL> col name for a40
SQL> select * from v$dbfile order by 1;
FILE# NAME
---------- ----------------------------------------
1 /opt/oracle/oradata/test/system01.dbf
2 /opt/oracle/oradata/test/undotbs01.dbf
3 /opt/oracle/oradata/test/sysaux01.dbf
4 /opt/oracle/oradata/test/users01.dbf
5 /opt/oracle/oradata/test/user32g.dbf
6 /opt/oracle/oradata/test/xifenfei01.dbf
7 /opt/oracle/oradata/test/user02.dbf
8 /opt/oracle/oradata/test/odu02.dbf
9 /opt/oracle/oradata/test/odu01.dbf
10 /opt/oracle/product/10.2.0/db_1/dbs/MISSING00010
10 rows selected.
--需要重建控制文件,删除不存在的数据文件
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP NOMOUNT
ORACLE instance started.
Total System Global Area 209715200 bytes
Fixed Size 2082784 bytes
Variable Size 130025504 bytes
Database Buffers 71303168 bytes
Redo Buffers 6303744 bytes
SQL> CREATE CONTROLFILE REUSE DATABASE "TEST" NORESETLOGS ARCHIVELOG
2 MAXLOGFILES 16
3 MAXLOGMEMBERS 3
4 MAXDATAFILES 100
5 MAXINSTANCES 8
6 MAXLOGHISTORY 292
7 LOGFILE
8 GROUP 1 '/opt/oracle/oradata/test/redo01.log' SIZE 50M,
9 GROUP 2 '/opt/oracle/oradata/test/redo02.log' SIZE 50M,
10 GROUP 3 '/opt/oracle/oradata/test/redo03.log' SIZE 50M
11 DATAFILE
12 '/opt/oracle/oradata/test/system01.dbf',
13 '/opt/oracle/oradata/test/undotbs01.dbf',
14 '/opt/oracle/oradata/test/sysaux01.dbf',
15 '/opt/oracle/oradata/test/users01.dbf',
16 '/opt/oracle/oradata/test/user32g.dbf',
17 '/opt/oracle/oradata/test/xifenfei01.dbf',
18 '/opt/oracle/oradata/test/user02.dbf',
19 '/opt/oracle/oradata/test/odu02.dbf',
20 '/opt/oracle/oradata/test/odu01.dbf'
21 CHARACTER SET ZHS16GBK
22 ;
Control file created.
SQL> alter database open;
Database altered.
SQL> select file_id,file_name,bytes from dba_data_files order by 1;
FILE_ID FILE_NAME BYTES
---------- ---------------------------------------- ----------
1 /opt/oracle/oradata/test/system01.dbf 524288000
2 /opt/oracle/oradata/test/undotbs01.dbf 1289748480
3 /opt/oracle/oradata/test/sysaux01.dbf 377487360
4 /opt/oracle/oradata/test/users01.dbf 5242880
5 /opt/oracle/oradata/test/user32g.dbf 10485760
6 /opt/oracle/oradata/test/xifenfei01.dbf 20971520
7 /opt/oracle/oradata/test/user02.dbf 10485760
8 /opt/oracle/oradata/test/odu02.dbf 1.1283E+10
9 /opt/oracle/oradata/test/odu01.dbf 104857600
9 rows selected.
SQL> select * from v$dbfile order by 1;
FILE# NAME
---------- ----------------------------------------
1 /opt/oracle/oradata/test/system01.dbf
2 /opt/oracle/oradata/test/undotbs01.dbf
3 /opt/oracle/oradata/test/sysaux01.dbf
4 /opt/oracle/oradata/test/users01.dbf
5 /opt/oracle/oradata/test/user32g.dbf
6 /opt/oracle/oradata/test/xifenfei01.dbf
7 /opt/oracle/oradata/test/user02.dbf
8 /opt/oracle/oradata/test/odu02.dbf
9 /opt/oracle/oradata/test/odu01.dbf
9 rows selected.
补充说明:非归档模式下,NOARCHIVELOG创建控制文件,其他无太大区别
测试来源:itpub:数据文件物理性删除相关问题疑惑?
参考blog:roger:如何彻底删除已经不存在的数据文件?
设置oracle 含特殊字符密码
oracle 修改设置密码复杂度渐增方法:
1、修改为常见密码(无特殊字符)
SQL> alter user chf identified by xifenfei;
User altered.
2、修改含一般特殊字符(如:$, %等)
SQL>
SQL> alter user chf identified by “xi%,fenfei”;
User altered.
SQL> conn chf/xi%,fenfei
Connected.
3、修改含”的特殊字符
3.1)修改制定用户密码(sys用户操作)
SQL> password chf
Changing password for chf
New password:
Retype new password:
Password changed
SQL> conn chf/aa””bb
Connected.
3.2)修改当前用户密码(需要有修改密码权限)
SQL> password
Changing password for CHF
Old password:
New password:
Retype new password:
Password changed
SQL>
注:因为一般特殊字符可以使用双引号处理,但是如果密码中含有双引号,就不能用双引号处理,可以直接使用password修改密码
sys用户密码含$ sqlplus登录数据库诡异事件分析
[oracle@ECP-UC-DB1 ~]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 17 23:37:51 2011 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> alter user sys identified by "ab$"; User altered. SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@ECP-UC-DB1 ~]$ sqlplus sys/ab$ as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 17 23:38:53 2011 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter name; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string db_name string test db_unique_name string test global_names boolean FALSE instance_name string test lock_name_space string log_file_name_convert string service_names string test SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@ECP-UC-DB1 ~]$ sqlplus sys/ab$abc as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 17 23:39:05 2011 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@ECP-UC-DB1 ~]$ sqlplus sys/ab$@abc as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 17 23:40:06 2011 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter name; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string db_name string test db_unique_name string test global_names boolean FALSE instance_name string test lock_name_space string log_file_name_convert string service_names string test SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options [oracle@ECP-UC-DB1 ~]$ sqlplus sys/ab$@abc11 as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 17 23:44:11 2011 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> show parameter name; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string db_name string test db_unique_name string test global_names boolean FALSE instance_name string test lock_name_space string log_file_name_convert string service_names string test SQL>
通过以上sql发现,把sys的密码改为ab$后,无论是什么tns都可以登录数据库,而且都是本地数据库,是不是感觉很诡异,其实你仔细观察发现,密码中有了$,使得$@的操作都变成了无效的,其实就是sqlplus sys/123(随意) as sysdba方式登录本地数据库
[oracle@ECP-UC-DB1 ~]$ sqlplus sys/123 as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Mon Oct 17 23:48:23 2011 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>
Oracle 小升级 opatch apply使用
这里记录的是Oracle 升级到10.2.0.4后,出现EM不能正常启动情况下,Oracle提示需要打上Patch 8350262,下面是记录打补丁过程
[oracle@ocp ~]$ unzip ~/p8350262_10204_Generic.zip
Archive: /home/oracle/p8350262_10204_Generic.zip
creating: 8350262/
inflating: 8350262/killDBConsole
creating: 8350262/files/
creating: 8350262/files/sysman/
creating: 8350262/files/sysman/jlib/
creating: 8350262/files/sysman/jlib/emCORE.jar/
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/fsc/
inflating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/fsc/FSWalletUtil.class
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/util/
inflating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/util/RootCert.class
inflating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/util/SecConstants.class
creating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/rep/
inflating: 8350262/files/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/rep/RepWalletUtil.class
creating: 8350262/files/sysman/jlib/emd_java.jar/
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/fsc/
inflating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/fsc/FSWalletUtil.class
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/util/
inflating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/util/RootCert.class
inflating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/util/SecConstants.class
creating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/rep/
inflating: 8350262/files/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/rep/RepWalletUtil.class
inflating: 8350262/killDBConsole.pl
inflating: 8350262/README.txt
creating: 8350262/etc/
creating: 8350262/etc/xml/
inflating: 8350262/etc/xml/ShiphomeDirectoryStructure.xml
inflating: 8350262/etc/xml/GenericActions.xml
creating: 8350262/etc/config/
inflating: 8350262/etc/config/inventory
inflating: 8350262/etc/config/actions
[oracle@ocp ~]cd 8350262
[oracle@ocp 8350262]$ $ORACLE_HOME/OPatch/opatch apply --Note:$ORACLE_HOME/OPatch/opatch路径
Invoking OPatch 10.2.0.4.2
Oracle Interim Patch Installer version 10.2.0.4.2
Copyright (c) 2007, Oracle Corporation. All rights reserved.
Oracle Home : /opt/oracle/app/10.2.0/db_1
Central Inventory : /opt/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 10.2.0.4.2
OUI version : 10.2.0.4.0
OUI location : /opt/oracle/app/10.2.0/db_1/oui
Log file location : /opt/oracle/app/10.2.0/db_1/cfgtoollogs/opatch/opatch2011-10-17_18-11-40PM.log
ApplySession applying interim patch '8350262' to OH '/opt/oracle/app/10.2.0/db_1'
Running prerequisite checks...
OPatch detected non-cluster Oracle Home from the inventory and will patch the local system only.
Backing up files and inventory (not for auto-rollback) for the Oracle Home
Backing up files affected by the patch '8350262' for restore. This might take a while...
Backing up files affected by the patch '8350262' for rollback. This might take a while...
Patching component oracle.sysman.agent.core, 10.2.0.4.0a...
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emCORE.jar" with "/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/fsc/FSWalletUtil.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emCORE.jar" with "/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/rep/RepWalletUtil.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emCORE.jar" with "/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/util/RootCert.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emCORE.jar" with "/sysman/jlib/emCORE.jar/oracle/sysman/eml/sec/util/SecConstants.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emd_java.jar" with "/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/fsc/FSWalletUtil.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emd_java.jar" with "/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/rep/RepWalletUtil.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emd_java.jar" with "/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/util/RootCert.class"
Updating jar file "/opt/oracle/app/10.2.0/db_1/sysman/jlib/emd_java.jar" with "/sysman/jlib/emd_java.jar/oracle/sysman/eml/sec/util/SecConstants.class"
ApplySession adding interim patch '8350262' to inventory
Verifying the update...
Inventory check OK: Patch ID 8350262 is registered in Oracle Home inventory with proper meta-data.
Files check OK: Files from Patch ID 8350262 are present in Oracle Home.
OPatch succeeded.
[oracle@ocp 8350262]$ ../opatch lsinventory --Note检测是否安装成功
Invoking OPatch 10.2.0.4.2
Oracle Interim Patch Installer version 10.2.0.4.2
Copyright (c) 2007, Oracle Corporation. All rights reserved.
Oracle Home : /opt/oracle/app/10.2.0/db_1
Central Inventory : /opt/oracle/oraInventory
from : /etc/oraInst.loc
OPatch version : 10.2.0.4.2
OUI version : 10.2.0.4.0
OUI location : /opt/oracle/app/10.2.0/db_1/oui
Log file location : /opt/oracle/app/10.2.0/db_1/cfgtoollogs/opatch/opatch2011-10-17_18-18-34PM.log
Lsinventory Output file location : /opt/oracle/app/10.2.0/db_1/cfgtoollogs/opatch/lsinv/lsinventory2011-10-17_18-18-34PM.txt
--------------------------------------------------------------------------------
Installed Top-level Products (2):
Oracle Database 10g 10.2.0.1.0
Oracle Database 10g Release 2 Patch Set 3 10.2.0.4.0
There are 2 products installed in this Oracle Home.
Interim patches (1) :
Patch 8350262 : applied on Mon Oct 17 18:17:28 CST 2011
Created on 14 Sep 2010, 04:59:44 hrs PST8PDT
Bugs fixed:
8350262
--------------------------------------------------------------------------------
OPatch succeeded.
Oracle常见后台进程及其功能汇总
今天参照oracle官方文档和metalink文档,对Oracle常见后台进程及其功能汇总进行了一次汇总
Oracle常见后台进程及其功能汇总
http://www.xifenfei.com/wp-content/uploads/2011/10/Oracle_Process.pdf
checking network configuration requirements
最近准备考ocp,所以决定按照教程,从头到尾系统的学习一次oracle,也算是为了对得起考证的几千大洋。
在安装oracle 10g的过程中,遇到了checking network configuration requirements is: Not executed的错误提示。

没有执行网络检测,google下,发现是/etc/hosts中没有指定静态ip地址导致,检测/etc/hosts发现果真如此(好久没有装oracle 了,竟然忘记这个基础的东西)修改如下配置
127.0.0.1 ocp localhost.localdomain localhost
192.168.1.55 ocp.xifenfei.com
重新检测,显示正常

rac中的spfile探讨
今天朋友的的rac,因为被同事做数据库升级,分别在两个节点的本地创建了spfile,然后使用这个spfile启动了数据库,因为他不是非常懂oracle,所以向我求救,我改他的建议是:
1、利用备份的原来的pfile文件创建在asm中的spfile,规则是:+ASM/SID/spfileSID
2、dbs目录下创建一个本地的initsid.ora,然后在里面加一个spfile=’+ASM pfile path’(两个节点同样操作,注意sid不同)
3、分别重启数据库
出现该问题的原因分析:
做数据库升级的朋友的同事也不懂rac的spfile的相关规则,应该是在重启数据库的时候,提示spfile不存在,然后自己手工创建利用pfile创建的spfile到dbs下面,然后朋友十一后检测数据库,发现spfile都放置在本地了。
1、通常读取参数文件顺序
我们知道,如果不指定参数文件,oracle是按照这个顺序查找文件来启动数据库的:
spfileSID.ora
spfile.ora
initSID.ora
init.ora
如果这些文件都没有找到,启动会失败。
2、RAC中关于spfile的启动探讨
[rac@cent1 dbs]$ echo $ORACLE_SID RACDB1 [rac@cent1 dbs]$ touch spfileRACDB1.ora <==手工创建一个空白的spfile [rac@cent1 dbs]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Thu Apr 29 13:45:50 2010 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORA-27091: unable to queue I/O <== 用sqlplus启动数据库时会报错 ORA-27069: attempt to do I/O beyond the range of the file Additional information: 1 Additional information: 1 SQL> SQL> exit Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options [rac@cent1 dbs]$ crs_stat -t Name Type Target State Host ------------------------------------------------------------ ora....B1.inst application OFFLINE OFFLINE ora....B2.inst application ONLINE ONLINE cent2 ora.RACDB.db application ONLINE ONLINE cent1 ora....SM1.asm application ONLINE ONLINE cent1 ora....T1.lsnr application ONLINE ONLINE cent1 ora.cent1.gsd application ONLINE ONLINE cent1 ora.cent1.ons application ONLINE ONLINE cent1 ora.cent1.vip application ONLINE ONLINE cent1 ora....SM2.asm application ONLINE ONLINE cent2 ora....T2.lsnr application ONLINE ONLINE cent2 ora.cent2.gsd application ONLINE ONLINE cent2 ora.cent2.ons application ONLINE ONLINE cent2 ora.cent2.vip application ONLINE ONLINE cent2 [rac@cent1 dbs]$ srvctl start instance -i racdb1 -d racdb <== 用srvctl启动成功 [rac@cent1 dbs]$ sqlplus / as sysdba SQL*Plus: Release 10.2.0.4.0 - Production on Thu Apr 29 13:47:25 2010 Copyright (c) 1982, 2007, Oracle. All Rights Reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Production With the Partitioning, Real Application Clusters, OLAP, Data Mining and Real Application Testing options SQL> select instance_name, status from v$instance; INSTANCE_NAME STATUS ---------------- ------------ RACDB1 OPEN --说明srvctl不是用那个顺序去查找参数文件
3、查看srvctl读取spfile位置
[rac@cent1 dbs]$ srvctl config database -d racdb -a cent1 RACDB1 /rac/product/10.2.0/db cent2 RACDB2 /rac/product/10.2.0/db DB_NAME: RACDB ORACLE_HOME: /rac/product/10.2.0/db SPFILE: +DATA/RACDB/spfileRACDB.ora DOMAIN: WORLD DB_ROLE: null START_OPTIONS: null POLICY: AUTOMATIC ENABLE FLAG: DB ENABLED
4、修改CRS中关于spfile位置
[rac@cent1 dbs]$ srvctl modify database -d racdb -p ' +DATA/RACDB/spfileRACDB1.ora'
利用rowid排序更新大表数据
现在有个案例,有一张很大的表t1,需要更新其中的一个列,然后这个列是参考另外一个表t2中的列
直接sql操作如:
update t1 ta set prov_code=(select area_code from t2 tb where ta.id=tb.id);
利用rowid,分批提交的思路写出如下sql,执行大表更新效率比较高
DECLARE
CURSOR cur IS
SELECT
a.area_code, b.ROWID ROW_ID
FROM t2 a, t1 b
WHERE a.id = b.id
ORDER BY b.ROWID;
V_COUNTER NUMBER;
BEGIN
V_COUNTER := 0;
FOR row IN cur LOOP
UPDATE t1
SET prov_code = row.area_code
WHERE ROWID = row.ROW_ID;
V_COUNTER := V_COUNTER + 1;
IF (V_COUNTER >= 1000) THEN
COMMIT;
V_COUNTER := 0;
END IF;
END LOOP;
COMMIT;
END;
这里利用了rowid排序,使得update操作是一个一个数据块的进行,减少逻辑读,分批提交减小undo压力