Postgres killed itself during a disk failure and while later trying to start it up I got messages along the lines of:
database system was interrupted; last known up at ...
database system was not properly shut down; automatic recovery in progress
redo starts at 309/3BA1EB48
record with zero length at 309/3C9F8ED8
redo done at 309/3C9F8EA8
last completed transaction was at log time ....
could not fdatasync log file 777, segment 60: Input/output error
startup process (PID 23142) was terminated by signal 6: Aborted
aborting startup due to startup process failure
On further investigation it sound like the transaction log was corrupted. This can be fixed with pg_resetxlog. This will clear the write ahead log and may result in some data loss or loss of integrity but when nothing else works it's a lifesaver. The documentation describes some follow up steps to ensure the integrity of data after postgres is starting properly.
You can do a dry run:
sudo -u postgres /usr/lib/postgresql/8.4/bin/pg_resetxlog -n /var/lib/postgresql/8.4/main
and if that indicates a new segment and there's no other option then you might as well reset with:
sudo -u postgres /usr/lib/postgresql/8.4/bin/pg_resetxlog /var/lib/postgresql/8.4/main
or
sudo -u postgres /usr/lib/postgresql/8.4/bin/pg_resetxlog -f /var/lib/postgresql/8.4/main
Tuesday, January 11, 2011
Friday, January 7, 2011
Pretty Print XML in Python
From the command line:
python -c "import xml.dom.minidom; xml = xml.dom.minidom.parse('myxmldoc.xml'); print xml.toprettyxml()"
python -c "import xml.dom.minidom; xml = xml.dom.minidom.parse('myxmldoc.xml'); print xml.toprettyxml()"
Saturday, October 2, 2010
Mounting an encrypted LUKS LVM volume from a live CD
Get Luks and dm-crypt running on the live disk:
sudo apt-get install lvm2 cryptsetupsudo modprobe dm-crypt
sudo cryptsetup luksOpen /dev/sda4 crypt1
If you LVM setup then you need to continue with:
sudo vgscan --mknodessudo vgchange -ay
Take note of the volume group name. 'vg0' in my case.
Mount the disk:
sudo mkdir /mnt/disk
sudo mount /dev/vg0/root /mnt/disk
Friday, July 30, 2010
Move Lucid min, max, close buttons to the right
gconftool-2 --set /apps/metacity/general/button_layout --type string menu:minimize,maximize,close
Tuesday, June 1, 2010
Inotify
Inotify is awesome, I've used the python bindings before to good effect but just today I needed to monitor a directory for whenever a file was created.
Pretty easy:
sudo aptitude install inotify-tools
inotifywait -m -r --format '%f' -e CREATE data/
Pretty easy:
sudo aptitude install inotify-tools
inotifywait -m -r --format '%f' -e CREATE data/
Friday, February 26, 2010
Clock Screensaver for Ubuntu
You can use the GLText screensaver to display the time whenever you lock your screen:
In the file /usr/share/applications/screensavers/gltext.desktop change
Exec=gltext -root
to
Exec=gltext -root -front -text '%l:%M:%S %p'
In the file /usr/share/applications/screensavers/gltext.desktop change
Exec=gltext -root
to
Exec=gltext -root -front -text '%l:%M:%S %p'
Monday, October 12, 2009
ipython and virtualenv
When recently working with virtualenv recently ipython wasn't picking up the correct sites packages directory. Anyhow this post cleared everything up.
In summary...
In summary...
create ~/.ipython/virtualenv.py
import site
from os import environ
from os.path import join
from sys import version_info
if 'VIRTUAL_ENV' in environ:
virtual_env = join(environ.get('VIRTUAL_ENV'),
'lib',
'python%d.%d' % version_info[:2],
'site-packages')
site.addsitedir(virtual_env)
print 'VIRTUAL_ENV ->', virtual_env
del virtual_env
del site, environ, join, version_info
add this to ~/.ipython/ipy_user_conf.py
def main():
execf('~/.ipython/virtualenv.py')
Subscribe to:
Posts (Atom)