PostgreSQL版本:9.4.0,获取路径:http://www.postgresql.org/ftp/source/v9.4.0/
操作系统:Unbutu
1.将代码上传到服务器
2.登陆服务器切换到代码路径,执行如下命令
apt-get installzlib1g-dev bison flex ##ubuntu默认安装中不包含下面的软件,需要安装Bison,Flex,zlib
cd /opt/
mkdir postgresql
cd /opt/pg_source/postgresql-9.4.0/chmod 700 * -R
./configure --prefix=/opt/postgresql --enable-debug --without-readline > pg_config.log
make > pg_make.log
make install > pg_make_install.log
adduser postgres
cd /opt/postgresql
mkdir data
chown postgres: data
su - postgres
cd /opt/postgresql/bin/
./initdb -D/opt/postgresql/data
##设置环境变量
cd /home/postgres/
echo "exportPGDATA=/opt/postgresql/data" >> .profile
echo "exportPATH=$PATH:/opt/postgresql/bin" >> .profile
echo "exportPGDIR=/opt/postgresql/bin" >> .profile
##启动数据库pg_ctl start
##登陆数据库
postgres@test:/opt/postgresql/bin$ psql postgres postgres 5432psql: warning: extra command-line argument "5432" ignored
psql (9.4.0)
Type "help" for help.
3.一些基本参数设置 参数文件 $PGDATA/postgresql.conf
1)监听地址端口
listen_addresses = 'localhost,192.168.35.128'
port = 1521
2)日志记录方式及目录(在生产环境上打开日志开关后,需要增加定时任务监控日志目录大小,防止日志占用磁盘空间太多)
log_destination = 'stderr'
logging_collector = on
log_directory = '/opt/postgresql/db_log'
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
log_file_mode = 0600
log_truncate_on_rotation = off