root身份安装

  1. 创建用户
  2.  
  3. 编译安装成功后,接下来要做的就是创建一个普通用户,因为默认超级用户(root)不能启动postgresql,所以需要创建一个普通用户来启动数据库,执行以下命令创建用户:
  4.  
  5. [root@localhost build_dir]# groupadd postgres
  6. [root@localhost build_dir]# useradd -g postgres postgres
  7. [root@localhost build_dir]# passwd postgres
  8.  
  9. 接下来设置权限,将pg的数据目录全部赋给postgres用户,执行以下命令:
  10.  
  11. [root@localhost build_dir]# chown -R postgres:postgres /usr/local/pgsql
  12.  
  13. 创建目录
  14.  
  15. [root@localhost build_dir]# mkdir -p /mnt/db1/pgdata/pgsql /mnt/db1/pgdata/pgtbs /mnt/db1/archivelog /backups
  16. [root@localhost build_dir]# chmod -R /mnt/db1
  17. [root@localhost build_dir]# chown -R postgres:postgres /mnt/db1
  18.  
  19. 设置环境变量
  20.  
  21. [root@localhost build_dir]# vi /home/postgres/.bash_profile
  22.  
  23. PATH=$PATH:$HOME/.local/bin:$HOME/bin
  24.  
  25. export PATH
  26.  
  27. export PGPORT=
  28. export PGHOME=/usr/local/pgsql
  29. export PGDATA=/mnt/db1/pgdata/pgsql
  30. export PATH=$PGHOME/bin:$PATH
  31. export MANPATH=$PGHOME/share/man:$MANPATH
  32. export LANG=en_US.UTF-
  33. export DATE='date +"%Y%m%d%H%M"'
  34. export LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH
  35. export PGHOST=$PGDATA
  36. export PGUSER=postgres
  37. export PGDATABASE=postgres
  38.  
  39. PATH=$PATH:$HOME/.local/bin:$HOME/bin:$PGHOME/bin
  40. export PATH
  41.  
  42. 执行如下命令使其生效:
  43.  
  44. [root@localhost build_dir]# source /home/postgres/.bash_profile

准备

  1. 由于centos自带的版本不够高,直接安装postgresql会报错,所以先给llvmclang升级
    # wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    # yum localinstall epel-release-latest-7.noarch.rpm
    # yum install llvm5.0 llvm5.0-devel clang
  2.  
  3. yum install -y
  4. gcc gcc-c++
  5. openssl openssl-devel
  6. readline readline-devel
  7. zlib zlib-devel
  8. llvm5. llvm5.-devel
  9. libxml2-devel
  10. libxslt-devel
  11. libicu-devel
  12.  
  13. python-devel
  14. tcl-devel
  15. systemd-devel
  16. openldap-devel
  17. pam-devel
  18.  
  19. clang
  20. perl-ExtUtils-Embed
  21. epel-release
  22.  
  23. 实际执行:

yum install -y gcc gcc-c++ epel-release llvm5.0 llvm5.0-devel clang libicu-devel perl-ExtUtils-Embed readline readline-devel zlib zlib-devel openssl openssl-devel pam-devel libxml2-devel libxslt-devel openldap-devel systemd-devel tcl-devel python-devel

  1. 但是公司centos6.3电脑上:无法安装systemd-develllvm5.0 llvm5.0-devel

