Показаны сообщения с ярлыком FreeBSD. Показать все сообщения
Показаны сообщения с ярлыком FreeBSD. Показать все сообщения

четверг, 21 марта 2013 г.

Deleted files in directory

I was just refreshing my knowledge about filesystems... In FreeBSD it is definately easier to investigate fs behavior. You can just do a hexdump of a directory. In Solaris and Linux this does not work. Hexdump of zfs directory is not very interesting. However, in ufs dump we can see that deleted files persist in directory listing:
# zfs create -V 1G zpool/zvol1
# newfs /dev/zvol/zpool/zvol1
# mkdir test
# mount  /dev/zvol/zpool/zvol1 `pwd`/test
# cd test
# mkdir 99
# cd 99
# touch a b c d e
# hd . 
00000000  00 14 01 00 0c 00 04 01  2e 00 00 00 02 00 00 00  |................|
00000010  0c 00 04 02 2e 2e 00 00  01 14 01 00 0c 00 08 01  |................|
00000020  61 00 05 9e 02 14 01 00  0c 00 08 01 62 00 05 9e  |a...........b...|
00000030  03 14 01 00 0c 00 08 01  63 00 05 9e 04 14 01 00  |........c.......|
00000040  0c 00 08 01 64 00 05 9e  05 14 01 00 b8 01 08 01  |....d...........|
00000050  65 00 05 9e 00 00 00 00  00 00 00 00 00 00 00 00  |e...............|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200
Now, after removing some files we can see that corresponding records still exist in directory:
# rm e d a
# hd .
00000000  00 14 01 00 0c 00 04 01  2e 00 00 00 02 00 00 00  |................|
00000010  18 00 04 02 2e 2e 00 00  01 14 01 00 0c 00 08 01  |................|
00000020  61 00 05 9e 02 14 01 00  0c 00 08 01 62 00 05 9e  |a...........b...|
00000030  03 14 01 00 d0 01 08 01  63 00 05 9e 04 14 01 00  |........c.......|
00000040  c4 01 08 01 64 00 05 9e  05 14 01 00 b8 01 08 01  |....d...........|
00000050  65 00 05 9e 00 00 00 00  00 00 00 00 00 00 00 00  |e...............|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200
# ls 
b       c
If we add some files, we can see that deleted record is used again:
# touch f 
# hd .
00000000  00 14 01 00 0c 00 04 01  2e 00 00 00 02 00 00 00  |................|
00000010  0c 00 04 02 2e 2e 00 00  01 14 01 00 0c 00 08 01  |................|
00000020  66 00 e9 05 02 14 01 00  0c 00 08 01 62 00 05 9e  |f...........b...|
00000030  03 14 01 00 d0 01 08 01  63 00 05 9e 04 14 01 00  |........c.......|
00000040  c4 01 08 01 64 00 05 9e  05 14 01 00 b8 01 08 01  |....d...........|
00000050  65 00 05 9e 00 00 00 00  00 00 00 00 00 00 00 00  |e...............|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
*
00000200

пятница, 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...

четверг, 22 марта 2012 г.

Redmine/Webrick rc script

I've just installed redmine 1.3.2 on FreeBSD server and met several inconviniences.

  1. It is not in ports

  2. It depends on old versions of different ruby gems, which are already not in ports.
    In particular, it didn't want to work with rack 1.4.1 and I had to do

    # gem install rake -v=1.1.0


  3. It doesn't have rc script to startup Webrick web server (I didn't want to install apache on this host)


So, I've taken mongrel_cluster rc script and made redmine rc script from it. It is here:

#!/bin/sh
# PROVIDE: redmine
# REQUIRE: DAEMON
# KEYWORD: shutdown
#
# This script is modified by placing the following variables inside
# /etc/rc.conf:
#
# redmine_enable (bool):
# Set it to YES to enable this service.
# Default: NO
# redmine_dir (path):
# The directory containing redmine
# Default: /usr/local/redmine/
# redmine_user (username):
# The user to run redmine as
# Default: redmine
# redmine_args (string):
# Additional command flags for ruby
# Default: "-e production -d"

. /etc/rc.subr

name=redmine
rcvar=redmine_enable

command="/usr/local/bin/ruby"

