在手工导入原始数据后,其中的id项为serial类,由原始数据赋值,会遇到不自动增长的问题。
解决方案参考:http://bbs2.chinaunix.net/thread-1353824-1-1.html
serial key其实是由sequence实现的,当你手动给serial列赋值的时候,sequence是不会自增量变化的,当你插入customer 6的时候看看customer_id sequence是多少?
最好不要给serial手工赋值
SELECT setval('序列名称', max(id)) FROM 表;
select setval('offlineapp_id_seq',max(id)) from offlineapp;
因为在另外一台机器上已经配置过,本以为很简单,复制过来就可以,没想到还是出问题,检查了半天,发现是group table没有设置的原因。
安装:
sudo aptitude install proftpd proftp-pgsql
配置:
在/etc/proftpd/proftpd.conf里把
#Include /etc/proftpd/sql.conf
这行的注释去掉,然后修改/etc/proftpd/sql.conf文件,修改为:
SQLBackend postgres
SQLEngine on
SQLAuthenticate users
SQLAuthTypes Crypt Plaintext
SQLConnectInfo db@server_name_or_ip user password
RequireValidShell off
SQLUserInfo ftp.users userid passwd uid gid homedir shell
SQLGroupInfo ftp.groups groupname gid members
SQLDefaultUID 108 # CHANGE FOR YOUR FTP USERS UID FOUND IN /etc/passwd
SQLDefaultGID 1002 # CHANGE FOR YOUR FTP USERS GID, FOUND IN /etc/groups
SQLDefaultHomedir /home/ftp
RequireValidShell off
SQLNegativeCache off
# 调试时打开
#SQLLogFile /var/log/proftpd-sql
SQLNamedQuery updatecount UPDATE "count=count+1 WHERE userid='%u'" ftp.users
SQLLOG PASS updatecount
SQLNamedQuery count SELECT "count from ftp.users where userid='%u'"
SQLShowInfo PASS "230" "You've logged on %{count} times, %u"
SQLLog STOR newfile
SQLNamedQuery newfile FREEFORM "INSERT INTO ftp.logs(userid,action,file,abs_path,bytes) VALUES ('%U','upload','%J','%f', '%b')"
SQLLog RETR insertfileinfo
SQLNamedQuery insertfileinfo FREEFORM "INSERT INTO ftp.logs(userid,action,file,abs_path,bytes) VALUES ('%U','download','%J','%f', '%b')"
数据库可以参考:http://www.howtoforge.com/proftpd_postgresql_auth_logging

参考amazon上的介绍。
书比较老,是2000年的,但作者是PostgreSQL的活跃的开发者。
第一章很有意思,是讲发展历史,非常清楚,而且介绍了该项目发展过程的一些困难以及如何解决的问题。
附录很多,几乎占了一半的内容。
升级的时候提示:
正在设置 postgresql-common (48ubuntu2) ...
dpkg:处理 postgresql-common (--configure)时出错:
子进程·post-installation script·返回了错误号·1
不知道是什么问题,搜索到ubuntu的BUG:
https://launchpad.net/distros/ubuntu/+source/postgresql-common/+bug/36921/+index
才知道是因为DAPPER修改了版本号导致了此问题。
临时的解决方法:
sudo apt-get install postgresql-client-common
sudo nano /usr/share/postgresql-common/supported-versions
# and change 6.04 to 6.06
sudo apt-get install postgresql-common
# install other postgres packages as needed.
# or just do
sudo apt-get -f install
目前,windows下的版本,postgresql官方已经开始支持,目前是8.0.1版本。POSTGIS目前官方尚不支持windows版本,但有支援者在进行同步维护windows版本,目前是1.0-rc6版本,估计很快就是1.0版本了。
安装很简单,首先要安装postgresql,注意其有两个帐号,一是系统帐号,二是数据库管理帐号。安装程序可以新建用户,要提到一点,目前的postgresql数据库不支持远程安装,就是说,不能通过远程桌面进行安装(这个限制,不爽)。windows版本还包括了pgadmin3,图形化的管理界面。
然后安装postgis,需要前面安装postgresql的管理员帐号,同时其还要安装一个postgis数据库。
默认情况下,可执行文件都安装到postgresql的bin目录,几个SQL文件安装在postgresql的share/contrib目录下。
对于中文用户来讲,首先要考虑数据库的编码问题,可以使用unicode,utf8,euc_cn等编码,默认的是unicode编码。
第一次使用unicode编码时移植linux下的应用,遇到了很多非常奇怪的问题。改用euc_cn编码,问题就少多了。
建库:
createdb -U postgres -E EUC_CN db
(linux环境下本机默认都不需要认证密码,但在windows系统下,默认是需要验证密码的)
alter database db set client_encode="EUC_CN"
(这个要进入到psql环境中才能运行的,不确定是否必须,在linux环境下不需要)
搭建postgis环境:
creatlang -U postgres plpgsql db
(这个在windows下默认好象是不需要处理的)
引入postgis支持:
psql -U postgres -d db -f lwpostgis.sql
psql -U postgres -d db -f spatial_ref_sys.sql
生成矢量数据的sql文件:
shp2pgsql xx.shp xx_table > xx.sql
导入到数据库:
psql -U postgres -d db -f xx.sql
到此,您的基本的postgis数据库就已经搭建好了,剩下的工作就是看您怎么去最大的压榨postgis的功能了。
Posted on 十一月 16th, 2004 in GIS | 1 Comment »
postgis-0.9,postgresql-8.0.0beta4,geos 2.0.1
1. install geos 2.0.1
LDFLAGS=-lstdc++ ./configure
make
make install
2. modify ld.so.conf
nano /etc/ld.so.conf
# add /usr/local/lib
/sbin/ldconfig
3. install postgresql
./configure
make
make install
# and run with computer start
4. install postgis
# modify Makefile.config
# change proj and geos directory
rm -f -r /where/postgresql_source/contrib/
cp -R postgis /where/postgresql_source/contrib/
cd /where/contrib/postgis
make
make install
5. init postgis
su postgres
createdb heihe
createlang plpgsql heihe
psql -d heihe -f lwpostgis.sql
psql -d heihe -f spatial_ref_sys.sql
6. dump your data to heihe db
shp2pgsql river river heihe > river.sql
psql -d heihe -f river.sql