PostgreSql 9.4.4 安装部署

PostgreSql 9.4.4 安装部署,第1张

概述*****************************************************1.编译安装*****************************************************/*******make --versiongcc --versionperl --versionpython --versionyum -
*****************************************************1.编译安装*****************************************************/*******make --versiongcc --versionperl --versionpython --versionyum -y install wget gcc gcc-c++ readline-devel zlib-devel make   systemtap systemtap-sdt-devel \perl perl-devel python python-devel tcl  tcl-devel    perl-ExtUtils-Embed \sgml-common docbook stylesheets openjade  sgml-tools  xsltproc libxslt libxslt-devel \libxml2 libxml2-devel zlib zlib-devel openssl openssl-devel   pam pam-devel bison flex libreadline6-devel ******/# wget https://ftp.postgresql.org/pub/source/v9.4.0/postgresql-9.4.0.tar.bz2#mkdir -p /soft && cd /soft#rz# tar xf postgresql-9.4.4.tar.gz && cd postgresql-9.4.4#./configure./configure --prefix=/data/pg \--with-pgport=5432  \--with-perl --with-python --with-tcl  \--with-openssl  --without-ldap  \ --with-libxml  --with-libxslt    \--enable-thread-safety    \--with-wal-blocksize=16   \--with-blocksize=16 \-enable-dtrace  \--enable-deBUG#make && make install#useradd postgres && passwd postgrespg01!@##mkdir /data/pg/data -p  && chown -R postgres /data/pg/data# su - postgres$ vi  .bash_profile# postgres#Postgresql端口PGPORT=5432#Postgresql数据目录PGDATA=/data/pg/dataexport PGPORT PGDATA #所使用的语言export LANG=en_US.utf8#Postgresql 安装目录export PGHOME=/data/pg#Postgresql 连接库文件export LD_liBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_liBRARY_PATHexport DATE=`date +"%Y%m%d%H%M"`#将Postgresql的命令行添加到 PATH 环境变量export PATH=$PGHOME/bin:$PATH#Postgresql的 man 手册export MANPATH=$PGHOME/share/man:$MANPATH#Postgresql的默认用户export PGUSER=postgres#Postgresql默认主机地址export PGHOST=127.0.0.1#默认的数据库名export PGDATABASE=postgres#source .bash_profile #echo $PATH#执行数据库初始化脚本$/data/pg/bin/initdb --enCoding=utf8 -D /data/pg/data---结果如下The files belonging to this database system will be owned by user "postgres".This user must also own the server process.The database cluster will be initialized with locale "en_US.utf8".The default text search configuration will be set to "english".Data page checksums are Disabled.fixing permissions on existing directory /data/pg/data ... okcreating subdirectorIEs ... okselecting default max_connections ... 100selecting default shared_buffers ... 128MBselecting dynamic shared memory implementation ... posixcreating configuration files ... okcreating template1 database in /data/pg/data/base/1 ... okinitializing pg_authID ... okinitializing dependencIEs ... okcreating system vIEws ... okloading system objects' descriptions ... okcreating collations ... okcreating conversions ... okcreating dictionarIEs ... oksetting privileges on built-in objects ... okcreating information schema ... okloading PL/pgsql server-sIDe language ... okvacuuming database template1 ... okcopying template1 to template0 ... okcopying template1 to postgres ... oksyncing data to disk ... okWARNING: enabling "trust" authentication for local connectionsYou can change this by editing pg_hba.conf or using the option -A,or--auth-local and --auth-host,the next time you run initdb.Success. You can Now start the database server using:    /data/pg/bin/postgres -D /data/pg/dataor    /data/pg/bin/pg_ctl -D /data/pg/data -l logfile start$退出变更登录exit#复制Postgresql执行脚本cp /soft/postgresql-9.4.4/contrib/start-scripts/linux  /etc/init.d/postgresql#增加执行权限chmod +x /etc/init.d/postgresql#编辑Postgresql执行脚本,确定以下参数或修改vi /etc/init.d/postgresql# Installation prefixprefix=/data/pg# Data directoryPGDATA="/data/pg/data"# Who to run the postmaster as,usually "postgres".  (NOT "root")PGUSER=postgres# Where to keep a log filePGLOG="$PGDATA/serverlog"#编辑配置文件,配置可访问数据库的网络地址(注意别忘了去掉#Listen_addresses=前面的#)#vi /data/pg/data/postgresql.conf59 Listen_addresses = '*' #启动或停止PG$pg_ctl start $pg_ctl stop# 设置开机自动启动服务chkconfig postgresql on*****************************************************2.数据库配置*****************************************************--2.1 设置远程登录数据库#vi /data/pg/data/postgresql.conf59 Listen_addresses = '*' 67 superuser_reserved_connections = 3 91 password_encryption = on101 tcp_keepalives_IDle = 60 115 shared_buffers = 6000MB 126 work_mem = 4MB151 vacuum_cost_delay = 10ms   159 bgwriter_delay = 10ms 180 wal_sync_method = fsync190 wal_buffers = 128000kB 192 wal_writer_delay = 20ms 200 checkpoint_timeout = 30min201 checkpoint_completion_target = 0.9 321 logging_collector = on   327 log_directory = 'pg_log'                329 log_filename = 'postgresql-%Y-%m-%d_%H%M%s.log' 333 log_truncate_on_rotation = off          341 log_rotation_age = 0            343 log_rotation_size = 50MB  395 log_min_duration_statement = 2000ms  #跟踪哪些sql执行时间长434 log_statement = 'ddl'   #记录DDL语句,一般用于跟踪数据库中的危险 *** 作407 log_checkpoints = on   #记录每一次checkpoint到日志中.433 log_lock_waits = on  #记录锁等待超过1秒的 *** 作,一般用于排查业务逻辑上的问题 558 deadlock_timeout = 1s451 track_activity_query_size = 2048  #显示更长的sql.468 autovacuum = on  #log_autovacuum_min_duration = 0记录所有的autovacuum *** 作.470 log_autovacuum_min_duration = 0#vi /data/pg/data/pg_hba.conf#to allow your clIEnt visiting postgresql serverhost all all 0.0.0.0 0.0.0.0 md5重启数据库.pg_ctl -m "immediate" restart--2.2 以postgres用户登录数据库,修改postgres用户的数据库密码psql -U postgrespostgres=# ALTER USER postgres PASSWORD 'password';postgres=# \q--2.3 远程连接psql -h 192.168.50.110  -d postgres -U postgres Password for user postgres: *****************************************************3.管理配置数据库*****************************************************1.登录postgre sql数据库# psql -U postgres -h 127.0.0.12.创建新用户wind,但不给建数据库的权限postgres=#select * from pg_user;postgres=# create user "wind" with password 'wind' nocreatedb;//注意用户名要用双引号,以区分大小写,密码不用3.建立数据库,并指定所有者postgres=# create database "wind" with owner="wind";4.在外部命令行的管理命令# -u postgres createuser -D -P test1//-D该用户没有创建数据库的权利,-P提示输入密码,选择管理类型y/n# -u postgres createdb -O test1 db1//-O设定所有者为test1*****************************************************4.环境变量*****************************************************---postgres用户vi ~/.bash_profile alias psqla="psql -U postgres -h 127.0.0.1"source ~/.bash_profile ---root用户vi ~/.bash_profile alias sudop="su - postgres"source ~/.bash_profile 
总结

以上是内存溢出为你收集整理的PostgreSql 9.4.4 安装部署全部内容,希望文章能够帮你解决PostgreSql 9.4.4 安装部署所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/sjk/1175288.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-02
下一篇 2022-06-02

发表评论

登录后才能评论

评论列表(0条)

保存