linux 下安装 postgresql-9.3.1.tar.gz

一、 环境

centos6.0 minimal

postgresql-9.3.1.tar.gz

二、准备工作

  • 1将虚拟机网卡使用NAT模式,方便上网
  • 2关闭防火墙,可以查看02.centos常用操作.md

三、先安装 make, gcc ,gcc-c++,readline-devel ,zlib-devel 。如果已安装,可以忽略

这些都是依赖。
[root@linhp local]# yum -y install gcc [root@linhp local]# yum -y install gcc-c++ [root@linhp local]# yum -y install readline-devel [root@linhp local]# yum -y install zlib-devel [root@linhp postgresql-9.3.1]# yum -y install make

四、开始安装

4.1 解压 tar -zvxf postgresql-9.3.1.tar.gz

我的postgresql-9.3.1.tar.gz 安装包放在 /usr/local 下

[root@linhp local]# pwd
/usr/local
[root@linhp local]# tar -zvxf postgresql-9.3.1.tar.gz
...解压过程
[root@linhp local]# cd postgresql-9.3.1
[root@linhp postgresql-9.3.1]#

4.2 创建linux用户及密码

我的密码设置为123456

[root@linhp postgresql-9.3.1]# adduser postgres
[root@linhp postgresql-9.3.1]# passwd postgres
Changing password for user postgres.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
[root@linhp postgresql-9.3.1]#

4.3 开始安装

[root@linhp postgresql-9.3.1]# pwd
/usr/local/postgresql-9.3.1
// 配置
[root@linhp postgresql-9.3.1]# ./configure --prefix=/usr/local/postgresql
// 编译
[root@linhp postgresql-9.3.1]# make
//安装
[root@linhp postgresql-9.3.1]# make install

4.4 配置环境变量

在环境变量 /etc/profile 最后加入

PATH=$PATH:/usr/local/postgresql/bin

[root@linhp postgresql]# cd /usr/local/postgresql
[root@linhp postgresql]# ls
bin include lib share
[root@linhp postgresql]# vi /etc/profile
在文件最后加入:PATH=$PATH:/usr/local/postgresql/bin 然后刷新环境变量,即时生效
[root@linhp postgresql]# source /etc/profile
输出环境变量,查看是否设置成功
[root@linhp postgresql]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/opt/java/jdk1.8.0_91/bin:/opt/java/jdk1.8.0_91/jre/bin:/root/bin:/opt/java/jdk1.8.0_91/bin:/opt/java/jdk1.8.0_91/jre/bin:/usr/local/postgresql/bin

4.5 初始化数据库

