Debian cookbook installation of NOC

410 views
Skip to first unread message

rskjels

unread,
Feb 25, 2009, 8:50:33 AM2/25/09
to nocproject users
This is a working document. Please comment if you find some errors.
Disclaimer, i am not a unix competent person so there is bound to be
mistakes.




Make sure that /etc/apt/sources list contain:

deb http://ftp.xx.debian.org/debian/ sid main non-free contrib
deb-src http://ftp.xx.debian.org/debian/ sid main non-free
contrib

The xx is simply the country code.

You should be running unstable(Sid) version, not the stable version

Run the apt-get circle
# apt-get update
# apt-get upgrade

Required packages ¶

Following packages are required to run NOC



* Python - 2.5 or later required
# apt-get install python2.5

IMPORTANT!!! Make sure you use python version 2.5 and not 2.4

# python --version
Python 2.5.4 <- Version may change in your version.

* PostgreSQL - 8.0 or later required
# apt-get install postgresql-8.3

* setuptools - Extension to python distutils (See wiki:Install/
setuptools)
# apt-get install python2.5-setuptools

* psycopg2 - PostgreSQL bindings for Python (See wiki:Install/
psycopg2)
# apt-get install python-psycopg2

* Django - version 1.0 or later required (See wiki:Install/Django)
# apt-get install python-django

Verify Django version:

# python
Python 2.5.4 (r254:67916, Feb 17 2009, 20:16:45)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> import django
>>> django.VERSION
(1, 0, 2, 'final', 0)
>>>

Alternative installation of Django
# easy_install-2.5 django

* South - Django schema migration tool (See wiki:Install/South)
Install as in outlined in the wiki. I could not find South as a
debian package.
# apt-get install subversion-tools # I installed the whole
package
# svn co https://svn.aeracode.org/svn/south/trunk south
# cd south
# python setup.py install

Verify that South is installed for Python2.5. You should find
South-0.x-pyx.x.egg is in /usr/lib/python2.5/site-packages

* protobuf - Google's data interchange format, used for internal
RPC
# apt-get install python2.5-protobuf

Optional packages ¶

* flup - Required to run NOC web daemon in FastCGI mode (See
wiki:Install/flup?)
# apt-get install python-flup

* Sphinx - Python documentation tool. Required to rebuild online
documentation
# apt-get install python-sphinx

* Mercurial - Distributed version control system. Required to
fetch updates from repository
# apt-get install mercurial # Perhaps trac-mercurial instead

* pysnmp4 - Python SNMP implementation. Required for trap
collector in noc-activator (disabled by default).
# apt-get install python-pysnmp4 # Perhaps python-pysnmp4-mibs
also

* pyasn1 - Python ASN.1 parser. Required for trap collector in noc-
activator (disabled by default).
# apt-get install python-pyasn1

* libsmi -- smidump required for MIB uploading
# apt-get install libsmi2-dev
# libsmi2-common should already be installed. I do not know if
this one is required.

* netifaces -- Python library to resolve interface names to IP
addresses.
Allows write interface names instead of IP addresses in configs
# apt-get install python2.5-netifaces

* Web Server - required for production use of NOC web interface
o lighttpd
o Apache
# apt-get install apache2

Create system user and group

I am confused by the doc. The NocInstall says the user should
be noc,
while the Updating NOC says nocadmin.
Serveral scenarios possible:
a. Single user/group noc. /var/www/noc owned by noc and all
daemons
are launched as noc
b. /var/www/noc owned by nocadmin, /var/www/noc/local owned
by noc,
all daemons launched as noc
second scenario is preferred but more complicated.

# groupadd noc
# useradd -g noc -d /var/www -s /bin/false noc

Creating database

The documentation says createuser test. I user simply noc
# su - postgres
$ createuser noc
Answer n on all questions
$ createdb -EUTF8 -Onoc noc
Exit to superuser

Verify that you can connect to the noc database as the noc user
and the password.
# su - noc
$ psql -h localhost -U noc -W

