CentOS7安装PostgresSQL和PGVector

一、PostgresSQL下载

官方网站:https://www.postgresql.org/

打开PostgreSQL官网,点击下载按钮:

可以根据系统选择对应的版本下载,因为我们是使用源码安装,所以这里选择下载源码:

我使用的是 17.7

二、编译安装PostgresSQL

1.创建用户

出于安全考虑,一般情况下PostgresSQL数据库不允许运行在root用户下,所以我们先来创建一个普通用户postgres:

bash 复制代码
#创建应用目录
mkdir app
#创建用户组
groupadd -g 1101 postgres
#创建用户并指定用户目录
useradd -u 1101 -g postgres -d /app/postgres -c "postgres." -m -s /bin/bash postgres

2.安装依赖包

bash 复制代码
useradd -u 1101 -g postgres -d /app/postgres -c "postgres." -m -s /bin/bash postgres

3.上传解压PostgresSQL

上传上面下载的安装包到 app目录

bash 复制代码
tar -zxvf postgresql-17.7.tar.gz

4.配置编译项目

bash 复制代码
cd postgresql-17.7
./configure --prefix=/app/postgres/pgsql

5.编译安装

bash 复制代码
make
sudo make install

6.设置用户目录权限

bash 复制代码
chown -R postgres:postgres /app/postgres
chmod -R 755 /app/postgres

7.设置环境变量

bash 复制代码
sed -i '$a PGHOME=/app/postgres/pgsql' /etc/profile
sed -i '$a export PATH=$PATH:$PGHOME/bin' /etc/profile
source /etc/profile

三、修改配置文件

1.切换到postgres用户

bash 复制代码
su - postgres

2.创建数据与日志目录

bash 复制代码
mkdir -p /app/postgres/pgsql/data
mkdir -p /app/postgres/pgsql/log

3.初始化数据目录

bash 复制代码
initdb /app/postgres/pgsql/data

4.修改postgresql.conf文件

bash 复制代码
vi /app/postgres/pgsql/data/postgresql.conf

找到以下行取消注释,并修改参数值:

bash 复制代码
listen_addresses = '*'     #允许远程连接
port = 5432                #默认端口
max_connections = 1000     #最大连接数
logging_collector = on     #启用日志
log_directory = '/app/postgres/pgsql/log'    #调整日志目录


5.修改pg_hba.conf文件

bash 复制代码
vi /app/postgres/pgsql/data/pg_hba.conf

添加以下行允许所有ip访问:

bash 复制代码
host    all             all             0.0.0.0/0            md5
host    all             all             ::/0                 md5

四、启动数据库

1.启动数据库

bash 复制代码
pg_ctl start -D /app/postgres/pgsql/data -l /app/postgres/pgsql/log/start.log

2.修改数据库密码

使用psql命令进入pg命令行环境,输入\password修改密码:

这里PostgresSQL数据库就安装完成了。

PGVector安装

下载源码文件: https://github.com/pgvector/pgvector/tags

我这安装的是 0.81版本

上传解压:

bash 复制代码
cd /tmp
cd pgvector
#没有对应目录就新建 也可自定义 
# 上传文件到 pgvector 解压
tar -zxvf
# make
make
make install # may need sudo

以上 就安装完成

相关推荐
脑子进水养啥鱼?21 小时前
PostgreSQL .history 文件
数据库·postgresql
乌托邦的逃亡者21 小时前
CentOS/Openeuler主机中,为一个网卡设置多个IP地址
linux·运维·网络·tcp/ip·centos
杨云龙UP1 天前
Oracle数据库启动失败:ORA-29701、ORA-01565、ORA-17503故障处理记录_20260429
linux·运维·数据库·oracle·centos
日取其半万世不竭1 天前
PostgreSQL 云服务器安装配置指南:从零开始搭建生产数据库
服务器·数据库·postgresql
IT WorryFree1 天前
FGT-KVM 完整部署极简教程(CentOS 7 + KVM 环境)
linux·运维·centos
审判长烧鸡1 天前
GO时区【4】PostgreSQL时区
postgresql·go
审判长烧鸡1 天前
GO时区【3】字段与连接设置
postgresql·go
中国lanwp1 天前
CentOS 7 搭建 NFS Server 服务端 + 客户端 完整一键配置
linux·运维·centos
qq_283720051 天前
Python3 模块精讲:psycopg2(第三方)- 连接 PostgreSQL
数据库·postgresql
idolao1 天前
CentOS 7 安装 xampp-linux-1.8.1.tar.gz 详细步骤(解压、启动、验证)
linux·运维·centos