Sunday, December 18, 2011

Mac 10.7, python-ldap, MySQL-python, homebrew

I configured a Mac 10.7 machine to resume writing a Python program I had to put on hold. I needed python-ldap and found a guide on how to get it working on Lion. I was also introduced to homebrew in the process. I also found a workaround for MySQL-python on Lion.

Wednesday, November 9, 2011

RHEL6 latency on Dell M610: C States

We ran into latency problems on Dell M610 servers using RHEL6 while RHEL5 performed perfectly. The RHEL6 stock kernel has a module called intel_idle which ignores Dell's BIOS settings to disable C-states. We've set the following in the tail of the boot line in /etc/grub.conf and so far so good.

intel_idle.max_cstate=0 processor.max_cstate=1
When I started here six years ago we had a DNS server with a similar problem solved basically the same way; with a "acpi=off" to disable ACPI.

Update: The above seems to have helped servers connected to the SAN but not one which just uses the local disk. RedHat had some interesting tweaks to try with MegaCli, hdparm, and the scheduler as they think it's IO related:

Set policy to cache data:

# MegaCli64 -LDSetProp -Cached -LAll -aAll
Enable disks' cache:
# MegaCli64 -LDSetProp EnDskCache -LAll -aAll
# MegaCli64 -LDSetProp ADRA -LALL -aALL
Enable write cache, but first verify if the controller is battery backed:
# MegaCli64 -AdpBbuCmd -GetBbuStatus -a0 | grep -e '^isSOHGood' -e '^Charger Status' 
If the above results display no BBU, do not proceed.
If we have a battery backed controller, enable write cache.
# MegaCli64 -LDSetProp WB -LALL -aALL
If battery fails or is discharged, disable write cache:
# MegaCli64 -LDSetProp NoCachedBadBBU -LALL -aALL
Verify policy is Enabled:
# MegaCli64 -LDInfo -LAll -aAll |grep 'Disk Cache'
Disk Cache Policy: Enabled
Disable local device caching:
# hdparm -W0 /dev/sda
- Add the above to /etc/rc.local to persist reboots.
Edit /etc/fstab and modify the mount options, ie: 
/dev/mapper/vg_root-lv_root / ext4 defaults,nobarriers,data=writeback 1 1
...
...
The filesystem(s) would need be remounted for changes to take effect.
Next, we will change the scheduler to Deadline.
# echo 'deadline' > /sys/block/sda/queue/scheduler
# echo 200 > /sys/block/sda/queue/iosched/read_expire
# echo 500 > /sys/block/sda/queue/iosched/write_expire
- Add the above commands to /etc/rc.local to persist reboots.

Monday, October 31, 2011

KVM PCI device assignment

My coworker is setting up KVM PCI device assignment to get around a problem he had with assigning more than four drives per server. Normally we'd just use clustered LVM and assign drives directly from the SAN by editing that VMs XML file contained in /etc/libvirt/qemu/ . However, this is the first time we've needed more than four drives per VM and KVM will only allow 4 drives per server since we're limited to a single disk controller.

Update: Turns out this was not a good idea since the VM would monopolize the device on the physical machine; e.g. the VM would get an HBA to the SAN.

Update 2: Using NPIV seems to be the right thing for this.

Monday, October 10, 2011

MySQL: replace into

I am having one of those nights where I appreciate Shlomi Noach's REPLACE INTO: think twice. "REPLACE INTO" is not a conditional insert or update based on if the same key exists. It's better thought of as a conditional insert OR delete then insert query. This will get you if you're trying to do a field_name=field_name in your query to preserve it's value as you would do with an update since the original field_value would be lost. I re-wrote my query to do a "INSERT ... ON DUPLICATE KEY UPDATE" instead.

Monday, September 26, 2011

web.py on Mac OS X 10.7

Lion comes with Python 2.7.1 and easy_install is working so all you have to do is:
$ sudo easy_install web.py
Password:
Searching for web.py
Reading http://pypi.python.org/simple/web.py/
Reading http://webpy.org/
Best match: web.py 0.36
Downloading http://pypi.python.org/packages/source/w/web.py/web.py-0.36.tar.gz#md5=3f9ee778c5c34357a0233c1f0e024d00
Processing web.py-0.36.tar.gz
Running web.py-0.36/setup.py -q bdist_egg --dist-dir /tmp/easy_install-qC65Ak/web.py-0.36/egg-dist-tmp-CjDoLl
zip_safe flag not set; analyzing archive contents...
web.application: module references __file__
web.debugerror: module references __file__
Adding web.py 0.36 to easy-install.pth file

Installed /Library/Python/2.7/site-packages/web.py-0.36-py2.7.egg
Processing dependencies for web.py
Finished processing dependencies for web.py
$  
You might also be interested in Setting up PHP & MySQL on OS X 10.7 Lion to get it working with MySQL.