load_rc_config $name

: ${redmine_enable="NO"}
: ${redmine_dir="/usr/local/redmine/"}
: ${redmine_args="-e production -d"}
: ${redmine_user="redmine"}

start_cmd="redmine_cmd start"
stop_cmd="redmine_cmd stop"
restart_cmd="redmine_cmd restart"
status_cmd="redmine_cmd status"

redmine_cmd()
{

if [ ! -d "${redmine_dir}/." ]; then
warn "${redmine_dir} is not a directory."
return 1
fi

case $1 in
"start")
su -l ${redmine_user} -c "cd ${redmine_dir} && pwd && eval $command script/server webrick $redmine_args"
;;
"stop")
if [ -f ${redmine_dir}/tmp/pids/server.pid ] ; then
PID=$(/usr/bin/head -1 ${redmine_dir}/tmp/pids/server.pid)
/bin/kill -s int $PID 2>/dev/null
sleep 3
/bin/kill -s 0 $PID 2>/dev/null && /bin/kill -s kill $PID;
fi
;;
"restart")
redmine_cmd stop
redmine_cmd start
;;
"status")
if [ -f ${redmine_dir}/tmp/pids/server.pid ] ; then
echo "PID file exists"
PID=$(/usr/bin/head -1 ${redmine_dir}/tmp/pids/server.pid)
/bin/kill -s 0 $PID 2>/dev/null && echo "Server is running with pid $PID" && exit 0;
echo "But server is not running..." && exit 1;
fi
echo "Server is not running" && exit 0;
;;
esac
}

run_rc_command "$1"


The interesting thing to note is that to terminate webrick correctly, you have to send it SIGINT, not SIGTERM.

вторник, 14 февраля 2012 г.

French symbols without azerty

So, sometimes I have to type some text in French. And I dislike AZERTY layout, it's too unfamiliar. So, what should I do? Right, to use altgr-intl US layout. To do this you just need to set XKB Variant to "altgr-intl" (something like this in hal policy file - /usr/local/etc/hal/fdi/policy/x11-input.fdi on my FreeBSD system):

<?xml version="1.0" encoding="ISO-8859-1"?>
<deviceinfo version="0.2">
<device>
<match key="info.capabilities" contains="input.keyboard">
<merge key="input.x11_options.XkbModel" type="string"> pc105</merge>
<merge key="input.x11_options.XkbLayout" type="string">us,ru</merge>
<merge key="input.x11_options.XkbOptions" type="string">grp:rwin_toggle,grp_led:scroll</merge>
<merge key="input.x11_options.XkbVariant" type="string">altgr-intl,winkeys</merge>
</match>
</device>
</deviceinfo>


