Tuesday, September 30, 2014

PHP: Fatal Error: Allowed Memory Size of X Bytes Exhausted

In case Ganglia's web page is unreachable while Apache is working, check Apache's error log for the following error:
PHP: Fatal Error: Allowed Memory Size of XXXXXX Bytes Exhausted
To solve this, we need to increase the size limit by using the following command:
## XXXM or -1 to set no limit at all.
sed -i 's/memory_limit.*/memory_limit = 512M/g' /etc/php.ini
OR
sed -i 's/memory_limit.*/memory_limit = -1/g' /etc/php.ini

Operation mds_connect failed with -11

When getting the following error:
kernel: LustreError: 11-0: fs01-MDT0000-lwp-MDT0000: Communicating with 0@lo, operation mds_connect failed with -11.
Please make sure to create MGS, MDT and at least one OST before starting the services.

Postfix: no local interface found for ::1

The following error can been seen in logs after disabling IPv6:
May 30 19:04:58 master postfix[16588]: fatal: parameter inet_interfaces: no local interface found for ::1
This prevents postfix from starting, to fix it use the following command:
sed -i 's/^inet_protocols = all/inet_protocols = ipv4/g' /etc/postfix/main.cf 
Start postfix :) :
service postfix start 

OpenCV 2.4.8 How_to_scan_images.cpp error

If you enocunter the following error:
make[2]: *** [samples/cpp/CMakeFiles/tutorial_how_to_scan_images.dir/tutorial_code/core/how_to_scan_images/how_to_scan_images.cpp.o] Error 1make[1]: *** [samples/cpp/CMakeFiles/tutorial_how_to_scan_images.dir/all] Error 2
Edit the CMake file and remove the building of examples:
sed -i 's/BUILD_EXAMPLES:BOOL=ON/BUILD_EXAMPLES:BOOL=OFF/g' CMakeCache.txt

OpenCV 2.4.8 Freak.cpp Error

If you encounter the following errors while trying to compile OpenCV 2.4.8 with Python 2.7.5:
OpenCV-2.4.3/modules/features2d/src/freak.cpp:437: error: unable to find a register to spill in class 'GENERAL_REGS'
OR
Generating pyopencv_generated_funcs.h, pyopencv_generated_func_tab.h, pyopencv_generated_types.h, pyopencv_generated_type_reg.h, pyopencv_generated_const_reg.h
Edit the following file using vi or any other text editor:
vi modules/features2d/CMakeFiles/opencv_features2d.dir/build.make
Search for freak.cpp and add -O0 after each $(CXX_FLAGS), it should look like this:
/usr/bin/c++   $(CXX_DEFINES) $(CXX_FLAGS) -O0 -o CMakeFiles/opencv_features2d.dir/src/freak.cpp.o -c /root/Downloads/Python_Project/opencv-2.4.8/modules/features2d/src/freak.cpp
/usr/bin/c++  $(CXX_DEFINES) $(CXX_FLAGS) -O0 -E /root/Downloads/Python_Project/opencv-2.4.8/modules/features2d/src/freak.cpp > CMakeFiles/opencv_features2d.dir/src/freak.cpp.i
/usr/bin/c++  $(CXX_DEFINES) $(CXX_FLAGS) -O0 -S /root/Downloads/Python_Project/opencv-2.4.8/modules/features2d/src/freak.cpp -o CMakeFiles/opencv_features2d.dir/src/freak.cpp.s

Install Skype on Debian

Add the i386 repository:
dpkg --add-architecture i386
Update all repositories:
sudo apt-get update
Download the multi arch version of Skype:
http://www.skype.com/en/download-skype/skype-for-computer/
Install the package:
dpkg -i skype-install.debsudo apt-get -f install

Install Viber on Debian

Download viber from the following site:
wget http://download.cdn.viber.com/cdn/desktop/Linux/viber.deb
Install the package using dpkg:
dpkg -i viber.deb
Open it and start using Viber.