[root@linhp postgresql]# pwd
/usr/local/postgresql
[root@linhp postgresql]# mkdir data
[root@linhp postgresql]# ls
bin data include lib share
[root@linhp postgresql]# chown postgres:postgres /usr/local/postgresql/data/
[root@linhp postgresql]# su postgres
[postgres@linhp postgresql]$ /usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data/```

4.6 复制并修改配置文件(修改存放数据目录)

切换到root
复制安装目录下的linux文件到/etc/init.d/中,并将linux名称重命名为postgresql
[root@linhp postgresql-9.3.1]# cp /usr/local/postgresql-9.3.1/contrib/start-scripts/linux /etc/init.d/postgresql
编辑复制出来的文件,修改下图中的位置即可
[root@linhp postgresql-9.3.1]# vi /etc/init.d/postgresql

[root@linhp postgresql-9.3.1]# chmod +x /etc/init.d/postgresql

4.7 启动数据库,和设置开机自启

[root@linhp postgresql-9.3.1]# /etc/init.d/postgresql start
Starting PostgreSQL: ok
[root@linhp postgresql-9.3.1]# chkconfig postgresql on
[root@linhp postgresql-9.3.1]#

4.8 创建数据库操作的历史文件

创建文件,并授予postgres权限

[root@linhp postgresql-9.3.1]# touch /usr/local/postgresql/.pgsql_history
[root@linhp postgresql-9.3.1]# chown postgres:postgres /usr/local/postgresql/.pgsql_history
[root@linhp postgresql-9.3.1]#

4.9 测试数据库是否创建成功,并且连接数据库

使用 \q 即可退出数据库连接

[root@linhp postgresql-9.3.1]# su postgres
[postgres@linhp postgresql-9.3.1]$ createdb test
[postgres@linhp postgresql-9.3.1]$ psql test
psql (9.3.1)
Type "help" for help. test=# \q
[postgres@linhp postgresql-9.3.1]$

到此,数据库已经安装成功。

五、修改数据库外网访问

Linux 修改PostgreSQL外部访问白名单

先关闭防火墙,或者开放5432端口

主要修改两个配置文件

[root@linhp postgresql-9.3.1]# find / -name pg_hba.conf
[root@linhp postgresql-9.3.1]# find / -name postgresql.conf

5.1 先关闭数据库服务

关闭数据库服务
[postgres@linhp postgresql-9.3.1]$ su
Password:
[root@linhp postgresql-9.3.1]# /etc/init.d/postgresql stop
Stopping PostgreSQL: ok
[root@linhp postgresql-9.3.1]#

5.2 修改pg_hba.conf

将默认的

host all all 127.0.0.1/32 trust

修改为

host all all 192.168.1.1/32 trust #IP全匹配

host all all 192.168.1.1/24 trust #IP匹配前三段

host all all 0.0.0.0/0 trust #全部允许

5.3修改postgresql.conf

listen_addresses 默认是注释掉的,打开即可

修改默认的

listen_addresses = 'localhost'

listen_addresses = '*'

如果需要修改端口,可以修改 listen_addresses下一行

5.4 重启postgresql服务

/etc/init.d/postgresql start

5.5 测试本地连接 ( 这里我修改了端口为5444)

[postgres@linhp postgresql-9.3.1]$ psql -h 127.0.0.1 -d postgres -U postgres -p 5444psql
psql (9.3.1)
Type "help" for help. postgres=#

linux(centos6) 下安装 postgresql-9.3.1.tar.gz的更多相关文章

  1. Linux下安装解压版(tar.gz)MySQL5.7

            最近尝试在Linux中安装了解压版MySQL,期间查阅了许多博客.很多博客看得我很懵逼,因此记录下自己的安装过程,方便后续查阅.         环境说明:CentOs7.2 一.清理 ...

  2. 如何在Ubuntu下安装”.deb“、”.bin“、”.tar.gz“、”.tar.bz2“格式的软件包!

    今天在Ubuntu11.10中安装Google chrome浏览器是遇到了问题,下载好的“.deb”格式的安装文件google-chrome-stable.deb双击后或者右键快捷菜单选择 Synap ...

  3. liunx下安装mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz

    1.解压准备一个赶紧的环境,然后安装mysql. 2.cd到/usr/local/目录下,修改文件名为mysql 修改完目录名以后我们cd到mysql下,建立一个data目录命令:cd mysql/ ...

  4. centos6.5安装jdk(解压tar.gz)

    0.说明 下载jdk文件包jdk-7u79-linux-x64.tar.gz. 1.环境清理(系统自带的OpenJDK) 1.1 查看OpenJDK的安装包 $ rpm -qa |grep java ...

  5. Java入门——在Linux环境下安装JDK并配置环境变量

    Java入门——在Linux环境下安装JDK并配置环境变量 摘要:本文主要说明在Linux环境下JDK的安装,以及安装完成之后环境变量的配置. 使用已下载的压缩包进行安装 下载并解压 在Java的官网 ...

  6. Linux下安装PostgreSQL 转载linux社区

    Linux下安装PostgreSQL [日期:2016-12-25] 来源:Linux社区  作者:xiaojian [字体:大 中 小]   在Linux下安装PostgreSQL有二进制格式安装和 ...

  7. CentOS 6.9下安装PostgreSQL

    操作系统:CentOS6.9_x64 PostgreSQL官方网址: https://www.postgresql.org/ 安装数据库 使用如下命令: yum install postgresql- ...

  8. centos6下安装dedecms

    几经波折,终于安装成功!!! 一.centos6下安装WDCP 1.连接linux 在百度直接搜索下载xshell,通过ssh连接 2.安装wdcp 下载安装wget http://dl.wdlinu ...

  9. linux环境下安装sphinx中文支持分词搜索(coreseek+mmseg)

     linux环境下安装sphinx中文支持分词搜索(coreseek+mmseg) 2013-11-10 16:51:14 分类: 系统运维 为什么要写这篇文章? 答:通过常规的三大步(./confi ...

随机推荐

  1. 【Unity Shader】---Alpha Blending的意义

    Alpha Blending 即Alpha混合 Blending 就是处理透明度的,处理光栅化最后阶段,显示在屏幕上的颜色 1 Blend Off 关闭alpha混合 2 混合公式:Blend Src ...

  2. Java基础/利用fastjson序列化对象为JSON

    利用fastjson序列化对象为JSON 参考博客:http://blog.csdn.net/zeuskingzb/article/details/17468079 Step1:定义实体类 //用户类 ...

  3. Spring Boot系列(四) Spring Cloud 之 Config Client

    Config 是通过 PropertySource 提供. 这节的内容主要是探讨配置, 特别是 PropertySource 的加载机制. Spring Cloud 技术体系 分布式配置 服务注册/发 ...

  4. SpringBoot 创建 console程序

    1.在pom中添加依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactId> ...

  5. SpringBoot 使用maven创建springboot项目

    有两种方式可以创建  1是使用spring-boot-starter-parent ,2是使用spring-boot-dependencies (即父项目dependencyManagement) ( ...

  6. [Python3 填坑] 012 字典的遍历在 Python2 与 Python3 中区别

    目录 1. print( 坑的信息 ) 2. 开始填坑 2.1 Python2 中字典的遍历 2.2 Python3 中字典的遍历 2.3 结论 1. print( 坑的信息 ) 挖坑时间:2019/ ...

  7. Billboard 题解 hdu2795

    Billboard 题解 hdu2795 题意 有个广告牌,上面需要依次贴广告,广告的高度均为1,但是宽度不同,每次都想贴在最靠左上的位置,按照顺序进行广告的话,输出每个广告位于广告牌的高度. 解题思 ...

  8. Appium+Python之生成html测试报告

    思考:测试用例执行后,如何生成一个直观漂亮的测试报告呢? 分析:1.unittest单元测试框架本身带有一个textTestRunner类,可以生成txt文本格式的测试报告,但是页面不够直观 2.我们 ...

  9. P3724 [AH2017/HNOI2017]大佬

    传送门 发现保持自信和做其他事情互不干扰,可以直接做一次 $dp$ 求出最多能空出几天来怼大佬 然后就变成给你若干天,是否能怼死大佬,考虑求出所有的 天数和输出的嘲讽值集合,因为天数不多,嘲讽值增长很 ...

  10. 汇编移位: SHL、SHR、SAL、SAR、ROL、ROR、RCL、RCR

    SHL.SHR.SAL.SAR: 移位指令 ;SHL(Shift Left):      逻辑左移 ;SHR(Shift Right):      逻辑右移 ;SAL(Shift Arithmetic ...