Java CAPS 管理和监视 API

将 Oracle 和其他数据库用于警报持久性

除 Derby 以外,Oracle 和其他支持的数据库也可以执行警报持久性。不过,您必须进行一些更改才能使其正常工作。


注 –

如果打算使用 Oracle 持久保存警报,而不是使用 Derby,请确保阅读此主题。


Procedure为警报持久性设置 Oracle 数据库

  1. 修改 appserver/domains/domain1/jbi/config 下面的 eventmanagement.properties 文件。

    1. 将 DatabaseType 更改为 ORACLE

    2. 将 AlertTablename 更改为 EMHOSTNAMEVistastccom8080


      注 –

      必须执行此步骤,因为默认名称 EVENTMANAGEMENTHOSTNAMEistastccom8080 超过了 Oracle 对表名的限制(30 个字符)。


    3. 将 DBJndiName 更改为 OracleXPDB


      注 –

      可以在管理控制台中创建该名称;步骤 2 中说明了这一点。


    4. 将 PersistenceEnbled 更改为 true

    5. 通过使用 Enterprise Manager,在普通警报管理配置代理中设置 DatabaseType、DBJndiName 和 PersistenceEnabled 的值。


      注 –

      在启用持久性之前,可能已运行了数据库脚本。必须在文件中手动更改表名。


  2. 在 Sun Java System Application Server 管理控制台中创建 JDBC 连接池和资源。

    1. classes12.zip 的位置添加到类路径中,选择“JVM 设置”->“路径设置”->“类路径后缀”,然后重新启动域。


      注 –

      要获取 Oracle 数据源,必须执行此操作。


    2. 创建 Oracle 连接池。

      1. 输入一个名称(如 OracleXPPool),您可以选择所用的名称。

      2. 选择 "javax.sql.DataSource" 作为资源类型。

      3. 选择 "Oracle" 作为数据库供应商。

      4. 设置相应的属性:

        1. 用户:eventdb_user

        2. 数据库名称:orcl


          注 –

          根据您配置 Oracle 数据库方式的不同,此配置以及其他特定于数据库的配置可能会有所变化。


        3. 密码:eventdb_user

        4. 服务器名称:hostname


          注 –

          这是运行数据库的服务器。


        5. 端口号:1521

        6. URL:jdbc:oracle:thin:@hostname:1521:orcl


          注意 – 注意 –

          此 URL 可能会实际覆盖其他设置;它应该与其他设置相匹配。


      5. 创建 JDBC 资源。

        1. 输入 JNDI 名称,例如 OracleXPDB


          注 –

          该名称应该与上述 Alert Management Config Agent/eventmanagement.properties 文件中设置的名称相匹配。


        2. 选择相应的池名称;在本示例中,我们使用 OracleXPPool。

  3. 手动创建警报持久性和日志功能所需的用户和表等。


    注 –

    对于 Derby,此操作是自动完成的。


    appserver/jbi/lib 下面的 jbi_rt.jar 文件中打包了一些数据库脚本。但存在一些错误,因此,您需要手动更正这些脚本。

    • 已修改了这些示例脚本以便用于 Oracle 10 GB 数据库;请参见Oracle 脚本示例

    • 以系统(管理员)用户身份依次运行 create_event_store_user.sqlcreate_event_store_schema.sql 脚本。

    • 在此示例中进行的更正:

      • 设置表空间数据文件的绝对路径(与数据库安装有关)

      • 修改命令,以便与业务流程持久性相匹配

      • 注释掉第二个数据文件

      • 移动注释

      • 修复表名引用,以便与上面在 eventmanagement.properties 中设置的用户模式和表名相匹配

      • 修复列引用;即,将第二列的名称由 event_timestamp 更改为 timestamp

      • 将数据类型由时间戳更改为十进制

      • 修复序列引用

Oracle 脚本示例

truncate_event_store_schema.sql

TRUNCATE TABLE eventdb_user.EMHostNameVistastccom8080;

create_event_store_schema.sql

