操作系统:CentOS7
安装文件:postgresql-10.0.tar.gz

系统环境:gcc、Python

1:源码安装

[postgres@localhost ~]# tar zxvf postgresql-10.0.tar.gz
[postgres@localhost ~]# mv postgresql-10.0 /usr/local/pgsql/
[postgres@localhost ~]# cd /usr/local/pgsql/
[root@localhost pgsql]# ./configure --prefix=/usr/local/pgsql --without-readline --without-zlib
[root@localhost pgsql]# make
[root@localhost pgsql]# make install

2:添加postgres用户,设置目录权限

[root@localhost ~]# adduser postgres
[root@localhost ~]# passwd postgres
[root@localhost ~]# mkdir -p /usr/local/pgsql/data
[root@localhost ~]# chown -R posgres:root /usr/local/pgsql/
[root@localhost ~]# chown -R postgres:root /usr/local/pgsql/

3:设置环境变量

[root@localhost ~]# su - postgres
[postgres@localhost ~]$ vim ~/.bash_profile
PATH=$PATH:/usr/local/pgsql/bin
[postgres@localhost ~]$ source ~/.bash_profile

4:添加启动服务

()添加启动服务
[root@localhost ~]# cp /usr/local/pgsql/contrib/start-scripts/linux /etc/init.d/postgresql
[root@localhost ~]# chmod u+x /etc/init.d/postgresql
()添加开机自启动
[root@localhost ~]# chkconfig --add postgresql
()启动服务
[root@localhost ~]# service postgresql start
Starting PostgreSQL: ok

5:切换到postgres用户,初始化数据库

[postgres@localhost data]$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/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 "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple". Data page checksums are disabled. fixing permissions on existing directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ...
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections
You 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: /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

6:修改postgresql配置

()允许所有连接
[postgres@localhost ~]$ vi /usr/local/pgsql/data/pg_hba.conf
# IPv4 local connections:
host all all 0.0.0.0/ trust
()侦听所有连接
[postgres@localhost ~]$ vi /usr/local/pgsql/data/postgresql.conf
listen_addresses = '*'
logging_collector = on

7:启动数据库

[postgres@localhost data]$  /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start
waiting for server to start.... done
server started

8:设置postgres用户的密码

[postgres@localhost ~]$ psql
psql (10.0)
Type "help" for help. postgres=# \password
Enter new password:
Enter it again:

9:查看当前数据库列表

10:创建角色、数据库,切换数据库、用户

postgres=# create role test login password 'test';
CREATE ROLE
postgres=# create database testdb with owner=test;
CREATE DATABASE
postgres=# \c testdb;
You are now connected to database "testdb" as user "postgres".
testdb=# \c - test;
You are now connected to database "testdb" as user "test".
testdb=>

11:本地通过pgAdmin4进行连接

在CentOS7(虚拟机)下通过源码安装Postgresql10以及基本配置的更多相关文章

  1. Centos7 linux下通过源码安装redis以及使用

    下载redis安装包 wget http://download.redis.io/releases/redis-5.0.3.tar.gz 解压压缩包 tar -zxvf redis-.tar.gz y ...

  2. linux下通过源码安装git

    1.移除旧版本git [root@Git ~]# git --version ## 查看自带的版本git version 1.8.3.1 [root@Git ~]# yum remove git ## ...

  3. Linux下通过源码编译安装程序

    本文简单的记录了下,在linux下如何通过源码安装程序,以及相关的知识.(大神勿喷^_^) 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 库文件: ...

  4. 通过源码安装PostgresSQL

    通过源码安装PostgresSQL 1.1 下载源码包环境: Centos6.8 64位 yum -y install bison flex readline-devel zlib-devel yum ...

  5. 在centos6.7通过源码安装python3.6.7报错“zipimport.ZipImportError: can't decompress data; zlib not available”

    在centos6.7通过源码安装python3.6.7报错: zipimport.ZipImportError: can't decompress data; zlib not available 从 ...

  6. Ubuntu 14.04 卸载通过源码安装的库

    cd cere-solvermkdir buildcd buildcmake ..sudo makesudo make install 卸载通过以上方式源码安装的库 再次进入buildsudo mak ...

  7. 【Git】CentOS7 通过源码安装Git

    yum源仓库里的Git版本更新不及时,最新版的Git是1.8.3,但是官方的最新版早已经更新到2.9.5.想要安装最新版本Git,只能下载源码进行安装 建议最好更新git为较新版本,便于使用 1.查看 ...

  8. Linux下通过源码编译安装程序(configure/make/make install的作用,然后在/etc/profile文件里修改PATH环境变量)

    一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 库文件:就是通常我们见到的lib目录下的文件 配置文件:这个不必多说,都知道 帮助文档:通常是我们在 ...

  9. CentOS7通过源码安装nginx

    需要先安装安装环境和库: yum install gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum i ...

随机推荐

  1. Win7 ArcGIS 10.5 安装错误 A service pack is required on this operatiing system

    前段时间有朋友反馈在Win7专业版下安装ArcGIS 10.5, 无法安装,弹出错误: A service pack is required on this operatiing system,如图: ...

  2. java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method 解决办法

    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an in ...

  3. Tomcat集群下获取memcached缓存对象数量,统计在线用户数据量

    项目需要统计在线用户数量,系统部署在集群环境下,使用会话粘贴的方式解决Session问题.要想得到真实在线用户数,必须是所有节点的总和. 这里考虑使用memcached存放用户登录数据,key为use ...

  4. Java 集合细节(二):asList 的缺陷

    在实际开发过程中我们经常使用 asList 讲数组转换为 List,这个方法使用起来非常方便,但是 asList 方法存在几个缺陷: 一.避免使用基本数据类型数组转换为列表 使用 8 个基本类型数组转 ...

  5. Kendall Rank(肯德尔等级)相关系数

    1.简介在统计学中,肯德尔相关系数是以Maurice Kendall命名的,并经常用希腊字母τ(tau)表示其值.肯德尔相关系数是一个用来测量两个随机变量相关性的统计值.一个肯德尔检验是一个无参数假设 ...

  6. Cannot create container for service peer1.org2.example.com: Conflict. 解决方案

    I have a docker-compose.yaml file defining 5 services: orderer.example.com peer0.org1.example.com pe ...

  7. Java常见异常(Runtime Exception )小结(转)

    原文链接:Java常见异常(Runtime Exception )小结 Java异常体系结构呈树状,其层次结构图如图 1所示:           本文重在Java中异常机制的一些概念.写本文的目的在 ...

  8. Java NIO Pipe

    A Java NIO Pipe is a one-way data connection between two threads. A Pipe has a source channel and a ...

  9. [转载]设置Chrome忽略网站证书错误

    某些用户可能经常会遇到Chrome浏览器提示网站证书错误的情况,尤其是在Google升级证书检查力度之后,访问Google时已经不能在浏览器界面中忽略证书错误访问. 比如说公司的IT修改过证书就会遇到 ...

  10. System.Diagnostics.Debug和System.Diagnostics.Trace

    在 .net 类库中有一个 system.diagnostics 命名空间,该命名空间提供了一些与系统进程.事件日志.和性能计数器进行交互的类库.当中包括了两个对开发人员而言十分有用的类——debug ...