常见错误及解决方案:
报错:configure: error: readline library not found
报错:configure: error: readline library not found
解决方法:yum -y install readline-devel
报错:configure: error: no acceptable C compiler found in $PATH
解决方法:yum -y install
gcc
报错:configure: error: zlib library not found
解决方法:yum
install zlib-devel
报错:make: command not found
解决方法:yum
-y install automake autoconf libtool make
注意事项:data文件夹不能放在postgres 用户权限之外的目录下。安装步骤如下
./configure --prefix=/usr/local/IMX_pgsql
make
make install
mkdir /usr/local/IMX_pgsql/data
chown imx:imx -R /usr/local/IMX_pgsql/
vi /usr/local/IMX_pgsql/data/postgresql.conf
su - imx
initdb -D /usr/local/IMX_pgsql/data/
su root
chown imx:imx -R /usr/local/IMX_pgsql
vi /etc/sysconfig/iptables
cd
/etc/rc.d/init.d
cp
/postgresql-9.0.4/contrib/start-scripts/linux IMX_pgsql
chmod +x IMX_pgsql
service IMX_pgsql start
这种方式安装的PostgreSQL可以随意移植到别的服务器上,继续使用
su - imx
pg_ctl -D /usr/local/IMX_pgsql/data -l /usr/local/IMX_pgsql/data/serverlog start
createuser -W imx_sql
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
createdb imx -O imx_sql
psql
alter database imx owner to imx_sql;
这种方式安装的PostgreSQL可以随意移植到别的服务器上,继续使用
移植
Postgresql 到98 服务器上过程
1.
创建用户:useradd imx
2.
解压pgsql.tar.gz:
tar zxvf pgsql.tar.gz
tar zxvf pgsql.tar.gz
3.
注册环境变量在home/postgres/.bash_profile 末尾追加
export PATH=$PATH:/usr/local/pgsql/bin
export MANPATH=$MANPATH:/usr/local/pgsql/man
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/pgsql/lib
3.
复制linux到/etc/init.d,注册服务:cp /usr/local/pgsql/linux /etc/init.d/postgresql
chkconfig
--add postgresql
4. su postgresql
5. 初始化数据库 initdb -D /usr/local/pgsql/data
6 切换到root 用户启动服务: service postgresql
start
Postgresql允许远程访问配置修改
postgresql默认情况下,远程访问不能成功,如果需要允许远程访问,需要修改两个配置文件,说明如下:
1.postgresql.conf
将该文件中的listen_addresses项值设定为“*”,在9.0 Windows版中,该项配置已经是“*”无需修改。
2.pg_hba.conf
在该配置文件的host all all 127.0.0.1/32 md5行下添加以下配置,或者直接将这一行修改为以下配置
host all all 0.0.0.0/0 md5
如果不希望允许所有IP远程访问,则可以将上述配置项中的0.0.0.0设定为特定的IP值。