Now, to type something with ^ , like û, you just type RightAlt+6 (^ symbol is there) and press u. To type è - RightAlt+` and e... Big list of shortcuts is here. And if you don't touch right alt this layout behaves just like basic us layout...

воскресенье, 4 декабря 2011 г.

One thing I hate in FreeBSD...

One thing I hate in FreeBSD - is the speed of maintainence operations.
To install (or upgrade) one port you have to wait half an hour...
To update system with custom kernel/userland parameters, you should wait several hours... Then you call mergemaster, which asks you a dozen questions about config files (and most of changes doesn't impact on the current system, but just in case there is something important, you have to review them).
Comparing to "do-release-upgrade" on ubuntu, the speed of operation is unberable. And binary updates just don't do everithing you need (e.g. dtrace world, necessary ports options...)

среда, 19 октября 2011 г.

PostgreSQL: server closed connection

Today I got a ton of messages

DBI connect('dbname=xxx;host=yyy','username',...) failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request. at....


from our network statistic collector.
I spent some time trying to understand what had happened (besides yesterdays power fail). I looked at PostgreSQL server debug log (it honestly told that client just closed connection). There were no traces of dying postgres backend. I rolled back some minor configuration changes which I made yesterday... And later it downed upon me: it was just one old server which was supposed to have its network interface shut down waked after power failure... It was seen in dmesg:

arp: x.y.z.w moved from AA:AA:AA:AA:AA:AA to BB:BB:BB:BB:BB:BB on em0
arp: x.y.z.w moved from BB:BB:BB:BB:BB:BB to AA:AA:AA:AA:AA:AA on em0


Really, power cycling is neccessary sometimes to ascertain that all your services are configured properly :)

суббота, 24 сентября 2011 г.

Adding vdev to raidz pool

There is one fundamental flaw in raidz ZFS pools: you can't add devices to raidz (as opposed to usual raid5). So, could we do anything to expand our pool without full rebuilding? Yes, if we are ready to sacrifice one more disk.
From zpool man page:

A pool can have any number of virtual devices at the top of the config‐
uration (known as "root vdevs"). Data is dynamically distributed across
all top-level devices to balance data among devices. As new virtual
devices are added, ZFS automatically places data on the newly available
devices.

So, to add some capacity to our pool, we can add one more raidz to it. Let's look at this process. Firstly, let's create test pool from three "disks":

freebsd# foreach i ( 1 2 3 4 5 6)
foreach? dd if=/dev/zero of=/tmp/disk$i bs=100M count=1
foreach? end
freebsd# zpool create testpool raidz /tmp/disk1 /tmp/disk2 /tmp/disk3

Now, let's see what we have:

freebsd# zpool status testpool
pool: testpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk1 ONLINE 0 0 0
/tmp/disk2 ONLINE 0 0 0
/tmp/disk3 ONLINE 0 0 0

errors: No known data errors
freebsd# zpool list testpool
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 286M 156K 286M 0% ONLINE -
freebsd# zfs list testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 95.9K 158M 28.0K /testpool

Now let's expand this pool:

freebsd# zpool add testpool raidz /tmp/disk4 /tmp/disk5 /tmp/disk6

So, we recieved the following configuration:

freebsd# zpool status testpool
pool: testpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk1 ONLINE 0 0 0
/tmp/disk2 ONLINE 0 0 0
/tmp/disk3 ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk4 ONLINE 0 0 0
/tmp/disk5 ONLINE 0 0 0
/tmp/disk6 ONLINE 0 0 0

errors: No known data errors
freebsd# zpool list testpool
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 572M 210K 572M 0% ONLINE -
freebsd# zfs list testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 114K 349M 28.0K /testpool

Let's compare this to raidz from 6 disks:

freebsd# zpool create testpool raidz /tmp/disk1 /tmp/disk2 /tmp/disk3 /tmp/disk4 /tmp/disk5 /tmp/disk6
freebsd# zpool status testpool
pool: testpool
state: ONLINE
scrub: none requested
config:

NAME STATE READ WRITE CKSUM
testpool ONLINE 0 0 0
raidz1 ONLINE 0 0 0
/tmp/disk1 ONLINE 0 0 0
/tmp/disk2 ONLINE 0 0 0
/tmp/disk3 ONLINE 0 0 0
/tmp/disk4 ONLINE 0 0 0
/tmp/disk5 ONLINE 0 0 0
/tmp/disk6 ONLINE 0 0 0

errors: No known data errors
freebsd# zpool list testpool
NAME SIZE USED AVAIL CAP HEALTH ALTROOT
testpool 572M 147K 572M 0% ONLINE -
freebsd# zfs list testpool
NAME USED AVAIL REFER MOUNTPOINT
testpool 112K 443M 34.9K /testpool

So, we lost more then 21% of space, but expanded our pool without downtime. Firstly, the lost of more then 20% space suprised me, but 20% was expectable (in second case only 5 disks, in first - 4, so 20% is the difference).
Let's see, where did 1 percent go. 443 MB is useful in second case, it means about 11.4 MB (100 /*disk size*/ - 443/*useful space*/ / 5 /*useful disks*/) metadata per disk. In first case we have 349 MB. It is provided by two pools with 2 useful disks in each. So, wasted space per disk is 12.75 MB (100 - 349/2/2). It seems, in this configuration we have a bit more metadata.

воскресенье, 28 августа 2011 г.

Change user password in script on FreeBSD host

Changing user password in script on FreeBSD host turned out to be very simpe. Use "pw" for this purpose:

echo "user_password" | pw usermod -V /jails/myjail/etc -h 0 username

пятница, 1 апреля 2011 г.

Weird boot0 behavior


It seems I've found one interesting bug in FreeBSD boot0. The long story is the following. We deploy new systems on IBM blade servers. After some local fixes made by Oleg we made FreeBSD gmultipath work with our EMC Clarion storage. However, we observed strange behavior. Periodically systems refused to boot. We could see only black screen and no usual "F1: FreeBSD" boot0 prompt. This was healed by some tricks - in particular we were able to make two servers boot in all cases by some BIOS and FC adapter settings. However, all these tricks (particular FC adapter settings, disabling Planar SAS and unnecessary boot methods in BIOS) didn't help in last case. It took about a week to make last server boot. At last I've found the certain bug in boot0.


I cassually stepped on this. I've tried to install boot2 loader from current and instead of "bsdlabel -e " executed "bsdlabel -w". And system booted 10 times in a row (to a point before mounting local filesystems). Luckily, "/" filesystem was on the first BSD partition. "bsdlabel -w" rewrote partition table and made one partition on whole slice. Root ("/") could be mounted, other filesystems were lost. So, OS was able to boot to a certain stage. There could be two reasons which influenced boot0 behavior: existence of several partitions and their labels. So I recreated partition table and labeled all BSD partitions as "unused" (instead of "4.4BSD"). This helped. System boots now without any random failures (at least it boots 12 times in a row).
I've created a bug entry for this boot0 failure and started to setup a new FreeBSD server... Why do partition labels influence boot0? I don't know, maybe it's related to OS probing (when boot0 writes "F1: FreeBSD" and not "F1: Disk1"). At least, I'm rather happy: we inclined to install Linux on our blades in case if we wouldn't be able to make FreeBSD booting robust. So I shouldn't learn OpenVZ peculiarities and bugs and can use familiar jail infrastructure (we are going to deploy vnet jails). And ZFS for storing jail images and applications' data. This is a killer feature of FreeBSD which made me struggle for a week :)

понедельник, 14 марта 2011 г.

FreeBSD, Java plugin and Firefox 3.6

I've just found out, that java plugin is working on FreeBSD with Firefox 3.6 and OpenJDK (openjdk6-b21_3). You just need to compile openjdk port with WEB option and later do

ln -s /usr/local/openjdk6/jre/lib/IcedTeaPlugin.so ~/.mozilla/plugins/

I can't determine the quality of plugin - all my admin applications work strange (don't work seems right expression), but it may be caused by SSH tunneling...

понедельник, 28 февраля 2011 г.

Read UPDATING, Luck...

I spent weekend updating my desktop system. I've built 8.2, updated Xorg, KDE and different trifles. Finally I reinstalled autoconf,automake,libltdl,libtool, because portmaster couldn't update them (ports moved). Periodically I had to kill grep during port install, because I forgot to update portmaster. These two problems could be solved if I had read "UPDATING"... But the last one was interesting: I didn't manage to make xf86-video-ati work, system hanged with "radeon" driver and performance dropped significantly with "radeonhd". At last, I rolled back to using x11-drivers/xf86-video-ati613. I have to update other major ports (OpenJDK, Chromium, Firefox), but this can wait. I'm going to wait for Chromium 9 (which was promised to land in ports tree in March-April) and to replace OpenOffice with LibreOffice on this week...

среда, 16 февраля 2011 г.

Finally wine is fixed...

Finally one irritating wine bug was fixed. Now I've just updated my wine to 1.3.3 (I had this in my port tree) with applied suggested patch. Some windows applications still don't work on my desktop (FreeBSD 8.1, xf86-video-ati-6.13.2, wine-1.3.3). However, they work on Linux and Intel integrated video adapter, but it seems I should blame ati video driver for this. It seems that Intel is the best video adapter for Unix-like system. At least, I hope Intel will not make it unusable by dropping support for no-KMS mode.

пятница, 21 января 2011 г.

Looking for virtualization solution

Now I'm looking something to replace VMware ESXi... So far I looked at XCP (xen cloud platform). It has issues running OpenIndiana, so it was not a best choice for me. Then I looked at OpenNode. But satisfactory WebUI was available only for latest beta version, and I didn't manage to make it working. Maybe I should look at Aeolus Project? When I return to this task, I'll give it a try. Just for now I'm going to deploy new PostgreSQL server in old proved FreeBSD jailed environment. At least its overhead and complexity is minimal...

пятница, 14 января 2011 г.

repmgr FreeBSD port

I've just managed to create initial prototype of repmgr port for FreeBSD. Port compiles, but repmgrd dumps core for unknown reason... Need to investigate. Shell archive of the port is provided.

Updated: repmgrd works fine with included patch.


# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# databases/postgresql-repmgr
# databases/postgresql-repmgr/Makefile
# databases/postgresql-repmgr/pkg-descr
# databases/postgresql-repmgr/distinfo
# databases/postgresql-repmgr/pkg-plist
# databases/postgresql-repmgr/files
# databases/postgresql-repmgr/files/patch-repmgrd.c
#
echo c - databases/postgresql-repmgr
mkdir -p databases/postgresql-repmgr > /dev/null 2>&1
echo x - databases/postgresql-repmgr/Makefile
sed 's/^X//' >databases/postgresql-repmgr/Makefile << '48fb6f3f1b95d8369d928a104f7bd6a3'
X# New ports collection makefile for: repmgr
X# Date created: January 15, 2011
X
XPORTNAME= postgresql-repmgr
XPORTVERSION= 1.0.0
XPORTREVISION= 0
XCATEGORIES= databases
XMASTER_SITES= http://projects.2ndquadrant.it/sites/default/files/
X#MASTER_SITE_SUBDIR= sites/default/files/
XDISTNAME= repmgr-${PORTVERSION}
X
XMAINTAINER= alp@sfedu.ru
XCOMMENT= PostgreSQL repmgr
X
XBUILD_DEPENDS+= postgresql-server>=9.0:${PORTSDIR}/databases/postgresql90-server
XRUN_DEPENDS:= ${BUILD_DEPNDS}
XRUN_DEPENDS+= rsync:${PORTSDIR}/net/rsync
X
XUSE_GMAKE= yes
XMAKE_ENV= USE_PGXS=1
X
XPORTDOCS= README.*
X
Xdo-install:
X ${INSTALL_PROGRAM} ${WRKSRC}/repmgr ${PREFIX}/bin
X ${INSTALL_PROGRAM} ${WRKSRC}/repmgrd ${PREFIX}/sbin
X.if !defined(NOPORTDOCS)
X @${MKDIR} ${DOCSDIR}
X ${INSTALL_DATA} ${WRKSRC}/README.rst ${DOCSDIR}
X.endif
X.if !defined(NOPORTDATA)
X @${MKDIR} ${DATADIR}
X ${INSTALL_DATA} ${WRKSRC}/repmgr.conf ${DATADIR}
X ${INSTALL_DATA} ${WRKSRC}/repmgr.sql ${DATADIR}
X.endif
X
X.include <bsd.port.mk>
48fb6f3f1b95d8369d928a104f7bd6a3
echo x - databases/postgresql-repmgr/pkg-descr
sed 's/^X//' >databases/postgresql-repmgr/pkg-descr << '4003202a12e35bb4d428938652326a06'
XPostgreSQL replication manager (repmgr)
X
XWWW: http://projects.2ndquadrant.com/repmgr
4003202a12e35bb4d428938652326a06
echo x - databases/postgresql-repmgr/distinfo
sed 's/^X//' >databases/postgresql-repmgr/distinfo << 'e1ae01bffabbb92bb754fc0eea6621aa'
XMD5 (repmgr-1.0.0.tar.gz) = e9a90058ff2ad81de20fd8dc7b8743f0
XSHA256 (repmgr-1.0.0.tar.gz) = b0345a9a32c3f3bab542c8d2ef72881f6f45b6c0d703f481998beb5755a1d79b
XSIZE (repmgr-1.0.0.tar.gz) = 35940
e1ae01bffabbb92bb754fc0eea6621aa
echo x - databases/postgresql-repmgr/pkg-plist
sed 's/^X//' >databases/postgresql-repmgr/pkg-plist << '1ca1316c7087064a99a71f8064202df0'
Xbin/repmgr
Xsbin/repmgrd
X%%DATADIR%%/repmgr.conf
X%%DATADIR%%/repmgr.sql
1ca1316c7087064a99a71f8064202df0
echo c - databases/postgresql-repmgr/files
mkdir -p databases/postgresql-repmgr/files > /dev/null 2>&1
echo x - databases/postgresql-repmgr/files/patch-repmgrd.c
sed 's/^X//' >databases/postgresql-repmgr/files/patch-repmgrd.c << '39954438281f6f4b810cfb628d4308b3'
X--- repmgrd.c 2010-12-06 05:09:48.000000000 +0300
X+++ repmgrd.c 2011-01-16 12:34:49.345998423 +0300
X@@ -173,7 +173,12 @@
X }
X
X /* close the connection to the database and cleanup */
X- CloseConnections();
X+ if (PQisBusy(primaryConn) == 1)
X+ CancelQuery();
X+ if (myLocalConn != NULL)
X+ PQfinish(myLocalConn);
X+ if (primaryConn != NULL && myLocalMode != PRIMARY_MODE)
X+ PQfinish(primaryConn);
X
X return 0;
X }
39954438281f6f4b810cfb628d4308b3
exit


понедельник, 20 декабря 2010 г.

Just remember never use ctrl+Ins in server console

I'm quite disturbed. I had found file to delete, had copied its name, entered "rm" and pressed ctrl+ins... What effectively pasted in the contents of one script. So I recieved "rm #!/bin/sh". I'm lucky, it wasn't "rm /bin/sh"... I hate several copy-paste buffers - one general buffer in KDE and separate buffer in Konsole.... Uuuuuu..........

среда, 27 октября 2010 г.

ZFS snapshots or something new on something old

Everyone knows that snapshots are fascinating feature of ZFS. Automatic snapshots in OpenSolaris used to save my mental health. After migration to FreeBSD I thought "It would be easy. There are a lot of decisions for managing ZFS snapshots in FreeBSD". In fact, theare are too many decisions for managing ZFS snapshots in FreeBSD. It's hard to choose one decision. I've looked for example, on sysutils/zfsnap, sysutils/zfs-snapshot-mgmt... But my needs are quite different:
  • I'd like the decision for making automatic snapshots to be simple and effective as an axe.
  • I'd like to understand how every line of these scripts (for creating and deleting snapshots) work to feel myself comfortable.
  • I'm going to use snapshots on my home desktop, and I'd only like to have quite recent copy of my data to recover files after making some silly mistakes.

At last, I decided to create my own solution which was supposed to work as rc script (I boot my computer once or twice per day, and it would be good to have startup snapshot of the system).
The text of script is provided below.

#!/bin/sh

. /etc/rc.subr

name="zfs_snapshot"

start_cmd="create_snapshots"
stop_cmd="drop_snapshots"
zfs_pool=${zfs_snapshot_pool:-"zpool"}
keep_days=${zfs_snapshot_keep_days:-30}

create_snapshots()
{
echo "Creating zfs snapshots..."

if [ -z "${zfs_snapshot_filesystems}" ]; then
snapshot_filesystems=`zfs list -H -o name -t filesystem`;
else
snapshot_filesystems=${zfs_snapshot_filesystems};
fi



DATE=`env LC_ALL=C date -j "+%Y_%m_%d-%H:%M"`
for fs in $snapshot_filesystems ; do
snap="${fs}@AUTO_${DATE}"
logger -t $name "Creating snapshot $snap"
zfs snapshot $snap
done
}

drop_snapshots()
{
echo "Destroying old automatic zfs snapshots"

current_date=`date "+%s"`
if [ -z "${zfs_snapshot_filesystems}" ]; then
snapshot_filesystems=`zfs list -H -o name -t filesystem`;
else
snapshot_filesystems=${zfs_snapshot_filesystems};
fi

for fs in $snapshot_filesystems ; do
snapshots=`zfs list -H -t snapshot -o name -r $fs |grep "^${fs}@AUTO_"`;
for snap in $snapshots; do
creation_local=`zfs list -H -t snapshot -o creation $snap`
creation_real=`date -j -f "%a %b %d %k:%M %Y" "${creation_local}" "+%s"`

eval creation_minus=$(( ( ${current_date} - ${creation_real})/3600/24 ))
if [ $creation_minus -gt $keep_days ]; then
logger -t $name "Destroying snapshot $snap"
zfs destroy $snap
fi
done
done

}

load_rc_config $name
run_rc_command $*


There are three parameters for my script - zfs_snapshot_pool, zfs_snapshot_filesystems and zfs_snapshot_keep_days. First or second parameter may be used to specify pool (and all its FS for creating snapshots) or explicitly selecting necessary filesystems. Parameter fs_snapshot_keep_days determines when snapshot is considered outdated.
This simple script is supposed to make my life more comfortable...

пятница, 15 октября 2010 г.

Chromium was added to FreeBSD ports tree

Chromium was added to FreeBSD ports tree. I'm going to try it... Currently I use Konqueror, but it is not always perfect. And Firefox wants too much memory, works quite slow and (the most annoying for me) doesn't look good with KDE :)

среда, 22 сентября 2010 г.

KDE 4.5.1 - Konqueror is a bit better

I've just updated my FreeBSD desktop. I haven't noticed big changes in KDE 4.5.1 yet, however, some small updates really matter. Now we have useful adblock-like feature in konqueror - I can block any frame/image I like and use some public adblock lists. However, konqueror can't block Flash objects. I'd like it to block them too...
And as always, Google Buzz doesn't work with konqueror. It's not suitable.
I'd like to try rekonq 0.6, but there is only 0.5 version in ports tree... WebKit-based browser it seems should be better in JavaScript processing.

пятница, 3 сентября 2010 г.

DTrace: it's really cool to have it working in FreeBSD

I've just managed to enable DTrace in FreeBSD and was playing a bit with it.
I've added necessary for i386 options to my kernel config:
options KDTRACE_HOOKS
options DDB_CTF

then run:
make kernel WITH_CTF=1 KERNCONF=MyKern

and received nothing good. The only working thing was dtrace -l. Everything other complained on uid_t in psinfo.d.

ctfdump showed a lot of stuff in kernel, but there was no uid_t. So, after adding the following line to my kernel config:
makeoptions DEBUG=-g

I got working dtrace!

So, now I can launch something like this...
# dtrace -qn 'syscall::open:entry { printf ("%d %s %s\n",pid,execname,copyinstr(arg0)) ; }'
1297 sh /lib/libncurses.so.8
1297 sh /lib/libc.so.7
1297 id /etc/libmap.conf
1297 id /var/run/ld-elf.so.hints
1297 id /usr/lib/libbsm.so.3
1297 id /lib/libc.so.7
1296 make /usr/ports/Mk/bsd.licenses.mk
1296 make /usr/ports/Mk/bsd.sites.mk
1298 sh /etc/libmap.conf
1298 sh /var/run/ld-elf.so.hints
1298 sh /lib/libedit.so.7
1298 sh /lib/libncurses.so.8
1298 sh /lib/libc.so.7
1298 sysctl /etc/libmap.conf
1298 sysctl /var/run/ld-elf.so.hints
1298 sysctl /lib/libc.so.7
1296 make .depend
1299 sh /etc/libmap.conf
1299 sh /var/run/ld-elf.so.hints
1299 sh /lib/libedit.so.7
1299 sh /lib/libncurses.so.8
1299 sh /lib/libc.so.7
1299 rm /etc/libmap.conf
1299 rm /var/run/ld-elf.so.hints
1299 rm /lib/libc.so.7
1299 rm .
1299 rm /usr/ports/textproc/libxml2/work
1299 rm libxml2-2.7.7

четверг, 19 августа 2010 г.

FreeBSD and wine... Progress or regression?

I've just got almost working wine on FreeBSD. To achieve this I've installed wine-1.1.30-1 from FreeBSD 8.0 package collection. Before this I unsuccessfully tried to make wine 1.2.1 work. It was impossible - it seems, later wine versions have some problems with DRI interoperability. So, after having enabled DRI on running (almost?) all DirectX games in wine on 8.1, you just get the following error:
> wine fallout2.exe
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 1 (X_CreateWindow)
Serial number of failed request: 397
Current serial number in output stream: 399
...
However, wine 1.1.30 works with enabled DRI. It seems, that all wine versions after 1.1.43 are broken.