Viber: Version `GLIBC_2.24' Not Found

If the following error appears after trying to execute Viber.sh on Debian Wheezy manually:
/usr/share/viber/Viber.sh 
/usr/share/viber/Viber: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.24' not found (required by /usr/share/viber/Viber)
You need the latest version of glibc, to do that add the following to /etc/apt/sources.list:
sudo vi /etc/apt/sources.list
deb http://debian.co.il/debian/ testing main
deb-src http://debian.co.il/debian/ testing main
Update apt and install the latest glibc library:
sudo apt-get update
sudo apt-get -t testing install libc6

XenServer restarts unexpectedly

When configuring HA through the gui, the default timeout in case of a failure is 30 seconds. It's important to increase it to avoid unnecessary restarts:

1. Disable HA through the GUI.
2. Connect to the Pool Master and type the following:
xe pool-ha-enable heartbeat-sr-uuids=<NFS's SR Storage> ha-config:timeout=<TimeInSeconds>

Xen Server NFS timeout

To change the timeout of the NFS mounts:
vi /opt/xensource/sm/nfs.py xen
Change the mathematical expression from:
SOFTMOUNT_TIMEOUT  = int((40.0/3.0) * 10.0) # 1/10 s
To the desired timeout, change only the 10.0 value:
SOFTMOUNT_TIMEOUT  = int((40.0/3.0) * 40.0) # 1/10 s

Installing Xen Server updates

Upload the patch to the server:
xe patch-upload -s <hostname> -u root -pw <password>file-name=<path to xsupdate file>
Apply the patch to the master server:
xe -s <hostname> -u root -pw <password> patch-pool-apply uuid=<uuid from the step 1's output>
Verify that the servers were updated:
xe patch-list -s <hostname> -u root -pw <password> name-label=<Updates ID>

Verifying who the master is

Run the following command to find a server with the master role:
xe pool-list params=uuid,master
Copy the UUID of the server and paste it in the following template:
xe host-list uuid=<uuid from last step>

Could not parse arguments: Cannot open display:

The following error appears after disabling IPv6:
Could not parse arguments: Cannot open display:
This is a known bug that hasn't been fixed yet, to fix it use the following command (it instructs sshd not to use IPv6):
 sed -i 's/#AddressFamily any/AddressFamily inet/' /etc/ssh/sshd_config

Deleting unnecessary osimages

To get the list of all images use the following and then decide which you don't want to keep around:
lsdef -t osimage
To delete images that you don't need use the following command:
rmdef -t osimage -o <imageName>

xCAT 2.8.5 stateless bug

When trying to create a stateless xCAT image using the following commands:
  1. genimage centos6.5-x86_64-netboot-compute
  2. packimage centos6.5-x86_64-netboot-compute
  3. nodeset n1 osimage=centos6.5-x86_64-netboot-compute
The following error appears when trying to boot the node:
dracut: FATAL: No or empty root= argument
dracut: Refusing to continue
/lib/dracut-lib.sh: line 101: /emergency/01-die.sh: No such file or directory
dracut Warning: Signal caught! (when trying to boot the machine).
The problem is that there is a directory missing, it was skipped by xCAT installation for some reason, therefore, we need to create it manually:
  1. cd /opt/xcat/share/xcat/netboot
  2. ln -s ../rh/dracut dracut
Repeat the three commands above and you all set to go ! 

Modify partitioning in xCAT's images

To modify the partition layout, edit /opt/xcat/share/xcat/install/scripts/pre.rh at line 274:
vi /opt/xcat/share/xcat/install/scripts/pre.rh
echo "part /boot --size 256 --fstype $BOOTFSTYPE --ondisk $instdisk" >> /tmp/partitioning
echo "part swap --recommended --ondisk $instdisk" >> /tmp/partitioning
echo "part / --size 1 --grow --ondisk $instdisk --fstype $FSTYPE" >> /tmp/partitioning

Save history immediately

To force bash to save each command you type instead of waiting for the session to terminate, edit .bash_profile that is located in your home directory:
vi ~/.bash_profile
export PROMPT_COMMAND='history -a'

Don't store specific commands in history

To force bash not to save duplicate commands, edit .bash_profile that is located in your home directory:
vi ~/.bash_profile
export HISTCONTROL=ignoredups
To force bash not to save lines that start with a space, edit .bash_profile that is located in your home directory:
vi ~/.bash_profile
export HISTCONTROL=ignorespace
To force bash not to save both(space and duplicates), edit .bash_profile that is located in your home directory:
vi ~/.bash_profile
export HISTCONTROL=ignoreboth

Increase history size limit

To increase your history size limit, edit .bash_profile that is located in your home directory:
vi ~/.bash_profile
export HISTSIZE=
export HISTFILESIZE=

Disable IPv6 on CentOS 6

To disable IPv6 on CentOS 6, run the following commands:
echo 'net.ipv6.conf.all.disable_ipv6 = 1' >> /etc/sysctl.conf
echo 'net.ipv6.conf.default.disable_ipv6 = 1' >> /etc/sysctl.conf
echo 'NETWORKING_IPV6=no' >> /etc/sysconfig/network

Clearing Auditlog/Auditlog

From time to time, these tables gets pretty big, it is recommended to clear them once a week:
tabprune eventlog -a
tabprune auditlog -a
Also, it is recommended to create a cron job that will do it automatically:
crontab -e
00 00 * * Sun /opt/xcat/sbin/tabprune auditlog -a
00 00 * * Sun /opt/xcat/sbin/tabprune eventlog -a

Backup and Restore xCAT DB

To backup the current xCAT database, run the following command:
dumpxCATdb -p /path/to/save/xcatdb
To restore the database, use the following command:
restorexCATdb -p /path/where/xcatdb/was/saved

Install ClusterSSH on CentOS 6

ClusterSSH is a tool to control multiple machines using ssh at the same time, basically it opens a few xterm windows and what ever you type is being typed at all the windows. 

1. Download and install EPEL repository:

yum install -y http://mirror.nonstop.co.il/epel/6/i386/epel-release-6-8.noarch.rpm
2. Install ClusterSSH using Yum:
yum install clusterssh -y
3. Create a file named clusters in /etc/:
vi /etc/clusters
clusters = clusternameclustername = hostname1 hostname2 hostname3
4. At the terminal, execute the following command:
cssh clustername