下载了一个VMware和Ubuntu的iso镜像,弄了个虚拟机尝试着使用源码安装Postgresql,我下载的Postgresql 的版本是9.3.5.
因为是linux和postgres的菜鸟,所以我参考下面这篇文章进行安装postgrs,
http://mingxinglai.com/cn/2014/03/compile-postgresql-in-linux/
第一次安装不是那么顺利的,在此我把我遇到的问题列于此,如果已经解决的解决方案也列于此。
1. 源码安装postgres的解压后的第一步是配置,生成makefile文件,使用命名 ./configure
第一个错误:
checking for main in -lm... yes checking for library containing setproctitle... no checking for library containing dlopen... -ldl checking for library containing socket... none required checking for library containing shl_load... no checking for library containing getopt_long... none required checking for library containing crypt... -lcrypt checking for library containing fdatasync... none required checking for library containing gethostbyname_r... none required checking for library containing shmget... none required checking for library containing readline... no <span style="color:#ff0000;">configure: error: readline library not found</span> If you have readline already installed,see config.log for details on the failure. It is possible the compiler isn't looking in the proper directory. Use --without-readline to disable readline support.提示说readline资源库没有找到。
先来讲讲readline是在这里的功能什么?
如果没安装Readline 库,既编译时加上 --without-readline 选项,那么 psql 端不能使用上下翻键和 Backspace 键,也不能查看历史 psql 命令,非常不方便。
参考地址;:http://francs3.blog.163.com/blog/static/405767272013101851228723/
解决方案1: 提示说readline库不存在,那我们就使用./configure配置的时候就不要readline插件了,但是这样带来的后果是不能上下翻键等等,非常不方便。
参考地址:http://mingxinglai.com/cn/2014/03/compile-postgresql-in-linux/他这里就直接忽略了readline的配置。
解决方案2: 我们自己安装readline资源库,然后在使用./configure配置的时候执行你的readline资源库。
那么我们就来安装readline:
参考地址:http://blog.chinaunix.net/uid-23242876-id-2480272.html
http://www.linuxdiyf.com/bbs/thread-129948-1-1.html
我就根据他们的教程执行:sudo apt-get install libreadline5-dev
错误又来了。
第二个错误:
Reading package lists... Done Building dependency tree... Done Package aptitude is not available,but is referred to by another package. This may mean that the package is missing,has been obsoleted,or is only available from another source <span style="color:#ff0000;">E: Package 'libreadline5-dev' has no installation candidate</span>
参考: http://blog.163.com/liuzhuqing_508/blog/static/606213512012111311532835/
http://www.jb51.cc/article/p-ciqhjagm-xk.html
然后根据blog的说明,也进行了apt-get update,后面有出现一堆错误,找资料弄了好半天也没有解决,最后在增加readline资源库的时候,不使用libreadline5-dev,而使用
libreadline6-dev, 命令如下:
sudo apt-get install libreadline6-dev
就正常进行了。
然后在重新配置Postgrsql
./Confirgure --prefix=/isr/local/postgres-9.3.5
也顺利通过。
问题:
postgres@ubuntu:/usr/local/postgres-9.3.5/bin$ initdb -D $PGDATA -E UTF8 -U postgres -W
The program 'initdb' is currently not installed. To run 'initdb' please ask your administrator to install the package 'postgres-xc'
我在安装的时候,出现好多问题是时候都会出现这个错误提示,这样我我都是直接去/usr/local/postgre-9.3.5/data下的pglog文件夹里面看日志文件,而我的问题是用户postgres 的环境变量没有起效。
环境变量配置在 /home/postgres/.profile中
添加:
export PGPORT=5432 export PGDATA=/usr/local/postgres-9.3.5/data export LANG=en_US.utf8 export PGHOME=/usr/local/postgres-9.3.5 export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH export DATE=`date +"%Y%m%d%H%M"` export PATH=$PGHOME/bin:$PATH:. export MANPATH=$PGHOME/share/man:$MANPATH export PGUSER=postgres export PGHOST=$PGDATA alias rm='rm -i' alias ll='ls -lh'
使用下列命令使配置文件起效
source /home/postres/.profile
参考地址: http://www.cnblogs.com/xiaofengkang/archive/2011/11/26/2264458.html
问题:
postgres@ubuntu:/usr/local/postgres-9.3.5/bin$ ./pg_ctl start -D /usr/local/postgres-9.3.5/data/ server starting postgres@ubuntu:/usr/local/postgres-9.3.5/bin$ LOG: redirecting log output to logging collector process HINT: Future log output will appear in directory "pg_log".
查看了/usr/local/postgres-9.3.5/data下的pg_log日志文件
2015-01-13 20:17:47.529 PST,4199,54b5edeb.1067,1,2015-01-13 20:17:47 PST,LOG,00000,"ending log output to stderr","Future log output will go to log destination ""csvlog"".","" 2015-01-13 20:17:47.529 PST,2,F0000,"invalid CIDR mask in address ""192.168.0.0/128""","line 89 of configuration file ""/usr/local/postgres-9.3.5/data/pg_hba.conf""",3,FATAL,XX000,"could not load pg_hba.conf",""不能加载pg_hba.conf文件,所以是pg_hba.conf文件配置错误导致,修改配置文件后重新启动数据库
更改之后:
postgres@ubuntu:/usr/local/postgres-9.3.5/bin$ ./pg_ctl start -D /usr/local/postgres-9.3.5/data/
成功启动。
原文链接:https://www.f2er.com/postgresql/195427.html