在ubuntu8.04中单步调试postgresql

先装readline包
sudo apt-get install libreadline5-dev zlib1g-dev

安装flex,为安装postgis使用
sudo apt-get install flex

(1)PostgreSQL 的安装

tar jzvf postgresql-8.3.1.tar.bz2

cd postgresql-8.3.1.tar.bz2

./configure –prefix=/opt/postgresql-8.3.1 LDFLAGS=-lstdc++ –enable-depend –enable-debug –enable-cassert

make

make install

cd /usr/local

ln -s /opt/postgresql-8.3.1 pgsql

cd ~

mkdir data

/usr/local/pgsql/bin/initdb -D data

(2)Proj 的安装

tar xvfz proj-4.6.0.tar.gz

cd proj-4.6.0

./configure –prefix=/opt/proj-4.6.0 –enable-debug

make

make install

ln -s /opt/proj-4.6.0 /usr/local/proj

(3)Geos 的安装

tar xvfj geos-3.0.0.tar.bz2

cd geos-3.0.0

./configure –prefix=/opt/geos-3.0.0 –enable-debug

make

make install

ln -s /opt/geos-3.0.0 /usr/local/geos

(4)PostGIS 的安装

把postgis-1.3.3.tar.gz 拷贝到 postgresql-8.3.1/contrib

tar xvfz postgis-1.3.3.tar.gz

cd postgis-1.3.3

./configure LDFLAGS=-lstdc++ –prefix=/opt/postgis-1.3.3 –with-pgsql=/usr/local/pgsql/bin/pg_config –with-proj=/usr/local/proj –with-proj-libdir=/usr/local/proj/lib –with-geos=/usr/local/geos/bin/geos-config –with-geos-libdir=/usr/local/geos/lib –enable-depend –enable-debug –enable-cassert

make

make install

ln -s /opt/postgis-1.3.3 /usr/local/postgis

5. 配置环境

cd ~

sudo gedit .bashrc

PGDATA=$HOME/data
PGSQL_HOME=/usr/local/pgsql
PROJ_HOME=/usr/local/proj
GEOS_HOME=/usr/local/geos
POSTGIS_HOME=/usr/local/postgis
LD_LIBRARY_PATH=$PGSQL_HOME/lib:$PROJ_HOME/lib:$GEOS_HOME/lib:$POSTGIS_HOME/lib
PATH=$PGSQL_HOME/bin:$PATH:$HOME/bin
export PATH PGDATA PGSQL_HOME PROJ_HOME GEOS_HOME POSTGIS_HOME LD_LIBRARY_PATH

source .bashrc

6.创建数据库

postgres -D data &

createdb testMap

createlang plpgsql testMap

cd $POSTGIS_HOME/share

psql -d testMap -f lwpostgis.sql

psql -d testMap -f lwpostgis_upgrade.sql

psql -d testMap -f spatial_ref_sys.sql

7.测试是否安装正确

postmaster -D data

启动SQL命令行
psql -d gisdb

CREATE TABLE gtest ( ID int4, NAME varchar(20) );

SELECT AddGeometryColumn('', 'gtest','geom',-1,'LINESTRING',2);

INSERT INTO gtest (ID, NAME, GEOM)
VALUES (
1,
'First Geometry',
GeomFromText('LINESTRING(2 3,4 5,6 5,7 8)', -1)
);


SELECT id, name, AsText(geom) AS geom FROM gtest;

如果以上命令都没出错,并且出现如下的结果,表明安装正确,可以使用了

id    | name    | geom
—-+—————-         +—————————–
1    | First Geometry   | LINESTRING(2 3,4 5,6 5,7 8)
(1 row)

8.单步调试postgis


postmaster -D data

新开窗口,启动SQL命令行
psql -d gisdb


取得进程postmaster的进程ID
SELECT pg_backend_pid();

ps -af | grep <userid> | grep postmaster

新窗口
gdb postgres

在gdb的命令中输入
attach pid
不调试时输入
detach pid


之后可以用gdb进行调试

转载自:https://blog.csdn.net/spche/article/details/5180564

You may also like...