Sunday, 4 November 2012

mysql, python, peewee

I want to use python to work with my mysql database

install the python bindings

$ sudo yum install MySQL-python

download and install peewee - an object-relational mapping utility to python

$ wget https://github.com/coleifer/peewee/archive/master.tar.gz
$ gunzip peewee-master.tar.gz
$ tar -xvf peewee-master.tar
$ cd peewee-master/
$ sudo python setup.py install
$ sudo python setup.py test


Saturday, 3 November 2012

mysql


Install the the client and server software

$ sudo yum install mysql
$ sudo yum install mysql-server

start mysql server

$ sudo service mysqld start

automatically start mysql daemon on startup

$ sudo chkconfig --level 2345 mysqld on

set root password

$ mysqladmin -u root password foobar

login to localhost server

$ mysql -u root -p
mysql>

create a new user

mysql> create user 'username'@'localhost' identified by 'password';
mysql> grant all privileges on *.* to 'username'@'localhost' with grant option;

mysql-workbench: admin GUI

$ sudo yum install mysql-workbench

Tutorial on creating a database using mysql-workbench here

Mount NTFS partition in linux

Display available hard disks:
$ sudo fdisk -l

Device Boot  Start    End       Blocks    Id  System
/dev/sda2    206848   307202047 153497600 7   HPFS/NTFS/exFAT

Manually mount:
$ sudo mount -t ntfs-3g -o defaults,user,rw /dev/sda2 /mnt/windows/

Set up auto mounting in /etc/fstab:
add the following line to your /etc/fstab:
/dev/sda2 /mnt/windows/ ntfs-3g defaults,user,rw 0 0






Thursday, 1 November 2012

gnu screen rc and commands

I am not 100% happy with my screen.rc; it kind of works at the moment but I will edit this post as I find improvements.

.screenrc

# skip the startup message
startup_message off

# go to home dir
chdir

# Automatically detach on hangup.
autodetach on

# Change default scrollback value for new windows
defscrollback 1000

# start with visual bell as default
vbell on
vbell_msg "bell on %t (%n)"

# look and feel

term screen-256color

hardstatus alwayslastline "%{=r}%{G} %{c}%w"

shelltitle "shell"

# highlighting for text marking and printing messages
# '=': replace current settings
# 's': standout
# 'dd': default fore / default back
sorendition =s dd

Commands

Move the current window to a new position (window number):
^a:number [new window number]

eg: ^a:number 5 will move the current window to position number 5

Rename a window
^a<shift>a [new window name]

Wednesday, 24 October 2012

TCP slow start

Slow start is a congestion control strategy used by TCP.

On startup, and after an idle period, since the session doesn't know what the congestion on the network is, the session will start with a TCP congestion window of only 2 segments. This means the session will only send 2 segments and then wait for an ACK before exponentially increasing the congestion window.

With today's modern 10Gb networks, congestion is rarely an issue; and in a low-latency environment practitioners will often say "congestion be damned, send as much as we can and deal with the issues later!"

We can override the default setting on a route by route basis in linux by setting the initial congestion window size:


$ ip route show
10.80.32.0/22 dev eth0  proto kernel  scope link  src 10.80.33.247 
169.254.0.0/16 dev eth0  scope link 
127.0.0.0/8 dev lo  scope link 
default via 10.80.32.1 dev eth0 

Now we can change the congestion window size on the default route as follows:

$ sudo ip route change default via 10.80.32.1 dev eth0 proto static initcwnd 10



Friday, 12 October 2012

Fedora 17: Squeezebox server 7.7.2

Go to http://www.mysqueezebox.com/ download and select the Linux RPM.

It will automatically be opened with the Software Installer, resolve dependencies and install the required packages.

Nothing is ever that simple though!

The service wasn't started, and attempts to force it to start using systemctl failed too

    $ sudo systemctl start squeezeboxserver.service

Looking in /var/log/messages I found the following:

    squeezeboxserver[3040]: Starting Squeezebox Server: Can't locate Slim/bootstrap.pm in @INC (...details of the $INC path)

I then went to /usr to find all files which had anything with Logitech, Squeezebox or Slim in their path

    $ cd /usr

    $ find . | egrep -i logitec\|squeeze\|slim > /tmp/squeezbox.details

I then searched for the missing file (Slim/bootstrap.pm)

    $ grep bootstrap /tmp/squeezbox.details 
    ./lib/perl5/vendor_perl/Slim/bootstrap.pm

So I created a symbolic link to Slim in one of the directories in the $INC path

    $ sudo ln -sf /usr/lib/perl5/vendor_perl/Slim /usr/lib64/perl5/vendor_perl/Slim

It still failed to start, so I looked back in /var/log/messages

    squeezeboxserver[22941]: Starting Squeezebox Server: Can't locate Digest/MD5.pm in @INC 

Some perl modules were missing, which I installed with Yum

    $ sudo yum install perl-Log-Log4perl perl-CGI perl-YAML-LibYAML

Now the service started

    $ sudo systemctl start squeezeboxserver.service
    $ sudo systemctl status squeezeboxserver.service

squeezeboxserver.service - LSB: Startup script for the Logitech Media Server
 Loaded: loaded (/etc/rc.d/init.d/squeezeboxserver)
 Active: active (running) since Sat, 13 Oct 2012 13:25:40 +1100; 1min 36s ago

I had to open a few ports on my firewall to enable my player to connect (namely 3483 tcp and udp for the player, and 9000 tcp for the web-interface).

    $ system-config-firewall
    Other ports
    Add port 9000, tcp
    Add port 3483, tcp and udp

    Apply

go to localhost:9000 to configure

Fedora 17: Installation

I have an old Core 2 Duo with 1 500GB hard drive and 4 x 2TB hard drives stuffed in a cupboard.

I have created a 6TB software RAID drive from the 4 x 2TB drives, whilst the 500GB drive is the boot device.

Today I installed Fedora 17 with Gnome using the LiveUSB creator tool.

I used these instructions: http://fedoraproject.org/wiki/How_to_create_and_use_Live_USB

I downloaded the LiveUSB creator tool from here: http://fedorahosted.org/liveusb-creator

I downloaded the 64 bit Fedora 17 Desktop Edition with Gnome desktop manager from here: http://fedoraproject.org/en/get-fedora-options

My existing RAID configuration remained intact, and I installed over Fedora 16 I had on the 500GB drive.

The Quick Start guide make it trivial to set up... just follow the instructions on-screen.

Configure Auto-Login

Since I run this headless in a cupboard, I needed to configure it to automatically login.

Again this is trivial - Just go to System Settings - User Accounts - click on the Unlock button to enable changes, and select Auto Login