linux(centos6) 下安装 postgresql-9.3.1.tar.gz
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的更多相关文章
- Linux下安装解压版(tar.gz)MySQL5.7
最近尝试在Linux中安装了解压版MySQL,期间查阅了许多博客.很多博客看得我很懵逼,因此记录下自己的安装过程,方便后续查阅. 环境说明:CentOs7.2 一.清理 ...
- 如何在Ubuntu下安装”.deb“、”.bin“、”.tar.gz“、”.tar.bz2“格式的软件包!
今天在Ubuntu11.10中安装Google chrome浏览器是遇到了问题,下载好的“.deb”格式的安装文件google-chrome-stable.deb双击后或者右键快捷菜单选择 Synap ...
- liunx下安装mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz
1.解压准备一个赶紧的环境,然后安装mysql. 2.cd到/usr/local/目录下,修改文件名为mysql 修改完目录名以后我们cd到mysql下,建立一个data目录命令:cd mysql/ ...
- centos6.5安装jdk(解压tar.gz)
0.说明 下载jdk文件包jdk-7u79-linux-x64.tar.gz. 1.环境清理(系统自带的OpenJDK) 1.1 查看OpenJDK的安装包 $ rpm -qa |grep java ...
- Java入门——在Linux环境下安装JDK并配置环境变量
Java入门——在Linux环境下安装JDK并配置环境变量 摘要:本文主要说明在Linux环境下JDK的安装,以及安装完成之后环境变量的配置. 使用已下载的压缩包进行安装 下载并解压 在Java的官网 ...
- Linux下安装PostgreSQL 转载linux社区
Linux下安装PostgreSQL [日期:2016-12-25] 来源:Linux社区 作者:xiaojian [字体:大 中 小] 在Linux下安装PostgreSQL有二进制格式安装和 ...
- CentOS 6.9下安装PostgreSQL
操作系统:CentOS6.9_x64 PostgreSQL官方网址: https://www.postgresql.org/ 安装数据库 使用如下命令: yum install postgresql- ...
- centos6下安装dedecms
几经波折,终于安装成功!!! 一.centos6下安装WDCP 1.连接linux 在百度直接搜索下载xshell,通过ssh连接 2.安装wdcp 下载安装wget http://dl.wdlinu ...
- linux环境下安装sphinx中文支持分词搜索(coreseek+mmseg)
linux环境下安装sphinx中文支持分词搜索(coreseek+mmseg) 2013-11-10 16:51:14 分类: 系统运维 为什么要写这篇文章? 答:通过常规的三大步(./confi ...
随机推荐
- 20191105 《Spring5高级编程》笔记-第5章
第5章 Spring AOP 面向切面编程(AOP)是面向对象编程(OOP)的补充.AOP通常被称为实施横切关注点的工具.术语横切关注点是指应用程序中无法从应用程序的其余部分分解并且可能导致代码重复和 ...
- Web高级 JavaScript中的算法
算法 排序算法 稳定排序 待排序序列中相等元素在排序完成后,原有先后顺序不变. 非稳定排序 有序度 待排序序列中有序关系的元素对个数. 逆序度 1. 插入排序 遍历有序数组,对比待插入的元素大小,找到 ...
- js之状态模式
level01:电灯程序 <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...
- JavaSE编码试题强化练习5
1.不使用函数实现字符串的翻转 /** * 1.不使用函数实现字符串的翻转 */ public class TestStringReverse { public static void main(St ...
- SpringBoot(五) -- SpringBootWeb登录示例
一.解决index.html访问 在SpringBoot中默认访问的首页是静态资源文件夹下的index.html,无法被Thymeleaf模板引擎解析,因此我们可以定义一个controller将默认请 ...
- Web API 入门三(参数绑定)
学到现在,感觉到微软的.NET各种框架和模型基础大致都差不多,所以,这部分内容大致和MVC部分差不多.在学习参事绑定之前,我们肯定要知道Controller(即控制器)是啥干啥的. 其实,Contro ...
- Codeforces 475D 题解(二分查找+ST表)
题面: 传送门:http://codeforces.com/problemset/problem/475/D Given a sequence of integers a1, -, an and q ...
- 问题 G: 圆桌上的晚餐
问题 G: 圆桌上的晚餐 时间限制: 1 Sec 内存限制: 128 MB提交: 1583 解决: 656[提交] [状态] [命题人:jsu_admin] 题目描述 大家一定在圆 ...
- 模块管理常规功能自己定义系统的设计与实现(15--进一步完好"省份"模块)
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jfok/article/details/24737483 "省份"模块的进一步完 ...
- CSS-子盒子撑开父盒子,让父盒子的高随内容自适应
方法一: height:auto!important; height:200px; min-height:200px; ie6并不支持min-height.ie7,opera,火狐没有问题. 方法二: ...