StatsPackを使用してみようと試みる。
SQL> @$ORACLE_HOME/rdbms/admin/spcreate.sql
しかしエラー。
どうやら、X$KCBFWAIT というviewを参照する権限がないらしい。
... Creating views create or replace view STATS$X_$KCBFWAIT as select * from X$KCBFWAIT * 行1でエラーが発生しました。: ORA-00942: 表またはビューが存在しません
sysdba権限で接続してみる。
しかし、OSユーザが oralceユーザでないとsysdba権限がダメらしい。
Oracle Database 11g Release 11.2.0.1.0 - 64bit Production に接続されました。 SQL> connect / as sysdba ERROR: ORA-01031: 権限が不足しています。
どうやら、OSのoracleユーザでないと怒られるようだ。
今まで、普通に何となく知っているつもりでOracleに接してきた。そのつけあってちょっとハマる。
反省。
su oracle
こんどはOSのユーザを変えて、systemユーザでログイン。そして sysdbaとして接続。
[oracle@work]$ sqlplus system/xxxxx SQL*Plus: Release 11.2.0.1.0 Production on 木 7月 26 14:49:17 2012 Copyright (c) 1982, 2009, Oracle. All rights reserved. Oracle Database 11g Release 11.2.0.1.0 - 64bit Production に接続されました。 SQL> connect / as sysdba 接続されました。
気を取り直して再度実行。
SQL> @$ORACLE_HOME/rdbms/admin/spcreate.sql
しかしまたエラー。
どうやら先程のスクリプト実行が中途半端で、ユーザだけ残ってしまったようだ。
... Creating PERFSTAT user create user perfstat * 行1でエラーが発生しました。: ORA-01920: ユーザー名'PERFSTAT'は他のユーザー名またはロール名と競合しています Oracle Database 11g Release 11.2.0.1.0 - 64bit Productionとの接続が切断されました。
迷わず、drop user。
SQL> drop user perfstat cascade; ユーザーが削除されました。
そして、$ORACLE_HOME/rdbms/admin/spcreate.sql を実行。
PERFSTATユーザが作られるので、パスワードとか表領域とか一時表領域とか尋ねられる。
SQL> @$ORACLE_HOME/rdbms/admin/spcreate.sql Choose the PERFSTAT user's password ----------------------------------- Not specifying a password will result in the installation FAILING perfstat_passwordに値を入力してください: xxxxxx perfstat Choose the Default tablespace for the PERFSTAT user --------------------------------------------------- Below is the list of online tablespaces in this database which can store user data. Specifying the SYSTEM tablespace for the user's default tablespace will result in the installation FAILING, as using SYSTEM for performance data is not supported. Choose the PERFSTAT users's default tablespace. This is the tablespace in which the STATSPACK tables and indexes will be created. TABLESPACE_NAME CONTENTS STATSPACK DEFAULT TABLESPACE ------------------------------ --------- ---------------------------- DATA1 PERMANENT INDEX1 PERMANENT SET_DTL PERMANENT SET_HST PERMANENT SET_HST2 PERMANENT SET_IDX PERMANENT SET_RP PERMANENT SET_SWK PERMANENT SET_TMP PERMANENT SYSAUX PERMANENT * USERS PERMANENT Pressing <return> will result in STATSPACK's recommended default tablespace (identified by *) being used. default_tablespaceに値を入力してください: Using tablespace SYSAUX as PERFSTAT default tablespace. Choose the Temporary tablespace for the PERFSTAT user ----------------------------------------------------- Below is the list of online tablespaces in this database which can store temporary data (e.g. for sort workareas). Specifying the SYSTEM tablespace for the user's temporary tablespace will result in the installation FAILING, as using SYSTEM for workareas is not supported. Choose the PERFSTAT user's Temporary tablespace. TABLESPACE_NAME CONTENTS DB DEFAULT TEMP TABLESPACE ------------------------------ --------- -------------------------- TEMP TEMPORARY * Pressing <return> will result in the database's default Temporary tablespace (identified by *) being used. temporary_tablespaceに値を入力してください: Using tablespace TEMP as PERFSTAT temporary tablespace.
すると、実行される。
... Creating PERFSTAT user ... Installing required packages ... Creating views ... Granting privileges NOTE: SPCUSR complete. Please check spcusr.lis for any errors. SQL> SQL> -- SQL> -- Build the tables and synonyms SQL> connect perfstat/&&perfstat_password 接続されました。 SQL> SQL> set showmode off echo off; …省略… ... Creating STATS$SNAPSHOT_ID Sequence 順序が作成されました。 シノニムが作成されました。 ... Creating STATS$... tables 表が作成されました。 シノニムが作成されました。 1行が作成されました。 1行が作成されました。 …省略… NOTE: SPCTAB complete. Please check spctab.lis for any errors. SQL> -- Create the statistics Package SQL> @@spcpkg SQL> Rem SQL> Rem densor.uk 03/31/93 - Modified SQL> Rem cellis.uk 11/15/89 - Created SQL> Rem SQL> SQL> set echo off; Creating Package STATSPACK... パッケージが作成されました。 エラーはありません。 Creating Package Body STATSPACK... パッケージ本体が作成されました。 エラーはありません。 NOTE: SPCPKG complete. Please check spcpkg.lis for any errors. SQL>
うまくいったようだ。