https://ftp.postgresql.org/pub/source/v9.5.19/postgresql-9.5.19.tar.bz2
02、requirementyum install -y ncurses-devel readline-devel zlib-devel
03、add_user postgres && pgdatauseradd postgresmkdir -p /pgdata/{data,archive} //创建数据及归档存储目录
su - postgres //配置环境变量tee <<-‘EOF‘ >>.bash_profileexport PGHOME=/pgdataexport PGDATA=/pgdata/dataexport PATH=$PGHOME/bin:$PATHexport LD_LIBRARY_PATH=$PGHOME/libEOFsource .bash_profile
04、compile/setup[root@lab-250 ~]# tar jxf postgresql-9.5.19.tar.bz2 //解压[root@lab-250 ~]# cd postgresql-9.5.19[root@lab-250 postgresql-9.5.19]#
[root@lab-210 postgresql-9.5.19]# ./configure --help //查看编译参数./configure -q --prefix=/pgdata make -s -j2make -s install
//ignore warningWithout Bison you will not be able to build PostgreSQL from Gitchown -R postgres:postgres /pgdata
05、init pgsql_instancesu - postgresinitdb -A md5 -U postgres -W -E ‘utf-8‘ -D $PGDATA
###更加颗粒度,设置super user pwdinitdb --auth=trust --auth-host=md5 --auth-local=trust --pgdata=$PGDATA --encoding=‘UTF-8‘ --username=postgres --pwprompt
[postgres@lab-210 ~]$ initdb --help //查看帮助initdb initializes a PostgreSQL database cluster.Usage: initdb [OPTION]... [DATADIR]Options: -A, --auth=METHOD default authentication method for local connections --auth-host=METHOD default authentication method for local TCP/IP connections --auth-local=METHOD default authentication method for local-socket connections [-D, --pgdata=]DATADIR location for this database cluster -E, --encoding=ENCODING set default encoding for new databases -U, --username=NAME database superuser name -W, --pwprompt prompt for a password for the new superuser....
pg_ctl -D /pgdata/data -l logfile start //启动pgsql -D 默认读取$PGDATApg_ctl startps -ef | grep postgres //查看pgsql进程pg_ctl status //查看数据状态pg_ctl stop -m fast //停止数据库
[postgres@lab-210 ~]$ pg_ctl --help //查看参数pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server.Usage: pg_ctl init[db] [-D DATADIR] [-s] [-o "OPTIONS"] pg_ctl start [-w] [-t SECS] [-D DATADIR] [-s] [-l FILENAME] [-o "OPTIONS"] pg_ctl stop [-W] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] pg_ctl restart [-w] [-t SECS] [-D DATADIR] [-s] [-m SHUTDOWN-MODE] [-o "OPTIONS"] pg_ctl reload [-D DATADIR] [-s] pg_ctl status [-D DATADIR] pg_ctl promote [-D DATADIR] [-s] pg_ctl kill SIGNALNAME PID
Common options: -D, --pgdata=DATADIR location of the database storage area -s, --silent only print errors, no informational messages -t, --timeout=SECS seconds to wait when using -w option -V, --version output version information, then exit -w wait until operation completes -W do not wait until operation completes -?, --help show this help, then exit(The default is to wait for shutdown, but not for start or restart.)
If the -D option is omitted, the environment variable PGDATA is used.
Options for start or restart: -c, --core-files allow postgres to produce core files -l, --log=FILENAME write (or append) server log to FILENAME -o OPTIONS command line options to pass to postgres (PostgreSQL server executable) or initdb -p PATH-TO-POSTGRES normally not necessary
Options for stop or restart: -m, --mode=MODE MODE can be "smart", "fast", or "immediate"
Shutdown modes are: smart quit after all clients have disconnected fast quit directly, with proper shutdown immediate quit without complete shutdown; will lead to recovery on restart
06、express pgsqlcreatedb testpsql testtest=#help
07、开启归档及日志记录###追加到配置文件中
tee <<-‘EOF‘ >> postgresql.auto.conflisten_addresses = ‘*‘port = 5432wal_level = hot_standbyarchive_mode = onarchive_command = ‘cp %p /pgdata/archive/%f‘#max_wal_senders = 10logging_collector = onEOF
08、设置为service管理postgres###脚本在源码编译的位置存放
copy到init.d/及给予权限
修改prefix/pgdata
启动验证
postgresql9.5编译安装体验
标签:mit cti host createdb dia centos7 service database ice
小编还为您整理了以下内容,可能对您也有帮助:
如何安装并且开始调试PostgreSQL
删除服务
PostgreSQL—安装
标签:nbsp code attr org 数据库服务 img 数据库安装 utf-8 pos
如何安装并且开始调试PostgreSQL
删除服务
PostgreSQL—安装
标签:nbsp code attr org 数据库服务 img 数据库安装 utf-8 pos
如何安装PostgreSQL
右击文件选择以管理员身份运行
开始执行程序的安装
设置安装目录
设置数据的保存目录
设置数据库管理员密码,请牢记此密码。
设置端口号,选择默认的端口号即可
根据自己选择设置地区:这里选择中国
正式安装
9.完成安装
END
三、PostgreSQL的启动确认
1.打开控制面板-找到管理工具-服务
2.检查服务对话框PostgreSQL的状态,若为开始,则表示它已经正常启动了。
END
经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。
举报作者声明:本篇经验系本人依照真实经历原创,未经许可,谢绝转载。
投票(2)
有得(0)
我有疑问(0)
换一批相关经验
kali2.0下配置Metasploit+postgresql链接82016.02.19
postgresql 安装(linux下)12015.10.26
postgresql数据库在linux(centos)上的安装22014.11.30
IIS的安装与配置详细图解教程。702013.05.08
超详细图解Java8下载安装,Java1.8环境变量配置312015.02.26