<?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>Here comes the Sun &#187; postgresql</title>
	<atom:link href="http://sunng.info/blog/tag/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://sunng.info/blog</link>
	<description>Homemade Clojure Geek</description>
	<lastBuildDate>Fri, 11 May 2012 02:24:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>pgpoolII的管理功能</title>
		<link>http://sunng.info/blog/2011/02/pgpoolii%e7%9a%84%e7%ae%a1%e7%90%86%e5%8a%9f%e8%83%bd/</link>
		<comments>http://sunng.info/blog/2011/02/pgpoolii%e7%9a%84%e7%ae%a1%e7%90%86%e5%8a%9f%e8%83%bd/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 14:26:20 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[postgresql]]></category>

		<guid isPermaLink="false">http://sunng.info/blog/2011/02/pgpoolii%e7%9a%84%e7%ae%a1%e7%90%86%e5%8a%9f%e8%83%bd/</guid>
		<description><![CDATA[pgpool是postgresql的中间件，他的主要功能包括： Connection Pooling 连接池 Replication 双写 Load Balance 负载均衡 Limiting Exceeding Connections 连接限制 Parallel Query 并行查询 除此以外，pgpool还提供了对数据库节点的健康检查功能，自动fail over。 对pgpool的管理，pgpool本身除了工作端口（默认5433）以外，还开放一个pcp端口9898，类似FTP的控制端口。通过pcp端口可以获取pgpool的运行时信息，也可以进行运行时的操作。这些功能罗列在： http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#reference 封装这些命令的二进制文件也随着pgpool发行，由于是通过网络通信，所以并不要求这些工具与pgpool安装在同一台机器上。 除此以外，为了用户友好，pgpool还有一个具有UI的用户管理工具。这个工具的功能包括： 系统信息，主要是pcp的信息 配置文件编辑，这个功能似乎要求pgpooladmin和pgpool安装在一台机器上以便直接都写配置文件 切分规则编辑 另外，pgpool还通过一些自定义的SQL语句允许用户从工作端口提取一些配置信息和运行时信息： http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#show-commands]]></description>
			<content:encoded><![CDATA[<p>pgpool是postgresql的中间件，他的主要功能包括：</p>
<ul>
<li>Connection Pooling 连接池</li>
<li>Replication 双写</li>
<li>Load Balance 负载均衡</li>
<li>Limiting Exceeding Connections 连接限制</li>
<li>Parallel Query 并行查询</li>
</ul>
<p>除此以外，pgpool还提供了对数据库节点的健康检查功能，自动fail over。</p>
<p>对pgpool的管理，pgpool本身除了工作端口（默认5433）以外，还开放一个pcp端口9898，类似FTP的控制端口。通过pcp端口可以获取pgpool的运行时信息，也可以进行运行时的操作。这些功能罗列在：</p>
<p>http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#reference</p>
<p>封装这些命令的二进制文件也随着pgpool发行，由于是通过网络通信，所以并不要求这些工具与pgpool安装在同一台机器上。</p>
<p>除此以外，为了用户友好，pgpool还有一个具有UI的用户管理工具。这个工具的功能包括：</p>
<ul>
<li>系统信息，主要是pcp的信息</li>
<li>配置文件编辑，这个功能似乎要求pgpooladmin和pgpool安装在一台机器上以便直接都写配置文件</li>
<li>切分规则编辑</li>
</ul>
<p>另外，pgpool还通过一些自定义的SQL语句允许用户从工作端口提取一些配置信息和运行时信息：</p>
<p>http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#show-commands</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2011/02/pgpoolii%e7%9a%84%e7%ae%a1%e7%90%86%e5%8a%9f%e8%83%bd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DB dump with chroot</title>
		<link>http://sunng.info/blog/2009/07/db-dump-with-chroot/</link>
		<comments>http://sunng.info/blog/2009/07/db-dump-with-chroot/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 11:59:07 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sqlite]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=104</guid>
		<description><![CDATA[I caught chroot first time when attempting to install gentoo linux. Of course, its a tool of great useful. Two months ago I had my laptop crashed, and all static files were recovery easily by copy while raw db data &#8230; <a href="http://sunng.info/blog/2009/07/db-dump-with-chroot/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I caught chroot first time when attempting to install gentoo linux. Of course, its a tool of great useful. Two months ago I had my laptop crashed, and all static files were recovery easily by copy while raw db data file seems to be difficult to handle.</p>
<p>The old file system is in a mobile disk, mounted at /media/disk-1/. Now I try to use chroot to rollback to that environment, so that all standard dump tools will be available.</p>
<p>Before you chroot to the system, don&#8217;t forget to bind /dev to new location. Or you might get error prompt such as &#8220;/dev/null Permission Denied&#8221; (it&#8217;s a common error). Just execute command below:<br />
<em>$ sudo mount &#8211;bind /dev /media/disk-1/dev</em></p>
<p>Then change root to my old system:<br />
<em>$ sudo chroot /media/disk-1</em></p>
<p>Now you become root user automatically.</p>
<h3>MySQL Dump</h3>
<p>In a standard ubuntu mysql installation, we should launch mysql db from init.d by:<br />
<em># /etc/init.d/mysql start</em></p>
<p>But it&#8217;s no longer available in such environment. Fortunately, there is a direct way:<br />
<em># mysqld_safe &amp;</em></p>
<p>OK, go on to dump database with mysqldump:<br />
<em># mysqldump &#8211;all-databases &gt; mysql_dump_file</em></p>
<h3>Postgresql Dump</h3>
<p>We cannot use init.d to start pgsql either. Therefore, try to run it by:<br />
<em># su postgres -c &#8220;/usr/lib/postgresql/8.3/bin/pg_ctl start -D /etc/postgresql/8.3/main&#8221;</em></p>
<p><em>/etc/postgresql/8.3/main</em> is the default data directory in standard installation(with apt-get). This directory is supposed to contain a file named with &#8220;postgesql.conf&#8221;</p>
<p>Now pgsql db is also running. As root user we have no privilege to run pgsql utilities. so take following steps:<br />
<em># touch pgsql_dump_file<br />
# chmod a+w pgsql_dump_file<br />
# su postgres -c &#8220;pg_dumpall -f pgsql_dump_file&#8221;</em></p>
<h3>Conclusion</h3>
<p>Personally, I found it&#8217;s too complex and low efficiency to backup and restore data with mysql and postgresql. If there is no critical requirement(just like personal data management), file based db(Surely I mean sqlite) is no doubt better choice. Easy management(lots of gui tool now provided), smooth copy and move, standard db interface for programming, and enough functionality.</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/07/db-dump-with-chroot/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[旧]Up and Running: PostgreSQL and PostGIS on Ubuntu 8.10, Step By Step</title>
		<link>http://sunng.info/blog/2009/07/up-and-running-postgresql-and-postgis-on-ubuntu-8-10-step-by-step/</link>
		<comments>http://sunng.info/blog/2009/07/up-and-running-postgresql-and-postgis-on-ubuntu-8-10-step-by-step/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 10:52:31 +0000</pubDate>
		<dc:creator>sunng</dc:creator>
				<category><![CDATA[装备]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.classicning.com/blog/?p=100</guid>
		<description><![CDATA[每次安装pgsql的过程都是这么震撼人心。以下在Ubuntu 8.10上安装配置运行pgsql及postgis的简单步骤。和Windows相比，用apt-get安装不会再有服务安装不上的问题，但是可能会有包装不全、缺少配置的问题。 首先用apt-get下载安装pgsql和postgis的需要的包 sudo apt-get install postgresql-8.3 postgresql-8.3-postgis postgresql-client-8.3 postgresql-contrib-8.3 pgadmin3 安装过程中会提示创建一个默认名为postgres的用户。 安装结束后，启动pgsql服务器 sudo /etc/init.d/postgresql-8.3 start 在默认情况下pgsql ident的设置为postgres用户用ident sameuser的方式登录，这种方式类似于sqlserver使用windows的用户管理。因此要用postgres用户登录系统。 修改postgres用户的密码 sudo passwd postgres 用新密码登录为postgres su &#8211; postgres 运行psql，可以检查pgsql的运行情况 psql 可以在psql中给postgres用户设置数据库密码 ALTER USER postgres ENCRYPTED PASSWORD &#8216;yournewpassword&#8217;; 继续在psql中创建plsql语言。如果安装时遗漏了contrib包这一步是不能完成的。 CREATE LANGUAGE plsql; &#8230; <a href="http://sunng.info/blog/2009/07/up-and-running-postgresql-and-postgis-on-ubuntu-8-10-step-by-step/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>每次安装pgsql的过程都是这么震撼人心。以下在Ubuntu 8.10上安装配置运行pgsql及postgis的简单步骤。和Windows相比，用apt-get安装不会再有服务安装不上的问题，但是可能会有包装不全、缺少配置的问题。</p>
<p>首先用apt-get下载安装pgsql和postgis的需要的包</p>
<p><em>sudo apt-get install postgresql-8.3 postgresql-8.3-postgis postgresql-client-8.3 postgresql-contrib-8.3 pgadmin3</em></p>
<p>安装过程中会提示创建一个默认名为<em>postgres</em>的用户。</p>
<p>安装结束后，启动pgsql服务器</p>
<p><em>sudo /etc/init.d/postgresql-8.3 start</em></p>
<p>在默认情况下pgsql ident的设置为postgres用户用ident sameuser的方式登录，这种方式类似于sqlserver使用windows的用户管理。因此要用postgres用户登录系统。</p>
<p>修改postgres用户的密码</p>
<p><em>sudo passwd postgres</em></p>
<p>用新密码登录为postgres</p>
<p><em>su &#8211; postgres</em></p>
<p>运行psql，可以检查pgsql的运行情况</p>
<p><em>psql</em></p>
<p>可以在psql中给postgres用户设置数据库密码</p>
<p><em>ALTER USER postgres ENCRYPTED PASSWORD &#8216;yournewpassword&#8217;;</em></p>
<p>继续在psql中创建plsql语言。如果安装时遗漏了contrib包这一步是不能完成的。</p>
<p><em>CREATE LANGUAGE plsql;</em></p>
<p>退出psql，创建Postgis数据库。</p>
<p><em>createdb postgis</em></p>
<p>导入postgis的两个sql文件，其中定义了EPSG数据库和Geometry类型。</p>
<p><em>psql -d postgis -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql<br />
psql -d postgis -f /usr/share/postgresql-8.3-postgis/spatial_ref_sys.sql</em></p>
<p>进入psql对当前用户GRAND ALL</p>
<p><em>GRANT ALL ON TABLE geometry_columns TO postgres;<br />
GRANT ALL ON TABLE spatial_ref_sys TO postgres;</em></p>
<p>这样做的结果是这两张表被导入到默认的postgres数据库中。这样今后创建postgis数据库就可以以postgres为template_db，不过这么做的后果是这两张表的owner都是postgres。在GeoServer里创建FeatureType时必须用postgres用户登录，否则权限不足。</p>
<p>这时PostGIS应该可以正常工作了，可以尝试导入shp</p>
<p><em>shp2pgsql /your/shp/file tablename | psql newgisdb</em></p>
<p>创建一个新的数据库用户</p>
<p><em>createuser -p username</em></p>
<p>修改<em>/etc/postgresql/8.3/main/pg_hda.conf</em>，设置数据库访问的认证方式</p>
<p>将local all all一行的验证方式(method)由ident sameuser改为password就可以用密码登录psql了，在python－psycopg中用新建的用户连接pgsql也不会报ident失败了。</p>
<p>将host all 127.0.0.1/32一行的验证方式也改为password就可以在本地用jdbc以用户名密码连接数据库了。</p>
]]></content:encoded>
			<wfw:commentRss>http://sunng.info/blog/2009/07/up-and-running-postgresql-and-postgis-on-ubuntu-8-10-step-by-step/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

