Ubuntu 14.04 – Memcached server for WordPress

First thing first: memcache vs memcached

According to http://blackbe.lt/php-memcache-vs-memcached/
PHP has two separate module implementations wrapping the memcached (as in memcache daemon) server.

The memcache module utilizes this daemon directly, whereas the memcached module wraps the libMemcached client library and contains some added bonuses.
Memcached module will be faster than memcache module => I’ll go with Memcached module

Install Memcached daemon on my dedicate Memcached host

sudo apt-get install memcached libmemcached-tools

My memcache server listen all of its address. So edit /etc/memcached.conf
-m 20000      #amount of RAM in MB
-p 11211      #listen port 11211
-l 0.0.0.0    #listen on all interfaces

Install memcached client
In other WordPress PHP server we need to install memcahed client and server (optional):
sudo apt-get install php5-memcached memcached libmemcached-tools php-pear

sudo mkdir /etc/php5/conf.d
ln -s /etc/php5/mods-available/memcached.ini /etc/php5/conf.d/memcached.ini
I need to store Php sessions in Memcached because store in memory will be faster than disk 
Default is session.save_handler = files
Add to /etc/php5/conf.d/memcached.ini
[Session]
session.save_handler = memcached
session.save_path = “tcp://localhost:11211”
WordPress and Memcached
Finally edit WordPress wp-config file to add list of Memcached server for WordPress Total cache plugin

global $memcached_servers;
$memcached_servers = array(‘default’ => array(‘192.1.3.30:11211′,’192.1.1.11:11211′,’192.1.1.12:11211’));

Now your WordPress can Memcached it.

Ubuntu 14.04 – Canon E500 network printing and scanning at home

Recently switch my Mom machine from Windows 7 to Ubuntu Gnome 14.04 which’s my favorite one. So I need to share Canon E500 (USB) printing and scanning for my other devices over Network.
I set this host with static IP: 192.168.1.10

Install Canon E500 driver

sudo add-apt-repository ppa:inameiname/stable

sudo apt-get update -y
sudo apt-get install -y cnijfilter-e500series scangearmp-e500series
Now I can add the printer from Printer Config
For Scanner: I use ScanGear instead of Simple Scan

Sharing Printer

This step is share printing service over network
Cups printing running on port 631 localhost -> go to CUPS admin at http://localhost:631/admin
In the Server part setting: Check these options
  • Share printers connected to this system
  • Allow printing from the Internet
  • Allow remote administration
  • Allow users to cancel any job (not just their own)  //this is my home purpose
=> Change Settings -> wait for Cup restarting
Manage E500 printer via CUPS. Now we need to access CUPS by its IP address, I also leave the printer name as E500-series
http://192.168.1.10:631/printers  make sure the printer E500-series is available otherwise add it to
From here you can print any test pages, maintenance, etc…I don’t need to set any allowed user. Just me and my mom

Sharing Scanner

On the server (E500 connect directly via USB) tell sane to run as server
sudo vi /etc/default/saned
Run=no -> Run=yes
Allow user from my subnet
sudo vi /etc/sane.d/saned.conf
## Access list
192.168.1.0/24
service saned restart
On the client
sudo vi  /etc/sane.d/net.conf
## saned hosts
192.168.1.10
connect_timeout = 60
Open Xsane and wait for Scanner discovery

Ubuntu server 14.04 – Auto mount network Drive Issue

Recently, due to maintanance upgrade I have to reboot my Server and notice that it stuck at boot screen waiting for external Network drive to mount. Previous article ubuntu-server-auto-mount-iscsi-storage

The message is “the disk drive for /backupdata is not ready or not presented”. 2 things I can do:

Remount network drive with UUID instead of /dev/blah..blah in /etc/fstab

#> blkid

/dev/mapper/datavg-backupdata: UUID=”85e81bbc-2c86-4bef-b1e9-f77d21929de5″ TYPE=”xfs” 

Add nobootwait option into mount target in /etc/fstab

UUID=85e81bbc-2c86-4bef-b1e9-f77d21929de5 /backupdata xfs auto,rw,user,nobootwait 0 0

Then reboot my system and It work!

Ubuntu server auto mount iSCSi storage

Install Open-iSCSI initiator

apt-get install open-iscsi

configuration file could be located at /etc/iscsi/iscsid.conf or ~/.iscsid.conf.

node.startup = automatic
node.session.auth.username = MY-ISCSI-USER
node.session.auth.password = MY-ISCSI-PASSWORD
discovery.sendtargets.auth.username = MY-ISCSI-USER
discovery.sendtargets.auth.password = MY-ISCSI-PASSWORD

Discover iSCSi Target

iscsiadm -m discovery -t sendtargets -p 172.31.1.150

Login to target

iscsiadm –mode node –targetname iqn.1992-04.com.emc:cx.fcnma082600013.a0 –portal 172.31.1.150 –login

Note: remember login to your iSCSi server (SAN) then allow your server connection
Make sure you auto connect to iSCSi server target when server start up

vi /etc/iscsi/nodes/iqn.1992-04.com.emc:cx.fcnma082600013.b1/172.31.2.151,3260,3/default

node.startup = automatic

Restart service

/etc/init.d/open-iscsi restart

Format and mount the iSCSi volume

dmesg or fdisk -l, or look at /var/log/messages to find new devices
You can use LVM or partition your disk now

fdisk /dev/sde

Format a partition ext4 or xfs or brtfs

mkfs.ext4 /dev/sde1

Mount file system

mkdir /backupdata
mount /dev/sde1 /backupdata

Add mount point to /etc/fstab 

/dev/sde1  /backupdata ext4 defaults 0 0

Bonding Network Card Ubuntu 14.04

Make sure your Cisco Switch support 802.3ad, then group 2 interface ports together

Router> enable
Router# configure terminal
Router(config)# interface port-channel 1
Router(config-if)# interface g1/0/24
Router(config-if)# channel-group 1 mode active
Router(config-if)# exit
Router(config)# interface g1/0/23
Router(config-if)# channel-group 1 mode active
Router(config-if)# end
Router# copy run start

Bonding mode: http://www.mjmwired.net/kernel/Documentation/networking/bonding.txt#508
802.3ad or 4 : IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

Bonding network card on Ubuntu Server

apt-get install ifenslave-2.6
echo “bonding” >> /etc/modules
modprobe bonding

vi /etc/network/interface

auto em1
iface em1 inet manual
bond-master bond0
bond-primary em1

auto em2
iface em2 inet manual
bond-master bond0

auto bond0
iface bond0 inet static
bond-slaves none
bond-mode 4
bond-miimon 100
        address 192.168.1.111
        netmask 255.255.0.0
        network 192.168.0.0
        broadcast 192.168.255.255
        gateway 192.168.1.1
        dns-nameservers 192.168.1.1 

Reboot server and wait a little bit for the bond interface become active

http://www.paulmellors.net/ubuntu-server-14-04-lts-nic-bonding/
http://ilostmynotes.blogspot.com/2009/04/bridging-bonded-network-interface-on.html

Ubuntu – 3 tricks to copy DVD into iso file

Built in command

cat /dev/sr0 > /home/Documents/mydisk.iso
dd if=/dev/sr0 of=/home/Documents/mydisk.iso

If both cat, and dd not work because of ‘/dev/sr0’: Input/output error
If I run dmesg, I recieve a lot of Buffer I/O error on device sr0

Try ddrescue in Ubuntu the package is gddrescue

sudo apt-get install gddrescue
ddrescue –direct –block-size=2048 –no-split /dev/sr0 /home/Documents/mydisk.iso

Now you can open iso file with VLC