文章目录
pgAdmin是Postgres的客户端管理工具,类似Oracle的sqldeveloper或者toad这样的工具。
先去官网下载源码,本文使用的是pgAdmin3-1.18.1版本,源码下载地址在这里。然后解压。
解压后的目录中,有README和INSTALL两个文件,其中详细说明了安装的步骤。这些步骤是标准的步骤,对各个系统来说可能略有一些差异,一些依赖有的系统已经安装了,有的没有。本文采用先安装,有问题再补的办法来安装。INSTALL中的安装步骤如下
1 2 3 4
| bash bootstrap ./configure make all sudo make install
|
按INSTALL中的步骤先运行bootstrap
1 2 3 4 5
| [root@anzhy pgadmin3-1.18.1] Stamping the version number... Configuring the build system... + aclocal ./bootstrap: line 38: aclocal: command not found
|
缺少aclocal,需要安装libtool。命令如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| [root@anzhy pgadmin3-1.18.1] Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.163.com * extras: mirrors.163.com * updates: mirrors.163.com Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package libtool.x86_64 0:2.2.6-15.5.el6 will be installed --> Processing Dependency: automake >= 1.4 for package: libtool-2.2.6-15.5.el6.x86_64 --> Processing Dependency: autoconf >= 2.58 for package: libtool-2.2.6-15.5.el6.x86_64 --> Running transaction check ---> Package autoconf.noarch 0:2.63-5.1.el6 will be installed ---> Package automake.noarch 0:1.11.1-4.el6 will be installed --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: libtool x86_64 2.2.6-15.5.el6 base 564 k Installing for dependencies: autoconf noarch 2.63-5.1.el6 base 781 k automake noarch 1.11.1-4.el6 base 550 k Transaction Summary ======================================================================================================================================================================= Install 3 Package(s) Total download size: 1.9 M Installed size: 5.8 M Is this ok [y/N]: y Downloading Packages: (1/3): autoconf-2.63-5.1.el6.noarch.rpm | 781 kB 00:00 (2/3): automake-1.11.1-4.el6.noarch.rpm | 550 kB 00:00 (3/3): libtool-2.2.6-15.5.el6.x86_64.rpm | 564 kB 00:00 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- Total 532 kB/s | 1.9 MB 00:03 Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : autoconf-2.63-5.1.el6.noarch 1/3 Installing : automake-1.11.1-4.el6.noarch 2/3 Installing : libtool-2.2.6-15.5.el6.x86_64 3/3 Verifying : libtool-2.2.6-15.5.el6.x86_64 1/3 Verifying : autoconf-2.63-5.1.el6.noarch 2/3 Verifying : automake-1.11.1-4.el6.noarch 3/3 Installed: libtool.x86_64 0:2.2.6-15.5.el6 Dependency Installed: autoconf.noarch 0:2.63-5.1.el6 automake.noarch 0:1.11.1-4.el6 Complete! [root@anzhy pgadmin3-1.18.1] Stamping the version number... ^[[AConfiguring the build system... + aclocal + autoheader + cp -f config.rpath.in config/config.rpath + automake --foreign --add-missing --copy + autoconf [root@anzhy pgadmin3-1.18.1]
|
看来bootstrap
已经过了,下一步是configure
,运行的时候报错,提示
1
| configure: error: could not find a suitable C++ compiler to build pgAdmin
|
原来是没有安装C++的编译环境,那就安装gcc,如下,输出比较长,不贴了
1
| [root@anzhy pgadmin3-1.18.1]
|
安装完成后继续configure
,仍然还是报错。
1
| configure: error: Could not find your wxWidgets installation. You might need to use the --with-wx=DIR configure option
|
于是安装wxGTK,用以下命令
1
| [root@anzhy pgadmin3-1.18.1]
|
安装后继续configure
,仍然还是报错。
1
| configure: error: Could not find your libxml2 installation. You might need to use the --with-libxml2=DIR configure option
|
还需要安装libxml2相关的东西,如下
1
| [root@anzhy pgadmin3-1.18.1]
|
再次configure
,提示成功,如下,中间内容省略,只贴最后部分
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| [root@anzhy pgadmin3-1.18.1] <<<<Omit Many Things Here......>>>> PostgreSQL directory: /usr/local/pgsql PostgreSQL pg_config binary: /usr/local/pgsql/bin/pg_config PostgreSQL version: PostgreSQL 9.3.4 PostgreSQL PQconninfoParse support: Present PostgreSQL SSL support: Missing wxWidgets directory: /usr wxWidgets wx-config binary: /usr/bin/wx-config wxWidgets version: wxWidgets 2.8.12 libxml2 directory: /usr libxml2 xml2-config binary: /usr/bin/xml2-config libxml2 version: libxml2 2.7.6 libxslt directory: /usr libxslt xslt-config binary: /usr/bin/xslt-config libxslt version: libxslt 1.1.26 Building Database Designer: No Building SSH Tunnel: No Building a debug version of pgAdmin: No Statically linking pgAdmin: No Building a Mac OS X appbundle: No sphinx-build executable: <not found> pgAdmin configuration is now complete. You can now compile and install pgAdmin using 'make; make install'.
|
其实以上步骤中的依赖,如果已经知道缺少哪些了的话,也可以一次性安装完成。
1
| yum install libtool gcc-c++ wxGTK wxGTK-devel libxml2 libxml2-devel libxslt libxslt-devel
|
其实,以上依赖,在INSTALL中已经有描述,如下,而且安装的前3步基本就是在解决依赖
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| You will need: - A modern development environment: - GTK 2.2 or above. - GNU automake 1.9 or above. - GNU autoconf 2.59 or above. - GNU gcc 3.4 or above. - wxGTK 2.8.x from http://www.wxwidgets.org/ - libxml2 2.6.18 or above from http://www.xmlsoft.org/ - libxslt 1.1.x or above from http://www.xmlsoft.org/ - PostgreSQL 8.4 or above from http://www.postgresql.org/ - Sphinx 1.0 or above from http://sphinx.pocoo.org/
|
其中Sphinx应该不是必须的,证据就是,在没有它的情况下,configure
也通过了。
接下去就是make,make的时候报错,如下
1 2 3 4 5 6 7 8 9 10 11 12 13
| make[3]: Entering directory `/root/Downloads/pgadmin3-1.18.1/xtra/png2c gcc -DHAVE_CONFIG_H -I. -I../.. -I../../pgadmin/include/libssh2 -I/usr/local/pgsql/include -I/usr/local/pgsql/include/server -I/usr/local/pgsql/include -DHAVE_CONNINFO_PARSE -I/usr/lib64/wx/include/gtk2-unicode-release-2.8 -I/usr/include/wx-2.8 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -D__WXGTK__ -DEMBED_XRC -I/usr/include/libxml2 -I/usr/include/libxml2 -O2 -MT png2c.o -MD -MP -MF .deps/png2c.Tpo -c -o png2c.o png2c.c mv -f .deps/png2c.Tpo .deps/png2c.Po gcc -O2 -L/usr/local/pgsql/lib -Wl,-as-needed -L/usr/lib -o png2c png2c.o -L/usr/local/pgsql/lib -lcrypto -lpq /usr/bin/ld: cannot find -lcrypto collect2: ld returned 1 exit status make[3]: *** [png2c] Error 1 make[3]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/xtra/png2c make[2]: *** [../xtra/png2c/png2c] Error 2 make[2]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/pgadmin make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory `/root/Downloads/pgadmin3-1.18.1 make: *** [all] Error 2
|
提示-lcrypto
找不到链接的lib,其实libcrypto应该已经安装(不然configure
就应该要报错),查一下安装在哪里了
1 2 3 4 5
| [root@anzhy lib] /usr/lib64/.libcrypto.so.1.0.1e.hmac /usr/lib64/.libcrypto.so.10.hmac /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.10
|
果然已经安装了,那就对libcrypto做一个软连接
1 2
| [root@anzhy ~] [root@anzhy lib64]
|
再次运行make,make的时间比较长,这次通过了,最后一段提示如下
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| Making all in src make[3]: Entering directory `/root/Downloads/pgadmin3-1.18.1/pkg/src' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/pkg/src' Making all in suse make[3]: Entering directory `/root/Downloads/pgadmin3-1.18.1/pkg/suse' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/pkg/suse' Making all in win32 make[3]: Entering directory `/root/Downloads/pgadmin3-1.18.1/pkg/win32' make[3]: Nothing to be done for `all'. make[3]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/pkg/win32' make[3]: Entering directory `/root/Downloads/pgadmin3-1.18.1/pkg' make[3]: Nothing to be done for `all-am'. make[3]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/pkg' make[2]: Leaving directory `/root/Downloads/pgadmin3-1.18.1/pkg' make[2]: Entering directory `/root/Downloads/pgadmin3-1.18.1' make[2]: Leaving directory `/root/Downloads/pgadmin3-1.18.1' make[1]: Leaving directory `/root/Downloads/pgadmin3-1.18.1'
|
然后就是make install,没有什么特别的,运行完就通过了。安装/usr/local/pgadmin3/,运行pgAdmin,提示错误,如下
1 2 3 4 5 6 7 8
| [root@anzhy lib64] [root@anzhy pgadmin3] bin share [root@anzhy pgadmin3] [root@anzhy bin] pgadmin3 [root@anzhy bin] ./pgadmin3: error while loading shared libraries: libpq.so.5: cannot open shared object file: No such file or directory
|
libpq.so.5是Postgres的动态链接库,没有找到这个库,是因为没有将其配置在lib_path里面,要做如下配置,
1 2 3
| [root@anzhy bin] [root@anzhy bin] [root@anzhy bin]
|
然后就能正常启动了。可以将上述两个环境变量放在.bashrc中,这样就可以不用每次都输入了。
如果su - postgres
来运行的话,会报错,gtk的问题,需要用xhost,如下
1 2 3 4 5 6 7 8 9 10
| [postgres@anzhy bin]$ ./pgadmin3 No protocol specified Error: Unable to initialize gtk, is DISPLAY set properly? [postgres@anzhy bin]$ xhost + No protocol specified xhost: unable to open display ":0.0" [postgres@anzhy bin]$ sudo xhost + [sudo] password for postgres: access control disabled, clients can connect from any host [postgres@anzhy bin]$ ./pgadmin3
|
如果有Oracle安装的经验的话,应该能很快想到这两个问题实际上是同一个,在此不再赘述。本文实验的截图如下,一并贴在下面