create table eventdb_user.EMHostNameVistastccom8080(
  	id NUMBER CONSTRAINT ID_PK PRIMARY KEY, 
			timeStamp decimal,
 		physicalHostName varchar(256),
			environmentName varchar(256),
			logicalHostName varchar(256),
			serverType varchar(256), 
			serverName varchar(256), 
			componentType varchar(256),
			componentProjectPathName varchar(1024),
			componentName varchar(256),
			eventType varchar(256),
			severity integer,
			operationalState int,
			messageCode varchar(256),
			messageDetail varchar(4000),
			observationalState int,
			deploymentName varchar(256));
);
-- INSERT statement need to use it to insure autoincrement functionality
CREATE SEQUENCE eventdb_user.autoincrement_id; 
create index  eventTime on eventdb_user.EMHostNameVistastccom8080(timeStamp);

create_event_store_user.sql

--Create a tablespace named EVENTDB_USER_DB. Change this value if a different 
name is desired.
--Specify the name and the location of the file where the data related to
the tablespace 
--created above will be stored. The location is by default the location determined by
--the database server/instance on which this script is run
--For example, for Windows c:\MyDatafiles\EVENTDB_USER_DB.dat, for Unix
/dev/home1/EVENTDB_USER_DB.dat
--Note that the name of the actual file need not be EVENTDB_USER_DB.dat
--Specify the size constraints

	-- Window and Oracle 9i there is a limitation on file size, it is 2 GB. 
This by default creats 4GB, add more files if you need more than 4 GB.
	--- provide abosolute path if you preference is not default location 
'C:\OracleDirectory\EVENTDB_USER_DB.dat' SIZE 2000M,

CREATE TABLESPACE EM_EVENTSTORE_DB
 DATAFILE
	'C:\oracle\product\10.2.0\oradata\orcl\EVENTDB_USER_DB.dat' SIZE 512M REUSE 
AUTOEXTEND ON NEXT 2048M MAXSIZE UNLIMITED;

	-- 'C:\oracle\product\10.2.0\oradata\orcl\EVENTDB_USER_DB1.dat' SIZE 512M 
REUSE AUTOEXTEND ON NEXT 2048M MAXSIZE UNLIMITED --- provide abosolute path 
if you preference is not defaultlocation 'C:\OracleDirectory\EVENTDB_USER_DB1.dat' 
SIZE 2000M
        -- when TABLESPACE is created with these options performance is degrading 
gradually as more and more records added to schema  EXTENT MANAGEMENT LOCAL SEGMENT 
SPACE MANAGEMENT AUTO


--Create a new user EVENTDB_USER. Change the name if so desired. Password will 
be same as
--the user name by default. This username and password will be used to create the 
--connection pool on the application server. Also specify the tablespace 
and the quota on
--the tablespace the user has. Note that if you used a different tablespace 
name above,
--you will have to specify that tablespace name here.

CREATE USER EVENTDB_USER IDENTIFIED BY EVENTDB_USER
DEFAULT TABLESPACE EM_EVENTSTORE_DB
QUOTA UNLIMITED ON EM_EVENTSTORE_DB
TEMPORARY TABLESPACE temp
QUOTA 0M ON system;

--Modify the user name if the default user name was changed

GRANT CREATE session to EVENTDB_USER;
GRANT CREATE table to EVENTDB_USER;
GRANT CREATE procedure to EVENTDB_USER;

drop_event_store_schema.sql

DROP TABLE eventdb_user.EMHostNameVistastccom8080;
drop sequence eventdb_user.autoincrement_id;

drop_event_store_user.sql

--Drop the user that was created earlier. Note that if you chose a 
different name for the 
--user while creating the user, you will have to specify that name here.
DROP USER EVENTDB_USER CASCADE;

--Drop the tablespace that was created earlier. Note that if you chose a 
different name for 
--the tablespace while creating the user, you will have to specify that name here.
DROP TABLESPACE EM_EVENTSTORE_DB INCLUDING CONTENTS AND DATAFILES CASCADE CONSTRAINTS;

--Manually delete the datafiles that were created. If you used the defaults 
while creating
--the datafiles, the names would be EVENTDB_USER_DB1.dat'and 'EVENTDB_USER_DB2.dat'