今日はこのエラーでちとハマったが、実はなんのことはない。 カンタンに再現可能なので、出してみた。 ポイントは、以下の3点。 1.サーバには複数のデータベースが稼動している 2.環境変数ORACLE_SIDに設定されているインスタンス名と、STATSPACKを作成しようとしているDBのインスタンス名が異なる 3.環境変数ORACLE_SIDに設定されているデータベースには、既にSTATSPACKが入っている。 この条件を満たすと、spcreate.sqlを実行したときに、ORA-00955が発生する。 ではやってみる。 現在、このサーバにはorcl01とorcl99というデータベースが稼動している。 ORACLE_SIDはorcl01である。 orcl01には、既にSTATSPACKが入っている。 そして、orcl99にSTATSPACKを入れてみる。 bash-3.00$ echo $ORACLE_SID orcl01 bash-3.00$ sqlplus /nolog SQL*Plus: Release 10.2.0.2.0 - Production on 木 6月 18 22:49:19 2009 Copyright (c) 1982, 2005, Oracle. All Rights Reserved. SQL> conn sys/*****@orcl99 as sysdba 接続されました。 ↑ORACLE_SIDと接続したインスタンス名が異なる。これが大きなポイント。 そして、spcreate.sqlを実行。 SQL> @?/rdbms/admin/spcreate.sql Choose the PERFSTAT user's password ----------------------------------- Not specifying a password will result in the installation FAILING perfstat_passwordに値を入力してください: perfstat 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 --------------------------- ---------------------------- PERFSTAT PERMANENT SYSAUX PERMANENT * USERS PERMANENT Pressing <return> will result in STATSPACK's recommended default tablespace (identified by *) being used. default_tablespaceに値を入力してください: perfstat Using tablespace PERFSTAT 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に値を入力してください: temp <中略> If this script is automatically called from spcreate (which is the supported method), all STATSPACK segments will be created in the PERFSTAT user's default tablespace. Using perfstat tablespace to store Statspack objects ... Creating STATS$SNAPSHOT_ID Sequence create sequence STATS$SNAPSHOT_ID * 行1でエラーが発生しました。: ORA-00955: すでに使用されているオブジェクト名です。 Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - Production With the Partitioning, OLAP and Data Mining optionsとの接続が切断されました。 新規に作ってんのに、「すでに使用されている」ってなんなんだよ? と思ったが、spcreate.sqlの中身を見て、あっさりと解決。 spcreate.sqlからは、PERFSTATユーザやロールを作成し、権限を付与するspusr.sql、 パブリックシノニムを作成するspctab.sql、 パッケージを作成するspcpkg.sqlの3つを呼び出して実行している。 実際に見てみると、こうなっている。 <以下spcreate.sqlの中身> -- -- Create PERFSTAT user and required privileges @@spcusr -- -- Build the tables and synonyms connect perfstat/&&perfstat_password @@spctab -- Create the statistics Package @@spcpkg <ここまで> spctab.sqlの実行前に、perfstatユーザにconnectしているが、接続先は指定されていない。 まぁ当たり前っちゃあ当たり前だが(そんなの指定してないし)、そんなわけで、ORACLE_SIDで設定されたインスタンスに接続されてしまう。 そっちの方には、前提条件に挙げたとおり、STATSPACKが既に入っている。 つまり、オブジェクトも存在しているから、エラーになる、というわけ。 で、回避するには、spcreate.sqlを都合よく書き換えてしまえばいいが、それもなんとなく気が引ける。 まずは、作成に失敗したSTATSPACKをアンインストール。 SYSDBAで接続して、spdrop.sqlを実行する。 SQL> conn sys/******@orcl99 as sysdba 接続されました。 SQL> @?/rdbms/admin/spdrop.sql 出力されたログを見ると、「〜がありません」とかのエラーが満載だが、気にしない。 spcreate.sqlを実行するのではなく、spcusr.sql、spctab.sql、spcpkg.sqlを個別に実行すればいい。 SQL> @?/rdbms/admin/spcusr.sql <中略> Choose the PERFSTAT user's password ----------------------------------- Not specifying a password will result in the installation FAILING perfstat_passwordに値を入力してください: perfstat 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 --------------------------- ---------------------------- PERFSTAT PERMANENT SYSAUX PERMANENT * USERS PERMANENT Pressing <return> will result in STATSPACK's recommended default tablespace (identified by *) being used default_tablespaceに値を入力してください:. perfstat Using tablespace PERFSTAT 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に値を入力してください: temp 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. 続いて、spctab.sqlを実行。その前に、PERFSTATユーザになっておく。 接続先もきちんと指定。 SQL> conn perfstat/perfstat@orcl99 接続されました。 SQL> @?/rdbms/admin/spctab.sql <中略> シノニムが作成されました。 NOTE: SPCTAB complete. Please check spctab.lis for any errors. 最後にspcpkg.sqlを実行。ユーザはPERFSTATのままでOK。 SQL> @?/rdbms/admin/spcpkg.sql <中略> Creating Package Body STATSPACK... パッケージ本体が作成されました。 エラーはありません。 NOTE: SPCPKG complete. Please check spcpkg.lis for any errors. というわけで、めでたくできましたとさ。 |
<< 前記事(2009/06/16) | ブログのトップへ | 後記事(2009/06/18) >> |
タイトル (本文) | ブログ名/日時 |
---|
内 容 | ニックネーム/日時 |
---|
<< 前記事(2009/06/16) | ブログのトップへ | 後記事(2009/06/18) >> |