Archive

Monthly Archives: August 2013

Today I decided to try out  memcached for php sessions instead of files.

Memcached is a server, that runs on port 11211 (by default). By installing a Php extensions and configuring php.ini you can save session data in RAM instead of on disk. 

First, you will need to grab some dependencies:

yum install memcached php-pecl-memcached phpMemcachedAdmin

You will need the EPEL repo to install the php extension and the option web interface to memcached.

Start up memcached and enable on boot:

service memcached start
chkconfig memcached on

Give yourself access to phpMemcachedAdmin by editing /etc/httpd/conf.d/phpMemcachedAdmin.conf:

<IfModule !mod_authz_core.c>
    # Apache 2.2
    Order Deny,Allow
    Deny from All 
    Allow from 127.0.0.1
    Allow from <YOUR IP HERE>
    Allow from ::1 
 </IfModule>

You can access the interface at http://<SERVER IP>/phpMemcachedAdmin

Update the following in php.ini:

session.save_handler = memcached
session.save_path = "127.0.0.1:11211"

Restart apache and you should be all set

service httpd restart

Watch the phpMemcachedAdmin interface as your application starts using sessions.

Now to run some benchmarks and see if I get any performance gains, if not than at least I could use memcached to host sessions for multiple app servers.

Advertisements

UPDATE 2/25/2014:

Chris Cappuccio has posted instructions that are MUCH better. Go follow those instead: http://undeadly.org/cgi?action=article&sid=20140225072408

I found a couple of links that suggested using qemu to install OpenBSD to a flash drive. I took the advice in those links and instead of using qemu, I booted from an install CD and installed directly to a USB drive. I then used that USB drive to do the install onto a CD-ROM-less machine.

I might try the qemu route later but this is what worked for me, perhaps it will help someone else.

You will need:

  • Blank CD-R
  • USB Drive +1GB
  • PC with CD-ROM Burner and USB Port
  • OpenBSD install media (installXX.iso)

The install iso can be found at a location such as <MIRROR>/pub/OpenBSD/<RELEASE>/<ARCH>/

Burn the install iso to the CD-R and boot it with the USB drive plugged into the machine. Install OpenBSD to your USB drive, it should be sd0.

Be sure to use DUID’s in the fstab when prompted (this will be the default). When installing sets you will only need “bsd”, “bsd.rd”, “baseXX.tgz”, and “etcXX.tgz”. You can select only those sets by typing de-selecting them all, then adding the needed sets individually:

  • “-all”
  • “+bsd”
  • “+bsd.rd”
  • “+base*”
  • “+etc*”

After installing those sets, the installer will ask if you’re sure you want to omit “bsd.mp”, confirm that you do not want it. You should now have a root prompt. You will need to copy the install scripts to the USB drive before leaving.

# mount /dev/cd0a /mnt2
# cp -r /mnt2/X.X /mnt
# halt

Replace /mnt2/X.X with the version that you are installing such as “/mnt2/5.3”.

Now that you have the OS installed to the USB drive, plug it into your target machine and boot. At the boot screen you will need to type “bsd.rd” like so:

boot> bsd.rd

You can install as usual but there will be one difference. When prompted to install sets you will need to choose “disk”. The installer will then ask if the disk partition is already mounted. Choose “no” and when prompted choose the USB Drive, it will usually be sd0 but in my case it was actually sd1. The sets will be on partition “a”.

These instructions were adapted from the following links. if something isn’t clear in my instructions check these out, they were very helpful to me: