Saturday, November 05, 2005

Install netdisco-0.94 on CentOS/Fedora Core with apache2/mos_perl2

Netdisco là một công cụ nguồn mở khá mạnh giúp quản lý các thiết bị Cisco như switch, router thông qua SNMP. Tài liệu hướng dẫn cài đặt cho Netdisco chỉ hỗ trợ Apache 1.x, điều này gây không ít khó khăn cho các admin muốn sử dụng những bản phân phối mới như CenOS 4, Fedora Core 4 với Apache2 đi kèm. Trên mailing list trao đổi của Netdisco có bàn về vấn đề này nhưng chưa có cài đặt thành công nào được báo cáo.

Sau 2 ngày vật lộn, tôi đã cài đặt thành công Netdisco trên CentOS 4.1 với Apache2 cách đây ... hơn 1 tháng, và đã đưa vào sử dụng. Tuy nhiên, bây giờ mới có chút thời gian để dọn dẹp và ghi lại cách cài đặt. Sau đây là các bước chính để cài đặt Netdisco 0.94 với Apache2/mod_perl2, các bước không được đề cập đề nghị xem tài liệu cài đặt trên website netdisco.

1. Install CPAN stuff
cpan> install Digest::MD5
cpan> install Digest::SHA1
cpan> install Bundle::DBI
cpan> install DBD::Pg
cpan> install DB_File
cpan> install Apache::Session
cpan> force install Apache::Test
cpan> install Apache::Request
cpan> install HTML::Entities
cpan> install HTML::Mason
cpan> install MasonX::Request::WithApacheSession
cpan> install Graph
cpan> install GraphViz
cpan> install Compress::Zlib
cpan> install Net::NBName
cpan> force install Apache::DBI
cpan> install Exception::Class
cpan> install Params::Validate
cpan> install Class::Container
cpan> install Apache::Session::Wrapper

2. Install mod_perl2
http://search.cpan.org/CPAN/authors/id/G/GO/GOZER/mod_perl-2.0.1.tar.gz

3. Install MasonX-Apache2Handler
http://search.cpan.org/CPAN/authors/id/B/BE/BEAU/MasonX-Apache2Handler-0.05.tar.gz

4. Install libapreq2
(ref: http://www.masonhq.com/node/view.html?name=ApacheModPerl2&version_id=7452)
http://search.cpan.org/CPAN/authors/id/J/JO/JOESUF/libapreq2-2.06-dev.tar.gz

# tar zxvf libapreq2-2.06-dev.tar.gz
# cd libapreq2-2.06-dev
# perl Makefile.PL --with-apache2-apxs=/usr/sbin/apxs
# make
# make install

Add below line to /etc/httpd/conf/httpd.conf:
LoadModule apreq_module modules/mod_apreq2.so

3. Change in netdisco code and configuration
--- netdisco-0.94/netdisco_apache.conf 2004-03-08 02:13:49.000000000 +0700
+++ /usr/local/netdisco/netdisco_apache.conf 2005-10-20 10:55:58.000000000 +0700
@@ -30,6 +30,7 @@
use strict;

my $ah = new HTML::Mason::ApacheHandler(
+ args_method => 'mod_perl',
comp_root => '/usr/local/netdisco/html',

--- ApacheHandler.pm.org 2005-11-05 10:27:30.676141760 +0700
+++ /usr/lib/perl5/site_perl/5.8.5/HTML/Mason/ApacheHandler.pm 2005-10-20 11:23:04.000000000 +0700
@@ -232,6 +232,7 @@
if ($ENV{MOD_PERL}) {
if (APACHE2) {
require Apache2::RequestRec;
+ require Apache2::Connection;
require Apache2::RequestIO;

--- netdisco-0.94/html/autohandler 2004-11-10 03:34:42.000000000 +0700
+++ /usr/local/netdisco/html/autohandler 2005-10-20 11:34:31.000000000 +0700
@@ -91,7 +91,7 @@
}

# For Logging, tell apache what user is in:
-$r->connection->user($m->session->{user}) if defined($m->session->{user});
+$r->user($m->session->{user}) if defined($m->session->{user});

--- netdisco-0.94/html/login.html 2004-09-28 02:00:27.000000000 +0700
+++ /usr/local/netdisco/html/login.html 2005-10-20 11:18:11.000000000 +0700
@@ -93,7 +93,7 @@
$m->session->{user_port_ctl} = $db_user->{port_control};
$m->session->{user_admin} = $db_user->{admin};
$m->session->{start} = time;
- $r->connection->user($db_user->{username});
+ $r->user($db_user->{username});

--- netdisco-0.94/netdisco 2004-12-07 06:45:47.000000000 +0700
+++ /usr/local/netdisco/netdisco 2005-11-05 10:29:47.196387528 +0700
@@ -2945,7 +2945,7 @@
return;
}

- my @S = $G->strongly_connected_components;
+ my @S = $G->connected_components;

No comments: