决定今后在科博上写postgresql的文章,cu上以后主要写一些lfs的东西。好听点就是不把鸡蛋们放到一个篮子里,我发现为了一个目的,我们总能找到理由来发扬该目的的长处。 以前一直用Eclipse CDT调试postgresql,有时候断点不准,很faint,心想是不是GDB和DDD断点就准了呢。所以决定鼓捣鼓捣GDB和DDD。关于如何搭建CDT的调试环境,请参考: 我写过一篇如何在Ubuntu里搭建hack环境:postgresql8.4+postgis1.5+eclipse CDT3.6 调试环境搭建, http://blog.chinaunix.net/u2/81513/showart_2168880.html http://wiki.postgresql.org/wiki/Working_with_Eclipse 先说说GDB和DDD的区别: 官方: http://www.gnu.org/software/ddd/ 上讲,GNU DDD is a graphical front-end for command-line debuggers such as GDB , DBX , WDB, Ladebug , JDB, XDB, the Perl debugger ,.. So,不用俺解释了。 下文都是在Ubuntu中调试,先说好,没耍赖的。 所以咱就先从如何用GDB调试PostgreSQL开始谈起: 首先,我们得定义一下,我们知道Postmaster启动作为后端damon进程,等待前端如PSQL的请求,然后Fork()一个Postgres进程来处理该请求,所以我们在服务器上就有Postmaster和处理该请求的Postgres (一个请求一个该进程)了,那么我们该调试哪个呢?是Postmaster还是Postgre呢?所以有如下定义(转载于 http://www-inst.eecs.berkeley.edu/~cs186/fa04/usingddd.pdf ): There are two ways to debug postgres (a) in the interactive mode and (b) in the bare backend mode. The interactive mode is where you start up the postmaster process (with pg ctl), use psql to connect to it, which spawns off a separate postgres process that is dedicated to serving requests from the psql client. This is the mode that the scripts in the Hw1/exec directory use, and the mode you used in Hw0. In the second mode, you don’t create a separate postmaster process and don’t use psql at all. Instead, you start up postgres from the command line and directly interact with it. While the latter is a very user-unfriendly way of using postgres it has the advantage that it is very easy to use a debugger (like ddd) with it. 原文讲的很清楚了,为了再清楚一点,我稍作解释,调试分成两类,一类是 interactive mode 二类是bare backend mode。第一类是先启动Postmaster,再启动Postgres,然后调试Postgres。第二类是只启动Postgres,直接调试Postgres。 我发现第一类比较符合CDT的情况,而且上面所引的文章中主要讲了第二类,所以第二类我们就不管了。所以结论是我们调试第一类的Postgres,而如果你对Postmaster的调试也感兴趣,其实更简单了,拔高一筹理论上讲岂不是和第二类一样了。 1.在Ubuntu中先添加postgres账号,以后全部用该账号登陆:关于如何添加postgres账号,请参考: http://blog.chinaunix.net/u2/81513/showart.php?id=2168880 第3条.然后: sudo mkdir /usr/local/pgsql sudo chown postgres /usr/local/pgsql 2.在Ubuntu中先下载必要的依赖文件,并安装: 先安装:libreadline6-dev sudo apt-get install libreadline6-dev 然后安装zlib tar zxvf zlib-1.2.3.tar.gz cd zlib-1.2.3/ make sudo make install 3.下载PostgreSQL源码,例如放在~/develop目录下面: tar zxvf postgresql-8.4.3.tar.gz cd postgresql-snapshot/ ./configure --enable-depend --enable-cassert --enable-debug /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data -- 初始化系统数据库 然后创建自己的数据库(mydb是数据库名) /usr/local/pgsql/bin/createdb mydb 然后启动postmaster /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data 4.新开一个Terminal,开启前端psql连mydb psql mydb select pg_backend_pid(); 是不是出现: pg_backend_pid ---------------- 2184 把该进程id记下来。 5.启动GDB调试进程progres 2184(记得GDB在UBUNTU里是系统自带的,所以不用再安装了) gdb progres 2184; O(∩_∩)O哈哈哈~,至此是不是GDB界面出来了: GNU gdb (GDB) 7.0-ubuntu Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type show copying and show warranty for details. This GDB was configured as i486-linux-gnu. For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... progres: No such file or directory. Attaching to process 2184 ptrace: Operation not permitted. /home/postgres/2184: No such file or directory. (gdb) 关于如何使用GDB,我就不介绍了,看官方文档: http://www.gnu.org/software/gdb/documentation/ 接下来写一下如何用DDD调试postgresql。 前4步和GDB的调试类似。 第5步,安装DDD sudo apt-get install ddd 第6步,启动DDD调试 ddd postgres 2184; 至此,DDD图形化的界面是不是出来了,上张图,庆祝一下: 第7步,在第4步的psql窗口里敲入sql命令: create table weather(tmp_lo int); 看看在DDD窗口中有什么变化,你按一下F6看看有什么效果,是不是和ECLIPSE的F6一样,F5也一样滴...接下来如何设置断点,如何跟踪,就参考官方文档吧: http://www.gnu.org/manual/ddd/html_mono/ddd.html 在文章最后给出我的结论: 我不推荐用GDB和DDD调试PostgreSQL,推荐用ECLIPSE CDT调试。原因就是ECLIPSE的调试结果和前二者一样,但是更容易看文件结构呀。 加我私人微信,交流技术。
首先LEED 2009最主要的变化是将总分提高到了100,并考虑了因地制宜的因素。分数变化最大的两个类别是能耗部分(EA: Energy and Atmosphere)和水耗(Water Efficiency)部分,分别从17分和5分上升到了35分和10分. 能耗部分Commissioning(调试)与LEED V2.2一样,占据一个必要条件(Prerequisite)和一个得分点EAc3,不同的是EAc3得分点从原先的1分上升到了2分。LEED认证将Commissioning(调试)维持在必要条件的范畴(即,没有按照LEED要求进行调试的建筑,不管采用了多少绿色技术和设计,都无法获得LEED认证)以及提高Enhanced Commissioning(升级调试)的分数,都显示了USGBC (U.S Green Building Council)对建筑设备调试的进一步重视。 调试的目的主要在于保证系统耗能系统运作、控制的质量,使建筑的主要耗能系统在运行时不会因为安装、施工和平衡上的差池出现问题,并使建筑设备的能耗控制在最优化的水平。建筑调试是保证建筑设备运行良好的重要环节,但长期以来,并未引起国内业界的重视。随着LEED认证在国内的流行,以及节能概念不断被强调,相信调试亦会受到应有的重视。 机遇与挑战总是并存的,节能概念的强调,节能技术和产品的开发和面世,给调试带来了新的挑战。尤其在内地市场,传统型建筑设备的调试在广度和深度上都和发达地区存在差距,如何面对新设备新系统带来的调试挑战,给调试单位带来了新的难题。