You may have to edit the /etc/postgresql/8.3/main/pg_hba.conf
This is an example, do not use in a production enviroment:

# Database administrative login by UNIX sockets
# TYPE DATABASE USER IP-ADDRESS IP-
MASK METHOD
local all
all trust
# TYPE DATABASE USER IP-ADDRESS IP-
MASK METHOD
host all all 127.0.0.1
255.255.255.255 trust
# TYPE DATABASE USER IP-ADDRESS IP-
MASK METHOD
host all all 0.0.0.0
0.0.0.0 trust

Also check:
# ls /var/run/postgresql/.s.PGSQL.*
/var/run/postgresql/.s.PGSQL.5433 /var/run/postgresql/.s.PGSQL.
5433.lock

You can also check with netstat what port the postgresql
listens on.
noc@dimurgos:~/noc$ netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign
Address State
tcp 0 0 127.0.0.1:5433
0.0.0.0:* LISTEN


If you find that it uses port 5433, change the following line
in
/etc/postgresql/8.3/main/postgresql.conf and restart.
port = 5433 # (change
requires restart)
to:
port = 5432 # (change
requiresrestart)


Install NOC

# cd /var/www
# This is just an example. Relasenumber will change. Make sure
you dowload the
right one from http://trac.nocproject.org/trac/wiki/NocDownload
# wget http://trac.nocproject.org/trac/raw-attachment/wiki/NocDownload/noc-0.1.4.tgz
# gunzip noc-0.1.4.tgz
# tar -xvf noc-0.1.4.tar


Prepare etc/noc.conf

# cd /var/www/noc
# cp etc/noc.defaults etc/noc.conf
Change noc.conf to suit your installation. At least the line:
pg_dump = /usr/local/bin/pg_dump
should be changed to :
pg_dump = /usr/bin/pg_dump

Create local cache

# cd /var/www/noc
# mkdir local

Give noc user and noc group rights to the whole /var/www/noc

# chown -R noc:noc *

Initialize NOC database

All "python manage.py" commands must be executed as user "noc"

# su - noc
$ cd /var/www/noc
$ python manage.py syncdb
Syncing...
Creating table auth_permission
Creating table auth_group
Creating table auth_user
Creating table auth_message
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table django_admin_log
Creating table south_migrationhistory

You just installed Django's auth system, which means you don't
have any superusers defined.
Would you like to create one now? (yes/no): yes
Username (Leave blank to use 'noc'): noc
E-mail address: n...@comace.net
Password:
Password (again):
Superuser created successfully.
Installing index for auth.Permission model
Installing index for auth.Message model
Installing index for admin.LogEntry model

Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.admin
> south

Not synced (use migrations):
- noc.main
- noc.sa
- noc.fm
- noc.cm
- noc.ip
- noc.vc
- noc.dns
- noc.peer

Then you have to run

$ ./manage.py migrate

Testing NOC web interface

As root
# python manage.py runserver 0.0.0.0:81
Port 80 is in use by apache.

In a webbrowser you can test the application. Log in with username noc
and password noc


d...@ax.ru

unread,
Feb 25, 2009, 9:14:14 AM2/25/09
to nocproject users
rksjels, thank you for good explanation,

Installation process mostly correct, though I warn you agains running
manage.py from root user.
Running manage.py you can create additional files (caches, logfiles)
that will have root user permissions.
Later, when running manage.py from noc user you can face permission
errors.

So the good practice is to always run manage py as noc user, even for
debugging purposes.

PS: I'll create new HOWTO section on wiki.

On Feb 25, 4:50 pm, rskjels <rskj...@pogostick.net> wrote:
> This is a working document. Please comment if you find some errors.
> Disclaimer, i am not a unix competent person so there is bound to be
> mistakes.
>
> Make sure that /etc/apt/sources list contain:
>
>      debhttp://ftp.xx.debian.org/debian/sid main non-free contrib
>      deb-srchttp://ftp.xx.debian.org/debian/sid  main non-free
>       # wgethttp://trac.nocproject.org/trac/raw-attachment/wiki/NocDownload/noc-0...

