在oracle 10.2.0.4上配置字符集掃描工具Csscan(一)

2008081036發表於2014-06-16

字符集掃描工具Csscancsscan的全稱是Character Set Scanner。顧名思義,此工具是用來對字符集進行掃描,來獲取當轉換字符集時可能發生的資料丟失。
 
The Csscan tool analyzes the code points in the database and verifies that they are known in the source the database characterset and known in the target database characterset. 

一、安裝Csscan

oracle軟體安裝好會自帶Csscan工具, 存放路徑位於$ORACLE_HOME/bin/csscan 。
Csscan工具需要用到CSMIG使用者,可以透過執行 $ORACLE_HOME/rdbms/admin下的指令碼csminst.sql來生成CSMIG使用者和相關資料字典物件。

1、修改csminst.sql指令碼
CSMIG預設的表空間是SYSTEM,可以透過修改指令碼中的內容來指定表空間:

The default tablespace is SYSTEM, if you plan to run csscan against a big database then we advice to create a separate tablespace and change the $ORACLE_HOME/rdbms/admin/csminst.sql script to use this tablespace. 

Modify the following statement in csminst.sql to assign your preferred tablespace to CSMIG instead of SYSTEM:

alter user csmig default tablespace SYSTEM
/

面的授權並不需要,在11.2 和10.2.0.5版本的Csminst.sqlw會被刪除掉。可以手工把它刪掉,或者忽略相關的"ORA-22930 directory does not exist" 報錯。

The amount of space needed depends mainly on the amount of exceptions found ( convertible and/or lossy data) and is impossible to predict upfront. It's useful to use on the first run of csscan a tablespace that is limited in size to avoid any disk space issues.

The Csminst.sql file is doing two grants to SYSTEM

grant READ on directory log_file_dir to system
/
grant READ on directory data_file_dir to system
/


2、執行csminst.sql指令碼
下面執行指令碼csminst.sql來生成CSMIG使用者和相關資料字典物件,執行之前最好先備份一份:


[oracle@HQ-CICUTESTDB-01 admin]$ echo $ORACLE_SID
cicutedb
[oracle@HQ-CICUTESTDB-01 admin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.4.0 - Production on Mon Jun 16 10:55:40 2014

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> set TERMOUT ON
SQL> set ECHO ON
SQL> spool csminst.log
SQL> @?/rdbms/admin/csminst.sql

Csscan實際使用中不會登入csmig使用者,可以把csmig鎖定:
The password for the CSMIG user will be asked when running the csminst.sql script, this can be anything and we suggest to lock the CSMIG account . The actual csmig login is not used by Csscan.

SQL> conn / as sysdba
SQL> alter user csmig account lock;

最後檢查安裝日誌:

Check the csminst.log for errors.

3、驗證csscan是否能正常使用

使用如下命令來驗證:
[oracle@HQ-CICUTESTDB-01 admin]$ csscan TABLE='(SYS.SQL_VERSION$)' FROMCHAR=US7ASCII TOCHAR=US7ASCII LOG=instchkc CAPTURE=N PROCESS=1 ARRAY=1024000

Character Set Scanner v2.1 : Release 10.2.0.3.0 - Production on Mon Jun 16 10:59:33 2014

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

Username: xiezq

Password: 

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

Enumerating table to scan...

. process 1 scanning SYS.SQL_VERSION$[AAAAIEAABAAAA/5AAA]

Creating Database Scan Summary Report...

Creating Individual Exception Report...

Scanner terminated successfully.

當看到“Scanner terminated successfully.”時,表明csscan已安裝成功。


參考Oracle Support:Installing and configuring Csscan in 10g and 11g (Database Character Set Scanner) (Doc ID 745809.1)

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25465866/viewspace-1184177/,如需轉載,請註明出處,否則將追究法律責任。

相關文章