<?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>Helion-Prime Solutions blog &#187; openBSD</title>
	<atom:link href="http://blogs.helion-prime.com/category/openbsd/feed" rel="self" type="application/rss+xml" />
	<link>http://blogs.helion-prime.com</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Sun, 18 Dec 2011 13:27:07 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Deployment of Ruby on Rails applications on OpenBSD</title>
		<link>http://blogs.helion-prime.com/2010/04/05/deployment-of-ruby-on-rails-applications-on-openbsd.html</link>
		<comments>http://blogs.helion-prime.com/2010/04/05/deployment-of-ruby-on-rails-applications-on-openbsd.html#comments</comments>
		<pubDate>Mon, 05 Apr 2010 12:35:56 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[openBSD]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=768</guid>
		<description><![CDATA[Preamble In this post I will define typical production environment on OpenBSD OS for deployment of Ruby on Rails applications. There are few common things: 1. The Ruby on Rails framework doesn&#8217;t support concurrent running in multiple threads within the same process, and so to scale it and fully utilize available hardware we need to [...]]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>In this post I will define typical production environment on OpenBSD OS for deployment of Ruby on Rails applications.</p>
<p>There are few common things:<br />
1. The Ruby on Rails framework doesn&#8217;t  support concurrent running in multiple threads within the same process, and so to scale it and fully utilize available hardware we need to execute application in several processes.<br />
2. We need load-balancer to spread incoming requests between application instances.<br />
3. We need separate web-server to serve static content.</p>
<h2>Overall configuration</h2>
<p>At first all incoming HTTP requests from a clients come to httpd web-server, it servers all static content, and send other requests to HAProxy.<br />
HAProxy receives requests and selects free Thin instance, forwards the request to it, receives a response and passes it back to httpd.</p>
<p>Following diagram should give you basic understanding about common work of components :<br />
<img class="alignnone size-full wp-image-779" title="deployment diagram" src="http://blogs.helion-prime.com/wp-content/uploads/2010/03/deployment_diagram.png" alt="deployment diagram" width="465" height="502" /></p>
<h2>OpenBSD Httpd – standard OpenBSD web-server</h2>
<p>I suggest OpenBSD standard web-server as you can find it as part of OpenBSD base installation, it checked for security issues and being updated as part of OpenBSD. We will use it to serve static content and don&#8217;t bother our Thin servers.</p>
<p>file: httpd.conf</p>
<div class="codecolorer-container apache mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br /></div></td><td><div class="apache codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #00007f;">BindAddress</span> SERVER_IP_ADDRESS<br />
<br />
<span style="color: #adadad; font-style: italic;"># Dynamic Shared Object (DSO) Support</span><br />
<span style="color: #adadad; font-style: italic;"># caching proxy</span><br />
<span style="color: #00007f;">LoadModule</span> proxy_module /usr/lib/apache/modules/libproxy.so<br />
<br />
<span style="color: #adadad; font-style: italic;"># allow Symbolic Links for root of our static content and all sub-directories</span><br />
<br />
<span style="color: #00007f;">Options</span> +<span style="color: #0000ff;">FollowSymLinks</span><br />
<span style="color: #00007f;">ServerAdmin</span> ADMIN_EMAIL<br />
<br />
<span style="color: #adadad; font-style: italic;"># path to root of our static content</span><br />
<span style="color: #00007f;">DocumentRoot</span> /var/www/railsdocs/RAILS_PROJECT/public<br />
<span style="color: #00007f;">ServerName</span> SERVER_NAME<br />
<span style="color: #00007f;">ServerAlias</span> www.SERVER_NAME<br />
<br />
<span style="color: #adadad; font-style: italic;"># directories that contain static content (they excluded from dispatching to HAProxy)</span><br />
<span style="color: #00007f;">ProxyPass</span> /images !<br />
<span style="color: #00007f;">ProxyPass</span> /stylesheets !<br />
<span style="color: #00007f;">ProxyPass</span> /javascripts !<br />
<span style="color: #00007f;">ProxyPass</span> /<span style="color: #ff0000;">500</span>.html !<br />
<span style="color: #00007f;">ProxyPass</span> /<span style="color: #ff0000;">503</span>.html !<br />
<br />
<span style="color: #adadad; font-style: italic;"># address where to send and from receive requests (HAProxy listens that address)</span><br />
<span style="color: #00007f;">ProxyPass</span> / http://127.0.0.1:<span style="color: #ff0000;">4000</span>/<br />
<span style="color: #00007f;">ProxyPassReverse</span> / http://127.0.0.1:<span style="color: #ff0000;">4000</span>/<br />
<br />
<span style="color: #adadad; font-style: italic;"># Disallows remote servers to be mapped into the space of the local server.</span><br />
<span style="color: #00007f;">ProxyRequests</span> <span style="color: #0000ff;">Off</span><br />
<br />
<span style="color: #adadad; font-style: italic;"># Don't use incoming Host HTTP request header for proxy request.</span><br />
<span style="color: #00007f;">ProxyPreserveHost</span> <span style="color: #0000ff;">Off</span><br />
<br />
<span style="color: #00007f;">ErrorLog</span> logs/SERVER_NAME-error_log<br />
<span style="color: #00007f;">CustomLog</span> logs/SERVER_NAME-access_log common</div></td></tr></tbody></table></div>
<p>see for configuration details: man httpd</p>
<p><strong>For OpenBSD 4.6/4.6 -Stable</strong><br />
It&#8217;s the hard part, OpenBSD4.6 has a bug in mod_proxy module so &#8216;!&#8217; directive doesn&#8217;t work.<br />
You have to edit following file:  /usr/src/usr.sbin/httpd/src/modules/proxy/mod_proxy.c</p>
<p>Find method: static int proxy_trans(request_rec *r)<br />
in that method after condition: if (len &gt; 0) {<br />
add 2 string:</p>
<div class="codecolorer-container c mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ent<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">real</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'!'</span> <span style="color: #339933;">&amp;&amp;</span> ent<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">real</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #b1b100;">return</span> DECLINED<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>so final part of code:<br />
&#8230;</p>
<div class="codecolorer-container c mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="c codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>len <span style="color: #339933;">&gt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><br />
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ent<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">real</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'!'</span> <span style="color: #339933;">&amp;&amp;</span> ent<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #202020;">real</span><span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'<span style="color: #006699; font-weight: bold;">\0</span>'</span><span style="color: #009900;">&#41;</span><br />
<span style="color: #b1b100;">return</span> DECLINED<span style="color: #339933;">;</span></div></td></tr></tbody></table></div>
<p>&#8230;</p>
<p>Then recompile your system, it&#8217;s common procedure for following -stable so you should already know it otherwise see for details for building instructions: <a href="http://www.openbsd.org/faq/faq5.html">http://www.openbsd.org/faq/faq5.html</a></p>
<h2>Thin – high performance ruby web server</h2>
<p>We need some Ruby web-server, and it seems that at this time Thin provides best performance.<br />
At least we see such results on Thin homepage: <a href="http://code.macournoyer.com/thin/">http://code.macournoyer.com/thin/</a></p>
<p>file: start.sh</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># start work instances</span><br />
thin start <span style="color: #660033;">-C</span> thin-production.yml</div></td></tr></tbody></table></div>
<p>file: thin-production.yml</p>
<div class="codecolorer-container yaml mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br /></div></td><td><div class="yaml codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: cyan;">---</span><span style="color: green;"><br />
environment</span><span style="font-weight: bold; color: brown;">: </span>production<br />
<span style="color: green;"><br />
port</span><span style="font-weight: bold; color: brown;">: </span><span style="">4001</span><span style="color: green;"><br />
address</span><span style="font-weight: bold; color: brown;">: </span>127.0.0.1<span style="color: green;"><br />
daemonize</span><span style="font-weight: bold; color: brown;">: </span>true<span style="color: green;"><br />
servers</span><span style="font-weight: bold; color: brown;">: </span><span style="">4</span><br />
<span style="color: green;"><br />
chdir</span><span style="font-weight: bold; color: brown;">: </span>/var/www/railsdocs/RAILS_PROJECT<span style="color: green;"><br />
pid</span><span style="font-weight: bold; color: brown;">: </span>tmp/pids/thin.pid<span style="color: green;"><br />
log</span><span style="font-weight: bold; color: brown;">: </span>log/thin.log<br />
<span style="color: green;"><br />
user</span><span style="font-weight: bold; color: brown;">: </span>myuser<span style="color: green;"><br />
group</span><span style="font-weight: bold; color: brown;">: </span>mygroup<br />
<span style="color: green;"><br />
require</span><span style="font-weight: bold; color: brown;">: </span><span class="br0">&#91;</span><span class="br0">&#93;</span></div></td></tr></tbody></table></div>
<p>see for configuration details: <a href="http://code.macournoyer.com/thin/usage/">http://code.macournoyer.com/thin/usage/</a></p>
<h2>HAproxy &#8211; TCP/ HTTP load balancer</h2>
<p>As Rails doesn&#8217;t  support concurrent running each incoming request should be assigned to a separate process. HAProxy can be configured to send only one request at a time to every Thin server, it will always pick instance that is not busy with something.</p>
<p>It provides bunch of other useful things like:<br />
– route HTTP requests depending on statically assigned cookies ;<br />
– switch to backup servers in the event a main one fails ;<br />
– accept connections to special ports dedicated to service monitoring ;<br />
– add/modify/delete HTTP headers both ways ;<br />
– block requests matching a particular pattern ;<br />
for full documentation see: <a href="http://haproxy.1wt.eu/#docs">http://haproxy.1wt.eu/#docs</a></p>
<p>note:<br />
If someone thinks that we could use nginx for that purpose check following performance comparison of HAProxy and Nginx:<br />
<a href="http://affectioncode.wordpress.com/2008/06/28/another-comparison-of-haproxy-and-nginx/">http://affectioncode.wordpress.com/2008/06/28/another-comparison-of-haproxy-and-nginx/</a></p>
<p>file: haproxy.cfg</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">defaults<br />
log &nbsp; &nbsp; global<br />
mode &nbsp; &nbsp;http<br />
<br />
<span style="color: #666666; font-style: italic;"># provides more detailed information about HTTP contents, such as the request and some cookies</span><br />
option &nbsp;httplog<br />
<span style="color: #666666; font-style: italic;"># do not to log any session which didn't transfer any data</span><br />
option &nbsp;dontlognull<br />
<span style="color: #666666; font-style: italic;"># allow the proxy to break their persistence and redistribute connections in case of failure</span><br />
option &nbsp;redispatch<br />
<br />
<span style="color: #666666; font-style: italic;"># the number of attempts to reconnect after a connection failure to a server</span><br />
retries <span style="color: #000000;">3</span><br />
<br />
<span style="color: #666666; font-style: italic;"># the time we accept to wait for a connection to establish on a server</span><br />
contimeout &nbsp; &nbsp; &nbsp;<span style="color: #000000;">100000</span><br />
<span style="color: #666666; font-style: italic;"># the time we accept to wait for data from the client, or for the client to accept data</span><br />
clitimeout &nbsp; &nbsp; &nbsp;<span style="color: #000000;">100000</span><br />
<span style="color: #666666; font-style: italic;"># the time we accept to wait for data from the server, or for the server to accept data</span><br />
srvtimeout &nbsp; &nbsp; &nbsp;<span style="color: #000000;">100000</span><br />
<br />
listen project_proxy 127.0.0.1:<span style="color: #000000;">4000</span><br />
balance roundrobin<br />
<br />
<span style="color: #666666; font-style: italic;"># creates an HTTP 'X-Forwarded-For' header which contains the client's IP address.</span><br />
<span style="color: #666666; font-style: italic;"># This is useful to let the final web server know what the client address was</span><br />
option forwardfor<br />
<br />
<span style="color: #666666; font-style: italic;"># using “maxconn 1″ improves performance with Rails.</span><br />
<span style="color: #666666; font-style: italic;"># As Rails instance can process only 1 request “maxconn 1″ force HAProxy to select next free instance</span><br />
<br />
server &nbsp;app1_1 127.0.0.1:<span style="color: #000000;">4001</span> check inter <span style="color: #000000;">60000</span> rise <span style="color: #000000;">2</span> fall <span style="color: #000000;">5</span> maxconn <span style="color: #000000;">1</span><br />
server &nbsp;app1_2 127.0.0.1:<span style="color: #000000;">4002</span> check inter <span style="color: #000000;">60000</span> rise <span style="color: #000000;">2</span> fall <span style="color: #000000;">5</span> maxconn <span style="color: #000000;">1</span><br />
server &nbsp;app1_3 127.0.0.1:<span style="color: #000000;">4003</span> check inter <span style="color: #000000;">60000</span> rise <span style="color: #000000;">2</span> fall <span style="color: #000000;">5</span> maxconn <span style="color: #000000;">1</span><br />
server &nbsp;app1_4 127.0.0.1:<span style="color: #000000;">4004</span> check inter <span style="color: #000000;">60000</span> rise <span style="color: #000000;">2</span> fall <span style="color: #000000;">5</span> maxconn <span style="color: #000000;">1</span><br />
<br />
<span style="color: #666666; font-style: italic;"># httpd web-server will handle it in case of 503, 504 errors due to it's static content</span><br />
errorloc &nbsp; &nbsp;<span style="color: #000000;">503</span> &nbsp;http:<span style="color: #000000; font-weight: bold;">//</span>DOMAIN_NAME<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">503</span>.html<br />
errorloc &nbsp; &nbsp;<span style="color: #000000;">504</span> &nbsp;http:<span style="color: #000000; font-weight: bold;">//</span>DOMAIN_NAME<span style="color: #000000; font-weight: bold;">/</span><span style="color: #000000;">504</span>.html<br />
<br />
<span style="color: #666666; font-style: italic;"># statistics page thru http://127.0.0.1:8080</span><br />
listen stats 127.0.0.1:<span style="color: #000000;">8080</span><br />
balance roundrobin<br />
mode http<br />
stats uri &nbsp; <span style="color: #000000; font-weight: bold;">/</span></div></td></tr></tbody></table></div>
<p>see for configuration details: <a href="http://haproxy.1wt.eu/#docs">http://haproxy.1wt.eu/#docs</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2010/04/05/deployment-of-ruby-on-rails-applications-on-openbsd.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Tuning of Postgresql under OpenBSD</title>
		<link>http://blogs.helion-prime.com/2010/02/25/tuning-of-postgresql-under-openbsd.html</link>
		<comments>http://blogs.helion-prime.com/2010/02/25/tuning-of-postgresql-under-openbsd.html#comments</comments>
		<pubDate>Thu, 25 Feb 2010 15:04:00 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[openBSD]]></category>
		<category><![CDATA[rdbms]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[RoR]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=664</guid>
		<description><![CDATA[Preamble I assume that you already made your best with help of your favorite programming language and recommended postgresql performance tips: http://www.postgresql.org/docs/8.4/static/performance-tips.html Postgresql resources No doubt that standard postgresql configuration is far from modern production environments. Therefore you need to spend enough time with following sources. 1. resource consumption documentation: http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html The most important parameters [...]]]></description>
			<content:encoded><![CDATA[<h2>Preamble</h2>
<p>I assume that you already made your best with help of your favorite programming language<br />
and recommended postgresql performance tips: <a href="http://www.postgresql.org/docs/8.4/static/performance-tips.html">http://www.postgresql.org/docs/8.4/static/performance-tips.html</a></p>
<h2>Postgresql resources</h2>
<p>No doubt that standard postgresql configuration is far from modern production environments.<br />
Therefore you need to spend enough time with following sources.</p>
<p><strong>1. resource consumption documentation:</strong><br />
<a href="http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html">http://www.postgresql.org/docs/8.4/static/runtime-config-resource.html</a></p>
<p>The most important parameters are:<br />
work_mem (integer)<br />
shared_buffers (integer)</p>
<p><strong>2. Query Planning documentation:</strong><br />
<a href="http://www.postgresql.org/docs/current/static/runtime-config-query.html">http://www.postgresql.org/docs/current/static/runtime-config-query.html</a></p>
<p>The most important parameters are:<br />
effective_cache_size (integer)<br />
random_page_cost (floating point)</p>
<h2>OpenBSD resources</h2>
<p>The default sizes in the GENERIC kernel are insignificant also and waiting for your tuning as well.<br />
Posgtresql doesn&#8217;t start without enough memory size so always know when you need to increase kern.shminfo.shmmax.</p>
<p><strong>Setting that we can change in /etc/sysctl.conf</strong><br />
the maximum number of System V IPC system-wide semaphore sets (and identifiers) which can exist at any given time:<br />
kern.seminfo.semmni</p>
<p>the maximum total individual System V IPC semaphores which can be assigned by applications:<br />
kern.seminfo.semmns</p>
<p>the amount of shared memory available in the system (bytes):<br />
kern.shminfo.shmmax</p>
<p>the maximum number of shared memory segments:<br />
sysctl kern.shminfo.shmseg</p>
<p>Full list of setting you can see with:<br />
# man sysctl</p>
<p><strong>OpenBSD kernel parameters</strong><br />
So, there are set of parameters that can be tuned only with kernel rebuild. </p>
<p>You should tune them only if system works unstable with default values and you have:<br />
kernel warnings: “uvm_mapent_alloc: out of static map entries”<br />
or panics like:  “panic: malloc: out of space in kmem_map”</p>
<p>NKMEMPAGES<br />
This option defines number of pages in kernel kmem_map structure.</p>
<p>MAX_KMAPENT<br />
It defines number of static entries in kernel kmem_map (kernel virtual memory).</p>
<p>They can be changed in:<br />
/usr/src/sys/arch/conf/GENERIC</p>
<p>As start you need to recheck  &#8216;Building the System from Source&#8217; part of OpenBSD documentation:<br />
<a href="http://openbsd.org/faq/faq5.htm">http://openbsd.org/faq/faq5.htm</a></p>
<p>Usually administrators select these parameters using set of tests on dedicated testing box where<br />
 they emulate load of  production servers.</p>
<h2>Example</h2>
<p>our test server: 1x Intel Quad core CPU, 2GB RAM<br />
software: Ruby on Rails application, postgresql DB, memcached.<br />
load: about 15.000 users/day, peak load: 10 users/sec.</p>
<p>postgresql_dir/data/postgresql.conf</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;"># RESOURCE USAGE</span><br />
shared_buffers = 738MB<br />
max_prepared_transactions = <span style="color: #000000;">30</span><br />
work_mem = 16MB<br />
max_fsm_pages = <span style="color: #000000;">2000000</span><br />
<br />
<span style="color: #666666; font-style: italic;"># QUERY TUNING</span><br />
effective_cache_size = 512MB<br />
random_page_cost = <span style="color: #000000;">1.7</span></div></td></tr></tbody></table></div>
<p>/etc/sysctl.conf</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">kern.seminfo.semmni = <span style="color: #000000;">256</span><br />
kern.seminfo.semmns = <span style="color: #000000;">2048</span><br />
kern.shminfo.shmmax = <span style="color: #000000;">805306368</span> &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># Shared memory segment size is 768M</span></div></td></tr></tbody></table></div>
<p>/usr/src/sys/arch/conf/GENERIC</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">## custom settings</span><br />
option MAX_KMAPENT = <span style="color: #000000;">3072</span><br />
option NKMEMPAGES = <span style="color: #000000;">32768</span></div></td></tr></tbody></table></div>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2010/02/25/tuning-of-postgresql-under-openbsd.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fast scalability of Ruby on Rails with mongrel under OpenBSD</title>
		<link>http://blogs.helion-prime.com/2009/08/12/fast-scalability-of-ruby-on-rails-with-mongrel-under-openbsd.html</link>
		<comments>http://blogs.helion-prime.com/2009/08/12/fast-scalability-of-ruby-on-rails-with-mongrel-under-openbsd.html#comments</comments>
		<pubDate>Wed, 12 Aug 2009 15:00:30 +0000</pubDate>
		<dc:creator>alex.shapovalov</dc:creator>
				<category><![CDATA[internet]]></category>
		<category><![CDATA[openBSD]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[web-development]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=546</guid>
		<description><![CDATA[preamble Everybody who works with ruby on rails more then month knows at least 2 things: it&#8217;s great framework, but can&#8217;t handle multiple requests simultaneously due to it still doesn&#8217;t use threads. fast start As scalability is common issue, rubyonrails site wiki provides full set of solutions: [http://wiki.rubyonrails.org/#deployment_stacks] But we as fast solution will use [...]]]></description>
			<content:encoded><![CDATA[<h2>preamble</h2>
<p>Everybody who works with ruby on rails more then month knows at least 2 things:<br />
it&#8217;s great framework, but can&#8217;t handle multiple requests simultaneously due to it still doesn&#8217;t use threads.</p>
<h2>fast start</h2>
<p>As scalability is common issue, rubyonrails site wiki provides full set of solutions:<br />
[<a href="http://wiki.rubyonrails.org/#deployment_stacks">http://wiki.rubyonrails.org/#deployment_stacks</a>]</p>
<p>But we as fast solution will use great OpenBSD pf (Packet Filter) that capable to do many cool things.<br />
First issue is standard mongrail cluster that can start several instances of mongrail can only create them on one IP with different ports, and pf can&#8217;t distribute requests among different ports on same IP.</p>
<p>Here we can create 2 simple scripts that start and destroy server instances:<br />
# cat start.sh</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">count</span>=<span style="color: #000000;">1</span><br />
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #c20cb9; font-weight: bold;">ip</span> <span style="color: #000000; font-weight: bold;">in</span> 10.0.0.1 10.0.0.2 10.0.0.3 10.0.0.4 10.0.0.5<br />
<span style="color: #000000; font-weight: bold;">do</span><br />
mongrel_rails start <span style="color: #660033;">-e</span> production <span style="color: #660033;">-d</span> <span style="color: #660033;">--user</span> myapp <span style="color: #660033;">--group</span> myapp <span style="color: #660033;">--chdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>railsdocs<span style="color: #000000; font-weight: bold;">/</span>myapp \<br />
<span style="color: #660033;">--address</span> <span style="color: #800000;">${ip}</span> \<br />
<span style="color: #660033;">--pid</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>railsdocs<span style="color: #000000; font-weight: bold;">/</span>myapp<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>pids<span style="color: #000000; font-weight: bold;">/</span>mongrel.<span style="color: #800000;">${count}</span>.pid \<br />
<span style="color: #660033;">--log</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>railsdocs<span style="color: #000000; font-weight: bold;">/</span>myapp<span style="color: #000000; font-weight: bold;">/</span>log<span style="color: #000000; font-weight: bold;">/</span>mongrel.<span style="color: #800000;">${count}</span>.log<br />
<br />
<span style="color: #007800;">count</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">$count</span> + <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
<span style="color: #000000; font-weight: bold;">done</span></div></td></tr></tbody></table></div>
<p># cat stop.sh</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">for</span> instance <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>..<span style="color: #000000;">5</span><span style="color: #7a0874; font-weight: bold;">&#125;</span><br />
<span style="color: #000000; font-weight: bold;">do</span><br />
mongrel_rails stop <span style="color: #660033;">--wait</span> <span style="color: #000000;">3</span> <span style="color: #660033;">--chdir</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>railsdocs<span style="color: #000000; font-weight: bold;">/</span>myapp \<br />
<span style="color: #660033;">--pid</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>www<span style="color: #000000; font-weight: bold;">/</span>railsdocs<span style="color: #000000; font-weight: bold;">/</span>myapp<span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>pids<span style="color: #000000; font-weight: bold;">/</span>mongrel.<span style="color: #800000;">${instance}</span>.pid<br />
end</div></td></tr></tbody></table></div>
<p>And we need to enable pf:<br />
#/etc/rc.conf.local</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">pf</span>=YES<br />
<span style="color: #666666; font-style: italic;">#pflogd_flags= &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # add more flags, ie. &quot;-s 256&quot;</span></div></td></tr></tbody></table></div>
<p>add one string to configuration file for load distribution:<br />
#/etc/pf.conf</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">rdr pass log on re0 proto tcp from any to SOME_IP port <span style="color: #000000;">80</span> -<span style="color: #000000; font-weight: bold;">&gt;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#123;</span>10.0.0.1, 10.0.0.2, 10.0.0.3, 10.0.0.4, 10.0.0.5 <span style="color: #7a0874; font-weight: bold;">&#125;</span> port <span style="color: #000000;">3000</span> round-robin</div></td></tr></tbody></table></div>
<p>check work with:<br />
# pfctl -s nat</p>
<p>monitor with:<br />
tcpdump -n -e -ttt -i pflog0</p>
<p>for more info on pf:<br />
<a href="http://www.openbsd.org/faq/pf/">http://www.openbsd.org/faq/pf/</a><br />
man pf.conf (especially &#8216;TRANSLATION&#8217; and &#8216;POOL OPTIONS&#8217; sections)</p>
<p>Then when you see you need more advanced solution for load distribution you can install haproxy.<br />
Check it with [<a href="http://www.openbsd.org/4.5_packages/i386/haproxy-1.3.15.7.tgz-long.html">http://www.openbsd.org/4.5_packages/i386/haproxy-1.3.15.7.tgz-long.html</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2009/08/12/fast-scalability-of-ruby-on-rails-with-mongrel-under-openbsd.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Authorization with LDAP on OpenBSD</title>
		<link>http://blogs.helion-prime.com/2009/05/07/authorization-with-ldap-on-openbsd.html</link>
		<comments>http://blogs.helion-prime.com/2009/05/07/authorization-with-ldap-on-openbsd.html#comments</comments>
		<pubDate>Thu, 07 May 2009 11:22:46 +0000</pubDate>
		<dc:creator>vasiliy.kiryanov</dc:creator>
				<category><![CDATA[openBSD]]></category>
		<category><![CDATA[ldap]]></category>
		<category><![CDATA[login_ldap]]></category>
		<category><![CDATA[ypldap]]></category>

		<guid isPermaLink="false">http://blogs.helion-prime.com/?p=486</guid>
		<description><![CDATA[preamble common case: you have LDAP server and want to use it to authorize your users on OpenBSD. First thing is to understand if you really want to use LDAP server for authorization due to OpenBSD doesn&#8217;t have build-in support for it. But has such support for many others authorization styles: # passwd local password [...]]]></description>
			<content:encoded><![CDATA[<h2>preamble</h2>
<p>common case: you have LDAP server and want to use it to authorize your users on OpenBSD.</p>
<p>First thing is to understand if you really want to use LDAP server for authorization due to OpenBSD doesn&#8217;t have build-in support for it.</p>
<p>But has such support for many others authorization styles:<br />
# passwd local password file<br />
# krb5 Kerberos V password<br />
# radius radius authentication<br />
# skey S/Key authentication<br />
# activ activCard X9.9 token authentication<br />
# crypto CRYPTOCard X9.9 token authentication<br />
# snk Digital Pathways SecureNet Key authentication<br />
# token Generic X9.9 token authentication</p>
<p>see for details: man login.conf</p>
<h2>setup as pain</h2>
<p><strong>1. login_ldap &#8211; contact ldap directory server for authentication</strong></p>
<p>install login_ldap package:<br />
# pkg_add -iv login_ldap</p>
<p>use example files in: [/usr/local/share/examples/login_ldap/]<br />
configure it in /etc/login.conf</p>
<p>you should add something like this:</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">ldap:\<br />
&nbsp; &nbsp; &nbsp; &nbsp; :<span style="color: #007800;">auth</span>=-ldap:\<br />
&nbsp; &nbsp; &nbsp; &nbsp; :x-ldap-server=127.0.0.1,,ssl:\<br />
&nbsp; &nbsp; &nbsp; &nbsp; :x-ldap-basedn=<span style="color: #007800;">ou</span>=Users,<span style="color: #007800;">ou</span>=auth,<span style="color: #007800;">dc</span>=helion-prime,<span style="color: #007800;">dc</span>=com:\<br />
&nbsp; &nbsp; &nbsp; &nbsp; :x-ldap-filter=<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">&amp;</span>amp;<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">objectclass</span>=posixAccount<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #007800;">uid</span>=<span style="color: #000000; font-weight: bold;">%</span>u<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>:\<br />
&nbsp; &nbsp; &nbsp; &nbsp; :<span style="color: #007800;">tc</span>=default:</div></td></tr></tbody></table></div>
<p>look for details:  man login_ldap</p>
<p>test it with: #  /usr/libexec/auth/login_-ldap -d -s login USERNAME ldap</p>
<p><strong>2. ypldap &#8211; YP map server using LDAP backend (provide users&#8217; info)</strong></p>
<p>as OpenBSD has great support for YP using of ypldap provides soft integration of LDAP server.</p>
<p>use example in man: man ypldap.conf<br />
configure it in /etc/ypldap.conf</p>
<p>you should have something like this:</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">interval <span style="color: #000000;">100</span><br />
domain <span style="color: #ff0000;">&quot;helion-prime.com&quot;</span><br />
<br />
provide map <span style="color: #ff0000;">&quot;passwd.byname&quot;</span><br />
provide map <span style="color: #ff0000;">&quot;passwd.byuid&quot;</span><br />
provide map <span style="color: #ff0000;">&quot;group.byname&quot;</span><br />
provide map <span style="color: #ff0000;">&quot;group.bygid&quot;</span><br />
<br />
directory <span style="color: #ff0000;">&quot;127.0.0.1&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># directory options</span><br />
&nbsp; &nbsp;binddn <span style="color: #ff0000;">&quot;cn=Manager,dc=helion-prime,dc=com&quot;</span><br />
&nbsp; &nbsp;bindcred <span style="color: #ff0000;">&quot;password&quot;</span> <span style="color: #666666; font-style: italic;">#we don't need it if anonymous searches are allowed</span><br />
&nbsp; &nbsp;basedn <span style="color: #ff0000;">&quot;ou=Users,ou=auth,dc=helion-prime,dc=com&quot;</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># passwd maps configuration</span><br />
&nbsp; &nbsp;<span style="color: #c20cb9; font-weight: bold;">passwd</span> filter <span style="color: #ff0000;">&quot;(objectClass=posixAccount)&quot;</span><br />
<br />
&nbsp; &nbsp;attribute name maps to <span style="color: #ff0000;">&quot;uid&quot;</span><br />
&nbsp; &nbsp;fixed attribute <span style="color: #c20cb9; font-weight: bold;">passwd</span> <span style="color: #ff0000;">&quot;*&quot;</span> <span style="color: #666666; font-style: italic;"># we do no need passwords - we use login_ldap for authentication</span><br />
&nbsp; &nbsp;attribute uid maps to <span style="color: #ff0000;">&quot;uidNumber&quot;</span><br />
&nbsp; &nbsp;attribute gid maps to <span style="color: #ff0000;">&quot;gidNumber&quot;</span><br />
&nbsp; &nbsp;attribute gecos maps to <span style="color: #ff0000;">&quot;cn&quot;</span><br />
&nbsp; &nbsp;attribute home maps to <span style="color: #ff0000;">&quot;homeDirectory&quot;</span><br />
&nbsp; &nbsp;fixed attribute shell <span style="color: #ff0000;">&quot;/bin/ksh&quot;</span> &nbsp;<span style="color: #666666; font-style: italic;"># no bash in default install (check it)</span><br />
&nbsp; &nbsp;fixed attribute change <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #666666; font-style: italic;"># we can have issues with time format (check it)</span><br />
&nbsp; &nbsp;fixed attribute expire <span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #666666; font-style: italic;"># we can have issues with time format (check it)</span><br />
&nbsp; &nbsp;fixed attribute class <span style="color: #ff0000;">&quot;ldap&quot;</span> <span style="color: #666666; font-style: italic;"># class of login.conf</span><br />
<br />
&nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># group maps configuration</span><br />
&nbsp; &nbsp;group filter <span style="color: #ff0000;">&quot;(objectClass=posixGroup)&quot;</span><br />
<br />
&nbsp; &nbsp;attribute groupname maps to <span style="color: #ff0000;">&quot;cn&quot;</span><br />
&nbsp; &nbsp;fixed attribute grouppasswd <span style="color: #ff0000;">&quot;*&quot;</span><br />
&nbsp; &nbsp;attribute groupgid maps to <span style="color: #ff0000;">&quot;gidNumber&quot;</span><br />
&nbsp; &nbsp;list groupmembers maps to <span style="color: #ff0000;">&quot;memberUid&quot;</span><br />
<span style="color: #7a0874; font-weight: bold;">&#125;</span></div></td></tr></tbody></table></div>
<p>test it with:  # ypldap -dv</p>
<p>as ypldad currently doesn&#8217;t support ldap over ssl, you should configure your ldap server to listen over regular ldap.<br />
I believe developer soon will create appropriate support for it.</p>
<p><strong>3. ypbind &#8211; create and maintain a binding to a YP server</strong></p>
<p>add your domainname to /etc/defaultdomain<br />
# echo DOMAINNAME &gt; /etc/defaultdomain</p>
<p>the standard way to enable YP passwd support in /etc/master.passwd is to add string: +:::::::::/bin/ksh<br />
use vipw to edit  master.passwd</p>
<p>see for details: man 5 passwd</p>
<p>same with groups:<br />
# echo &#8220;+:::&#8221; &gt;&gt; /etc/group</p>
<p>see for details: man 5 group</p>
<p><strong>4. automate execution</strong></p>
<p>worst part is: we should modify: /etc/rc script</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> X<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">domainname</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #000000; font-weight: bold;">!</span>= X <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>yp<span style="color: #000000; font-weight: bold;">/`</span><span style="color: #c20cb9; font-weight: bold;">domainname</span><span style="color: #000000; font-weight: bold;">`</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;"># YP server capabilities needed...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">' ypserv'</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ypserv <span style="color: #800000;">${ypserv_flags}</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666666; font-style: italic;">#echo -n ' ypxfrd'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ypxfrd</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#if [ -d /var/yp/binding ]; then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; # YP client capabilities needed...</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># &nbsp; &nbsp; &nbsp; echo -n ' ypbind'; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ypbind</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #666666; font-style: italic;">#fi</span><br />
....</div></td></tr></tbody></table></div>
<p>second entry will run ypbind before  ypldap that we exec according to OpenBSD rules in rc.local</p>
<p>Then we should add something like this to: /etc/rc/local</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> X<span style="color: #ff0000;">&quot;<span style="color: #007800;">${ypldap_flags}</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= X<span style="color: #ff0000;">&quot;NO&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">' ypldap'</span>; <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>sbin<span style="color: #000000; font-weight: bold;">/</span>ypldap <span style="color: #800000;">${ypldap_flags}</span> <span style="color: #000000;">1</span><span style="color: #000000; font-weight: bold;">&amp;</span>gt; <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null <span style="color: #000000; font-weight: bold;">&amp;</span>amp;<br />
<span style="color: #000000; font-weight: bold;">fi</span><br />
<br />
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #660033;">-d</span> <span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>yp<span style="color: #000000; font-weight: bold;">/</span>binding <span style="color: #7a0874; font-weight: bold;">&#93;</span>; <span style="color: #000000; font-weight: bold;">then</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #660033;">-n</span> <span style="color: #ff0000;">' ypbind'</span>; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ypbind<br />
<span style="color: #000000; font-weight: bold;">fi</span></div></td></tr></tbody></table></div>
<p>And to /etc/rc.conf.local:</p>
<div class="codecolorer-container bash mac-classic" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #007800;">portmap</span>=YES<br />
<span style="color: #007800;">ypldap_flags</span>=<span style="color: #ff0000;">&quot;&quot;</span></div></td></tr></tbody></table></div>
<p>When I review text I see that it is quite easy and it is hard to believe someone can spend more then hour on this ..<br />
Good luck, guys..</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.helion-prime.com/2009/05/07/authorization-with-ldap-on-openbsd.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

