<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Gkoenig&#039;s Blog</title>
	<atom:link href="http://gkoenig.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gkoenig.wordpress.com</link>
	<description>content is almost exclusive related to IT stuff (linux, database,...)</description>
	<lastBuildDate>Fri, 25 Nov 2011 06:43:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gkoenig.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Gkoenig&#039;s Blog</title>
		<link>http://gkoenig.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gkoenig.wordpress.com/osd.xml" title="Gkoenig&#039;s Blog" />
	<atom:link rel='hub' href='http://gkoenig.wordpress.com/?pushpress=hub'/>
		<item>
		<title>pgTAP ~ Unit Tests for PostgreSQL ~ Part II ~</title>
		<link>http://gkoenig.wordpress.com/2011/03/15/pgtap-unit-tests-for-postgresql-part-ii/</link>
		<comments>http://gkoenig.wordpress.com/2011/03/15/pgtap-unit-tests-for-postgresql-part-ii/#comments</comments>
		<pubDate>Tue, 15 Mar 2011 07:53:24 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[pgtap]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[unittest]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=128</guid>
		<description><![CDATA[as promised in my previous post regarding pgTAP ( aka Part I ) here, I&#8217;ll continue this topic with checking some data in the database. Setup and basic handling of pgTAP was described in Part I also, for this reason I&#8217;ll concentrate on the test functions, which are used in the following script frame (just [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=128&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>as promised in my previous post regarding pgTAP ( aka Part I ) <a href="http://gkoenig.wordpress.com/2011/03/04/pgtap-unit-tests-for-postgresql/">here</a>, I&#8217;ll continue this topic with checking some data in the database. Setup and basic handling of pgTAP was described in  <a href="http://gkoenig.wordpress.com/2011/03/04/pgtap-unit-tests-for-postgresql/">Part I</a> also, for this reason I&#8217;ll concentrate on the test functions, which are used in the following script frame (just replace &#8220;##put_ypur_tests_here##&#8221; with the test scenarios described later on):</p>
<p><code>-- Format the output for nice TAP.<br />
\pset format unaligned<br />
\pset tuples_only true<br />
\pset pager<br />
-- Revert all changes on failure.<br />
\set ON_ERROR_ROLLBACK 1<br />
\set ON_ERROR_STOP true<br />
\set QUIET 1<br />
BEGIN;<br />
\i ./pgtap.sql<br />
-- create two tables with referential constraint<br />
create table tab1 (id integer not null, a_text varchar(200), dt timestamp default now(), CONSTRAINT tab1_pkey PRIMARY KEY (id));<br />
create table tab2 (id integer not null, a_text varchar(200), id_ref integer, CONSTRAINT id_ref FOREIGN KEY (id_ref) REFERENCES tab1 (id));<br />
-- insert some test data<br />
insert into tab1 (id,a_text) values (1,'test entry one');<br />
insert into tab1 (id,a_text) values (2,'test entry two');<br />
insert into tab1 (id,a_text) values (3,'test entry three');<br />
insert into tab2 (id,a_text,id_ref) values (1,'ref test entry one',1);<br />
insert into tab2 (id,a_text,id_ref) values (2,'ref test entry one',2);<br />
insert into tab2 (id,a_text,id_ref) values (3,'ref test entry one',3);<br />
SELECT plan(10);  -- run a maximum of ten tests<br />
##put_your_tests_here##<br />
-- get the results<br />
SELECT * FROM finish();<br />
ROLLBACK;</code></p>
<p><strong>What do we want to test ?</strong></p>
<ul>
<li>Are the inserted values really there ?<br />
The preferrable way to check data is via prepared statements compared to your expected result/array of results, if you just want to test plain data.<br />
A very convenient way is the function <strong>results_eq()</strong>, easy to show with an example:&nbsp;</p>
<p><code>-- check inserted data<br />
-- ...with two prepared statements. 2nd example will be more flexible with cursors<br />
PREPARE ids_fetched AS select id from tab1 where id in (1,2,3) order by id asc;<br />
PREPARE ids_expected AS VALUES (1),(2),(3);<br />
SELECT results_eq( 'ids_fetched', 'ids_expected', 'fetched the expected ids from tab1');<br />
PREPARE ids_fetched1 AS select id from tab1 where id in (1,2,3) order by id asc;<br />
PREPARE ids_fetched2 AS select id from tab2 where id in (1,2,3) order by id asc;<br />
SELECT results_eq( 'ids_fetched1', 'ids_fetched2');</code></p>
<p>You don&#8217;t have to put your expected values in a prepared statement (like in the 1st example), it is also possible to pass this values as function parameters for <strong>set_eq()</strong>:</p>
<p><code>-- ...with a mixture of prepared statements and predefined values<br />
PREPARE text_fetched AS select a_text::text from tab1 where id in (1,2) order by id asc;<br />
SELECT set_eq( 'text_fetched', ARRAY[ 'test entry one','test entry two' ], 'fetched the expected text from tab1');<br />
</code></li>
<li>Does a function return the expected result ?<br />
In addition to test the availability of expected values is to check the return values of your own designed functions. Let&#8217;s assume that we created a function which returns all the ids from tab1 in ascending order, now let&#8217;s test if it is working as expected. In this case there are two alternatives performing the test recordset by recordset. On the one hand by simple function/statement comparison, on the other hand by using cursors. I&#8217;ll show you both:</p>
<p><code><br />
-- create a (simple) function<br />
create or replace function get_ids_tab1() returns setof integer as 'select id from tab1 order by id asc' language 'sql';<br />
-- check output of function<br />
-- ...with simple calls<br />
SELECT results_eq('select * from get_ids_tab1()', 'select id from tab1 order by id asc','get_ids_tab1() should return ids from relation tab1 in ascending order');<br />
-- ...with cursors<br />
DECLARE ids_function CURSOR FOR SELECT * FROM get_ids_tab1();<br />
DECLARE ids_relation CURSOR FOR SELECT id FROM tab1 order by id asc;<br />
SELECT results_eq('ids_function'::refcursor,'ids_relation'::refcursor,'Gotcha ! function returned the expected values.');<br />
</code>
</li>
<li>Raising errors intentionally and catching them
<p><code>-- simulate some errors<br />
PREPARE throw_error AS insert into tab1 (id,a_text) values (1,'this insert throws a duplicate key error');<br />
SELECT throws_ok('throw_error','23505',NULL,'Insert failed because of duplicate key violation (id)');<br />
</code></p>
<p>But how do one know this error number postgres will throw ?<br />
throws_ok() will tell you <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  . Have a look at the next example. It will try to insert a row in tab2 with a reference to id &#8220;4&#8243; in tab1, which obviously doesn&#8217;t exist. Therefore we expect an error. Since we don&#8217;t know the error number, I put the value &#8220;-1&#8243; as error number and the function call will fail with a verbose message what was thrown, and what we did expect:</p>
<p><code><br />
PREPARE ref_fail AS insert into tab2 (id, a_text, id_ref) values (4,'ref test entry four',4);<br />
SELECT throws_ok('ref_fail','-1',NULL,'Insert failed because of (ref_id)');<br />
</code></p>
<p>Running the test script will produce the following output (in my case this was the 6th test which had been executed):</p>
<p><code><br />
# Failed test 6: "Insert failed because of (ref_id)"<br />
#       caught: 23503: insert or update on table "tab2" violates foreign key constraint "id_ref"<br />
#       wanted: -1<br />
</code></p>
<p>Aaaahhhh&#8230;.the violated foreign key constraint has the errorcode 23503, so we can replace the &#8220;-1&#8243; by &#8220;23503&#8243; and the test will succeed.</li>
</ul>
<p>These are just some of the available test functions pgTAP provides. A complete overview is <a href="http://pgtap.org/documentation.html">here</a> and it is worth looking.</p>
<p>Hopefully you got a first, short overview what pgTAP is for, please let me know if you miss something or there&#8217;s something wrong.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=128&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2011/03/15/pgtap-unit-tests-for-postgresql-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>pgTAP ~ Unit Tests for PostgreSQL</title>
		<link>http://gkoenig.wordpress.com/2011/03/04/pgtap-unit-tests-for-postgresql/</link>
		<comments>http://gkoenig.wordpress.com/2011/03/04/pgtap-unit-tests-for-postgresql/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 13:46:40 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[pgtap]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[unit test]]></category>
		<category><![CDATA[unit tests]]></category>
		<category><![CDATA[unittest]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=124</guid>
		<description><![CDATA[I&#8217;ll show you a short introduction to pgTAP, a testing framework for postgres, including basic theory and short examples. I&#8217;ll just show the &#8220;simple test script&#8221; way, not the xUnit way of testing. My test db is postgres version 9.0.2 The framework around your tests is built on putting your tests in one transaction and [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=124&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ll show you a short introduction to pgTAP, a testing framework for postgres, including basic theory and short examples. I&#8217;ll just show the &#8220;simple test script&#8221; way, not the xUnit way of testing. My test db is postgres version 9.0.2</p>
<p>The framework around your tests is built on putting your tests in one transaction and rollback it at the end. Additionally statements for starting and showing the results are mandatory:<br />
BEGIN;<br />
SELECT plan();<br />
&#8230;your tests are here&#8230;<br />
SELECT * FROM finish();<br />
ROLLBACK;</p>
<p>download source package from http://pgtap.org download section, or go directly to http://pgfoundry.org/frs/?group_id=1000389<br />
install it like the common linux way, e.g. the .gz (or just run the pgtap.sql from the extracted sourcedir/sql in your target database):<br />
<code>tar -xzf pgtap-.gz<br />
cd pgtap-<br />
make<br />
make install<br />
make installcheck</code><br />
This will work if the binary pg_control is in your PATH and you are a db superuser. Most likely you&#8217;ll need additional settings like:<br />
<code>env PG_CONFIG=/path/to/pg_config<br />
make installcheck PGUSER=postgres</code></p>
<p>Detailed instructions are here: http://pgtap.org/documentation.html#Installation, probably you need additional perl modules..</p>
<p>Now let&#8217;s test some stuff&#8230;.<br />
If you need the pgTAP-functions in a different database, just run the sql-script called pgtap.sql (you&#8217;ll find it in the subdirectory sql under the sourcedir pgtap-) or include the call to pgtap.sql in your script with <code>\i /pgtap.sql</code></p>
<p>HelloWorld:<br />
<code>-- Format the output for nice TAP.<br />
\pset format unaligned<br />
\pset tuples_only true<br />
\pset pager<br />
-- Revert all changes on failure.<br />
\set ON_ERROR_ROLLBACK 1<br />
\set ON_ERROR_STOP true<br />
\set QUIET 1<br />
BEGIN;<br />
SELECT plan(1);<br />
SELECT pass( 'Hello World !' );<br />
SELECT * FROM finish();<br />
ROLLBACK;</code></p>
<p>save this as helloworld.txt and call it: psql -U postgres -f helloworld.txt </p>
<p>The snipped output will look like:<br />
<code>1..1<br />
ok 1 - Hello World !</code></p>
<p>What does this mean ?<br />
1..1 =&gt; you ran tests from #1 to #1 (exactly one <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  )<br />
ok 1 &#8211; Hello World ! =&gt; your test returned &#8220;ok&#8221;, it was test number &#8220;1&#8243; and the string &#8220;Hello World!&#8221; is the description (==output) of the pass() function.</p>
<p>Yes, this test doesn&#8217;t make any sense at all, but it shows the basic format.<br />
Now you&#8217;re free to check any detail of your database structure. Let&#8217;s start checking some tables and columns. Create a table first with<br />
<code>CREATE TABLE tab_test<br />
(<br />
  datetime timestamp without time zone NOT NULL DEFAULT now(),<br />
  "number" integer NOT NULL,<br />
  price real NOT NULL DEFAULT 0.000000000000000,<br />
  currency_id character varying(3) DEFAULT 'eur'::character varying<br />
);<br />
CREATE INDEX idx_number ON tab_test USING btree (number);<br />
CREATE INDEX idx_price ON tab_test USING btree (price);</code></p>
<p>tables_and_columns.txt:<br />
<code>-- Format the output for nice TAP.<br />
\pset format unaligned<br />
\pset tuples_only true<br />
\pset pager<br />
-- Revert all changes on failure.<br />
\set ON_ERROR_ROLLBACK 1<br />
\set ON_ERROR_STOP true<br />
\set QUIET 1<br />
BEGIN;<br />
SELECT plan(3);<br />
SELECT has_table( 'tab_test', 'table tab_test exists' );<br />
SELECT has_column( 'tab_test', 'number' );<br />
SELECT col_type_is( 'tab_test', 'number', 'integer' );<br />
SELECT * FROM finish();<br />
ROLLBACK;</code></p>
<p>Run the tests:  psql -U postgres -f tables_and_columns.txt<br />
The output will be:<br />
<code>1..3<br />
ok 1 - table tab_test exists<br />
ok 2 - Column tab_test.number should exist<br />
ok 3 - Column tab_test.number should be type integer<br />
</code><br />
The call of has_table got the additional parameter &#8220;description&#8221;, which will be printed out instead of the default message you see for tests no. 2 and 3. It&#8217;s possible to put a schemaname as the first parameter to this function call, if your table is not in the default search schema.<br />
To receive a &#8220;not ok&#8221; result, just modify e.g. the call of has_column to SELECT has_column(&#8216;tab_test&#8217;,'id&#8217;);<br />
Now the output tells you that something failed:<br />
<code>1..3<br />
ok 1 - table tab_test exists<br />
not ok 2 - Column tab_test.id should exist<br />
# Failed test 2: "Column tab_test.id should exist"<br />
ok 3 - Column tab_test.number should be type integer<br />
# Looks like you failed 1 test of 3</code></p>
<p>extend tables_and_columns.txt by:<br />
<code>...<br />
SELECT plan(5);<br />
...<br />
SELECT has_index('tab_test','idx_number', 'Index idx_number on tab_test');<br />
SELECT has_index('tab_test','idx_price','currency_id', 'Index idx_price on tab_test');<br />
...</code></p>
<p>Now you get a helpful hint in the output, which tells you that the table has an index called idx_price, but it is on a different column:<br />
<code>1..5<br />
ok 1 - table tab_test exists<br />
not ok 2 - Column tab_test.id should exist<br />
# Failed test 2: "Column tab_test.id should exist"<br />
ok 3 - Column tab_test.number should be type integer<br />
ok 4 - Index idx_number on tab_test<br />
not ok 5 - Index idx_price on tab_test<br />
# Failed test 5: "Index idx_price on tab_test"<br />
#         have: idx_price ON tab_test(price)<br />
#         want: idx_price ON tab_test(currency_id)<br />
# Looks like you failed 2 tests of 5</code></p>
<p>There are pgTAP functions for almost everything in your postgres db, like Triggers, Functions, Schemas, Tablespaces, &#8230;. just check the documentation.<br />
It is also possible to create relationships of, or better conditional, tests. This means calling a testfunction only if certain conditions are met.<br />
Again an example will illustrate this best:<br />
The following code fragment will check the table tab_test in schema1 if there exists a primary key on the table. If yes the next test will check if the primary key contains the two columns an_id and another_id. If there&#8217;s no primary key found the function fail() will be called. You can call several test functions within collect_tap(&#8230;) to build something like a subfunction<br />
<code>...<br />
SELECT CASE WHEN has_pk('schema1','tab_test',NULL) ~* '^ok'<br />
  THEN<br />
    collect_tap(<br />
      col_is_pk ('schema1','tab_test', ARRAY['an_id','another_id'],'table "schema1.tab_test" should have a combined primary key over two columns'),<br />
      pass('passed')<br />
    )<br />
    ELSE<br />
      fail('did not find any primary key in table "schema1.tab_test".')<br />
END;<br />
...</code></p>
<p>Now you should have a basic understanding of how to create a test scenario for testing a db structure, there are a lot more functions available than described in this post, so feel free to play with it.<br />
In my next post I&#8217;ll show how to check data&#8230;.</p>
<p>any hints are highly welcome</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/124/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/124/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/124/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=124&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2011/03/04/pgtap-unit-tests-for-postgresql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>Postgres Partitioning</title>
		<link>http://gkoenig.wordpress.com/2011/02/22/postgres-partitioning/</link>
		<comments>http://gkoenig.wordpress.com/2011/02/22/postgres-partitioning/#comments</comments>
		<pubDate>Tue, 22 Feb 2011 09:31:55 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[partitioning]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[trigger]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=114</guid>
		<description><![CDATA[Sometimes it is very useful to store your data not in one big table, but in several so called partitions. A partition is just an inherited table storing the data that fit the given rule. Thereby you can avoid scanning a huge table if you are just looking for a small part of data, or [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=114&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Sometimes it is very useful to store your data not in one big table, but in several so called partitions. A partition is just an inherited table storing the data that fit the given rule. Thereby you can avoid scanning a huge table if you are just looking for a small part of data, or you can put older data to a slower/cheaper storage (put the partitions in tablespaces on that storage).<br />
You don&#8217;t have to adapt your code, the CRUD actions are offered to the application in the same way it is for one big table. The whole logic is in Postgresql itself, a trigger function puts the data in the desired partition and the parameter <code>constraint_exclusion=on</code> informs the planner to scan only the affected partitions.<br />
A basic request is to split data on a given timestamp, e.g. create a partition on a monthly basis. In such a scenario you can dive into historical data with no performance impact to the current data. Additionally you can delete no longer needed, old data just by dropping the partition.</p>
<p>It will be best to explain the stuff by an example&#8230;..</p>
<p><strong>create a test db</strong></p>
<p><code>psql -U postgres postgres<br />
postgres=&gt; CREATE DATABASE pgtestdb encoding='UTF-8';<br />
postgres=&gt;\q<br />
psql -U postgres pgtestdb<br />
postgres=&gt; CREATE SCHEMA part_test;<br />
</code><br />
<strong>create master table</strong></p>
<p><code>CREATE TABLE tab_test<br />
(<br />
datetime timestamp without time zone NOT NULL DEFAULT now(),<br />
number integer NOT NULL,<br />
price real NOT NULL DEFAULT 0.000000000000000,<br />
currency_id character varying(3) DEFAULT 'eur'::character varying<br />
);</code></p>
<p><strong>create four partition tables (inherited from master table)</strong><br />
<code><br />
create table tab_test201011 ( CHECK (datetime &gt;= DATE '2010-11-01' AND datetime &lt; DATE '2010-12-01') ) INHERITS (tab_test); <br />
create table tab_test201012 ( CHECK (datetime &gt;= DATE '2010-12-01' AND datetime &lt; DATE '2011-01-01') ) INHERITS (tab_test); <br />
create table tab_test201101 ( CHECK (datetime &gt;= DATE '2011-01-01' AND datetime &lt; DATE '2011-02-01') ) INHERITS (tab_test); <br />
create table tab_test201102 ( CHECK (datetime &gt;= DATE '2011-02-01' AND datetime &lt; DATE '2011-03-01') ) INHERITS (tab_test);<br />
</code></p>
<p><strong>create trigger function</strong></p>
<p><code>CREATE OR REPLACE FUNCTION test_insert_trigger()<br />
RETURNS TRIGGER AS $$<br />
BEGIN<br />
IF ( NEW.datetime &gt;= DATE '2010-11-01' AND   NEW.datetime &lt; DATE '2010-12-01' ) THEN   INSERT INTO tab_test201011 VALUES (NEW.*);<br />
ELSIF ( NEW.datetime &gt;= DATE '2010-12-01' AND   NEW.datetime &lt; DATE '2011-01-01' ) THEN  INSERT INTO tab_test201012 VALUES (NEW.*);<br />
ELSIF ( NEW.datetime &gt;= DATE '2011-01-01' AND   NEW.datetime &lt; DATE '2011-02-01' ) THEN  INSERT INTO tab_test201101 VALUES (NEW.*);<br />
ELSIF ( NEW.datetime &gt;= DATE '2011-02-01' AND   NEW.datetime &lt; DATE '2011-03-01' ) THEN  INSERT INTO tab_test201102 VALUES (NEW.*);<br />
ELSE<br />
RAISE EXCEPTION 'column datetime out of range.  Fix the tour_insert_trigger() function!';<br />
END IF;<br />
RETURN NULL;<br />
END;<br />
$$<br />
LANGUAGE plpgsql;</code></p>
<p>== UPDATE ==<br />
to simplify the trigger function you can replace the code above with the following dynamic creation of the insert statement, moving the row in the appropriate target table. As a further enhancement you don&#8217;t have to extend the trigger function every time you&#8217;ve added new partitions:</p>
<p><code>CREATE OR REPLACE FUNCTION test_insert_trigger()<br />
  RETURNS trigger AS<br />
$BODY$<br />
DECLARE<br />
  date_part varchar(20);<br />
  tablename varchar(100);<br />
BEGIN<br />
    date_part='';<br />
    date_part = to_char(new.datetime,'yyyy') || to_char(new.datetime,'mm');<br />
    tablename = 'tab_test' || date_part;<br />
    --raise notice 'target table: %', tablename;<br />
    execute 'insert into ' || tablename::regclass || '(datetime,number,price,currency_id) select $1,$2,$3,$4' using NEW.datetime,NEW.number,NEW.price,NEW.currency_id;<br />
    RETURN NULL;<br />
END;<br />
$BODY$<br />
  LANGUAGE plpgsql VOLATILE<br />
  COST 100;<br />
ALTER FUNCTION test_insert_trigger() OWNER TO postgres;<br />
</code></p>
<p><strong>create trigger on master table</strong></p>
<p><code>CREATE TRIGGER insert_test_trigger BEFORE INSERT ON tab_test FOR EACH ROW EXECUTE PROCEDURE test_insert_trigger();</code></p>
<p><strong>create some indices (not for functionality, just for select performance)</strong></p>
<p><code>CREATE INDEX idx_test_dt_201011 ON tab_test201011 (datetime);<br />
CREATE INDEX idx_test_dt_201012 ON tab_test201012 (datetime);<br />
CREATE INDEX idx_test_dt_201101 ON tab_test201101 (datetime);<br />
CREATE INDEX idx_test_dt_201102 ON tab_test201102 (datetime);</code></p>
<p><strong>insert some test data (100000 rows in each partition)</strong></p>
<p><code><br />
insert into tab_test (datetime, number, price) (select DATE('2010-11-01') + (i%30) * INTERVAL '1 days', i,i::real from (select generate_series(1,100000) as i) as q);<br />
insert into tab_test (datetime, number, price) (select DATE('2010-12-01') + (i%30) * INTERVAL '1 days', i,i::real from (select generate_series(1,100000) as i) as q);<br />
insert into tab_test (datetime, number, price) (select DATE('2011-01-01') + (i%30) * INTERVAL '1 days', i,i::real from (select generate_series(1,100000) as i) as q);<br />
insert into tab_test (datetime, number, price) (select DATE('2011-02-01') + (i%28) * INTERVAL '1 days', i,i::real from (select generate_series(1,100000) as i) as q);<br />
</code><br />
<strong>test the stuff</strong></p>
<p><code>pgtestdb=# set constraint_exclusion=off;<br />
SET<br />
pgtestdb=# explain select count(number) from tab_test where datetime between '2010-10-05 00:00:00' and '2010-10-20 00:00:00';<br />
</code><br />
QUERY PLAN<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-<br />
Aggregate  (cost=43.90..43.91 rows=1 width=4)<br />
-&gt;  Append  (cost=0.00..43.89 rows=5 width=4)<br />
-&gt;  Seq Scan on tab_test  (cost=0.00..10.75 rows=1 width=4)<br />
Filter: ((datetime &gt;= &#8217;2010-10-05 00:00:00&#8242;::timestamp without time zone) AND (datetime &lt;= &#8217;2010-10-20 00:00:00&#8242;::timestamp without time zone))          -&gt;  Index Scan using idx_tour_dt_201011 on tab_test201011 tab_test  (cost=0.00..8.28 rows=1 width=4)<br />
Index Cond: ((datetime &gt;= &#8217;2010-10-05 00:00:00&#8242;::timestamp without time zone) AND (datetime &lt;= &#8217;2010-10-20 00:00:00&#8242;::timestamp without time zone))          -&gt;  Index Scan using idx_tour_dt_201012 on tab_test201012 tab_test  (cost=0.00..8.28 rows=1 width=4)<br />
Index Cond: ((datetime &gt;= &#8217;2010-10-05 00:00:00&#8242;::timestamp without time zone) AND (datetime &lt;= &#8217;2010-10-20 00:00:00&#8242;::timestamp without time zone))          -&gt;  Index Scan using idx_tour_dt_201101 on tab_test201101 tab_test  (cost=0.00..8.28 rows=1 width=4)<br />
Index Cond: ((datetime &gt;= &#8217;2010-10-05 00:00:00&#8242;::timestamp without time zone) AND (datetime &lt;= &#8217;2010-10-20 00:00:00&#8242;::timestamp without time zone))          -&gt;  Index Scan using idx_tour_dt_201102 on tab_test201102 tab_test  (cost=0.00..8.28 rows=1 width=4)<br />
Index Cond: ((datetime &gt;= &#8217;2010-10-05 00:00:00&#8242;::timestamp without time zone) AND (datetime &lt;= &#8217;2010-10-20 00:00:00&#8242;::timestamp without time zone)) (12 rows) </p>
<p><code>pgtestdb=# set constraint_exclusion=on;<br />
SET<br />
pgtestdb=# explain select count(number) from tab_test where datetime between '2010-10-05 00:00:00' and '2010-10-20 00:00:00';<br />
</code><br />
                  QUERY PLAN                                                                            &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;  Aggregate  (cost=10.76..10.77 rows=1 width=4)    -&gt;  Append  (cost=0.00..10.75 rows=1 width=4)<br />
-&gt;  Seq Scan on tab_test  (cost=0.00..10.75 rows=1 width=4)<br />
Filter: ((datetime &gt;= &#8217;2010-10-05 00:00:00&#8242;::timestamp without time zone) AND (datetime &lt;= &#8217;2010-10-20 00:00:00&#8242;::timestamp without time zone))<br />
(4 rows)<br />
</code></p>
<p>
That's it, with enabled constraint_exclusion just one partition will be scanned !<br />
I tried the example in PostgreSQL version 8.3 and newer (up to latest 9.0.2), I don't know which older versions of Postgres supports partitioning....</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/114/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/114/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/114/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=114&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2011/02/22/postgres-partitioning/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>create virtual machines for kvm on fedora 12</title>
		<link>http://gkoenig.wordpress.com/2010/05/07/create-virtual-machines-for-kvm-on-fedora-12/</link>
		<comments>http://gkoenig.wordpress.com/2010/05/07/create-virtual-machines-for-kvm-on-fedora-12/#comments</comments>
		<pubDate>Fri, 07 May 2010 07:32:44 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=109</guid>
		<description><![CDATA[In my last post I described how to enable kvm on fedora 12. Now it&#8217;s time to create some virtual machines&#8230;.. 1.) I copy the iso&#8217;s of the guest os in the directory /var/lib/libvirt/isos to prevent SELinux from throwing errors like &#8220;cannot open XYZ.iso&#8230;permissio denied&#8221;, even if it&#8217;s world readable. Get your installation media for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=109&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://gkoenig.wordpress.com/2010/05/07/kvm-on-fedora-12/">last post</a> I described how to enable kvm on fedora 12.<br />
Now it&#8217;s time to create some virtual machines&#8230;..</p>
<p>1.) I copy the iso&#8217;s of the guest os in the directory /var/lib/libvirt/isos to prevent SELinux from throwing errors like &#8220;cannot open XYZ.iso&#8230;permissio denied&#8221;, even if it&#8217;s world readable.<br />
Get your installation media for your guest os you want to install, e.g.</p>
<ul>
<li>FreeBSD8.0 =&gt; ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.0/8.0-RELEASE-i386-dvd1.iso.gz
<li>Debian =&gt; http://caesar.acc.umu.se/debian-cd/5.0.4/i386/iso-cd/debian-504-i386-netinst.iso
<li>OpenSolaris =&gt; http://dlc-cdn-rd.sun.com/c1/osol/opensolaris/2009/06/osol-0906-ai-x86.iso
</ul>
<p>or whatever system you want&#8230;</p>
<p>2.) create the virtual machine on your kvm server<br />
2.1) evaluate the &#8220;virt-install&#8221; command to check the parameters for creating a virt. machine =&gt; <code>man virt-install</code><br />
2.2) create FreeBSD8.0 vm called &#8220;fb8&#8243; with 1 vCPU, 512MB Ram, 16GB HDD, source install file under /var/lib/libvirt/isos, target vm under /vm/fb8.qcow2<br />
<code>virt-install --connect qemu:///system -n fb8 -r 512 --vcpus=1 -s 12 \\<br />
-c /var/lib/libvirt/isos/8.0-RELEASE-i386-dvd1.iso \\<br />
--vnc --noautoconsole --os-type unix --os-variant freebsd7 \\<br />
--accelerate --network=bridge:br0 --hvm -f /vm/fb8.qcow2</code></p>
<p>3.) switch to your desktop and start virt-manager to access the virtual machine<br />
open <code>virt-manager</code></p>
<ul>
<li>click <code>File</code> -&gt; <code>add connection</code>
<li>connection type (most probably) &#8220;remote tunnel over ssh&#8221;
<li>type the hostname (or ip address) of the kvm server
<li>click <code>Connect</code>
</ul>
<p>At first connection you&#8217;ll get a dialog which shows RSA fingerprint, type <code>yes</code> and click <code>OK</code><br />
In the next dialog you have to type the root password of your kvm server</p>
<p>Now you should see your vm in state &#8220;running&#8221;. Click &#8220;open&#8221; and type the root password again to login to your vm. You should have access to the graphical terminal and the installer of your guest OS should have been started. Now you can install your guest OS&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/109/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/109/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/109/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=109&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2010/05/07/create-virtual-machines-for-kvm-on-fedora-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>kvm on Fedora 12</title>
		<link>http://gkoenig.wordpress.com/2010/05/07/kvm-on-fedora-12/</link>
		<comments>http://gkoenig.wordpress.com/2010/05/07/kvm-on-fedora-12/#comments</comments>
		<pubDate>Fri, 07 May 2010 06:57:16 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[fedora]]></category>
		<category><![CDATA[linux]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=106</guid>
		<description><![CDATA[Here are the steps how I setup kvm on my fedora12 workstation. Normally you would install kvm and the virtual machines on a real server and access it from your desktop via virt-manager. If you are going to go this way perform steps 1) &#8211; 5) on the server and step 6) on your client. [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=106&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here are the steps how I setup kvm on my fedora12 workstation. Normally you would install kvm and the virtual machines on a real server and access it from<br />
your desktop via virt-manager. If you are going to go this way perform steps 1) &#8211; 5) on the server and step 6) on your client.</p>
<p>1) check if your CPU supports hardware virtualization<br />
<code>egrep '(vmx|svm)' --color=always /proc/cpuinfo</code><br />
..the output should contain some highlighted string like &#8220;..vmx..&#8221;, if not you can stop here since your processor doesn&#8217;t support hardware virt.</p>
<p>2) install required packages on kvm server<br />
<code>yum install kvm qemu libvirt python-virtinst</code><br />
3) start  libvirt daemon<br />
<code>/etc/init.d/libvirtd start</code><br />
4) check if installation was successfull<br />
<code>virsh -c qemu:///system list</code><br />
..output should look like<br />
<em> Id Name                 State<br />
&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;-</em></p>
<p>5) to access the virtual machines like a &#8220;real&#8221; physical machine we need a network bridge<br />
<code>yum install bridge-utils<br />
/usr/sbin/brctl addbr br0<br />
/sbin/ifconfig eth0 0.0.0.0 promisc up<br />
/usr/sbin/brctl addif br0 eth0<br />
/sbin/dhclient br0<br />
/sbin/iptables -F FORWARD</code></p>
<p>check via: <code>ifconfig</code></p>
<p>6) install the virt-manager on a &#8220;client&#8221; to access the virtual machines<br />
<code>yum install virt-manager</code></p>
<p>I&#8217;ll describe how to create a vm in a different blog entry immediately <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/106/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/106/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/106/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=106&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2010/05/07/kvm-on-fedora-12/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>install JBoss on CentOS 4.5</title>
		<link>http://gkoenig.wordpress.com/2010/03/25/install-jboss-on-centos-4-5/</link>
		<comments>http://gkoenig.wordpress.com/2010/03/25/install-jboss-on-centos-4-5/#comments</comments>
		<pubDate>Thu, 25 Mar 2010 13:19:25 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[CentOS 5.4]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=100</guid>
		<description><![CDATA[Hello, latest developments point to a so far different direction -&#62; Java Therefore we need an environment to publish those apps/servlets/beans/whatever&#8230; Afterwards you&#8217;ll find the steps for an initial setup of JBoss on a 64bit CentOS 4.5 (virtual machine): starting point: fresh centos 5.4 installation a) install JDK, both 1.5 and 1.6 are suitable. I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=100&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>latest developments point to a so far different direction -&gt; Java<br />
Therefore we need an environment to publish those apps/servlets/beans/whatever&#8230;<br />
Afterwards you&#8217;ll find the steps for an initial setup of JBoss on a 64bit CentOS 4.5 (virtual machine):</p>
<p>starting point: fresh centos 5.4 installation<br />
<strong>a) install JDK, both 1.5 and 1.6 are suitable</strong>. I did the easiest way <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
   <code> yum install java-1.6.0*</code></p>
<p>    check the installed JDK with the command <code>java -version</code>. The output should look like (I&#8217;m running the server in a virtual machine):<br />
    <em>java version &#8220;1.6.0&#8243;<br />
    OpenJDK  Runtime Environment (build 1.6.0-b09)<br />
    OpenJDK 64-Bit Server VM (build 1.6.0-b09, mixed mode)</em></p>
<p><strong>b) install JBoss</strong>.<br />
There are 2 options. Installation with a binary package or compile yourself out of the source package. Since I don&#8217;t need some special settings, &#8230; I&#8217;ll it install via the binary package.<br />
There are different versions of JBoss available:<br />
<em>JBoss Enterprise Application Platform</em> &#8211; for highly transactional Java EE applications<br />
<em>JBoss Enterprise Web Platform</em> &#8211; for mid-sized, light and rich Java applications<br />
<em>JBoss Enterprise Web Server</em> &#8211; for simple Java workloads that only require enterprise Apache Tomcat.<br />
We need the Spring-functionality, therefore I use the second one, the Enterprise-Web-Platform-Edition. Currently released version is 5.1, version 6.0 isn&#8217;t finally released yet.</p>
<p>Download and extract<br />
<code>mkdir /srv<br />
cd /srv<br />
wget http://sourceforge.net/projects/jboss/files/JBoss/JBoss-5.1.0.GA/jboss-5.1.0.GA.zip<br />
jar -xf jboss-5.1.0.GA.zip</code><br />
set environment variable JBOSS_HOME<br />
<code>vi ~/.bashrc</code><br />
add the following lines<br />
<em>export JBOSS_HOME=/srv/jboss-5.1.0.GA<br />
export PATH=$PATH:$JBOSS_HOME/bin</em><br />
and &#8220;source&#8221; it<br />
<code>source ~/.bashrc</code></p>
<p>Now JBoss is ready to run, but there&#8217;s <strong>one important note</strong> !!!!<br />
By default JBoss listens only to localhost, keep this in mind, and provide the startup with the &#8220;-b 0.0.0.0&#8243; if you want your installation be accessible from anywhere</p>
<p>&#8230;startup<br />
<code>chmod +x $JBOSS_HOME/bin/*.sh<br />
$JBOSS_HOME/bin/run.sh -b 0.0.0.0</code><br />
&#8230;and test, point a browser to </p>
<p>http://:8080</p>
<p>create user jboss, under which jboss should be started<br />
<code>adduser jboss<br />
chown -Rf jboss.jboss /srv/jboss-5.1.0.GA</code></p>
<p>and copy the init-script for starting/stopping jboss<br />
<code>cd /srv/jboss-5.1.0.GA/bin<br />
cp jboss_init_redhat.sh /etc/init.d/jboss<br />
chmod +x /etc/init.d/jboss<br />
vi /etc/init.d/jboss</code></p>
<blockquote><p>adjust the parameters:<br />
JBOSS_HOME,JAVAPTH, JBOSS_CONF and JBOSS_HOST, like =&gt;</p>
<p>JBOSS_HOME=${JBOSS_HOME:-&#8221;/srv/jboss-5.1.0.GA&#8221;}<br />
JBOSS_USER=${JBOSS_USER:-&#8221;jboss&#8221;}<br />
JAVAPTH=${JAVAPTH:-&#8221;/usr/bin&#8221;}<br />
JBOSS_CONF=${JBOSS_CONF:-&#8221;default&#8221;}<br />
JBOSS_HOST=&#8221;0.0.0.0&#8243;<br />
JBOSS_BIND_ADDR=${JBOSS_HOST:+&#8221;-b $JBOSS_HOST&#8221;}</p></blockquote>
<p>..done, ready to use JBoss&#8230;..but keep in mind, this was just the initial setup&#8230;..the real work isn&#8217;t done yet&#8230;..configuration and adjust it to your needs will start right now <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> )</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/100/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/100/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/100/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=100&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2010/03/25/install-jboss-on-centos-4-5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>create a read-only user in postgres for all relations in several schemas</title>
		<link>http://gkoenig.wordpress.com/2010/01/22/create-a-read-only-user-in-postgres-for-all-relations-in-several-schemas/</link>
		<comments>http://gkoenig.wordpress.com/2010/01/22/create-a-read-only-user-in-postgres-for-all-relations-in-several-schemas/#comments</comments>
		<pubDate>Fri, 22 Jan 2010 10:33:17 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[open source]]></category>
		<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=92</guid>
		<description><![CDATA[Hi, recently I got the task to create a user in postgres limited to execute SELECT statements only (read-only user). The problem is, that you have to grant this right table by table &#8220;manually&#8221;. Since we have several schemas with lots of relations, it would be a boring and long running task to to do [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=92&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>recently I got the task to create a user in postgres limited to execute SELECT statements only (read-only user).<br />
The problem is, that you have to grant this right table by table &#8220;manually&#8221;. Since we have several schemas with lots of relations, it would be a boring and long running task to to do this&#8230;..</p>
<p>A much better approach is to create a procedure, which is doing the job for you.<br />
Assuming that we have the schemas &#8220;schema1&#8243;, &#8220;schema2&#8243; and &#8220;schema3&#8243; and we want to have a user called &#8220;ronly&#8221;.<br />
Here are the steps, I made (within a psql session as superuser):</p>
<ul>
<li>create new user ronly<br />
<code><br />
CREATE ROLE ronly NOSUPERUSER LOGIN password 'ronly';<br />
</code></p>
<li>create new group ro_group<br />
<code><br />
CREATE ROLE ro_group VALID UNTIL 'infinity';<br />
</code></p>
<li>add user ronly to group ro_group<br />
<code><br />
GRANT ro_group TO ronly;<br />
</code></p>
<li>grant access to the schemas in general<br />
<code><br />
GRANT USAGE ON SCHEMA schema1 TO ro_group;<br />
GRANT USAGE ON SCHEMA schema2 TO ro_group;<br />
GRANT USAGE ON SCHEMA schema3 TO ro_group;<br />
</code></p>
<li> now, let&#8217;s create a procedure which grants SELECT to all relations in our 3 schemas<br />
<code><br />
CREATE OR REPLACE FUNCTION grant_select_to_ro_group()<br />
  RETURNS text AS<br />
$BODY$<br />
DECLARE<br />
    sql text;<br />
    rel record;<br />
BEGIN<br />
    FOR rel IN SELECT pg_catalog.quote_ident(s.nspname) AS schema_name,<br />
                      pg_catalog.quote_ident(t.relname) AS relation_name<br />
        FROM pg_class t, pg_namespace s<br />
        WHERE t.relkind IN ('r', 'v','S')<br />
	AND t.relnamespace=s.oid AND s.nspname in ('schema1','schema2','schema3') order by s.nspname<br />
    LOOP sql := 'GRANT SELECT ON ' || rel.schema_name || '.' || rel.relation_name || ' TO ro_group';<br />
        RAISE NOTICE '%', sql;<br />
        EXECUTE sql;<br />
    END LOOP;<br />
    RETURN 'OK';<br />
END;<br />
$BODY$<br />
  LANGUAGE 'plpgsql' VOLATILE<br />
  COST 100;<br />
ALTER FUNCTION grant_select_to_ro_group() OWNER TO postgres;<br />
</code></p>
<li> &#8230; <strong>and call it afterwards</strong> =&gt;<br />
<code><br />
select grant_select_to_ro_group();<br />
</code>
</ul>
<p>You can image how easy it is to create a function which e.g. gets a schemaname as parameter and grant SELECT to this schema only:<br />
<code><br />
CREATE OR REPLACE FUNCTION grant_select_to_ro_group(character varying)<br />
  RETURNS text AS<br />
$BODY$<br />
DECLARE<br />
    the_schema ALIAS FOR $1;<br />
    sql text;<br />
    rel record;<br />
BEGIN<br />
    FOR rel IN SELECT pg_catalog.quote_ident(s.nspname) AS schema_name,<br />
                      pg_catalog.quote_ident(t.relname) AS relation_name<br />
        FROM pg_class t, pg_namespace s<br />
        WHERE t.relkind IN ('r', 'v','S')<br />
	AND t.relnamespace=s.oid AND s.nspname = the_schema order by s.nspname<br />
    LOOP sql := 'GRANT SELECT ON ' || rel.schema_name || '.' || rel.relation_name || ' TO ro_group';<br />
        RAISE NOTICE '%', sql;<br />
        EXECUTE sql;<br />
    END LOOP;<br />
    RETURN 'OK';<br />
END;<br />
$BODY$<br />
  LANGUAGE 'plpgsql' VOLATILE<br />
  COST 100;<br />
ALTER FUNCTION grant_select_to_ro_group(character varying) OWNER TO postgres;<br />
</code><br />
<strong>&#8230;and call it like =&gt;</strong><br />
<code><br />
select grant_select_to_ro_group('schema3');<br />
</code></p>
<p>hth&#8230;&#8230;GERD&#8230;..</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/92/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/92/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/92/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=92&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2010/01/22/create-a-read-only-user-in-postgres-for-all-relations-in-several-schemas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>install latest OTRS (ticketing system)  with postgres on CentOS 5.4</title>
		<link>http://gkoenig.wordpress.com/2010/01/14/install-latest-otrs-ticketing-system-with-postgres-on-centos-5-4/</link>
		<comments>http://gkoenig.wordpress.com/2010/01/14/install-latest-otrs-ticketing-system-with-postgres-on-centos-5-4/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 12:18:13 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[CentOS 5.4]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=83</guid>
		<description><![CDATA[Hello, again one more installation guide for CentOS users. I&#8217;m currently looking for a ticketing system and I heard a lot about otrs. Since I want to use the latest version I didn&#8217;t use the yum-based installation, except to cover the perl dependencies As prerequisites you should have a running apache2 and postgresql (I&#8217;m running [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=83&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>again one more installation guide for CentOS users. I&#8217;m currently looking for a ticketing system and I heard a lot about <a href="http://otrs.org/">otrs</a>.<br />
Since I want to use the latest version I didn&#8217;t use the yum-based installation, except to cover the perl dependencies <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>As prerequisites you should have a running apache2 and postgresql (I&#8217;m running 8.4).</p>
<p>First of all otrs needs a lot of perl modules. To resolve the dependencies I performed a</p>
<p><code>yum install otrs</code> to install all of them in this step. Afterwards a<br />
<code>yum erase otrs</code> deletes the &#8220;old&#8221; version of otrs.</p>
<p>Now we can start installing otrs itself.</p>
<ol>
<li>get latest rpm<br />
http://otrs.org/download/ -&gt; CentOS -&gt; OTRS 2.4.6 for RHEL 4,5,6 + CentOS 4,5,6 RPM (copy it to e.g. /tmp/ )</li>
<li>install the rpm without dependencies, since I don&#8217;t want to use mysql<br />
<code>rpm --nodeps -Uvh /tmp/otrs-2.4.6-01.noarch.rpm</code></li>
<li>create database stuff
<ul>
<li>user and database<br />
<code><br />
psql -U postgres<br />
#psql&gt;create role otrs password '' nosuperuser;<br />
#psql&gt;create database otrs owner otrs;<br />
#psql&gt;\q<br />
</code></li>
<li> create tables and insert initial data<br />
<code><br />
cd /opt/otrs/scripts/database<br />
psql -U otrs otrs -f otrs-schema.postgresql.sql<br />
psql -U otrs otrs -f initial_insert.sql<br />
psql -U otrs otrs -f otrs-schema-post.postgresql.sql<br />
</code></li>
</ul>
</li>
<li>set file permissions (I&#8217;m running otrs as user &#8220;otrs&#8221; and group &#8220;apache&#8221;)<br />
<code><br />
/opt/otrs/bin/SetPermissions.sh /opt/otrs otrs apache apache apache<br />
</code></li>
<li>modify the default parameters, since mysql is the default database<br />
open the file /opt/otrs/Kernel/Config.pm and</p>
<ul>
<li> comment the line<br />
<code>$Self-&gt;{DatabaseDSN}= "DBI:mysql:database=$Self-&gt;{Database};host=$Self-&gt;{DatabaseHost};";</code><br />
to disable mysql, and</li>
<li>uncomment the line<br />
<code>$Self-&gt;{DatabaseDSN} = "DBI:Pg:dbname=$Self-&gt;{Database};";</code></li>
<li> and don&#8217;t forget to set the dbuser and password to one you created some steps ago</li>
<li>edit start script of otrs<br />
open the file /etc/sysconfig/otrs and disable again the mysql stuff and enable postgres</p>
<p><code><br />
#OTRS_USED_DB=mysqld<br />
#OTRS_USED_DB_TEST="ps --pid $(cat /var/lib/mysql/$HOST.pid)"<br />
#OTRS_USED_DB_TEST="/sbin/service $OTRS_USED_DB status | grep 'is running'"<br />
# --- The Wonderfull redhat's mysql init script does not have a status check.. sucks<br />
OTRS_USED_DB=postgresql<br />
OTRS_USED_DB_RCSCRIPT="service $OTRS_USED_DB status| grep 'is running' &gt; /dev/null 2&gt;&amp;1"<br />
</code></li>
</ul>
<li>let&#8217;s start otrs&#8230;<br />
<code>service otrs start</code></li>
<li>the first login&#8230;<br />
<code> open http://localhost/otrs/index.pl</code></p>
<p>and login with user &#8220;root@localhost&#8221;, password &#8220;root&#8221; !! change the password afterwards !!<br />
You have to modify the hostname &#8220;localhost&#8221; if you&#8217;ve installed otrs on a remote server, of course <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </li>
</ol>
<p>Now you can start creating users, groups and a lot more. Check it out, OTRS is a great tool and with the ITSM addon you can easily extend this tool for some ITIL features like CMDB &#8230;</p>
<p>any comments welcome&#8230;.GERD&#8230;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/83/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/83/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/83/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=83&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2010/01/14/install-latest-otrs-ticketing-system-with-postgres-on-centos-5-4/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>install vlc on CentOS 5.4 (libdvdread.so.3 libcucul missing)</title>
		<link>http://gkoenig.wordpress.com/2010/01/08/install-vlc-on-centos-5-4-libdvdread-so-3-libcucul-missing/</link>
		<comments>http://gkoenig.wordpress.com/2010/01/08/install-vlc-on-centos-5-4-libdvdread-so-3-libcucul-missing/#comments</comments>
		<pubDate>Fri, 08 Jan 2010 11:11:20 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[CentOS 5.4]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[libcucul]]></category>
		<category><![CDATA[libdvdread]]></category>
		<category><![CDATA[vlc]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=74</guid>
		<description><![CDATA[I wanted to use vlc as client for multimedia files, but ran into some dependency errors with libraries libdvdread.so.3 and libcucul.so.0. Installation was initially started by yum install vlc but finished with errors, described above. I wondered why the installation cannot find the libraries, since they are installed. ll /usr/lib &#124; grep libdvd* ll /usr/lib [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=74&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I wanted to use vlc as client for multimedia files, but ran into some dependency errors with libraries <b>libdvdread.so.3</b> and <b>libcucul.so.0</b>.<br />
Installation was initially started by<br />
<code><br />
yum install vlc<br />
</code><br />
but finished with errors, described above.</p>
<p>I wondered why the installation cannot find the libraries, since they <b>are installed</b>.<br />
<code><br />
ll /usr/lib | grep libdvd*<br />
ll /usr/lib | grep libcu*<br />
</code><br />
showed me both libraries. I tried to manually set a symbolic link for libdvdread.so.3 (since there only was a link for xxx.so.4), but with no success.</p>
<p>The solution of this problem was to resolve the mixture of libraries installed from different repositories.<br />
In this case the libdvdread from epel and rpmforge caused the confusion. You can check this (if both repositories are enabled) by<br />
<code><br />
yum  provides libdvdread<br />
</code><br />
Both repositories offer a libdvdread, but completely different.<br />
Therefore I performed the following steps to get a working vlc installation.</p>
<ul>
<li>deinstall current libdvdread and libcucul<br />
<code><br />
yum erase libdvdread<br />
yum erase libcaca<br />
</code></p>
<li>cleanup yum<br />
<code><br />
yum clean all<br />
</code></p>
<li>install vlc and dependencies from rpmforge<br />
<code><br />
yum --disablerepo \* --enablerepo base,updates,rpmforge install vlc<br />
</code>
</ul>
<p>finished&#8230;.installed 25 packages. </p>
<p>Check again which repository provided the libdvdread, just to be sure <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
<code><br />
yum list libdvdread<br />
</code><br />
prints the following output (on my box)<br />
<code><br />
...<br />
Installed Packages<br />
libdvdread.i386     0.9.7-1.el5.rf                                                   installed<br />
Available Packages<br />
libdvdread.i386     4.1.3-1.el5                                                      epel<br />
</code></p>
<p>Besides this, it is a preferable method to use priorities in your yum repositorities in <b>/etc/yum.repos.d/*.repo</b> files to avoid a confusion about different versions of files installed from different repositories.<br />
Details about yum and priorities <a href="http://wiki.centos.org/PackageManagement/Yum/Priorities">here</a></p>
<p>any comment highly appreciated&#8230;.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/74/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/74/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/74/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=74&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2010/01/08/install-vlc-on-centos-5-4-libdvdread-so-3-libcucul-missing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
		<item>
		<title>install tracks (project/task management tool) on centos 5.4 with postgres backend</title>
		<link>http://gkoenig.wordpress.com/2009/12/14/install-tracks-projecttask-management-tool-on-centos-5-4-with-postgres-backend/</link>
		<comments>http://gkoenig.wordpress.com/2009/12/14/install-tracks-projecttask-management-tool-on-centos-5-4-with-postgres-backend/#comments</comments>
		<pubDate>Mon, 14 Dec 2009 15:14:17 +0000</pubDate>
		<dc:creator>gkoenig</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[PostgreSQL]]></category>

		<guid isPermaLink="false">http://gkoenig.wordpress.com/?p=68</guid>
		<description><![CDATA[Hello, if you&#8217;re looking for a very nice and flexible tool to manage tasks/projects you should give Tracks a try. It runs as a ruby app with its builtin web-server (others are possible, too) and is very easy to setup. As a starting guide I took the blog-post here, and modified some parts (especially the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=68&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello,<br />
if you&#8217;re looking for a very nice and flexible tool to manage tasks/projects you should give <a href="http://getontracks.org/">Tracks</a> a try.<br />
It runs as a ruby app with its builtin web-server (others are possible, too) and is very easy to setup.<br />
As a starting guide I took the blog-post <a href="http://www.how-to-linux.com/2009/04/how-to-install-tracks-17-on-centos-52/">here</a>, and modified some parts (especially the database settings since I&#8217;m using postgres).</p>
<p><strong>get latest release (used version is 1.7)</strong></p>
<ul>
<li>cd /opt (or wherever you want to install tracks, and have sufficient permissions to do so)</li>
<li>wget http://bsag.bingodisk.com/public/files/tracks-current.zip</li>
<li>unpack the archive, now you should have a directory structure &#8220;/opt/tracks-1.7&#8243;</li>
</ul>
<p><strong>prepare database</strong></p>
<ul>
<li> open a postgres session, e.g. &#8220;psql -U postgres&#8221;</li>
<li> create user tracks LOGIN password &#8216;tracks&#8217;;</li>
<li> create database tracks owner tracks encoding &#8216;UTF-8&#8242;;</li>
</ul>
<p><strong>configure the database setting</strong></p>
<ul>
<li> cd /opt/tracks-1.7 (or wherever you&#8217;ve installed it)</li>
<li> vi config/database.yml</li>
</ul>
<ul>
<li> <em># enter the credentials for db connection to the recently created database/user<br />
production:<br />
adapter: postgresql<br />
database: tracks<br />
host: localhost<br />
username: tracks<br />
password: tracks<br />
encoding: utf8</em></li>
</ul>
<p><strong>create the db structure by running</strong></p>
<ul>
<li> RAILS_ENV=production rake db:migrate &#8211;trace</li>
</ul>
<p><strong>start tracks with builtin webserver. Listen on port 3030 (since default port 3000 is busy with redmine project management tool <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  ).</strong></p>
<ul>
<li> cd /opt/tracks-1.7</li>
<li> script/server &#8211;port=3030 -e production</li>
</ul>
<p>That&#8217;s it&#8230;..now point your browser to http://localhost:3030 and login</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gkoenig.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gkoenig.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gkoenig.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gkoenig.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gkoenig.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gkoenig.wordpress.com/68/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gkoenig.wordpress.com/68/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gkoenig.wordpress.com/68/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gkoenig.wordpress.com&amp;blog=6634712&amp;post=68&amp;subd=gkoenig&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gkoenig.wordpress.com/2009/12/14/install-tracks-projecttask-management-tool-on-centos-5-4-with-postgres-backend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="" medium="image">
			<media:title type="html">gkoenig</media:title>
		</media:content>
	</item>
	</channel>
</rss>
