PHP Sessions on MS Azure Redis service

I sure hope you’ll never end up facing this, but in case you do indeed have a PHP application on MS Azure, and you want to use MS Azure Redis service for the session backend, you’ll have to set your session.save_path to something like:

session.save_path='tcp://UNIQUENAME.redis.cache.windows.net:6379?auth=MSHATESYOU4FUNandPROFIT=&timeout=1&prefix=OHNOMS'

Easy enough, unless your auth key happens to contain a + symbol. In that case, your PHP session creation will fail with this error:

# php count.php
PHP Fatal error:  Uncaught exception 'RedisException' with message 'Failed to AUTH connection' in count.php:3
Stack trace:
#0 count.php(3): session_start()
#1 {main}
  thrown in count.php on line 3
PHP Fatal error:  Uncaught exception 'RedisException' with message 'Failed to AUTH connection' in [no active file]:0
Stack trace:
#0 {main}
  thrown in [no active file] on line 0

From redis-cli the authentication was working fine, so it took us a while to debug. It ended up being a problem with the + symbol, and the the quickest solution in our case was to just regen the auth key so it didn’t have a + in it, but I suspect (but I didn’t test this solution) that URLencoding the + as %2B might work as well.

How to install and use SPICE for VMs in Debian, Ubuntu or Mint

SPICE is a suite of tools for interfacing with desktop-oriented Virtual Machines. I’ve been using it for a couple of years, on Fedora and CentOS systems, mostly for Windows VMs that I required for work.

Until recently, it was fairly complicated to get SPICE to work on Debian-based systems, but I’ve just installed and got it working on Mint. Thankfully, nowadays you don’t need to recompile anything. All the patches and support are included by default, and you need to install these packages:

# apt-get update
# apt-get install virt-manager libvirt-daemon python-spice-client-gtk qemu-kvm-spice virt-viewer spice-vdagent qemu-utils  gir1.2-spice-client-gtk-3.0 gir1.2-spice-client-gtk-2.0 gir1.2-spice-client-glib-2.0

After this, I just created a new VM with virt-manager and it had SPICE enabled by default.

For more information, I recommend checking:

Pacemaker cluster maintenance mode

This is intended as a quick reminder for all the sysadmins out there (me included) that keep forgetting the syntax while working on different environments.

For older clusters you would use:

crm configure property maintenance-mode=true

While for newer cluster you might want to use:

pcs property set maintenance-mode=true

Set the property to “false” to exit maintenance mode.

For reference, check the official Red Hat documentation.

How to start rails or puma (installed with rvm) with systemd

Just a few notes I took about how to start rails server or puma (installed with rvm) with systemd.

I started reading this question on StackOverflow, but it has no answers. Then I found out this gist containing an interesting example: it shows how to create a wrapper with rvm, and then how to use this wrapper to start the server.

I read more in systemd.service documentation and the rails command line documentation and wrote this (gist):

# based on https://gist.github.com/twtw/5494223
# create systemd service file for rails/puma startup
# 0. [if required: rvm use ruby@default]
# 1. rvm wrapper default systemd rails
# 2. put this file in /etc/systemd/system/rails-puma.service
# 3. systemctl enable rails-puma
# 4. systemctl start rails-puma
[Unit]
Description=Rails-Puma Webserver
 
[Service]
Type=simple
User=app
WorkingDirectory=/home/app/your-app
ExecStart=/home/app/.rvm/bin/systemd_rails server -e production
TimeoutSec=15
Restart=always
 
[Install]
WantedBy=multi-user.target

I didn’t get to test it yet, if it works for you let me know :)

How to find out the PCI address for a given ethernet device

This is something I was looking for since ages, because it could be useful for automating deployiments on bare metal.

When building bond interfaces, something you really want is to bond devices on different hardware paths, for example one embedded ethernet and one from a PCI lane.

On recent Linux systems (CentOS 6.x), you can use udevadm info to find out the PCI address for your interfaces:

# for E in eth{0..3} ; do echo $E ; udevadm info --query=path --path=/sys/class/net/${E} ; done
eth0
/devices/pci0000:00/0000:00:01.1/0000:02:00.0/net/eth0
eth1
/devices/pci0000:00/0000:00:01.1/0000:02:00.1/net/eth1
eth2
/devices/pci0000:00/0000:00:02.0/0000:04:00.0/net/eth2
eth3
/devices/pci0000:00/0000:00:02.0/0000:04:00.1/net/eth3

So on this system I want to bind eth0+2 and eth1+3.

For reference, I found the original info on this (outdated) Linux Questions post.