---恢复内容开始---

安装方法:

1、可以使用操作系统自带的安装源

2、可以使用官网下载的源码进行安装

3、可以使用编译好的包入.run格式的安装包安装(本文使用的是这种安装方法,下载地址http://www.postgres.cn/download)

安装之前首先需要为postgresql数据库新建一个管理员用户:

  groupadd postgres

  mkdir /home/postgres

  useradd postgres -g postgres -s /bin/bash -b /home/postgres

开始安装:

  安装使用root用户安装,上传了赋予文件执行权限chmod +x postgresql-9.4.5-1-linux-x64.ru。根据提示一路安装至结束。安装完了之后进入安装目录ll查看一下目录信息,会发现.cache和data两个目录是postgres用户组的。

配置:

进入data目录下,配置文件说明:

  pg_hba.conf--此文件是配置链接权限的,共分5列,请求连接类型--要连接的数据库--请求连接的用户--请求来的地址--请求认证的方式。默认的第一行local   all             all                                     md5,意思是本地登陆,我们本地登录不验证密码,将md5换成trust

  pg_ident.conf--此文件是配置登陆数据库所需要验证的用户名码,格式username:password

  postgresql.conf--此文件是主要数据库的配置信息,具体的每个参数含义不再列出,listen_addresses和port使用默认的。

启动、关闭数据库:

  为管理员用户postgres配置环境变量。cd && vim .profile,我能当末尾添加如下信息:

export PG_HOME=/opt/PostgreSQL/9.4
export PGDATA=/opt/PostgreSQL/9.4/data
export PATH=$PATH:$PG_HOME/bin

当让别忘记source .profile,下面就试试效果如何,直接输入pg_ 然后使用TAB键会带出很多pg_***的文件,这就说明环境变量已生效,那就开始启动数据库吧.

postgres@ubuntu:~$ pg_ctl start
pg_ctl: another server might be running; trying to start server anyway
server starting
postgres@ubuntu:~$ 2016-06-08 22:35:40 CST FATAL: lock file "postmaster.pid" already exists
2016-06-08 22:35:40 CST HINT: Is another postmaster (PID 2392) running in data directory "/opt/PostgreSQL/9.4/data"?

这个错误是说postmaster.pid这个文件已经存在了,说明这个数据库已经被启动了。那就先关掉吧

postgres@ubuntu:~$ pg_ctl stop
waiting for server to shut down.... done
server stopped

然后再启动一下。

postgres@ubuntu:~$ pg_ctl start
server starting
postgres@ubuntu:~$ 2016-06-08 22:37:16 CST LOG: redirecting log output to logging collector process
2016-06-08 22:37:16 CST HINT: Future log output will appear in directory "pg_log".

postgres@ubuntu:~$ ps -ef|grep postgres  --说明postgresql启动成功
root 2660 1655 0 22:24 pts/2 00:00:00 su - postgres                                        --这个用户切换的进程,不用管
postgres 2661 2660 0 22:24 pts/2 00:00:00 -su                                                --同上
postgres 2719 1 0 22:37 pts/2 00:00:00 /opt/PostgreSQL/9.4/bin/postgres         --这个是postgresql的主进程
postgres 2720 2719 0 22:37 ? 00:00:00 postgres: logger process                       --这个是子进程,在PostgreSQL中称为SysLogger(8.0),用于整个系统的日志输出;
postgres 2722 2719 0 22:37 ? 00:00:00 postgres: checkpointer process              --这个是子进程,在PostgreSQL中称为Checkpointer(9.2),用于处理checkpoints;
postgres 2723 2719 0 22:37 ? 00:00:00 postgres: writer process                        --这个是子进程,在PostgreSQL中称为BgWriter,用于将脏页刷出到磁盘;
postgres 2724 2719 0 22:37 ? 00:00:00 postgres: wal writer process                   --这个是子进程,在PostgreSQL中称为WalWriter(8.3),处理预写日志输出;
postgres 2725 2719 0 22:37 ? 00:00:00 postgres: autovacuum launcher process  --这个是子进程,在PostgreSQL中称为AutoVacuum(8.1),用于系统的自动清理;
postgres 2726 2719 0 22:37 ? 00:00:00 postgres: stats collector process            --这个是子进程,在PostgreSQL中称为PgStat,用于统计数据收集。 
postgres 2728 2661 0 22:37 pts/2 00:00:00 ps -ef
postgres 2729 2661 0 22:37 pts/2 00:00:00 grep postgres

此外,如果配置了副本的话,应该还有一个进程  postgres: archiver process:  在PostgreSQL中称为PgArch,用于预写日志归档;同步数据用的。

详细关于进程的可以参考http://wiki.postgresql.org/wiki/Pgsrcstructure

如果修改过配置需要执行pg_ctl reload重新加载数据库

postgres@ubuntu:~$ psql -h 127.0.0.1 -p 5432
Password:
psql (9.3.10, server 9.4.5)
WARNING: psql major version 9.3, server major version 9.4.
Some psql features might not work.
Type "help" for help.

postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | zh_CN.utf8 | zh_CN.utf8 |
template0 | postgres | UTF8 | zh_CN.utf8 | zh_CN.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.utf8 | zh_CN.utf8 | =c/postgres +
| | | | | postgres=CTc/postgres
(3 rows)

postgresql学习之安装篇的更多相关文章

  1. SystemTap 学习笔记 - 安装篇

    https://segmentfault.com/a/1190000000671438 在安装前,需要知道下自己的系统环境,我的环境如下: uname -r 2.6.18-308.el5 Linux ...

  2. PCI GXL学习之安装篇

    作者:朱金灿 来源:http://blog.csdn.net/clever101 上周简单学习了PCI gxl的使用和二次开发.说实话gxl没有我想象中那么自动化,我原以为把一个数据处理作业扔给gxl ...

  3. Appium学习路-安装篇

    比较好的文章:http://www.15yan.com/story/4GbuTwXQKDU/ 官网资料:http://appium.io/slate/cn/v1.2.0/?python#appium ...

  4. postgresql学习笔记--基础篇

    1. 客户端程序和服务器端程序 1.1 客户端程序 Command Example Describe clusterdb clusterdb -h pghost1 -p 1921 -d mydb Cl ...

  5. Redis学习笔记-安装篇(Centos7)

    1.安装 这里使用源代码安装的方式,如果你希望使用yum或者rpm包安装的方式,可以百度一下,安装方法可谓多如牛毛. # 下载安装包 # wget http://download.redis.io/r ...

  6. postgresql学习笔记--基础篇 - copy

    1. psql 导入/导出数据 psql支持文件数据导入到数据库,也支持数据库表数据导出到文件中. COPY命令和\copy 命令都支持这两类操作,但两者有如下区别: COPY 命令是SQL命令,\c ...

  7. postgresql学习笔记--基础篇 -psql工具

    --创建用户 CREATE ROLE pguser WITH ENCRYPTED PASSWORD 'pguser'; --创建表空间目录 mkdir -p /database/pg10/pg_tbs ...

  8. jmeter学习之安装篇(一)

    一.Jmeter简介 Jmeter是Apache组织开发的基于Java开源项目,设计之初是用于做性能测试的,同时它在实现对各种接口的调用方面做的比较成熟,因此,常被用做接口功能测试和性能测试. Jme ...

  9. OracleDesigner学习笔记1――安装篇

    OracleDesigner学习笔记1――安装篇   QQ:King MSN:qiutianwh@msn.com Email:qqking@gmail.com 一.       前言 Oracle是当 ...

随机推荐

  1. linux命令之------部分细节点

    创建文件夹/文件命令以及清除模式 mkdir +文件夹名字 touch +文件名字 rm -fr 删除文件,文件夹 -f强制删除 -r是递归 查询linux下所有启动的线程: ps -ef|grep ...

  2. LINK : fatal error LNK1181: cannot open input file 'glew32.lib' error: command 'C:\\Program Files (

    下载 库文件 参考: https://stackoverflow.com/questions/53355474/kivent-installation-fatal-error-lnk1181-cant ...

  3. ssh 可以登录但是 sftp 不能登录的解决办法

    将 /etc/ssh/sshd_config 中的 Subsystem      sftp    /usr/libexec/openssh/sftp-server 改为 Subsystem       ...

  4. Debian系Linux 发行版 源配置说明

    概述: 本文是在逛论坛是的发现,借鉴过来,以便学习.源列表主文件 /etc/apt/sources.list同时也可创建独立的源配置文件到 /etc/apt/sources.list.d/* 下 so ...

  5. Spring Transaction 使用入门

    一.开篇陈述 1.1 写文缘由 最近在系统学习spring框架IoC.AOP.Transaction相关的知识点,准备写三篇随笔记录学习过程中的感悟.这是第一篇,记录spring Transactio ...

  6. Octopus501工作站 安装记录

    cmake libreadline-dev 没有运行程序,nvidia-smi查看GPU-Util 达到100% 解决方案:需要把驱动模式设置为常驻内存才可以,设置命令:nvidia-smi -pm ...

  7. Tensorflow 损失函数(loss function)及自定义损失函数(三)

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明. 本文链接:https://blog.csdn.net/limiyudianzi/article ...

  8. Cross-channel Communication Networks

    Cross-channel Communication Networks 2019-12-13 14:17:18 Paper: https://papers.nips.cc/paper/8411-cr ...

  9. Ubuntu命令行下缩小磁盘镜像img文件尺寸

    要解决的问题 一个固件包里的system.img, 尺寸是1GB, 里面的内容只有470MB, 在设备上写入的时候报超出大小了, 所以想把这个img调整为512MB 网上查了很多, 没有一个好用的, ...

  10. 取response里 Json格式的字段值

    1.