Monday, August 12, 2013

Oracle 10g: Reconfigure Enterprise Manager


Remove existing Enterprise Manager Configuration and Repository
$ emca -deconfig dbcontrol db -repos drop

Configure Enterprise Manager
$ emca -config dbcontrol db -repos create

If Enterprise Manager failed to start, Check the log file, and if it is certificate relater, try to unsecure enterprise manager

If existing Enterprise Manager is running, you need stop it first

$ emctl stop agent
$ emctl stop dbconsole

Sometime, the agent/dbconsole cannot be stopped properly, you have to find the process and kill them.

For example,

When you try to stop dbconsole, it says:
Stopping Oracle Enterprise Manager 10g Database Control ...
--- Failed to shutdown DBConsole Gracefully ---
failed.

but when you try to find dbconsole status, it reads:
Oracle Enterprise Manager 10g is not running.

try to start it, it reads:
An instance of Oracle Enterprise Manager 10g Database Control is already running.

but if you can find its port number, you can run below perl file to find out who is using the port number, and kill it.

below scripts is quoted from internet, and don't have the writer's name

cat portuser.pl

#! /usr/bin/env perl
##
## Search the processes which are listening on the given port.
##
## For SunOS 5.10.
##

use strict;
use warnings;

die "Port missing" unless $#ARGV >= 0;
my $port = int($ARGV[0]);
die "Invalid port" unless $port > 0;

my @pids;
map { push @pids, $_ if $_ > 0; } map { int($_) } `ls /proc`;

foreach my $pid (@pids) {
    open (PF, "pfiles $pid 2>/dev/null |")
        || warn "Can not read pfiles $pid";
    $_ = <PF>;
    my $fd;
    my $type;
    my $sockname;
    my $peername;
    my $report = sub {
        if (defined $fd) {
            if (defined $sockname && ! defined $peername) {
                print "$pid $type $sockname\n"; } } };
    while (<PF>) {
        if (/^\s*(\d+):.*$/) {
            &$report();
            $fd = int ($1);
            undef $type;
            undef $sockname;
            undef $peername; }
        elsif (/(SOCK_DGRAM|SOCK_STREAM)/) { $type = $1; }
        elsif (/sockname: AF_INET[6]? (.*)  port: $port/) {
            $sockname = $1; }
        elsif (/peername: AF_INET/) { $peername = 1; } }
    &$report();
    close (PF); }

$ perl portuser.pl 5503
9303 SOCK_STREAM 0.0.0.0

Verify with pargs

$ pargs 9303
9303:   /app/oracle/product/10.2.0.1/jdk/bin/java -server -Xmx256M -XX:MaxPermSize
argv[0]: /app/oracle/product/10.2.0.1/jdk/bin/java
argv[1]: -server
argv[2]: -Xmx256M
argv[3]: -XX:MaxPermSize=96m
argv[4]: -XX:MinHeapFreeRatio=20
argv[5]: -XX:MaxHeapFreeRatio=40
argv[6]: -DORACLE_HOME=/app/oracle/product/10.2.0.1
argv[7]: -Doracle.home=/app/oracle/product/10.2.0.1/oc4j
argv[8]: -Doracle.oc4j.localhome=/app/oracle/product/10.2.0.1/db.goweekend.ca_WEND/sysman
argv[9]: -DEMSTATE=/app/oracle/product/10.2.0.1/db.goweekend.ca_WEND
argv[10]: -Doracle.j2ee.dont.use.memory.archive=true
argv[11]: -Djava.protocol.handler.pkgs=HTTPClient
argv[12]: -Doracle.security.jazn.config=/app/oracle/product/10.2.0.1/oc4j/j2ee/OC4J_DBConsole_db.goweekend.ca_WEND/config/jazn.xml
argv[13]: -Djava.security.policy=/app/oracle/product/10.2.0.1/oc4j/j2ee/OC4J_DBConsole_db.goweekend.ca_WEND/config/java2.policy
argv[14]: -Djava.security.properties=/app/oracle/product/10.2.0.1/oc4j/j2ee/home/config/jazn.security.props
argv[15]: -DEMDROOT=/app/oracle/product/10.2.0.1/db.goweekend.ca_WEND
argv[16]: -Dsysman.md5password=true
argv[17]: -Drepapi.oracle.home=/app/oracle/product/10.2.0.1
argv[18]: -Ddisable.checkForUpdate=true
argv[19]: -Djava.awt.headless=true
argv[20]: -jar
argv[21]: /app/oracle/product/10.2.0.1/oc4j/j2ee/home/oc4j.jar
argv[22]: -config
argv[23]: /app/oracle/product/10.2.0.1/oc4j/j2ee/OC4J_DBConsole_db.goweekend.ca_WEND/config/server.xml

$ kill -9 9303

$ ps -ef | grep -i emagent
oracle  9535  9298   0 09:24:09 pts/2       0:15 /usr2/app/oracle/product/10.2.0.1/bin/emagent

$ kill -9 9535


$ emctl unsecure dbconsole

You may force to clean up EM, please check http://feijiangnan.blogspot.ca/2013/06/oracle-reconfigure-em-after-hostname.html


No comments:

Post a Comment