[root@localhost postgresql-11.4]# gcc --version gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36) Copyright © 2015 Free Software Foundation, Inc. 本程序是自由软件;请参看源代码的版权声明。本软件没有任何担保; 包括没有适销性和某一专用目的下的适用性担保。
gcc用于编译源码
[root@localhost postgresql-11.4]# make --version GNU Make 3.82 Built for x86_64-redhat-linux-gnu Copyright (C) 2010 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.
make用于批量编译连接源码,实际干活的仍是gcc
yum install readline yum -y install -y readline-devel
readline是个坑啊。能够选择不安装readline,后果是在psql里执行完命令,想用方向键再次获取该命令时就成了乱码。因此必需要安装readline。
只yum install readline时,configure的时候任然会报错,提示找不到readline。解决方法是安装readline-devel。
yum install zlib //通常状况下,系统已经默认安装了zlib yum install zlib-devel
zlib用于数据压缩
postgresql的官方网站下载:https://www.postgresql.org/
cd /home/software/ tar -xzvf postgresql-11.4.tar.gz
mkdir /home/app/postgresql
./configure --prefix=/home/app/postgresql
make && make install
All of PostgreSQL successfully made. Ready to install.
[1]+ 完成 make
cd /home/software/postgresql-11.4/contrib make && make install
groupadd postgres useradd -g postgres postgres
为了安全考虑,postgresql不容许使用root用户操做数据库,咱们在系统中为了使用postgresql添加一个用户postgres:
也能够是其余用户名,可是习惯上你们都是建立postgres用户做为数据库的超级用户。
初始化数据库时,就以这个用户做为数据库的超级用户
chown -R postgres:postgres /home/app/postgresql/data
su postgres vim /home/postgres/.bash_profile
添加环境变量:html
export PGHOME=/home/app/postgresql export PGDATA=/home/app/postgresql/data export PATH=$PGHOME/bin:$PATH export MANPATH=$PGHOME/share/man:$MANPATH export LANG=en_US.utf8 export DATE=`date +"%Y-%m-%d %H:%M:%S"` export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH alias rm='rm -i' alias ll='ls -lh'
而后使环境变量当即生效,不然initdb命令会找不到:linux
source /home/postgres/.bash_profile
initdb -D /home/app/postgresql/data/
Success. You can now start the database server using:
pg_ctl -D /home/app/postgresql/data/ -l logfile start
su postgres cd /home/postgres //logfile须要在postgres的用户目录下建立 pg_ctl -D /home/app/postgresql/data/ -l logfile start
查看5432端口是否已经启动redis
netstat -nltp|grep 5432
cd /home/software/postgresql-11.4/contrib/start-scripts chmod a+x linux. cp linux /etc/init.d/postgresql
此时就可使用 /etc/init.d/postgresql stop 来中止postgresql
也可使用:service postgresql start 来启动postgresql
修改postgresql脚本中prefix和PGDATA的内容
chkconfig --add postgresql //设置服务开机启动
#设置监听整个网络,查找“listen_addresses ”字符串, vim /home/app/postgresql/data/postgresql.conf #修改成以下: listen_addresses = '*' #配置链接方式: vim /home/app/postgresql/data/pg_hba.conf #修改成以下: host all all 192.168.2.0/24 md5