当前位置: 首页 > news >正文

在ubuntu 24安装 postgresql 17 (源码安装)

1 操作系统(ubuntu24 最小化安装)

root@u24-pg-110:~# cat /etc/issue
Ubuntu 24.04.2 LTS \n \l

2 安装依赖

apt install systemtap-sdt-dev -y
apt install build-essential -y
apt install libssl-dev -y
apt install libicu-dev icu-devtools pkg-config -y
apt install liblz4-dev -y
apt install libzstd-dev -y
apt install bison -y
apt install flex -y
apt install readline -y
apt install libreadline-dev -y
apt install zlib1g-dev -y
apt install krb5-user libkrb5-dev libgssapi-krb5-2 -y
apt install libpam0g-dev -y
apt install libxml2-dev -y
apt install libxslt1-dev -y
apt install libldap2-dev libsasl2-dev libssl-dev -y
apt install libselinux1-dev -y
apt install uuid-dev -y
apt install gettext -y 
apt install tcl-dev tcl8.6-dev -y
apt install perl libperl-dev -y 
apt install python3-dev -y

3 postgresql编译

./configure --prefix=/usr/local/postgresql-17 \
--with-icu \
--with-perl  \
--with-python  \
--with-tcl   \
--with-tclconfig=/usr/lib/tcl8.6 \
--with-openssl   \
--with-includes=/usr/include/openssl \
--with-readline \
--with-pam   \
--with-gssapi  \
--with-libraries=/usr/lib64   \
--enable-nls  \
--enable-dtrace   \
--with-uuid=e2fs  \
--with-libxml   \
--with-libxslt  \
--with-ldap   \
--with-selinux   \
--with-system-tzdata=/usr/share/zoneinfo   \
--with-lz4  \
--with-zstd

make -j 2

make install

4 创建postgres 用户

adduser postgres

5 初始化数据库

mkdir /postgresql/data -p

chown -R postgres:postgres /postgresql/data/

su - postgres

#初始化数据库

/usr/local/postgresql-17/bin/initdb -D /postgresql/data/

#启动postgresql 

/usr/local/postgresql-17/bin/pg_ctl -D /postgresql/data/ -l logfile start

#测试

postgres@u24-pg-110:~$ /usr/local/postgresql-17/bin/psql 
psql (17.5)
Type "help" for help.

postgres=# 

6 配置systemd和环境变量

vi ~/.bashrc

export PATH=/usr/local/postgresql-17/bin:$PATH

source ~/.bashrc

root@u24-pg-110:~# vi /lib/systemd/system/postgresql.service
[Unit]
Description=PostgreSQl database server
After=network.target
[Service]
Type=forking
User=postgres
Group=postgres
Environment=PGDATA=/postgresql/data
ExecStart=/usr/local/postgresql-17/bin/pg_ctl start -D ${PGDATA} 
ExecStop=/usr/local/postgresql-17/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/local/postgresql-17/bin/pg_ctl reload -D ${PGDATA} -s
TimeoutSec=300
KillMode=mixed
[Install]
WantedBy=multi-user.target

#启动和设置开机启动

systemctl start postgresql

systemctl enable postgresql

相关文章:

  • 【Python数据库全栈指南】从SQL到ORM深度实践
  • 深入浅出IIC协议 - 从总线原理到FPGA实战开发 -- 第五篇:多主仲裁与错误恢复
  • 【编程语言】【Python】一篇文章搭建python知识体系
  • 数据保护与通讯安全
  • 基于 STC89C52 的养殖场智能温控系统设计与实现
  • 基于S7-1200 PLC与MM440变频器的速冻库制冷控制系统设计与实现
  • 算法打卡第五天
  • CMake指令:option()
  • vue-table-print 一个强大的Vue 3表格打印工具,支持ElementPlus、Ant Design Vue等主流UI组件库。
  • Windows逆向工程提升之IMAGE_IMPORT_DESCRIPTOR
  • 【Django DRF】一篇文章总结Django DRF框架
  • LabVIEW与SQLServer2019换计算机重新安装数据库
  • LET 2025盛大开幕!数智工厂×智慧物流×机器人,一展get创新科技
  • ConceptAttention:Diffusion Transformers learn highly interpretable features
  • 【LaTex】基础语法入门
  • Maven打包SpringBoot项目,因包含SpringBootTest单元测试和Java预览版特性导致打包失败
  • 第35节:PyTorch与TensorFlow框架对比分析
  • 40 岁 Windows 开启 AI 转型:从系统到生态的智能重构
  • Golang基于 Swagger + JWT + RBAC 的认证授权中间件设计
  • Go语言爬虫系列教程(二) HTTP请求与响应处理详解
  • 网站可信/旅游推广赚佣金哪个平台好
  • 深圳网站制作建设/关键字搜索引擎
  • wordpress 4.9.5 中文/广州seo培训
  • wordpress kalium/广告投放优化师
  • 台州卓远做网站好不好/西安seo外包行者seo
  • 知名草根博客 卢松松网站被攻击/百度云网盘入口