<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Vtrio Sysadmins &#187; Misc</title>
	<atom:link href="https://sysadmin.vtrio.com/?cat=10&#038;feed=rss2" rel="self" type="application/rss+xml" />
	<link>https://sysadmin.vtrio.com</link>
	<description></description>
	<lastBuildDate>Fri, 11 May 2018 07:40:10 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>Authentication in mongodb</title>
		<link>https://sysadmin.vtrio.com/?p=135</link>
		<comments>https://sysadmin.vtrio.com/?p=135#comments</comments>
		<pubDate>Thu, 08 May 2014 11:50:28 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=135</guid>
		<description><![CDATA[Mysql databases allow username and password. Similarly if you require to keep authentication for your mongodb database as well, please do the following. Suppose, I have a database named abc, and I need to create a user named abc with password abc123. First, create an admin user. root@abc:~# mongo MongoDB shell version: 2.4.10 connecting to:]]></description>
				<content:encoded><![CDATA[<p>Mysql databases allow username and password. Similarly if you require to keep authentication for your mongodb database as well, please do the following. Suppose, I have a database named abc, and I need to create a user named abc with password abc123.</p>
<p>First, create an admin user.</p>
<p>root@abc:~# mongo<br />
MongoDB shell version: 2.4.10<br />
connecting to: test<br />
&gt; use admin<br />
&gt; db.addUser(&#8220;admin&#8221;, &#8220;admin&#8221;)</p>
<p>&gt; use abc                   (Switch to the database abc)</p>
<p>&gt; db.addUser(&#8220;abc&#8221;, &#8220;abc123&#8243;)</p>
<p>Quit the mongoshell and stop mongo</p>
<p>root@abc:~# /etc/init.d/mongodb stop</p>
<p>root@abc:~# vi /etc/mongodb.conf    and make the following change</p>
<p>auth = true</p>
<p>root@abc:~#/etc/init.d/mongodb start</p>
<p>Now we need to test if authentication works. Which means, if not authenticated, you should not be able to saw the details of the database.</p>
<p>root@abc:~# mongo<br />
MongoDB shell version: 2.4.10<br />
connecting to: test</p>
<p>&gt; use abc</p>
<p>&gt; show collections</p>
<p>&#8220;$err&#8221; : &#8220;not authorized for query on abc.system.namespaces&#8221;,<br />
&#8220;code&#8221; : 16550</p>
<p>Now it shows the error that you are not authorized to view the collections. Now, authenticate with the details you created earlier and try.</p>
<p>&gt; db.auth(&#8220;abc&#8221;, &#8220;abc123&#8243;)<br />
&gt;show collections<br />
testcollection<br />
system.indexes</p>
<p>This is how you create a user for mongodb database.</p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=135</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Accessing Gmail with Roundcube</title>
		<link>https://sysadmin.vtrio.com/?p=132</link>
		<comments>https://sysadmin.vtrio.com/?p=132#comments</comments>
		<pubDate>Thu, 08 May 2014 11:27:07 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Cpanel]]></category>
		<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=132</guid>
		<description><![CDATA[Requirement : I want to access my gmail under my own domain with the help of webmail. Say my domain name is abc.com , I want to access it as http://abc.com/mail Suppose I am on a cpanel server. Download and install Roundcube as follows. root@me [/home/abc/public_html]# wget http://downloads.sourceforge.net/project/roundcubemail/roundcubemail/1.0.0/roundcubemail-1.0.0.tar.gz root@me [/home/abc/public_html]# tar -xzvf roundcubemail-1.0.0.tar.gz root@me [/home/abc/public_html]#]]></description>
				<content:encoded><![CDATA[<p>Requirement : I want to access my gmail under my own domain with the help of webmail.</p>
<p>Say my domain name is abc.com , I want to access it as http://abc.com/mail</p>
<p>Suppose I am on a cpanel server. Download and install Roundcube as follows.</p>
<p>root@me [/home/abc/public_html]# wget http://downloads.sourceforge.net/project/roundcubemail/roundcubemail/1.0.0/roundcubemail-1.0.0.tar.gz</p>
<p>root@me [/home/abc/public_html]# tar -xzvf roundcubemail-1.0.0.tar.gz</p>
<p>root@me [/home/abc/public_html]# mv roundcubemail-1.0.0 mail</p>
<p>root@me [/home/abc/public_html]# chown -R abc:abc mail</p>
<p>root@me [/home/abc/public_html]# cd mail</p>
<p>Now login to your cpanel and create a database for roundcube installation, create a database user and assign privileges. This can all be done from cpanel.</p>
<p>Once done, go to the installer link as  http://abc.com/mail/installer, follow the on screen instructions, make sure to give the database details correct and do not overwrite or create any conflict with the existing roundcube installation that comes with cpanel.</p>
<p>Once the installation is done, there are two files which requires attention.</p>
<p>&nbsp;</p>
<p>root@me [/home/abc/public_html/mail]# cd  /home/abc/public_html/mail/config</p>
<p>Make sure the config.inc.php and defaults.inc.php are populated with the correct database details.</p>
<p>root@me [/home/abc/public_html/mail/config]# vi defaults.inc.php    and edit the following fields</p>
<p>// IMAP Settings<br />
$rcmail_config[&#8216;default_host&#8217;] = &#8216;ssl://imap.gmail.com';<br />
$rcmail_config[&#8216;defaul_port&#8217;] = 993;<br />
$rcmail_config[&#8216;imap_auth_type&#8217;] = null;<br />
$rcmail_config[&#8216;username_domain&#8217;] = &#8216;yourdomainname';  // Give the domain name that use googleapps. If you are using gmail account, give gmail.com<br />
$rcmail_config[&#8216;mail_domain&#8217;] = &#8216;yourdomainname';           // Give the domain name that use googleapps. If you are using gmail account, give gmail.com<br />
// SMTP Settings<br />
$rcmail_config[&#8216;smtp_server&#8217;] = &#8216;ssl://smtp.gmail.com';<br />
$rcmail_config[&#8216;smtp_port&#8217;] = 465;<br />
$rcmail_config[&#8216;smtp_user&#8217;] = &#8216;%u';<br />
$rcmail_config[&#8216;smtp_pass&#8217;] = &#8216;%p';<br />
//MBOX Settings<br />
$rcmail_config[&#8216;drafts_mbox&#8217;] = &#8216;[Gmail]/Drafts';<br />
$rcmail_config[&#8216;junk_mbox&#8217;] = &#8216;[Gmail]/Spam';<br />
$rcmail_config[&#8216;sent_mbox&#8217;] = &#8221;;<br />
$rcmail_config[&#8216;trash_mbox&#8217;] = &#8221;;</p>
<p>Save and quit the file. Remove the installer folder.</p>
<p>root@me [/home/abc/public_html/mail/config]# rm -rf /home/abc/public_html/mail/installer</p>
<p>&nbsp;</p>
<p>Now access your gmail through your roundcube installation.</p>
<p>http://abc.com/mail</p>
<p>Username : test   if my gmail account is test@gmail.com</p>
<p>Password : test123    if my gmail pass is test123</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=132</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Migrating emails from mailenable to exim</title>
		<link>https://sysadmin.vtrio.com/?p=130</link>
		<comments>https://sysadmin.vtrio.com/?p=130#comments</comments>
		<pubDate>Thu, 08 May 2014 11:24:58 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=130</guid>
		<description><![CDATA[If you want to copy emails from a windows mailenable server to linux server with exim, you can do it as follows. I am copying the email account test@abc.com to new server. Its password is test123c on both servers. root@abc [~]# cd /usr/local/src/ root@abc [/usr/local/src]#  wget http://home.arcor.de/armin.diehl/imapcopy/imapcopy.tar.gz root@abc [/usr/local/src]#  tar -xvf imapcopy.tar.gz root@abc [/usr/local/src]# cd]]></description>
				<content:encoded><![CDATA[<p>If you want to copy emails from a windows mailenable server to linux server with exim, you can do it as follows.</p>
<p>I am copying the email account test@abc.com to new server. Its password is test123c on both servers.</p>
<p><strong>root@abc [~]# cd /usr/local/src/</strong></p>
<p><strong>root@abc [/usr/local/src]#  wget http://home.arcor.de/armin.diehl/imapcopy/imapcopy.tar.gz<br />
<strong></strong></strong></p>
<p>root@<strong>abc </strong> [/usr/local/src]#  tar -xvf imapcopy.tar.gz</p>
<p>root@<strong>abc </strong> [/usr/local/src]# cd imapcopy</p>
<p>root@<strong>abc </strong> [/usr/local/src/imapcopy]# ls<br />
./  ../  imapcopy*  ImapCopy.cfg</p>
<p>root@<strong>abc </strong> [/usr/local/src/imapcopy]# cp -pv ImapCopy.cfg ImapCopy.cfg.original</p>
<p>`ImapCopy.cfg&#8217; -&gt; `ImapCopy.cfg.original&#8217;</p>
<p>root@<strong>abc </strong> [/usr/local/src/imapcopy]# vi ImapCopy.cfg<br />
You need to edit the following values to make the migration smoother.</p>
<p>##############<br />
# Sourceserver<br />
##############<br />
SourceServer 1.2.3.4 (Source Server IP Address)<br />
SourcePort 143<br />
###################<br />
# Destinationserver<br />
###################<br />
DestServer localhost<br />
DestPort 143</p>
<p>#############################<br />
# List of users and passwords<br />
#############################</p>
<p>#       SourceUser    SourcePassword   DestinationUser  DestinationPassword<br />
Copy   &#8220;test@abc.com&#8221;  &#8220;test123c&#8221; &#8220;test@abc.com&#8221;  &#8220;test123c&#8221;</p>
<p>[/stextbox]</p>
<p>Make sure you are able to connect to port 143 of source server from destination server</p>
<p>[stextbox id=&#8221;info&#8221;]</p>
<p>root@<strong>abc </strong> [/usr/local/src/imapcopy]# telnet 1.2.3.4  143<br />
Trying 1.2.3.4&#8230;<br />
Connected to abc.greproot.com (1.2.3.4).<br />
Escape character is &#8216;^]&#8217;.<br />
* OK IMAP4rev1 server ready at 05/07/14 05:46:17<br />
^]<br />
telnet&gt; q<br />
Connection closed.<br />
[/stextbox]</p>
<p>Now test the configuration</p>
<p>[stextbox id=&#8221;info&#8221;]</p>
<p>root@<strong>abc </strong> [/usr/local/src/imapcopy]# ./imapcopy -t<br />
IMAPCopy 1.04 &#8211; 2009/07/18 [compiled with FreePascal]<br />
written 2001-2009 by Armin Diehl &lt;ad@ardiehl.de&gt;<br />
Running on Linux</p>
<p>Login on sourceserver as test@abc.com OK<br />
Login on destinationserver as test@abc.com OK<br />
Getting folderlist on sourceserver OK, found 1 folder</p>
<p>1 User processed, 0 Messages copied, 0 Error(s)<br />
0 Folder(s) created, 0 Folder create errors, 0 Folder not copied<br />
[/stextbox]</p>
<p>The configuration looks fine without any errors. Now we can start copying the email account contents.</p>
<p>[stextbox id=&#8221;info&#8221;]</p>
<p>root@abc [/usr/local/src/imapcopy]#./imapcopy<br />
IMAPCopy 1.04 &#8211; 2009/07/18 [compiled with FreePascal]<br />
written 2001-2009 by Armin Diehl &lt;ad@ardiehl.de&gt;<br />
Running on Linux</p>
<p>Login on sourceserver as test@abc.com OK<br />
Login on destinationserver as test@abc.com OK<br />
Getting folderlist on sourceserver OK, found 1 folder<br />
Getting List of messages in &#8220;INBOX&#8221; OK, 7 Messages found<br />
Processing Folder INBOX<br />
7 Messages copied, 0 Errors</p>
<p>1 User processed, 7 Messages copied, 0 Error(s)<br />
0 Folder(s) created, 0 Folder create errors, 0 Folder not copied<br />
[/stextbox]</p>
<p>Now the mails have been copied. Try accessing webmail of the account test@abc.com and see if mails are displayed fine.</p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=130</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Xen Virtualization in Centos 6</title>
		<link>https://sysadmin.vtrio.com/?p=122</link>
		<comments>https://sysadmin.vtrio.com/?p=122#comments</comments>
		<pubDate>Thu, 03 Apr 2014 04:06:16 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=122</guid>
		<description><![CDATA[Xen virtualization steps are given below. 1. Make sure that SELinux is disabled or permissive. vi /etc/sysconfig/selinux and set &#8220;SELINUX=disabled&#8221;. Then reboot server. &#160; 2. Creating A Network Bridge. We need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems]]></description>
				<content:encoded><![CDATA[<p>Xen virtualization steps are given below.</p>
<p>1. Make sure that SELinux is disabled or permissive.</p>
<p>vi /etc/sysconfig/selinux</p>
<p>and set &#8220;SELINUX=disabled&#8221;. Then reboot server.</p>
<p>&nbsp;</p>
<p>2. Creating A Network Bridge.</p>
<p>We need to set up a network bridge on our server so that our virtual machines can be accessed from other hosts as if they were physical systems in the network.</p>
<p>To do this, we install the package bridge-utils</p>
<p>=========</p>
<p>yum install bridge-utils</p>
<p>=========</p>
<p>&#8230; and configure a bridge. Create the file /etc/sysconfig/network-scripts/ifcfg-br0 (please use the IPADDR, PREFIX, GATEWAY, DNS1 and DNS2 values from the/etc/sysconfig/network-scripts/ifcfg-eth0 file); make sure you use TYPE=Bridge, not TYPE=Ethernet:</p>
<p>vi /etc/sysconfig/network-scripts/ifcfg-br0</p>
<pre>DEVICE="br0"
NM_CONTROLLED="yes"
ONBOOT=yes
TYPE=Bridge
BOOTPROTO=none
IPADDR=192.168.0.100
PREFIX=24
GATEWAY=192.168.0.1
DNS1=8.8.8.8
DNS2=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System br0"

Modify /etc/sysconfig/network-scripts/ifcfg-eth0 as follows (comment out BOOTPROTO, IPADDR, PREFIX, GATEWAY, DNS1, and DNS2 and add BRIDGE=br0):

vi /etc/sysconfig/network-scripts/ifcfg-eth0</pre>
<pre>DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:1E:90:F3:F0:02
TYPE=Ethernet
#BOOTPROTO=none
#IPADDR=192.168.0.100
#PREFIX=24
#GATEWAY=192.168.0.1
#DNS1=8.8.8.8
#DNS2=8.8.4.4
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
NAME="System eth0"
UUID=5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03
BRIDGE=br0

Restart the network:
/etc/init.d/network restart

and run "ifconfig", it should network bridge.

[root@server1 ~]# ifconfig
br0       Link encap:Ethernet  HWaddr 00:1E:90:F3:F0:02
          inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0
          inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:17 errors:0 dropped:0 overruns:0 frame:0
          TX packets:29 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1196 (1.1 KiB)  TX bytes:2794 (2.7 KiB)

eth0      Link encap:Ethernet  HWaddr 00:1E:90:F3:F0:02
          inet6 addr: fe80::21e:90ff:fef3:f002/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4554 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3020 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:6249612 (5.9 MiB)  TX bytes:254928 (248.9 KiB)
          Interrupt:25 Base address:0x6000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:3 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:1304 (1.2 KiB)  TX bytes:1304 (1.2 KiB)

3. Installing XEN:
First check if your CPU supports hardware virtualization - if this is the case, the command
egrep '(vmx|svm)' --color=always /proc/cpuinfo</pre>
<p>should display something, e.g. like this:</p>
<p>[root@server1 ~]# egrep &#8216;(vmx|svm)&#8217; &#8211;color=always /proc/cpuinfo<br />
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall<br />
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy misalignsse<br />
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall<br />
nx mmxext fxsr_opt rdtscp lm 3dnowext 3dnow pni cx16 lahf_lm cmp_legacy svm extapic cr8_legacy misalignsse<br />
[root@server1 ~]#</p>
<p>If nothing is displayed, then your processor doesn&#8217;t support hardware virtualization. This means you can use only paravirtualization with Xen, but not hardware virtualization.</p>
<p>As CentOS 6 is based on RedHat 6, and RedHat has dropped support for Xen in version 6, we need to get Xen from a <a href="http://www.crc.id.au/repo/" target="_blank">third-party repository</a>. We can enable the repo as follows:</p>
<p>&nbsp;</p>
<p>yum install wget</p>
<p>&nbsp;</p>
<p>yum install http://au1.mirror.crc.id.au/repo/kernel-xen-release-6-3.noarch.rpm</p>
<p>&nbsp;</p>
<p>yum install kernel-xen xen</p>
<p>&nbsp;</p>
<p>This installs Xen and a Xen kernel on our CentOS system.</p>
<p>&nbsp;</p>
<p>Before we can boot the system with the Xen kernel, please check your GRUB bootloader configuration. We open /boot/grub/menu.lst:</p>
<p>vi /boot/grub/menu.lst</p>
<p>The first listed kernel should be the Xen kernel that you&#8217;ve just installed:</p>
<pre>[...]
title CentOS (2.6.32.54-1.el6xen.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32.54-1.el6xen.x86_64 ro root=/dev/mapper/VolGroup00-LogVol00 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=de rd_LVM_LV=VolGroup00/LogVol01 rd_LVM_LV=VolGroup00/LogVol00 rd_NO_DM
        initrd /initramfs-2.6.32.54-1.el6xen.x86_64.img
[...]

We need to modify that section so that the Xen hypervisor gets loaded first. In the kernel /vmlinuz... line, replace the first word kernel with module. Do the same in the next line - replace the first word initrd with module in the initrd /initramfs... line. Then add the line kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin after the root line and before the first module line (if you have more than one CPU core, you can specify another number than 1 fordom0_max_vcpus). The final kernel section should look like this:</pre>
<pre>[...]
title CentOS (2.6.32.54-1.el6xen.x86_64)
        root (hd0,0)
        kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
        module /vmlinuz-2.6.32.54-1.el6xen.x86_64 ro root=/dev/mapper/VolGroup00-LogVol00 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=de rd_LVM_LV=VolGroup00/LogVol01 rd_LVM_LV=VolGroup00/LogVol00 rd_NO_DM
        module /initramfs-2.6.32.54-1.el6xen.x86_64.img
[...]

Change the value of default to 0 (so that the first kernel (the Xen kernel) will be booted by default):</pre>
<pre>[...]
default=0
[...]

The complete /boot/grub/menu.lst should look something like this:</pre>
<pre># grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/VolGroup00-LogVol00
#          initrd /initrd-[generic-]version.img
#boot=/dev/sde
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32.54-1.el6xen.x86_64)
        root (hd0,0)
        kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
        module /vmlinuz-2.6.32.54-1.el6xen.x86_64 ro root=/dev/mapper/VolGroup00-LogVol00 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=de rd_LVM_LV=VolGroup00/LogVol01 rd_LVM_LV=VolGroup00/LogVol00 rd_NO_DM
        module /initramfs-2.6.32.54-1.el6xen.x86_64.img
title CentOS (2.6.32-220.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/VolGroup00-LogVol00 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=de rd_LVM_LV=VolGroup00/LogVol01 rd_LVM_LV=VolGroup00/LogVol00 rd_NO_DM
        initrd /initramfs-2.6.32-220.el6.x86_64.img

Before we reboot, we install the libvirt and python-virtinst (which contains the virt-install tool which we will use later on to install Xen VMs) packages:

yum install libvirt python-virtinst

Because the libvirt package from CentOS 6/RedHat 6 has no support for Xen, we must rebuild it with Xen support. To do this, we install a few prerequisites now:

yum groupinstall 'Development Tools'

yum install python-devel xen-devel libxml2-devel xhtml1-dtds readline-devel ncurses-devel libtasn1-devel gnutls-devel augeas libudev-devel libpciaccess-devel yajl-devel sanlock-devel libpcap-devel libnl-devel avahi-devel libselinux-devel cyrus-sasl-devel parted-devel device-mapper-devel numactl-devel libcap-ng-devel netcf-devel libcurl-devel audit-libs-devel systemtap-sdt-devel

Now reboot machine to load new kernel

The system should now automatically boot the new Xen kernel. After the system has booted, we can check that by running

uname -r</pre>
<p>[root@server1 ~]# uname -r<br />
2.6.32.54-1.el6xen.x86_64<br />
[root@server1 ~]#</p>
<p>So it&#8217;s really using the new Xen kernel!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>a. xm list</p>
<p>b. to check if Xen has started. It should list Domain-0 (dom0):</p>
<p>&nbsp;</p>
<p>[root@server1 ~]# xm list<br />
Name                                        ID   Mem VCPUs      State   Time(s)<br />
Domain-0                                     0  1024     1     r&#8212;&#8211;     18.9<br />
[root@server1 ~]#</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Instead of using the xm command, I will from now on use the virsh command to manage Xen VMs. This is the preferred way as we are using libvirt.</p>
<p>&nbsp;</p>
<p>virsh list</p>
<p>should show this:</p>
<p>[root@server1 ~]# virsh list<br />
Id Name                 State<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
0 Domain-0             running</p>
<p>[root@server1 ~]#</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>4. Paravirtualization:</p>
<p>CentOS has a nice tool called virt-install with which we can create virtual machines for Xen. To start it, we simply run</p>
<p>virt-install &#8211;prompt &#8211;network bridge=br0 &#8211;virt-type=xen</p>
<p>&nbsp;</p>
<p>The tools asks a few questions before it creates a virtual machine. I want to call my first virtual machine vm01, with 1024MB RAM and a disk size of 10GB. I want to store it in the file /var/lib/libvirt/images/vm01.img:</p>
<p>Would you like a fully virtualized guest (yes or no)? This will allow you to run unmodified operating systems.<br />
&lt;&#8211; no<br />
What is the name of your virtual machine?<br />
&lt;&#8211; vm01<br />
How much RAM should be allocated (in megabytes)?<br />
&lt;&#8211; 1024<br />
What would you like to use as the disk (file path)?<br />
&lt;&#8211; /var/lib/libvirt/images/vm01.img<br />
How large would you like the disk (/vm/vm01.img) to be (in gigabytes)?<br />
&lt;&#8211; 10<br />
What is the install URL?<br />
&lt;&#8211; http://ftp.tu-chemnitz.de/pub/linux/centos/6.2/os/x86_64</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Regards,</p>
<p>Jeen</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<pre></pre>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=122</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Multiple php versions on Centos</title>
		<link>https://sysadmin.vtrio.com/?p=106</link>
		<comments>https://sysadmin.vtrio.com/?p=106#comments</comments>
		<pubDate>Wed, 05 Feb 2014 06:28:22 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[multiplephp]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=106</guid>
		<description><![CDATA[Hi , you may come across situations to have multiple php versions installed on a server. Here I will explain a simple method to accomplish this. Lets take php versions 5.2 and 5.4 and I am going to install it in different locations than default installation directory. Note for 2 versions of php one version]]></description>
				<content:encoded><![CDATA[<p>Hi , you may come across situations to have multiple php versions installed on a server. Here I will explain a simple method to accomplish this. Lets take php versions 5.2 and 5.4 and I am going to install it in different locations than default installation directory.</p>
<p>Note for 2 versions of php one version should be compiled as fcgi.</p>
<p>1. Install php 5.2:</p>
<p>a. Download php tar file from &#8220;http://php.net/downloads.php&#8221;</p>
<p>Here I am going to compile this php as fastcgi and using custom installation directory /opt/php52. Configure command is given below.</p>
<p>==========</p>
<p># ./configure &#8211;prefix=/opt/php52 &#8211;with-config-file-path=/opt/php52 &#8211;with-curl &#8211;enable-cli &#8211;enable-fastcgi &#8211;enable-discard-path &#8211;enable-force-cgi-redirect &#8211;with-mysql &#8211;with-mysqli &#8211;enable-bcmath &#8211;enable-ftp &#8211;enable-magic-quotes &#8211;with-pear &#8211;enable-sockets &#8211;with-zlib &#8211;with-gd &#8211;with-jpeg-dir=/usr/lib &#8211;with-libdir=lib64 &#8211;with-bz2 &#8211;enable-calendar &#8211;with-curl &#8211;enable-dbase &#8211;enable-exif &#8211;with-gettext &#8211;with-gmp &#8211;enable-mbstring &#8211;with-mcrypt &#8211;with-mhash &#8211;with-ncurses=shared &#8211;with-openssl &#8211;enable-pcntl &#8211;with-pdo-mysql &#8211;with-pspell &#8211;with-readline &#8211;enable-shmop &#8211;with-snmp=shared &#8211;enable-sysvsem &#8211;enable-sysvshm &#8211;enable-sysvmsg &#8211;enable-wddx &#8211;with-kerberos &#8211;with-imap-ssl &#8211;enable-zip &#8211;with-xsl &#8211;with-tidy &#8211;enable-soap</p>
<p># make &amp;&amp; make install</p>
<p>============</p>
<p>If you got error while executing &#8216;make&#8217; command  like &#8220;Compile: /usr/bin/ld: cannot find -lltdl, collect2: ld returned 1 exit status&#8221; please install libtool using following command.</p>
<p>yum install libtool-ltdl-devel</p>
<p><span style="line-height: 1.5em"> </span></p>
<p>Copy php.ini-recommended from the install directory to /opt/php52/</p>
<p>&nbsp;</p>
<p>2. Install php 5.4</p>
<p>This one also going to install in separate location say /opt/php54</p>
<p>===========</p>
<p>#./configure &#8211;prefix=/opt/php54 &#8211;with-config-file-path=/opt/php54 &#8211;with-curl &#8211;enable-cli &#8211;enable-discard-path &#8211;with-mysql &#8211;with-mysqli &#8211;enable-bcmath &#8211;enable-ftp &#8211;enable-magic-quotes &#8211;with-pear &#8211;enable-sockets &#8211;with-zlib &#8211;with-gd &#8211;with-jpeg-dir=/usr/lib &#8211;with-libdir=lib64 &#8211;with-bz2 &#8211;enable-calendar &#8211;with-curl &#8211;enable-dbase &#8211;enable-exif &#8211;with-gettext &#8211;with-gmp &#8211;enable-mbstring &#8211;with-mcrypt &#8211;with-mhash &#8211;with-ncurses=shared &#8211;with-openssl &#8211;enable-pcntl &#8211;with-pdo-mysql &#8211;with-pspell &#8211;with-readline &#8211;enable-shmop &#8211;with-snmp=shared &#8211;enable-sysvsem &#8211;enable-sysvshm &#8211;enable-sysvmsg &#8211;enable-wddx &#8211;with-kerberos &#8211;with-imap-ssl &#8211;enable-zip &#8211;with-xsl &#8211;with-tidy &#8211;enable-soap</p>
<p># make &amp;&amp; make install</p>
<p>===========</p>
<p>&nbsp;</p>
<p>Copy php.ini-production from install directory to /opt/php54.</p>
<p>&nbsp;</p>
<p>Now in apache configuration file include following line or uncomment it.</p>
<p>&nbsp;</p>
<p>Include conf/extra/httpd-fastcgi.conf</p>
<p>&nbsp;</p>
<p>Now create this file &#8220;/usr/local/apache/conf/extra/httpd-fastcgi.conf&#8221; and add below contents to it.</p>
<p>&nbsp;</p>
<p>==========</p>
<p>LoadModule fastcgi_module modules/mod_fastcgi.so<br />
FastCgiIpcDir /opt/tmp/fcgi<br />
AddHandler fastcgi-script .fcgi<br />
FastCgiConfig -autoUpdate -singleThreshold 200 -killInterval 600 -idle-timeout 150<br />
AddType application/x-httpd-php .php<br />
ScriptAlias /fastcgi/ /usr/local/apache/cgi-bin/<br />
&lt;Directory &#8220;/usr/local/apache/cgi-bin&#8221;&gt;<br />
Options ExecCGI<br />
SetHandler fastcgi-script<br />
Order allow,deny<br />
Allow from all<br />
&lt;/Directory&gt;</p>
<p>==========</p>
<p>&nbsp;</p>
<p>Make sure that &#8220;mod_fastcgi.so&#8221; exists in the modules directory. Now create a directory &#8220;/opt/tmp/fcgi&#8221; and give 777 permission.</p>
<p>&nbsp;</p>
<p>Navigate to directory &#8220;/usr/local/apache/cgi-bin/&#8221;.</p>
<p>a. Create a file for php 5.2 say &#8220;php52.fcgi&#8221; with 755 or executable permission and add following contents to it. Make sure you have added correct path for php-cgi binary.</p>
<p>&nbsp;</p>
<p>==========</p>
<p>#!/bin/sh<br />
PHP_FCGI_CHILDREN=8<br />
export PHP_FCGI_CHILDREN<br />
PHP_FCGI_MAX_REQUESTS=5000<br />
export PHP_FCGI_MAX_REQUESTS<br />
exec /opt/php52/bin/php-cgi</p>
<p>==========</p>
<p>&nbsp;</p>
<p>Similarly create a file for php 5.4 say php54.cgi with following contents.</p>
<p>&nbsp;</p>
<p>==========</p>
<p>#!/bin/sh<br />
PHP_FCGI_CHILDREN=8<br />
export PHP_FCGI_CHILDREN<br />
PHP_FCGI_MAX_REQUESTS=5000<br />
export PHP_FCGI_MAX_REQUESTS<br />
exec /opt/php54/bin/php-cgi</p>
<p>==========</p>
<p>&nbsp;</p>
<p>Finally go to virtual host section of each domain and specify which php to use for the domain. Imagine I have to use php 5.2 for a domain called abc.com. Go to virtual host of domain abc.com and add following line to it.</p>
<p>&nbsp;</p>
<p>==========</p>
<p>Action  application/x-httpd-php /fastcgi/php52.fcgi</p>
<p>==========</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>For domains using php version 5.4 add following line.</p>
<p>&nbsp;</p>
<p>==========</p>
<p>Action  application/x-httpd-php /fastcgi/php54.fcgi</p>
<p>==========</p>
<p>&nbsp;</p>
<p>Finally restart apache service. Thats it. Put a php info page and check php versions displaying.</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Thanks,</p>
<p>Jeen</p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=106</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Script to download multiple files concurrently</title>
		<link>https://sysadmin.vtrio.com/?p=99</link>
		<comments>https://sysadmin.vtrio.com/?p=99#comments</comments>
		<pubDate>Mon, 13 Jan 2014 08:46:25 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=99</guid>
		<description><![CDATA[This script will show you an example of how to download multiple files concurrently using the curl_multi commands in PHP 5.While php itself doesn’t support multi threading and concurrency, libcurl does and php allows us to download multiple files at the same time from php.  Script Author &#8211; JeenaJoy &#60;?php//This script will show you an]]></description>
				<content:encoded><![CDATA[<p><span style="font-family: Arial; font-size: small;">This script will show you an example of how to download multiple files concurrently<br />
using the curl_multi commands in PHP 5.While php itself doesn’t support multi threading and concurrency,<br />
libcurl does and php allows us to download multiple files at the same time from php.</span></p>
<div> Script Author &#8211; JeenaJoy</div>
<div></div>
<div>&lt;?php//This script will show you an example of how to download multiple files concurrently<br />
//using the curl_multi commands in PHP 5.While php itself doesnt support multi threading and concurrency,<br />
//libcurl does and php allows us to download multiple files at the same time from php.// Files to download<br />
$urls = array(&#8216;http://abc.com/docs/cdbwpohq0ayey.pdf&#8217;,<br />
&#8216;http://abc.com/docs/8wyxlxfufftas.pdf&#8217;,<br />
&#8216;http://abc.com/docs/9q29bbglnc2gk.pdf&#8217;,);</p>
<p>$save_to=&#8217;/tmp/';  // Path to save files in</p>
<p>$mh = curl_multi_init();<br />
// Add curl multi handles<br />
foreach ($urls as $i =&gt; $url) {</p>
<p>// Path to save files in<br />
$g=$save_to.basename($url);</p>
<p>$conn[$i]=curl_init($url);<br />
$fp[$i]=fopen ($g, &#8220;wb&#8221;);</p>
<p>curl_setopt ($conn[$i], CURLOPT_HEADER ,0);///it should come first<br />
curl_setopt ($conn[$i], CURLOPT_FILE, $fp[$i]);<br />
curl_multi_add_handle ($mh,$conn[$i]);</p>
<p>}<br />
// Download the files<br />
do {<br />
$n=curl_multi_exec($mh,$active);<br />
}<br />
while ($active);<br />
foreach ($urls as $i =&gt; $url)<br />
{<br />
curl_multi_remove_handle($mh,$conn[$i]);</p>
<p>curl_close($conn[$i]);<br />
fclose ($fp[$i]);</p>
<p>}<br />
curl_multi_close($mh);</p>
<p>?&gt;</p>
</div>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=99</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding SSL to a site in nginx</title>
		<link>https://sysadmin.vtrio.com/?p=97</link>
		<comments>https://sysadmin.vtrio.com/?p=97#comments</comments>
		<pubDate>Thu, 09 Jan 2014 11:03:30 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=97</guid>
		<description><![CDATA[1) First create a folder where SSL certs are to be placed #mkdir /etc/ssl/certs #cd /etc/ssl/certs Create key # openssl genrsa -out abc.com.key 2048 # chmod 600 abc.com.key Generate CSR # openssl req -new -key abc.com.key -out abc.com.csr If all that you need is a self signed certificated, do as follows. # openssl x509 -req]]></description>
				<content:encoded><![CDATA[<p>1) First create a folder where SSL certs are to be placed</p>
<p>#mkdir /etc/ssl/certs</p>
<p>#cd /etc/ssl/certs</p>
<p>Create key</p>
<p># openssl genrsa -out abc.com.key 2048</p>
<p># chmod 600 abc.com.key</p>
<p>Generate CSR</p>
<p># openssl req -new -key abc.com.key -out abc.com.csr</p>
<p>If all that you need is a self signed certificated, do as follows.</p>
<p># openssl x509 -req -days 365 -in abc.com.csr -signkey abc.com.key -out abc.com.crt</p>
<p>Otherwise get the cert signed and place it in /etc/ssl/certs/abc.com.crt</p>
<p>Now, open up your nginx config file for this domain.</p>
<p># vi /etc/nginx/sites-available/abc.com</p>
<p>If you are planning to use both http and https, you need two separate server modules in your config. Hence, copy the config for 80 and put it to the bottom of the page and make modifications. What you need to add to the https server module is given below. Paste it before server_name line.</p>
<p>server {</p>
<p>listen   1.2.1.3:443 ssl;</p>
<p>ssl    on;<br />
ssl_certificate    /etc/ssl/certs/abc.com.crt;<br />
ssl_certificate_key    /etc/ssl/certs/abc.com.key;<br />
server_name abc.com www.abc.com</p>
<p>&#8230;.</p>
<p>&#8230;</p>
<p>}</p>
<p>Now restart nginx.</p>
<p>#/etc/rc.d/init.d/nginx restart</p>
<p>Now try accessing site with https.</p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=97</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Password protecting a site in nginx</title>
		<link>https://sysadmin.vtrio.com/?p=95</link>
		<comments>https://sysadmin.vtrio.com/?p=95#comments</comments>
		<pubDate>Thu, 09 Jan 2014 10:45:46 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=95</guid>
		<description><![CDATA[This post will explain how to password protect a site in nginx. It is very simple and it uses the normal htpasswd protection Suppose I need to password protect the site abc.com whose document root is /var/www/abc/public_html Simple follow the steps given below [root@abc ~]#  cd /var/www/abc/public_html [root@abc ~]#  htpasswd -c .htpasswd admin        where admin]]></description>
				<content:encoded><![CDATA[<p>This post will explain how to password protect a site in nginx. It is very simple and it uses the normal htpasswd protection</p>
<div></div>
<p>Suppose I need to password protect the site abc.com whose document root is /var/www/abc/public_html</p>
<p>Simple follow the steps given below</p>
<div id="stb-box-7417">
<p>[root@abc ~]#  cd /var/www/abc/public_html</p>
<p>[root@abc ~]#  htpasswd -c .htpasswd admin        where admin is the username chosen. It will prompt for password, give <a id="ch-link-5" rel="a|5"></a>a strong password.</p>
</div>
<p>Now, your login details are stored to the file /var/www/abc/public_html/.htpasswd and we need to call this file from abc.com’s conf.</p>
<p>Simply add the following two lines before the locations</p>
<div id="stb-box-1514">
<p>[root@abc ~]# cd /etc/nginx/sites-available/</p>
<p>[root@abc ~]# vi abc.com</p>
<p>auth_basic “Restricted”;<br />
auth_basic_user_file /var/www/abc/public_html/.htpasswd;</p>
</div>
<p>&nbsp;</p>
<p>So your final conf will now look as follows.</p>
<div id="stb-box-7965">
<p>server {<br />
server_name www.abc.com abc.com;<br />
access_log /var/www/abc/logs/access.log;<br />
error_log /var/www/abc/logs/error.log;<br />
root /var/www/abc/public_html/;</p>
<p>auth_basic “Restricted”;<br />
auth_basic_user_file /var/www/abc/public_html/.htpasswd;</p>
<p>location / {</p>
<p>index index.html index.htm index.php;</p>
<p>}</p>
<p>location ~ \.php$ {<br />
if (!-e $request_filename) { rewrite / /index.php last; }<br />
include /etc/nginx/fastcgi_params;<br />
fastcgi_pass  127.0.0.1:9000;<br />
fastcgi_index index.php;<br />
fastcgi_param SCRIPT_FILENAME  /var/www/abc/public_html$fastcgi_script_name;<br />
fastcgi_param MAGE_RUN_CODE base;<br />
fastcgi_param MAGE_RUN_TYPE website;</p>
<p>}<br />
}</p>
</div>
<p>All done, save the configuration file and exit. Now restart <a id="ch-link-6" rel="nginx|6"></a>nginx and see if it starts without errors.</p>
<div id="stb-box-3929">
<p>[root@abc ~]# /etc/rc.d/init.d/nginx restart<br />
Stopping nginx:                                            [  OK  ]<br />
Starting nginx:                                            [  OK  ]</p>
</div>
<p>Now clear your browser cache and try accessing the site. Bingo!! isnt’t it protected? <img alt=":-)" src="http://greproot.com/wp-includes/images/smilies/icon_smile.gif" /></p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=95</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MongoDB backup/restore</title>
		<link>https://sysadmin.vtrio.com/?p=86</link>
		<comments>https://sysadmin.vtrio.com/?p=86#comments</comments>
		<pubDate>Tue, 31 Dec 2013 06:42:46 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=86</guid>
		<description><![CDATA[Want to know how the backup of mongo database can be taken. Read below… Four tools are described here. 1) mongoexport mongoexport can be used to take the backup of a mongo database. It takes the backup to a CSV, TSV or JSON files. The syntax is as follows. mongoexport -d db_name -c test -o]]></description>
				<content:encoded><![CDATA[<p>Want to know how the <a id="ch-link-2" rel="backup|2"></a>backup of mongo database can be taken. Read below…</p>
<div></div>
<p>Four tools are described here.</p>
<p>1)<strong> mongoexport</strong></p>
<p>mongoexport can be used to take the <a id="ch-link-3" rel="backup|3"></a>backup of a mongo database. It takes the <a id="ch-link-4" rel="backup|4"></a>backup to a CSV, TSV or JSON files. The syntax is as follows.</p>
<div id="stb-box-383">
mongoexport -d db_name -c test -o db_name.csvwhere -d is the database name<br />
-c is the collection name<br />
-o is the file name to which the <a id="ch-link-5" rel="backup|5"></a>backup is to be taken</p>
</div>
<p>2) <strong>mongoimport</strong></p>
<p>mongoimport can be used to import a <a id="ch-link-6" rel="backup|6"></a>backup to a database. You can import from the <a id="ch-link-7" rel="backup|7"></a>backup file as follows.</p>
<div id="stb-box-3166">
mongoimport -d db_restore -c test –file db_name.csvwhere -d is the name of the database to which the file is to be restored<br />
-c is the collection name<br />
–file is the <a id="ch-link-8" rel="backup|8"></a>backup file</p>
</div>
<p>3) <strong>mongodump</strong></p>
<p>For those who need a complete <a id="ch-link-9" rel="backup|9"></a>backup of the database, you can use mongodump command to do so. Unlike mongoexport, the <a id="ch-link-10" rel="backup|10"></a>backup will be done into a folder and not file.</p>
<div id="stb-box-8643">
mongodump -d db_test -o /backuptestwhere -d is the database name<br />
-o is the folder to which data is to be backed up</p>
</div>
<p>Once completed, the backup will be present in /backuptest/db_test/</p>
<p>4) <strong>mongorestore</strong></p>
<p>To restore an entire database, you can use the mongorestore command. Let’s restore the backup that we took in the previous step.</p>
<div id="stb-box-9953">
mongorestore -d db_test_restore /backuptest/db_test/where -d is the existing or new database to which the data is to be restored<br />
and the folder /backuptest/db_test/ is where the backup of db_test exists.</p>
</div>
<p>Try it and see, it works <img alt=":-)" src="http://greproot.com/wp-includes/images/smilies/icon_smile.gif" /></p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=86</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WARNING: You are running on a NUMA machine We suggest launching mongod like this to avoid performance problems: ** numactl –interleave=all mongod [other options]</title>
		<link>https://sysadmin.vtrio.com/?p=84</link>
		<comments>https://sysadmin.vtrio.com/?p=84#comments</comments>
		<pubDate>Tue, 31 Dec 2013 06:40:52 +0000</pubDate>
		<dc:creator><![CDATA[]]></dc:creator>
				<category><![CDATA[Misc]]></category>

		<guid isPermaLink="false">http://sysadmin.vtrio.com/?p=84</guid>
		<description><![CDATA[Mongo was working fine in my Ubuntu machine, but whenever I access mongo shell, it will display the following warning. root@abc:~# mongo MongoDB shell version: 2.4.5 connecting to: test Server has startup warnings: Tue Aug 13 03:47:13.764 [initandlisten] Tue Aug 13 03:47:13.764 [initandlisten] ** WARNING: You are running on a NUMA machine. Tue Aug 13]]></description>
				<content:encoded><![CDATA[<p>Mongo was working fine in my Ubuntu machine, but whenever I access mongo shell, it will <a id="ch-link-2" rel="display|2"></a>display the following warning.</p>
<div></div>
<div id="stb-box-262">
<p>root@abc:~# mongo<br />
MongoDB shell version: 2.4.5<br />
connecting to: test<br />
Server has startup warnings:<br />
Tue Aug 13 03:47:13.764 [initandlisten]<br />
Tue Aug 13 03:47:13.764 [initandlisten] ** WARNING: You are running on a NUMA machine.<br />
Tue Aug 13 03:47:13.764 [initandlisten] **          We suggest launching mongod like this to avoid performance problems:<br />
Tue Aug 13 03:47:13.764 [initandlisten] **              numactl –interleave=all mongod [other options]<br />
Tue Aug 13 03:47:13.764 [initandlisten]</p>
</div>
<p>First I checked, whether my hardware is NUMA(Non-Uniform Access Memory) enabled. I got the following output which said the answer is yes, it is NUMA enabled.</p>
<div id="stb-box-4158">
<p>root@abcl# dmesg | grep -i numa<br />
[    0.000000] NUMA: Node 1 [mem 0x00000000-0xcfffffff] + [mem 0x100000000-0x82fffffff] -&gt; [mem 0x00000000-0x82fffffff]</p>
</div>
<p>I can simply start mongo as said in the warning message, but what I was looking forward was a permanent fix which will let me start/stop mongo using the startup script.</p>
<p>&nbsp;</p>
<p>Unfortunately, numactl command was not present in the server, so I installed the package as follows.</p>
<div id="stb-box-5841">
<p>apt-get install numactl</p>
</div>
<p>After that, I did the following.</p>
<div id="stb-box-894">
<p>Added the following line to <code>/etc/sysctl.conf</code></p>
<p>vm.zone_reclaim_mode = 0</p>
<p>Now, made the following change to the file /etc/init/mongodb.conf</p>
<p>Commented out line 18 which is as follows.</p>
<p>#  if [ &#8220;x$ENABLE_MONGODB&#8221; = &#8220;xyes&#8221; ]; then exec start-stop-daemon –start –quiet –chuid mongodb –exec  /usr/bin/mongod — –config /etc/mongodb.conf; fi</p>
<p>Now added the following line.</p>
<p>if [ &#8220;x$ENABLE_MONGODB&#8221; = &#8220;xyes&#8221; ]; then exec start-stop-daemon –start –quiet –chuid mongodb –exec  /usr/bin/numactl — –interleave=all /usr/bin/mongod –config  /etc/mongodb.conf; fi</p>
<p>Save and quit the file.</p>
</div>
<p>After doing this you need to restart mongodb and <a id="ch-link-5" rel="check|5"></a>check whether mongo shell is accessible without the warning.</p>
<p>&nbsp;</p>
<div id="stb-box-5045">
<p>root@abc# /etc/init.d/mongodb start<br />
Rather than invoking init scripts through /etc/init.d, use the service(8)<br />
utility, e.g. service mongodb start</p>
<p>Since the script you are attempting to invoke has been converted to an<br />
Upstart job, you may also use the start(8) utility, e.g. start mongodb<br />
mongodb start/running, process 21750</p>
</div>
<p><a id="ch-link-6" rel="check|6"></a>Check if mongo is running</p>
<p>&nbsp;</p>
<div id="stb-box-7984">
root@abc# ps aux | grep mongo<br />
mongodb  21750  1.0  0.0 348116 37516 ?        Ssl  04:13   0:00 /usr/bin/mongod –config /etc/mongodb.conf<br />
root     21762  0.0  0.0   9384   920 pts/0    S+   04:13   0:00 grep –color=auto mongo</div>
<p>Try accessing the mongo shell</p>
<div id="stb-box-2198">
root@abc# mongo<br />
MongoDB shell version: 2.4.5<br />
connecting to: test<br />
&gt;<br />
bye</div>
<p>&nbsp;</p>
<p>Success!!!! In case of error, you can <a id="ch-link-7" rel="check|7"></a>check the log file at /var/log/mongodb/mongodb.log</p>
]]></content:encoded>
			<wfw:commentRss>https://sysadmin.vtrio.com/?feed=rss2&#038;p=84</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