rskjels

unread,
Feb 25, 2009, 9:30:44 AM2/25/09
to nocproject users
python manage.py syncdb and manage.py migrate is run as noc.
As i write:
All "python manage.py" commands must be executed as user "noc"

# su - noc
$ cd /var/www/noc
$ python manage.py syncdb
....
Then you have to run

$ ./manage.py migrate

But i had to run python manage.py runserver as root and on port 81.
On port 81 because apache runs on port 80. Apache is also installed
because of dependencies by on of the packages.

When running manage.py runserver as noc, i get the following error

noc@dimurgos:~/noc$ python manage.py runserver 0.0.0.0:81
Validating models...
0 errors found

Django version 1.0.2 final, using settings 'noc.settings'
Development server is running at http://0.0.0.0:81/
Quit the server with CONTROL-C.
Error: You don't have permission to access that port.

It seems to me that i have to find a way of making NOC coexist as a
site in/with Apache.

Tim

unread,
Feb 25, 2009, 10:04:51 AM2/25/09
to nocproject users
On Feb 25, 3:30 pm, rskjels <rskj...@pogostick.net> wrote:
> It seems to me that i have to find a way of making NOC coexist as a
> site in/with Apache.

I run lighttpd with this config on port 81 :

server.modules = (
"mod_rewrite",
"mod_fastcgi",
"mod_cgi",
"mod_redirect",
"mod_alias",
"mod_access",
"mod_accesslog" )

mimetype.assign = ( ".css" => "text/css", )

server.document-root = "/var/www/noc"
server.errorlog = "/var/log/lighttpd/error.log"
server.port = 81

fastcgi.server = (
"/noc.fcgi" => (
"main" => (
"socket" => "/tmp/noc.fcgi",
"check-local" => "disable",
)

)
)

alias.url = ( "/media/" => "/usr/lib/python2.5/site-packages/
Django-1.0.2_final-py2.5.egg/django/contrib/admin/media/", )
alias.url += ( "/static/" => "/var/www/noc/static/", )


url.rewrite-once = (
"^(/media.*)$" => "$1",
"^/static/(.*)$" => "/static/$1",
"^(/.*)$" => "/noc.fcgi$1",
)

Cheers,
Tim

d...@ax.ru

unread,
Feb 25, 2009, 11:13:31 AM2/25/09
to nocproject users
NOC has noc-fcgi - FastCGI interface, which can be used together with
your apache installation.
Additional web servers on the other ports are not required. Apache
will serve as primary web frontend,
routing requests to designated domain to the noc-fcgi.

On Feb 25, 5:30 pm, rskjels <rskj...@pogostick.net> wrote:
> python manage.py syncdb and manage.py migrate is run as noc.
> As i write:
> All "python manage.py" commands must be executed as user "noc"
>
>        # su - noc
>        $ cd /var/www/noc
>        $ python manage.py syncdb
>       ....
> Then you have to run
>
>          $ ./manage.py migrate
>
> But i had to run python manage.py runserver as root and on port 81.
> On port 81 because apache runs on port 80. Apache is also installed
> because of dependencies by on of the packages.
>
> When running manage.py runserver as noc, i get the following error
>
> noc@dimurgos:~/noc$ python manage.py runserver 0.0.0.0:81
> Validating models...
> 0 errors found
>
> Django version 1.0.2 final, using settings 'noc.settings'
> Development server is running athttp://0.0.0.0:81/

d...@ax.ru

unread,
Feb 28, 2009, 11:58:20 AM2/28/09
to nocproject users
Slightly corrected version available on wiki:
http://trac.nocproject.org/trac/wiki/DebianInstallationHOWTO

Please correct online if errors been made
Reply all
Reply to author
Forward
0 new messages