пятница, 31 августа 2012 г.

Amazing new world with pkgng

I really like it. It's a pure magic... It's pkgng. So, my task is to deploy about 20-30 servers (jails) for practical courses in PostgreSQL. So, every student will have its own unique DBMS to crack and crash. Two years ago I said students to do:
# cd /usr/ports/databases/postgresql84-server/ && make install
So, for half a lesson we monitored building of postgresql... Cool. Last year I've prebuilt necessary packages and put them in /var/packages/. It was faster, a student just had to do:
# cd /var/packages
# pkg_add postgresql90-server*tbz
or something similar. But later we had to update database in one of tasks. Dealing with packages (and scripts to copy them to every jail was not pleasant. I even started to think about OpenVZ, debian and apt... However, i dislike the way of treating postgresql in Debian. It is overcomplicated by pg_ctlcluster, separation of config files from $PGDATA... However, this time I looked at pkgng. And so far I happy. To create package server I just installed pkg from ports:
# cd /usr/ports/ports-mgmt/pkg && make install
Added WITH_PKGNG=yes to /etc/make.conf, run pkg2ng, created required packages by
cd /usr/ports/databases/postgresql91-server/ && make package-recursive
Now I could install nginx, copy /usr/ports/packages/* to /data, run
# pkg repo /data/
share /data with nginx with the following location in server section:
location / {
            root   /data;
            autoindex on;
        }
Repository server is ready. On client I downloaded pkg-1.0.r6.tbz from freebsd package server (old one, with pkg_install packages), installed it and could use repository:
# pkg_add pkg-1.0.r6.tbz
Converted packages db to new format with pkg2ng, changed PACKAGESITE in pkg.conf to my server:
# cp /usr/local/etc/pkg.conf.sample /usr/local/etc/pkg.conf
# vi /usr/local/etc/pkg.conf
Run:
 
# pkg update
# pkg rquery -e '%n ~ pos*' '%n-%v'
postgresql-client-9.1.5
postgresql-contrib-9.1.5
postgresql-plperl-9.1.5
postgresql-server-9.1.5
But when I tried to install postgresql-server, I was asked to update pkg:
# pkg install postgresql-server-9.1.5
Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
New version of pkg detected; it needs to be installed first.
After this upgrade it is recommendedthat you do a full upgrade using: 'pkg upgrade'

The following packages will be installed:

 Upgrading pkg: 1.0.r6 -> 1.0

The installation will free 12 MB

1 MB to be downloaded

Proceed with installing packages [y/N]: n

# pkg install pkg
Updating repository catalogue
Repository catalogue is up-to-date, no need to fetch fresh copy
New version of pkg detected; it needs to be installed first.
After this upgrade it is recommendedthat you do a full upgrade using: 'pkg upgrade'

The following packages will be installed:

 Upgrading pkg: 1.0.r6 -> 1.0

The installation will free 12 MB

1 MB to be downloaded

Proceed with installing packages [y/N]: y
pkg-1.0.txz                                                                                                                                                                                      100% 1686KB   1.7MB/s   1.7MB/s   00:00    
Checking integrity... done
Upgrading pkg from 1.0.r6 to 1.0... done
After this I could quickly install postgresql:
# pkg install postgresql-server
The only inconvenience is a bootstrap problem. The bootstrap tool is necessary requirement to make work with pkg easier...

1 комментарий:

  1. Hi,

    You could also use the pkgng Mongoose plugin if you wish to simply serve a directory from pkgng, useful for package repositories.

    The Mongoose plugin can be found in the pkgng Github project.

    -- dnaeon

    ОтветитьУдалить