<?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>Miljan Karadzic</title>
	<atom:link href="http://www.miljan.org/main/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.miljan.org/main</link>
	<description>Wisdom is the key</description>
	<lastBuildDate>Sat, 21 Jul 2012 07:56:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Solaris MPxIO: LUN distribution</title>
		<link>http://www.miljan.org/main/2011/01/25/solaris-mpxio-lun-distribution/</link>
		<comments>http://www.miljan.org/main/2011/01/25/solaris-mpxio-lun-distribution/#comments</comments>
		<pubDate>Tue, 25 Jan 2011 22:01:28 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Python]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=326</guid>
		<description><![CDATA[Lately my work tasks are leading me to learn a lot about Solaris storage configuration. I have a &#8220;test&#8221; environment with 13 HP ProLiant servers, Solaris x86 and HP EVA8400 storage. EVA8400 is advertised as an active-active (AA) storage &#8211; a LUN can be accessed via both controllers. But if you look at the small [...]]]></description>
			<content:encoded><![CDATA[<p>Lately my work tasks are leading me to learn a lot about Solaris storage configuration. I have a &#8220;test&#8221; environment with 13 HP ProLiant servers, Solaris x86 and HP EVA8400 storage. </p>
<p>EVA8400 is advertised as an active-active (AA) storage &#8211; a LUN can be accessed via both controllers. But if you look at the small letters you will see that it is actually asymmetric AA storage (AAA), which is a cheaper class of AA storages. While all LUNs can still be accessed via both controllers, LUNs still have owning controller. If I/O request comes to a non-owning controller it will be transfered to the owner and only then performed. This of course has impact on the performance. To avoid this EVA monitors the requests, and if more than 60% of requests are coming through non-owning controller ownership is changed.</p>
<p>Preferred method of access for AAA storages is using asymmetric logical unit access (ALUA) &#8211; method that enables target (storage system) to set different access characteristics to different paths based on the owning controller (this is known as target port group support (TPGS)). For example, if Controller_A owns LUN_1, all paths for LUN_1 to Controller_A will be marked as Active/Optimized, while all paths to Controller_B will be marked as Active/NonOptimized. </p>
<p>Knowing all this, it is only obvious that ideal setup for AAA storages is when one half of LUNs is owned by one controller and the other half by second controller. This enables us to balance the load on both controllers and get the maximum performance out of the storage.</p>
<p>Now, on the client side some systems have Veritas suite installed, but there are a couple of servers that are using Solaris native MPxIO as a multipathing solution. By specification MPxIO is ALUA aware plus it comes with a nice feature to balance the traffic across all Active paths. EVA8400 controllers have 4 x 4Gbps fibre channel ports each, while my servers have 2 x 8Gbps HBAs. Spreading the traffic across all 4 target ports would help me get needed performance.</p>
<p>Everything sounds perfect in theory, but I&#8217;m having problems to make this work in practice. For some reason MPxIO does all the I/O over Controller A and, since with MPxIO path priority can  not be set manually, after a while all LUNs are moved to this controller leaving second controller idle. Since TPGS specification is vendor specific there seems to be some incompatibility between HP and Sun implementation. Or maybe there are some hidden undocumented options that have to be set &#8211; so far I had no luck in finding these. :-/</p>
<p>During the tests and in order to see how the LUNs were spread I wrote a script that counts Active paths per target port. Maybe someone else will find it useful. Download can be found <a href="http://www.miljan.org/download/get_san_paths.py">here</a>. And here is how it looks in action:</p>
<p class="code"><b>root@xdb1-ora:~# get_san_paths.py</b><br />
Initiator ports found:&nbsp;&nbsp;&nbsp;&nbsp;2<br />
Target ports found:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;8<br />
LUNs found:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;87<br />
&nbsp;<br />
Path \ LUNs:<br />
&nbsp;&nbsp;50001fe150229f78: 77 LUNs<br />
&nbsp;&nbsp;50001fe150229f79: 77 LUNs<br />
&nbsp;&nbsp;50001fe150229f7c: 10 LUNs<br />
&nbsp;&nbsp;50001fe150229f7d: 10 LUNs<br />
&nbsp;&nbsp;50001fe150229f7a: 77 LUNs<br />
&nbsp;&nbsp;50001fe150229f7b: 77 LUNs<br />
&nbsp;&nbsp;50001fe150229f7e: 10 LUNs<br />
&nbsp;&nbsp;50001fe150229f7f: 10 LUNs</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2011/01/25/solaris-mpxio-lun-distribution/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FreeIPA and automount NIS maps</title>
		<link>http://www.miljan.org/main/2010/10/18/freeipa-and-automount-nis-maps/</link>
		<comments>http://www.miljan.org/main/2010/10/18/freeipa-and-automount-nis-maps/#comments</comments>
		<pubDate>Mon, 18 Oct 2010 06:00:18 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=303</guid>
		<description><![CDATA[I am playing since recently with FreeIPA, Red Hat's identity management solution built on top of Red Hat's DS389 directory server. One of the main reasons why I decided for FreeIPA (apart from integrated Kerberos for single sign-on and possible integration with Microsoft Active Directory in the future) is, also integrated, NIS server - proxy [...]]]></description>
			<content:encoded><![CDATA[<p>I am playing since recently with FreeIPA, Red Hat's identity management solution built on top of Red Hat's DS389 directory server. One of the main reasons why I decided for FreeIPA (apart from integrated Kerberos for single sign-on and possible integration with Microsoft Active Directory in the future) is, also integrated, NIS server - proxy system that receives requests from NIS clients, gets the data from LDAP server and sends it back to clients. Now, in order to understand why I need to support both LDAP and NIS you need to know few things about the environment I'm in charge of. </p>
<p>I'm working for a software development company. We produce billing software for telecommunication operators - mainly used by mobile telecommunication companies. That means, when you make a call, your call needs to be tracked, recorded and properly billed on the end, all done by our software (called BSCS btw). Sounds simple enough. Multiply that by one hundred million customers making calls and it's not so simple anymore. :) Anyway, our customers use our software on different platforms, most of them use HP-UX, some are on Solaris, some AIX, some are on Linux and we even have some customers on Tru64. In order to provide support to all those customers we need to have all those systems as well. So on the end we end up 100+ servers of all types of UNIX systems. That's not a big problem, it's even interesting, but the problem comes up when those systems are not being upgraded. We have Solaris 2.6 servers and Tru64 4.0D servers, until recently we even had AIX 4.3 and HP-UX 10.30 servers. All of the mentioned systems are 13 years old! Scary! </p>
<p>As you can imagine, those outdated systems do not support many things we take for granted today. Shadow passwords and LDAP authentication are few of those things. And this gets us back to the main topic of this post. FreeIPA (or rather DS389) provides integrated NIS server for unlucky people like myself via SLAPI-NIS plugin. All you have to do in order to use it, is to enable compat and NIS plugin.</p>
<p class="code"><b># ipa-compat-manage enable</b><br />
Directory Manager password:<br />
&nbsp;<br />
Enabling plugin<br />
This setting will not take effect until you restart Directory Server.<br />
&nbsp;<br />
<b># ipa-nis-manage enable</b><br />
Directory Manager password:<br />
&nbsp;<br />
Enabling plugin<br />
This setting will not take effect until you restart Directory Server.<br />
The rpcbind service may need to be started.</p>
<p>And after directory server restart you have a working NIS server.</p>
<p class="code"><b># rpcinfo -p</b><br />
   program vers proto&nbsp;&nbsp;&nbsp;port&nbsp;&nbsp;service<br />
100000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;tcp&nbsp;&nbsp;&nbsp;&nbsp;111&nbsp;&nbsp;portmapper<br />
    100000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;tcp&nbsp;&nbsp;&nbsp;&nbsp;111&nbsp;&nbsp;portmapper<br />
    100000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;tcp&nbsp;&nbsp;&nbsp;&nbsp;111&nbsp;&nbsp;portmapper<br />
    100000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;4&nbsp;&nbsp;&nbsp;udp&nbsp;&nbsp;&nbsp;&nbsp;111&nbsp;&nbsp;portmapper<br />
    100000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;3&nbsp;&nbsp;&nbsp;udp&nbsp;&nbsp;&nbsp;&nbsp;111&nbsp;&nbsp;portmapper<br />
    100000&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;udp&nbsp;&nbsp;&nbsp;&nbsp;111&nbsp;&nbsp;portmapper<br />
    100024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;udp&nbsp;&nbsp;49833&nbsp;&nbsp;status<br />
    100024&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;tcp&nbsp;&nbsp;36837&nbsp;&nbsp;status<br />
    100004&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;udp&nbsp;&nbsp;&nbsp;&nbsp;699&nbsp;&nbsp;ypserv<br />
    100004&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2&nbsp;&nbsp;&nbsp;tcp&nbsp;&nbsp;&nbsp;&nbsp;699&nbsp;&nbsp;ypserv</p>
<p>By default only passwd, group and netgroup maps are supported but other maps can easily be added. In our environment we are heavily relaying on automounter maps so I had to find a way to add them into FreeIPA NIS server. Luckily, as everything else with FreeIPA, this is very simple. First let me show you how to add automount entries in FreeIPA, it is surprisingly easy.</p>
<p>When it comes to automounter, FreeIPA has support for different locations. So for example, you can have different maps for your production environment, test environment and DMZ environment. Pretty neat. In my example, I will create a new location for our DMZ environment.</p>
<p class="code"><b># ipa automountlocation-add dmz</b><br />
&nbsp;&nbsp;Location: dmz</p>
<p>New location is automatically created with auto.master and auto.direct maps.</p>
<p class="code"><b># ipa automountmap-find dmz</b><br />
&nbsp;&nbsp;Map: auto.master<br />
&nbsp;<br />
&nbsp;&nbsp;Map: auto.direct<br />
&nbsp;&nbsp;----------------------------<br />
&nbsp;&nbsp;Number of entries returned 2<br />
&nbsp;&nbsp;----------------------------</p>
<p>I would like to add a new map for user home folders.</p>
<p class="code"><b># ipa automountmap-add dmz auto.home</b><br />
&nbsp;&nbsp;Map: auto.home</p>
<p>Then we need to add an entry in auto.master map to associate /home mount point with auto.home map.</p>
<p class="code"><b># ipa automountkey-add dmz auto.master /home --info=auto.home</b><br />
&nbsp;&nbsp;Key: /home<br />
&nbsp;&nbsp;Mount information: auto.home</p>
<p>Finally, we add an entry into auto.home map specifying which share to mount for user miljan.</p>
<p class="code"><b># ipa automountkey-add dmz auto.home miljan --info=filer01:/vol/users/home/miljan</b><br />
&nbsp;&nbsp;Key: miljan<br />
&nbsp;&nbsp;Mount information: filer01:/vol/users/home/miljan</p>
<p>And voila, when user miljan logs-on he will have his home folder mounted.</p>
<p>Final step would be to have this in NIS as well. For this we need to manually add few entries into LDAP server. In the example below we add support for auto.master map. There are probably few things you would need to change, though. First, the domain name in DN and nis-domain lines - in the example I am using example.com as a domain. Second, nis-base line - value of this attribute needs to be the DN of your automount map. </p>
<p class="code"><b># ldapadd -x -D "cn=Directory Manager" -W</b><br />
dn: nis-domain=example.com+nis-map=auto.master,cn=NIS Server,cn=plugins,cn=config<br />
objectClass: extensibleObject<br />
nis-domain: example.com<br />
nis-map: auto.master<br />
nis-base: automountmapname=auto.master,cn=dmz,cn=automount,dc=example,dc=com<br />
nis-filter: (objectclass=*)<br />
nis-key-format: %{automountKey}<br />
nis-value-format: %{automountInformation}</p>
<p>Repeat the same for auto.home map and you are set to go.</p>
<p class="code"><b>$ ypcat -d example.com -h freeipa.example.com -k auto.master</b><br />
/home auto.home<br />
&nbsp;<br />
<b>$ ypcat -d example.com -h freeipa.example.com -k auto.home</b><br />
miljan filer01:/vol/users/home/miljan</p>
<p>Nice and easy. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2010/10/18/freeipa-and-automount-nis-maps/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SVC lsmigrate</title>
		<link>http://www.miljan.org/main/2010/10/06/svc-lsmigrate/</link>
		<comments>http://www.miljan.org/main/2010/10/06/svc-lsmigrate/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 09:04:51 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[IBM]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Storage]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=238</guid>
		<description><![CDATA[A year or so ago, I got annoyed by the ugly and unreadable output of IBM SVC lsmigrate command so I sat down and wrote a short script that will provide much nicer and more informational output. Output includes information about the VDisk that is being migrated (name, ID and size), destination MDisk group and [...]]]></description>
			<content:encoded><![CDATA[<p>A year or so ago, I got annoyed by the ugly and unreadable output of IBM SVC lsmigrate command so I sat down and wrote a short script that will provide much nicer and more informational output. Output includes information about the VDisk that is being migrated (name, ID and size), destination MDisk group and migration information (number of threads and progress). If started in verbose mode, information about the source MDisk group is printed as well.</p>
<p>Non-verbose mode:</p>
<p class="code">$ ./svc_lsmigrate.py -H svccluster<br />
#&nbsp;(ID&nbsp;&nbsp;)&nbsp;Vdisk&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Size&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(ID&nbsp;)&nbsp;Mdisk Group&nbsp;&nbsp;&nbsp; Threads Progress<br />
======================================================================<br />
1&nbsp;(67&nbsp;&nbsp;)&nbsp;esx_srvf05_d&nbsp;&nbsp;1000.00GB&nbsp;(8&nbsp;&nbsp;)&nbsp;DS482_5r10_SK1&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;48 %<br />
2&nbsp;(157&nbsp;)&nbsp;esx_srvf06_g&nbsp;&nbsp;1000.00GB&nbsp;(5&nbsp;&nbsp;)&nbsp;DS483_8r5_2SK3&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;96 %<br />
3&nbsp;(118&nbsp;)&nbsp;esx_srvf01_h&nbsp;&nbsp;1022.00GB&nbsp;(1&nbsp;&nbsp;)&nbsp;DS482_8r5_SK3&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63 %<br />
4&nbsp;(117&nbsp;)&nbsp;esx_srvf01_g&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.00TB&nbsp;(1&nbsp;&nbsp;)&nbsp;DS482_8r5_SK3&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63 %<br />
5&nbsp;(120&nbsp;)&nbsp;esx_srvf01_i&nbsp;&nbsp;1023.00GB&nbsp;(1&nbsp;&nbsp;)&nbsp;DS482_8r5_SK3&nbsp;&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;63 %<br />
6&nbsp;(39&nbsp;&nbsp;)&nbsp;tsm_disk4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;5.00GB&nbsp;(10 )&nbsp;DS484_9r5_1SK2&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;98 %<br />
7&nbsp;(19&nbsp;&nbsp;)&nbsp;oracode_tunis&nbsp;&nbsp;800.00GB&nbsp;(5&nbsp;&nbsp;)&nbsp;DS483_8r5_2SK3&nbsp;1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;59&nbsp;%</p>
<p>If you find the script useful, you can download it <a href="http://www.miljan.org/download/svc_lsmigrate.py">here</a>.</p>
<p><strong>Note</strong>: in order for script to work, you need to have SVC connection parameters set in your SSH config file. Example could be:</p>
<p class="code">$ grep -p svccluster ~/.ssh/config<br />
Host svccluster<br />
&nbsp;&nbsp;Hostname 192.168.1.34<br />
&nbsp;&nbsp;User admin<br />
&nbsp;&nbsp;IdentityFile ~/.ssh/admin.key</p>
<p><strong>Note #2</strong>: Script was tested on SVC software levels 4.3 and 5.1.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2010/10/06/svc-lsmigrate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linux LVM: logical volume migration</title>
		<link>http://www.miljan.org/main/2010/05/04/linux-lvm-logical-volume-migration/</link>
		<comments>http://www.miljan.org/main/2010/05/04/linux-lvm-logical-volume-migration/#comments</comments>
		<pubDate>Tue, 04 May 2010 20:49:10 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=148</guid>
		<description><![CDATA[I was recently confronted with the task of migrating logical volume holding MySQL databases to a separate physical volume. Due to important application running on top of MySQL any downtime was out of the question. Easiest way to perform this operation would be using pvmove command. [root@r2d2 ~]# pvmove -n test /dev/sda5 /dev/sdb1 /dev/sda5: Moved: [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently confronted with the task of migrating logical volume holding MySQL databases to a separate physical volume. Due to important application running on top of MySQL any downtime was out of the question.</p>
<p>Easiest way to perform this operation would be using pvmove command.</p>
<p class="code">[root@r2d2 ~]# pvmove -n test /dev/sda5 /dev/sdb1<br />
/dev/sda5: Moved: 6.2%<br />
/dev/sda5: Moved: 18.8%<br />
/dev/sda5: Moved: 28.1%<br />
/dev/sda5: Moved: 37.5%<br />
/dev/sda5: Moved: 46.9%<br />
/dev/sda5: Moved: 56.2%<br />
/dev/sda5: Moved: 65.6%<br />
/dev/sda5: Moved: 75.0%<br />
/dev/sda5: Moved: 84.4%<br />
/dev/sda5: Moved: 93.8%<br />
/dev/sda5: Moved: 100.0%</p>
<p>In the example we moved logical volume 'test' from physical volume /dev/sda5 to /dev/sdb1. While pvmove is running, we can get the necessary information including the progress by issuing command lvs.</p>
<p class="code">[root@r2d2 ~]# lvs -a -o+devices<br />
LV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VG&nbsp;&nbsp;Attr&nbsp;&nbsp;&nbsp;LSize&nbsp;&nbsp;Move&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Copy%  Devices<br />
home&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao 20.00G &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /dev/sda5(544)<br />
mysql&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-a-  1.00G &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1888)<br />
[pvmove0] sys  p-C-ao  1.00G               /dev/sda5      56.25         /dev/sda5(1920),/dev/sdb1(0)<br />
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  7.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(256)<br />
swap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  2.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(480)<br />
test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wI-ao  1.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;pvmove0(0)<br />
usr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  8.00G &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(0)<br />
usr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  8.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1856)<br />
var&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  2.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(224)<br />
var&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  2.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1824)</p>
<p>Another, and somewhat more tricky way of doing this is to use LV mirroring. I say more tricky because it requires more work and the last part of the operation is not really intuitive so it may be prone to errors.</p>
<p>We start with this:</p>
<p class="code">[root@r2d2 ~]# pvs<br />
PV &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VG&nbsp;&nbsp;Fmt&nbsp;&nbsp;Attr PSize&nbsp;&nbsp;&nbsp;PFree<br />
/dev/sda5  sys  lvm2 a-   &nbsp;&nbsp;220.75G 179.75G<br />
/dev/sdb1  sys  lvm2 a-     &nbsp;&nbsp;3.72G   &nbsp;&nbsp;3.72G<br />
 &nbsp;<br />
[root@r2d2 ~]# lvs -a -o+devices<br />
LV&nbsp;&nbsp;&nbsp;VG&nbsp;&nbsp;Attr&nbsp;&nbsp;&nbsp;LSize  Devices<br />
[---]<br />
test&nbsp;sys  -wi-a-  1.00G                                       /dev/sda5(1920)<br />
[---]</p>
<p>Two PVs, the source - sda5, and unused, target PV - sdb1. Logical volume test is the LV we want to move to sdb1.</p>
<p>In order to verify that the content of the LV is consistent on the end, we will create a sample file and compare its content before and after.</p>
<p class="code">[root@r2d2 ~]# dd if=/dev/zero of=/mnt/random bs=512 count=20000<br />
20000+0 records in<br />
20000+0 records out<br />
10240000 bytes (10 MB) copied, 0.122046 s, 83.9 MB/s<br />
&nbsp;<br />
[root@r2d2 ~]# md5sum /mnt/random<br />
596c35b949baf46b721744a13f76a258  /mnt/random</p>
<p>We start by adding another copy to 'test' LV and placing it on a new PV.</p>
<p class="code">[root@r2d2 ~]# lvconvert -m 1 sys/test /dev/sdb1<br />
Not enough PVs with free space available for parallel allocation.<br />
Consider --alloc anywhere if desperate.<br />
Unable to allocate extents for mirror(s).</p>
<p>Hm, confusing error. :) The reason for this is that Linux LVM implementation requires mirror to use a log volume, and this log volume needs to reside on a PV of its own. In order to go around this we can instruct LVM to place the log in the memory. This is not recommended for situations when mirroring is needed on the long run, since mirror needs to be rebuilt every time the LV is activated. But this is the perfect solution for our needs as our mirror will not last for long.</p>
<p class="code">[root@r2d2 ~]# lvconvert -m 1 sys/test /dev/sdb1 --mirrorlog core<br />
sys/test: Converted: 6.2%<br />
sys/test: Converted: 15.6%<br />
sys/test: Converted: 28.1%<br />
sys/test: Converted: 37.5%<br />
sys/test: Converted: 46.9%<br />
sys/test: Converted: 56.2%<br />
sys/test: Converted: 65.6%<br />
sys/test: Converted: 75.0%<br />
sys/test: Converted: 84.4%<br />
sys/test: Converted: 93.8%<br />
sys/test: Converted: 100.0%<br />
Logical volume test converted.</p>
<p>Again, we can get all information with lvs command.</p>
<p class="code">[root@r2d2 ~]# lvs -a -o+devices<br />
LV&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;VG&nbsp;&nbsp;Attr&nbsp;&nbsp;&nbsp;LSize&nbsp;Copy%  &nbsp;Devices<br />
home&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao 20.00G &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /dev/sda5(544)<br />
mysql&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-a-  1.00G &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1888)<br />
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  7.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(256)<br />
swap&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  2.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(480)<br />
test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  mwi-a-  1.00G                         15.62&nbsp;&nbsp;test_mimage_0(0),test_mimage_1(0)<br />
[test_mimage_0] sys  Iwi-ao  1.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1920)<br />
[test_mimage_1] sys  Iwi-ao  1.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sdb1(0)<br />
usr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  8.00G &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(0)<br />
usr&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  8.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1856)<br />
var&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  2.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(224)<br />
var&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sys  -wi-ao  2.00G&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/dev/sda5(1824)</p>
<p>So now we have our LV mirrored with copies on both PVs. Just for test, we can verify the content of the file.</p>
<p class="code">[root@r2d2 ~]# md5sum /mnt/random<br />
596c35b949baf46b721744a13f76a258  /mnt/random</p>
<p>Seems fine. :)</p>
<p>Last step, the one where we have to be more careful, is removing mirror copy from old PV. We have to be more careful because the PV name in this case is the name of a PV we want to remove from mirroring, which is the opposite from what we had when establishing the mirror. If we use wrong PV name we will end up on the begining, with LV on a wrong PV and without mirroring.</p>
<p class="code">[root@r2d2 ~]# lvconvert -m 0 sys/test /dev/sda5<br />
Logical volume test converted.</p>
<p>Again we use lvs to see the status.</p>
<p class="code">[root@r2d2 ~]# lvs -a -o+devices<br />
LV&nbsp;&nbsp;&nbsp;VG&nbsp;&nbsp;Attr&nbsp;&nbsp;&nbsp;LSize  Devices<br />
[---]<br />
test&nbsp;sys  -wi-a-  1.00G                                       /dev/sdb1(0)<br />
[---]</p>
<p>On the end, to verify that we have a clean situation, we can remount the LV and compare the content.</p>
<p class="code">[root@r2d2 ~]# umount /mnt/<br />
[root@r2d2 ~]# lvchange -an /dev/sys/test<br />
[root@r2d2 ~]# lvchange -ay /dev/sys/test<br />
[root@r2d2 ~]# mount /dev/sys/test /mnt<br />
&nbsp;<br />
[root@r2d2 ~]# md5sum /mnt/random<br />
596c35b949baf46b721744a13f76a258  /mnt/random</p>
<p>Everything fine. :)</p>
<p>Just a small note for the end. In case you try to create a mirror on a logical volume that was not yet activated, sync of the mirror will start after the activation.</p>
<p class="code">[root@r2d2 ~]# lvconvert -m 1 sys/test /dev/sdb1 --mirrorlog core<br />
  Conversion starts after activation</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2010/05/04/linux-lvm-logical-volume-migration/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PS1 for your Shell?</title>
		<link>http://www.miljan.org/main/2009/11/30/ps1-for-your-shell/</link>
		<comments>http://www.miljan.org/main/2009/11/30/ps1-for-your-shell/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 22:22:42 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell]]></category>
		<category><![CDATA[UNIX]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=123</guid>
		<description><![CDATA[Few years ago I went on a quest to find a perfect shell prompt. I asked the mighty Internets for ideas, but it seemed futile. I tried many things, simple prompts, complex prompts, but nothing could satisfy my requirements (I don't even remember what were my requirements back then.) So I picked best of both [...]]]></description>
			<content:encoded><![CDATA[Few years ago I went on a quest to find a perfect shell prompt. I asked the mighty Internets for ideas, but it seemed futile. I tried many things, simple prompts, complex prompts, but nothing could satisfy my requirements (I don't even remember what were my requirements back then.) So I picked best of both worlds and got this little monster.

<p class="code">:) oscar:~# </p>

Happy face! And in case of an error, it looks sad.

<p class="code">:( 2 oscar:~# </p>

Cute, a? It even prints the exit code. Useful and cute at the same time!

And here is definition of the prompt. As you can see it uses simple function to determine return code of executed command and adjust its feelings accordingly.

<p class="code">smiley() {<br />
&nbsp;&nbsp;&nbsp;&nbsp;RC=$?<br />
&nbsp;&nbsp;&nbsp;&nbsp;[[ ${RC} == 0 ]] &#038;& echo ':)' || echo ":( ${RC}"<br />
}<br />
export PS1="\$(smiley) \u@\h:\w\\$ "</p>

I think I got the idea for the smiley thing somewhere, but unfortunately I don't remember anymore where from.<br />

For more adventurous people, maybe this prompt would be more interesting.<br />

<p class="code">export PS1="\[\033[0;36m\]\033(0l\033(B\[\033[0m\][\[\033[1;31m\]\u\[\033[0m\]]\[\033[0;36m\]\033(0q\033(B\[\033[0m\][\[\033[1;33m\]@\h\[\033[0m\]]\[\033[0;36m\]\033(0q\033(B\[\033[0m\][\[\033[0;37m\]\T\[\033[0m\]]\[\033[0;36m\]\033(0q\033(B\033(0q\033(B\033(0q\033(B\033(0q\033(B\033(0q\033(B\033(0q\033(B\033(0q\033(B\033(0q\033(B\[\033[0m\][\[\033[1;33m\]\w\[\033[0m\]]\n\[\033[0;36m\]\033(0m\033(B\[\033[0m\]\$ "</p>

Magic! :)<br />
<br />
What is your favorite prompt? Please leave boring \u@\h:\w for dinner with your parents. :P]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2009/11/30/ps1-for-your-shell/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Load Average &gt; 680</title>
		<link>http://www.miljan.org/main/2009/11/23/load-average-680/</link>
		<comments>http://www.miljan.org/main/2009/11/23/load-average-680/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 09:15:57 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=103</guid>
		<description><![CDATA[I just found this old screenshot from one of my previous jobs. It was taken on December 9th 2003, while one of the web hosting servers went woowoo due to badly optimized web site. Load average went sky high to 682! Anyone else had such a high load before or am I the absolute champion? [...]]]></description>
			<content:encoded><![CDATA[<p>I just found this old screenshot from one of my previous jobs. It was taken on December 9th 2003, while one of the web hosting servers went woowoo due to badly optimized web site. Load average went sky high to 682! Anyone else had such a high load before or am I the absolute champion? :)</p>
<p><a href="http://www.miljan.org/gallery/blog/load.jpg"><img alt="" src="http://www.miljan.org/gallery/blog/load.jpg" title="load average" class="alignnone" width="650" height="488" /></a></p>
<p>PS: I was using Fluxbox back than! Wow, crazy youth! :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2009/11/23/load-average-680/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>LVM Snapshots and XFS</title>
		<link>http://www.miljan.org/main/2009/11/16/lvm-snapshots-and-xfs/</link>
		<comments>http://www.miljan.org/main/2009/11/16/lvm-snapshots-and-xfs/#comments</comments>
		<pubDate>Mon, 16 Nov 2009 10:39:10 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=95</guid>
		<description><![CDATA[Small note for everyone planing to use Linux LVM snapshots and using XFS at the same time. XFS has UUIDs which are unique identifiers of the filesystem. Two file systems with same UUID can not be mounted on the same server. Now, if we know that a snapshot of a logical volume represents a point-in-time [...]]]></description>
			<content:encoded><![CDATA[Small note for everyone planing to use Linux LVM snapshots and using XFS at the same time. XFS has UUIDs which are unique identifiers of the filesystem. Two file systems with same UUID can not be mounted on the same server. Now, if we know that a snapshot of a logical volume represents a point-in-time copy of the original logical volume it doesn't take much time to realize that the filesystem on the snapshot is also a copy, thus it will have the same UUID as the filesystem on the original logical volume. So here is what happens when you try to mount the snapshot:

<p class="code">[root@server ~]# df -hT /var/lib/mysql_backup/<br />
FilesystemÂ Â Â Â TypeÂ Â Â Â SizeÂ Â UsedÂ AvailÂ Use%Â MountedÂ on<br />
/dev/mapper/sys-mysql_backup<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xfs&nbsp;&nbsp;&nbsp;&nbsp;25G&nbsp;&nbsp;&nbsp;19G&nbsp;&nbsp;6.3G&nbsp;&nbsp;76%Â /var/lib/mysql_backup<br />
&nbsp;<br />
[root@server ~]# lvcreate -s -n bkp-snap -L1G /dev/sys/mysql_backup<br />
&nbsp;&nbsp;Logical volume "bkp-snap" created<br />
&nbsp;<br />
[root@server ~]# mount /dev/sys/bkp-snap /mnt/misc/<br />
mount: wrong fs type, bad option, bad superblock on /dev/sys/bkp-snap,<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;missing codepage or other<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;In some cases useful info is found in syslog - try<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;dmesg | tail  or so<br />
&nbsp;<br />
[root@server ~]# dmesg | tail -1<br />
XFS: Filesystem dm-9 has duplicate UUID - can't mount</p>

It doesn't look very good.
There are two solution for this problem. One is to use nouuid option for mount command.
<p class="code">[root@server ~]# mount -o nouuid /dev/sys/bkp-snap /mnt/misc/<br />
&nbsp;<br />
[root@server ~]# dmesg | tail -3<br />
XFS mounting filesystem dm-9<br />
Starting XFS recovery on filesystem: dm-9 (logdev: internal)<br />
Ending XFS recovery on filesystem: dm-9 (logdev: internal)</p>

Another option would be to change UUID of the filesystem on the snapshot using xfs_admin command.
<p class="code">[root@server ~]# xfs_admin -U generate /dev/sys/bkp-snap<br />
Clearing log and setting UUID<br />
writing all SBs<br />
new UUID = 1bdcf6e1-62fb-47f2-83e4-dc398bb7a1cd<br />
&nbsp;<br />
[root@server ~]# dmesg | tail -2<br />
XFS mounting filesystem dm-9<br />
Ending clean XFS mount for filesystem: dm-9</p>

I am in favour of the first option (mount -o nouuid) since it does not perform any modification on the filesystem. It just feels safer, that's all... :)]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2009/11/16/lvm-snapshots-and-xfs/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>More information on Linux memory management</title>
		<link>http://www.miljan.org/main/2009/11/10/more-information-on-linux-memory-management/</link>
		<comments>http://www.miljan.org/main/2009/11/10/more-information-on-linux-memory-management/#comments</comments>
		<pubDate>Tue, 10 Nov 2009 15:13:19 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=90</guid>
		<description><![CDATA[I have just noticed that I missed to mention one very important thing in my previous post. File /proc/meminfo contains a very useful field named Committed_AS. This field indicates TOTAL value of committed memory. If all applications would require all memory allocated to them your server would need this amount of memory. If we look [...]]]></description>
			<content:encoded><![CDATA[<p>I have just noticed that I missed to mention one very important thing in my previous post.</p>
<p>File /proc/meminfo contains a very useful field named Committed_AS. This field indicates TOTAL value of committed memory. If all applications would require all memory allocated to them your server would need this amount of memory.</p>
<p>If we look in the example from my previous post we would find following values:</p>
<p class="code">loreto:/tmp # cat /proc/meminfo<br />
MemTotal:Â Â Â Â Â 33274944 kB<br />
&#8230;<br />
Committed_AS:Â 49751960 kB<br />
&#8230;</p>
<p>So my server has 32GB of RAM, but total amount of memory allocated is 48GB. That is 150%! If all this memory would be required at once server would crash pretty bad (or OOM killer would start butchering my Oracle databases to get some memory back!). :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2009/11/10/more-information-on-linux-memory-management/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Linux memory management</title>
		<link>http://www.miljan.org/main/2009/07/10/linux-memory-management/</link>
		<comments>http://www.miljan.org/main/2009/07/10/linux-memory-management/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 15:45:04 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Linux]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=76</guid>
		<description><![CDATA[Yesterday I had a request for memory usage report on Oracle servers in my company. As we are using Centreon, Nagios frontend which makes good use of performance data reported by Nagios plugins and makes nice graphs out of it, it was a matter of pasting the images into the mail and sending it. But [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I had a request for memory usage report on Oracle servers in my company. As we are using <a title="Centreon" href="http://www.centreon.com" target="_blank">Centreon</a>, <a title="Nagios" href="http://www.nagios.org/" target="_blank">Nagios</a> frontend which makes good use of performance data reported by Nagios plugins and makes nice graphs out of it, it was a matter of pasting the images into the mail and sending it. But than interesting question was raised: how come on a server with 32GB of RAM and with 30+ databases running, only 5GB of RAM is reported as used? Strange indeed.</p>
<p>I quickly logged in to server and checked memory usage:</p>
<p class="code">loreto:/tmp # free<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;total&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;used&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;free&nbsp;&nbsp;&nbsp;&nbsp;shared&nbsp;&nbsp;&nbsp;buffers&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cached<br />
Mem:Â Â Â Â Â  33274944Â Â  32931032Â Â Â Â  343912&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;20Â Â  27013200<br />
-/+ buffers/cache:Â Â Â  5917812Â Â  27357132<br />
Swap:Â Â Â Â  16779884Â Â Â  5603256Â Â  11176628</p>
<p>Really only 5GB, check_memory plugin was not wrong. Next this I checked were shared memory segments &#8211; Oracle uses shared memory in huge quantities, so this is also very important parameter.
</p>
<p class="code">loreto:/tmp # a=0; for i in $(ipcs -m|grep ^0x|awk &#8216;{print $5}&#8217;); do let a+=$i; done; echo $a<br />
20443037885</p>
<p>Ugh, 20GB allocated  for shared memory, while system reports only 5GB. Something is very wrong here. Confused, I took out the artillery.
</p>
<p class="code">loreto:/tmp # cat /proc/meminfo<br />
MemTotal:Â Â Â Â  33274944 kB<br />
MemFree:Â Â Â Â Â Â Â  198580 kB<br />
Buffers:Â Â Â Â Â Â Â Â Â Â Â  20 kB<br />
Cached:Â Â Â Â Â Â  27439580 kB<br />
SwapCached:Â Â Â Â  223880 kB<br />
Active:Â Â Â Â Â Â  16333936 kB<br />
Inactive:Â Â Â Â  15428724 kB<br />
HighTotal:Â Â Â  32634140 kB<br />
HighFree:Â Â Â Â Â Â Â  33516 kB<br />
LowTotal:Â Â Â Â Â Â  640804 kB<br />
LowFree:Â Â Â Â Â Â Â  165064 kB<br />
SwapTotal:Â Â Â  16779884 kB<br />
SwapFree:Â Â Â Â  10856700 kB<br />
Dirty:Â Â Â Â Â Â Â Â Â Â Â  1668 kB<br />
Writeback:Â Â Â Â Â Â Â Â Â Â  0 kB<br />
AnonPages:Â Â Â Â  4089416 kB<br />
Mapped:Â Â Â Â Â Â  10222968 kB<br />
Slab:Â Â Â Â Â Â Â Â Â Â  427584 kB<br />
CommitLimit:Â  33417356 kB<br />
Committed_AS: 49751960 kB<br />
PageTables:Â Â Â Â  826016 kB<br />
VmallocTotal:Â Â  112632 kB<br />
VmallocUsed:Â Â Â Â  22228 kB<br />
VmallocChunk:Â Â Â  90180 kB<br />
HugePages_Total:Â Â Â Â  0<br />
HugePages_Free:Â Â Â Â Â  0<br />
HugePages_Rsvd:Â Â Â Â Â  0<br />
Hugepagesize:Â Â Â Â  2048 kB</p>
<p>Usually, used memory on Linux is calculated as (Total Memory &#8211; (Unused Memory + Buffers + Page Cache)). Why buffers and caches are not counted into memory usage? Simply because it contains data that is not really critical for operating system and applications running. It contains data that can be flushed and removed from the memory at any time.</p>
<p>So in my case that was:
</p>
<p class="code">33274944 &#8211; (198580 + 20 + 27439580) = 5636764</p>
<p>OK, this matches output from free command. But what about those 20GB of allocated shared memory?</p>
<p>Next few hours I spent in searching and reading Linux documentation on memory management and found few interesting things.</p>
<p>Linux uses principle of memory overcommitment. Basically, what this means is that when application requests memory to be allocated, kernel will always &#8220;give: the memory hoping that application will not really use it, or at least not the whole size allocated. Only when application tries to write the data into the memory, kernel will mark the memory as used. This can lead to situation where the size of allocated memory is actually higher than the size of physical memory inside the machine. But as long as there is no demand for allocated memory, system is running without problems.</p>
<p>And this is the core of my dilemma. Shared memory is allocated, but since there is no data in it, it is not counted into used memory.</p>
<p>Memory overcommit can be configured via two parameters:</p>
<p class="code">loreto:/tmp # sysctl -a|grep overcommit<br />
vm.overcommit_ratio = 50<br />
vm.overcommit_memory = 0</p>
<p>From Red Hat manual:</p>
<ul>
<li><strong>overcommit_memory</strong> â€” Configures the conditions under which a large memory request is accepted or denied. The following three modes are available:
<ul>
<li><strong>0</strong> â€” The kernel performs heuristic memory over commit handling by estimating the amount of memory available and failing requests that are blatantly invalid. Unfortunately, since memory is allocated using a heuristic rather than a precise algorithm, this setting can sometimes allow available memory on the system to be overloaded. This is the default setting.</li>
<li><strong>1</strong> â€” The kernel performs no memory over commit handling. Under this setting, the potential for memory overload is increased, but so is performance for memory intensive tasks (such as those executed by some scientific software).</li>
<li><strong>2</strong> â€” The kernel fails requests for memory that add up to all of swap plus the percent of physical RAM specified in /proc/sys/vm/overcommit_ratio. This setting is best for those who desire less risk of memory overcommitment.<br />
<strong>Note</strong> This setting is only recommended for systems with swap areas larger than physical memory.</li>
</ul>
</li>
<li><strong>overcommit_ratio</strong> â€” Specifies the percentage of physical RAM considered when /proc/sys/vm/overcommit_memory is set to 2. The default value is 50.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2009/07/10/linux-memory-management/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pidgin status v2</title>
		<link>http://www.miljan.org/main/2008/10/10/pidgin-status-v2/</link>
		<comments>http://www.miljan.org/main/2008/10/10/pidgin-status-v2/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 19:34:58 +0000</pubDate>
		<dc:creator>miljan</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[News]]></category>
		<category><![CDATA[Pidgin]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.miljan.org/main/?p=64</guid>
		<description><![CDATA[As requested by bleketux, I made some modifications to pidgin_status.py script. Main news is that now it is possible to change Pidgin status message periodically. Script will go to background (it is a real daemon now :P), change the status, and wait for the set time interval until it changes the message again, and then [...]]]></description>
			<content:encoded><![CDATA[<p>As requested by bleketux, I made some modifications to pidgin_status.py script.</p>
<p>Main news is that now it is possible to change Pidgin status message periodically. Script will go to background (it is a real daemon now :P), change the status, and wait for the set time interval until it changes the message again, and then all over again, wait-change-wait-change.</p>
<p>To change status message every 5 minutes with a random line from file /home/miljan/quotes/dusko_radovic.txt:</p>
<p class="code">pidgin_status.py -d -t 5 -f /home/miljan/quote/dusko_radovic.txt</p>
<p>And in Pidgin you would get something like this every five minutes:<br />
<a href="http://www.miljan.org/main/wp-content/uploads/2008/10/status.png"><img class="alignnone size-full wp-image-63" title="status" src="http://www.miljan.org/main/wp-content/uploads/2008/10/status.png" alt="" width="264" height="88" /></a></p>
<p>To show the song you are listening to as status message:</p>
<p class="code">pidgin_status.py -s &#8220;Mukeka di Rato &#8211; Kustapassaaessedrmobral&#8221;</p>
<p>And in Pidgin it would look like:</p>
<p><a href="http://www.miljan.org/main/wp-content/uploads/2008/10/status1.png"><img class="alignnone size-full wp-image-65" title="status1" src="http://www.miljan.org/main/wp-content/uploads/2008/10/status1.png" alt="" width="267" height="90" /></a></p>
<p>You can see all possible options by running script with -h argument for help.</p>
<p>bleketux, I hope you are still around to enjoy this. ;)</p>
<p class="download"> Download: https://github.com/miljank/pidgin-status</p>
]]></content:encoded>
			<wfw:commentRss>http://www.miljan.org/main/2008/10/10/pidgin-status-v2/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
