暂无图片
暂无图片
暂无图片
暂无图片
暂无图片
1.pgsql二进制安装.txt
107
2页
0次
2023-05-06
5墨值下载
1.下载二进制安装包
https://www.postgresql.org/ftp/source
2.上传解压安装包
[root@postgresql data]# tar -zxvf postgresql-15.2.tar.gz
3.创建用户
[root@postgresql ~]# useradd postgres
[root@postgresql ~]# passwd postgres
4.创建目录
[root@postgresql ~]# mkdir -p /app/install
[root@postgresql ~]# mkdir -p /data/pgsql
5.安装依赖
[root@postgresql yum.repos.d]# yum -y groupinstall "Development Tools" "Legacy
UNIX Compatibility"
[root@postgresql yum.repos.d]# yum -y install bison flex readline* zlib-devel
gcc* make
6.编译
[root@postgresql postgresql-15.2]#cd /app/install/postgresql-15.2
[root@postgresql postgresql-15.2]#./configure --prefix=/app/postgresql
[root@postgresql postgresql-15.2]#make && make install
7.初始化
[root@postgresql ~]# chown -R postgres:postgres /app/install
[root@postgresql ~]# chown -R postgres:postgres /data/pgsql
[root@postgresql ~]# chown -R postgres:postgres /app/postgres
[root@postgresql ~]# su - postgres
[root@postgresql ~]# cd /app/postgresql/
[postgres@postgresql postgresql]$bin/initdb -D /data/pgsql -E UTF8 --locale=C -U
postgres
8.修改配置文件
[root@postgresql ~]# su - postgres
[postgres@postgresql ~]$cd /app/postgresql
[postgres@postgresql postgresql]$ mkdir conf && cd conf
[postgres@postgresql conf]$ ln -s /data/pgsql/postgresql.conf .
[postgres@postgresql conf]$ ln -s /data/pgsql/pg_hba.conf .
修改 pg_hba.conf,允许某些 IP 通过客户端工具使用某个用户连接 pg 的某个库,配置如下:
# TYPE DATABASE USER ADDRESS METHOD
# IPv4 local connections:
#host all all 127.0.0.1/32 trust
host all all 0.0.0.0/0 trust
修改 postgresql.conf,编辑 IP、端口、socket、数据存放目录等,如下(仅列出修改的内容):
data_directory = '/data/pgsql'
hba_file = '/app/postgresql/conf/pg_hba.conf'
listen_addresses = '192.168.100.201'
port = 18086
max_connections = 10000
unix_socket_directories = '/app/postgresql/'
unix_socket_group = 'postgres'
9.尝试启动
[root@postgresql ~]# su - postgres
[postgres@postgresql ~]$cd /app/postgresql
# 启动
[postgres@postgresql postgresql]$ bin/pg_ctl -D /data/pgsql/ start
# 停止
[postgres@postgresql postgresql]$ bin/pg_ctl -D /data/pgsql/ stop
# 状态查看
[postgres@postgresql postgresql]$ bin/pg_ctl -D /data/pgsql/ status
10.测试连接
# 登录 PG 数据库
[postgres@postgresql bin]$ ./psql -h 192.168.100.201 -p 18086 -U postgres -d
postgres -W
Password:
psql (15.2)
Type "help" for help.
postgres=# help
You are using psql, the command-line interface to PostgreSQL.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help with psql commands
\g or terminate with semicolon to execute query
\q to quit
11.启停脚本
# 创建一个日志目录
[root@postgresql ~]# su - postgres
[postgres@postgresql ~]$cd /app/postgresql
[postgres@postgresql postgresql]$ mkdir logs && touch logs/pg.log
# 启动脚本
[postgres@postgresql postgresql]$ cat start.sh
#!/bin/bash
PG_HOME=/app/postgresql
$PG_HOME/bin/pg_ctl -D /data/pgsql/ start > $PG_HOME/logs/pg.log &
# 停止脚本
[postgres@postgresql postgresql]$ cat stop.sh
#!/bin/bash
PG_HOME=/app/postgresql
$PG_HOME/bin/pg_ctl -D /data/pgsql/ stop > $PG_HOME/logs/pg.log &
[postgres@postgresql postgresql]$
of 2
5墨值下载
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文档的来源(墨天轮),文档链接,文档作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

关注
最新上传
暂无内容,敬请期待...
下载排行榜
Top250 周榜 月榜