configure

  1. # cd build_dir/
  2. vim ../src/Makefile.global.in
  3. 修改以下行:
  4. COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -flto=thin -emit-llvm -c
  5. 修改为:
  6. COMPILE.c.bc = $(CLANG) -Wno-ignored-attributes $(BITCODE_CFLAGS) $(CPPFLAGS) -emit-llvm -c
  7.  
  8. -- --prefix 指定默认安装路径
  9. [root@localhost build_dir]# ../configure
  10. --prefix=/usr/local/pgsql
  11. --enable-nls
  12. --with-perl
  13. --with-python
  14. --with-tcl
  15. --with-gssapi
  16. --with-llvm LLVM_CONFIG='/usr/lib64/llvm5.0/bin/llvm-config'
  17. --with-icu
  18. --with-openssl
  19. --with-pam
  20. --with-ldap
  21. --with-systemd
  22. --with-libxml
  23. --with-libxslt
  24.  
  25. #configure 命令完成后,会发现创建了 config.status 配置文件
    # 实际执行:
    ./configure --prefix=/home/cdrom/work/postgresql11_5432 --enable-nls --with-perl --with-python --with-tcl --with-gssapi --with-llvm LLVM_CONFIG='/usr/lib64/llvm5.0/bin/llvm-config' --with-icu --with-openssl --with-pam --with-ldap --with-systemd --with-libxml --with-libxslt
  1. make
  2. make install
  1. 初始化数据库
  2.  
  3. 切换用户
  4. [root@localhost build_dir]# su - postgres
  5. 初始化数据库
  6. [postgres@localhost ~]$ initdb -D $PGDATA -U postgres --locale=en_US.UTF8 -E UTF8
  7.  
  8. 修改监听地址 listen_addresses的值设置成*,使其监听整个网络,端口号默认是5432,也可以自己设置。
  9.  
  10. [postgres@localhost ~]$ vim /mnt/db1/pgdata/pgsql/postgresql.conf
  11. 修改内容:
  12. listen_addresses = '*'
  13. unix_socket_directories = '.'
  14. port =
  15.  
  16. 修改客户端认证方式
  17.  
  18. [postgres@localhost ~]$ vim /mnt/db1/pgdata/pgsql/pg_hba.conf
  19. 添加内容:
  20. host all all 0.0.0.0/ md5 # 其他用户登陆
  21.  
  22. 设置防火墙规则
  23.  
  24. #切换回root用户
  25. [postgres@localhost ~]$ exit
  26. [root@localhost build_dir]# firewall-cmd --zone=public --add-port=/tcp --permanent
  27. [root@localhost build_dir]# firewall-cmd --reload
  28.  
  29. 启动数据库
  30.  
  31. [root@localhost build_dir]# su - postgres
  32. 启动
  33. [postgres@localhost ~]$ pg_ctl -D /mnt/db1/pgdata/pgsql -l /mnt/db1/archivelog/pgsql.log start
  34. 停止
  35. [root@localhost postgres]# pg_ctl -D /mnt/db1/pgdata/pgsql/ -s -m fast stop
  36.  
  37. 连接测试
  38.  
  39. [postgres@localhost ~]$ psql
  40. 查询所有用户
  41. postgres=# select * from pg_user;
  42. postgres=# select * from pg_roles;
  43. 查询权限
  44. postgres=# select * from information_schema.table_privileges where grantee='cc';
  45. 查看有哪些数据库
  46. postgres=# \l
  47. 相当与mysqlshow databases;
  48. postgres=# select datname from pg_database;
  49. 相当于mysqlshow tables, public 是默认的schema的名字
  50. postgres=# SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';
  51. 相当与mysqldescribe table_name, 'table_name'是要查询的表的名字
  52. postgres=# SELECT column_name FROM information_schema.columns WHERE table_name ='table_name';
  53. 退出
  54. postgres=# \q
  55.  
  56. psql PostgreSQL 的客户端程序,要连接 PostgreSQL 数据库,我们需要指定以下内容:
  57.  
  58. -d or --dbname 数据库名
  59. -h or --host 主机名
  60. -p or --port 端口号,默认5432 端口
  61. -U or --username 用户名
  62. [postgres@localhost ~]$ psql -h localhost -p -U postgres
  63.  
  64. 设置postgres用户密码
  65.  
  66. [postgres@localhost ~]$ psql
  67. postgres=# ALTER USER postgres WITH encrypted PASSWORD 'new password';
  68. postgres=# \q
  69. [postgres@localhost ~]$ psql -h localhost -p -U postgres
  70.  
  71. 设置开机自启动
  72.  
  73. 设置启动配置
  74.  
  75. vim /usr/lib/systemd/system/postgresql-.service
  76. 添加内容:
  77. [Unit]
  78. Description=PostgreSQL database server
  79. Documentation=https://www.postgresql.org/docs/11/static/
  80. After=syslog.target
  81. After=network.target
  82.  
  83. [Service]
  84. Type=notify
  85.  
  86. User=postgres
  87. Group=postgres
  88.  
  89. # Location of database directory
  90. Environment=PGDATA=/mnt/db1/pgdata/pgsql/
  91.  
  92. # Where to send early-startup messages from the server (before the logging
  93. # options of postgresql.conf take effect)
  94. # This is normally controlled by the global default set by systemd
  95. # StandardOutput=syslog
  96.  
  97. # Disable OOM kill on the postmaster
  98. OOMScoreAdjust=-
  99.  
  100. Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
  101. Environment=PG_OOM_ADJUST_VALUE=
  102.  
  103. # ExecStartPre=/usr/pgsql-/bin/postgresql--check-db-dir ${PGDATA}
  104. ExecStart=/usr/local/pgsql/bin/postmaster -D ${PGDATA}
  105. ExecReload=/bin/kill -HUP $MAINPID
  106. # ExecStart=/usr/local/pgsql9./bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t
  107. # ExecStop=/usr/local/pgsql9./bin/pg_ctl stop -D ${PGDATA} -s -m fast
  108. # ExecReload=/usr/local/pgsql9./bin/pg_ctl reload -D ${PGDATA} -s
  109. KillMode=mixed
  110. KillSignal=SIGINT
  111.  
  112. # Do not set any timeout value, so that systemd will not kill postmaster
  113. # during crash recovery.
  114. TimeoutSec=
  115.  
  116. [Install]
  117. WantedBy=multi-user.target
  118.  
  119. 添加可执行权限
  120.  
  121. [root@localhost postgres]# chmod /usr/lib/systemd/system/postgresql-.service
  122.  
  123. 设置开机自启动
  124.  
  125. 自动启动
  126. [root@localhost postgres]# systemctl enable postgresql-.service
  127. 启动
  128. [root@localhost postgres]# systemctl start postgresql-.service
  129. 停止某服务
  130. [root@localhost postgres]# systemctl stop postgresql-.service
  131. 不自动启动
  132. [root@localhost postgres]# systemctl disable postgresql-.service
  133. 检查服务状态(服务详细信息)
  134. systemctl status postgresql-.service
  135. 检查服务状态(仅显示是否Active
  136. systemctl is-active postgresql-.service
  137. 显示所有已启动的服务
  138. systemctl list-units --type=service

################################################################

centos6.3上安装如下:

  1. systemd-develllvm5. llvm5.-devel,没有安装上。
  2. ./configure --prefix=/home/postgres/postgres11_5434 --enable-nls --with-perl --with-python --with-tcl --with-gssapi --with-openssl --with-pam --with-ldap --with-libxml --with-libxslt

  3. 同时在make的时候会出错,需要将postgresql-11.5/src/test/isolation目录下面的specs目录给换个名称,但是目前还不知道有什么影响
  1. make -j4
  2.  
  3. make install
  1.  

安装postgresql11.5的更多相关文章

  1. Windows安装PostgreSQL11.1

    Windows安装PostgreSQL11.1 安装过程如下: 1.下载安装包postgresql-11.1-1-windows-x64.exe 2.点击下一步 3.选择安装位置,默认路径C:\Pro ...

  2. Centos75 安装 postgresql11

    切换到root账户, #安装yum 源 yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel-7-x86_6 ...

  3. CentOs7.5安装PostgreSQL11

    前言 本章介绍在CentOs上安装一个PostgreSQL数据库 下一篇可能是安装 Redis 本篇使用的服务器是已经安装过Python/Nginx等常用软件的环境,因此在安装过程中可能会遇到按照本章 ...

  4. centos7 安装postgresql11

    1 进入postresql官网下载页面,提示了centos相关下载安装等信息. https://www.postgresql.org/download/linux/redhat/   image.pn ...

  5. 离线安装PostgreSQL11.6

    因为客户最近有一台CentOS7的虚拟机,但是没有联网,需要安装离线安装PostgreSQL 1.首先去官网下载离线安装包 https://www.postgresql.org/download/ 说 ...

  6. CentOS7安装postgreSQL11

    1.添加PostgreSQL Yum存储库 sudo yum install https://download.postgresql.org/pub/repos/yum/11/redhat/rhel- ...

  7. CentOS7(64) yum安装、配置PostgreSQL 11

    一.安装postgresql11 1.Install the repository RPM: 添加RPM yum install https://download.postgresql.org/pub ...

  8. 在CentOS7上部署PostgreSQL11数据库系统

    在数据库上的选择,也是基于了稳定性为前提.其实选择的范围并不是太大,基本可以选择的范围也就是SQLServer.MySQL.PostgreSQL这三种.SQL Server是微软的商业数据库,无论是性 ...

  9. Centos7 源码安装PostgreSQL Citus集群 (转载)

    citus的分布式集群目前在苏宁大规模应用,苏宁陈华军也做了很多技术分享和博客介绍.目前所有的教程都是rpm和pg一起安装,个人不喜欢,毕竟citus定位是个插件,我想在我已安装的pg上源码装一个ci ...

随机推荐

  1. 记一次付工解决Sqlserver问题的过程

    问题:Sqlserver连接不上 1 检查自身 Sqlserve服务是否开启 Windows服务是否开启 2 用CMD尝试连接Sqlserver 显示详细错误 由于文件不可访问,或者内存或磁盘空间不 ...

  2. Spring Cloud失散多年的哥哥Dubbo学习笔记

    Spring Cloud失散多年的哥哥Dubbo 随着互联网项目用户量的急剧增长,访问并发良突然暴增,将一个应用使用多个独立的工程共同实现的系统架构,称为SOA系统架构,各个工程可以允许在不同的机器上 ...

  3. 阿里第一颗芯片问世,平头哥发布最强AI芯片含光800

    阿里巴巴第一颗自研芯片正式问世.9月25日的杭州云栖大会上,达摩院院长张建锋现场展示了这款全球最强的AI芯片——含光800.在业界标准的ResNet-50测试中,含光800推理性能达到78563 IP ...

  4. 广义欧拉降幂(欧拉定理)——bzoj3884,fzu1759

    广义欧拉降幂对于狭义欧拉降幂任然适用 https://blog.csdn.net/qq_37632935/article/details/81264965?tdsourcetag=s_pctim_ai ...

  5. PSCC2019常用基础操作

    一.常用设置 1.界面设置(快捷键Ctrl+K):可以对PS界面的颜色.导出格式.性能等等进行设置(这里暂存盘建议设置D盘或F盘,默认C盘). 2.常用面板整理(菜单栏->窗口) 二.常用快捷键 ...

  6. 基础数据类型补充 set集合 深浅拷贝

    一.基础数据类型补充 1. "拼接字符串".join(可迭代对象) 可迭代对象为列表时,输出列表元素与拼接字符串的拼接 li = ['张三', '李四', '王五', '赵四'] ...

  7. (1)mysql数据库操作

    1.安装mysql https://dev.mysql.com/downloads/windows/installer/8.0.html 2.mysql启停 运行mysql         net s ...

  8. 怎么规划一个零基础学习Unity3D的“方法”或者“流程”?

    具体出处:https://www.zhihu.com/question/35542990 我只是一个计算机相关专业毕业的,已经掌握了基础的C#并开发过.net的.目前突然心血来潮对unity3D有兴趣 ...

  9. 有道云笔记新功能发现——有道云笔记剪报,完美解决不开会员保存csdn博客到本地的问题。

    怎么用 方法一:谷歌插件 方法二:http://note.youdao.com/web-clipper-chrome.html 添加到书签 功能: 能够把网页浏览的内容保存到有道云笔记 解决了自己的难 ...

  10. Stern-Brocot Tree、伪.GCD 副本

    Stern-Brocot Tree.伪.GCD 副本 伪.GCD 问题 1:\(f(a,b,c,n) = \sum_{i=0}^{n} [\frac{ai+b}{c}]\) Case 1: \(a\g ...