postgreSQL16.6源码安装

1.获取源码

从PostgreSQL: File Browser获取tar.bz2或者tar.gz源码

2.解压

tar xf postgresql-version.tar.bz2

root@hwz-VMware-Virtual-Platform:/usr/local# tar xf postgresql-16.6.tar.bz2
root@hwz-VMware-Virtual-Platform:/usr/local# ll
总计 24324
drwxr-xr-x 12 root root     4096  2月  6 11:35 ./
drwxr-xr-x 12 root root     4096 10月  9 21:16 ../
drwxr-xr-x  2 root root     4096 10月  9 21:16 bin/
drwxr-xr-x  2 root root     4096 10月  9 21:16 etc/
drwxr-xr-x  2 root root     4096 10月  9 21:16 games/
drwxr-xr-x  2 root root     4096 10月  9 21:16 include/
drwxr-xr-x  3 root root     4096 10月  9 21:16 lib/
drwxr-xr-x  2 root root     4096 10月  9 21:16 libexec/
lrwxrwxrwx  1 root root        9 10月  9 21:16 man -> share/man/
drwxrwxrwx  6 1107 1107     4096 11月 19 04:48 postgresql-16.6/
-rw-r--r--  1 root root 24856956  2月  6 11:34 postgresql-16.6.tar.bz2
drwxr-xr-x  2 root root     4096 10月  9 21:16 sbin/
drwxr-xr-x  7 root root     4096 10月  9 21:19 share/
drwxr-xr-x  2 root root     4096 10月  9 21:16 src/

3.编译构建程序

root@hwz-VMware-Virtual-Platform:/usr/local# cd postgresql-16.6/
root@hwz-VMware-Virtual-Platform:/usr/local/postgresql-16.6# ./configure --prefix=/usr/local/pgsql16

可能会缺少库,按需安装即可 

make&make install

编译后生成目录

root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# ll
总计 24
drwxr-xr-x  6 root root 4096  2月  7 09:04 ./
drwxr-xr-x 13 root root 4096  2月  7 09:04 ../
drwxr-xr-x  2 root root 4096  2月  7 09:04 bin/
drwxr-xr-x  6 root root 4096  2月  7 09:04 include/
drwxr-xr-x  4 root root 4096  2月  7 09:04 lib/
drwxr-xr-x  6 root root 4096  2月  7 09:04 share/

4.初始化数据库

 先增加一个postgresql用户

useradd postgres
passwd postgres

创建数据目录并让它属于postgres用户

root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# useradd -m postgres
root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# chown postgres . /pgdata/16/data

官方useradd postgres 不加-m参数 Ubuntu可能不会创建用户家目录

root@hwz-VMware-Virtual-Platform:/usr/local/pgsql16# su - postgres
postgres@hwz-VMware-Virtual-Platform:~$ ll

这种前面只有$是因为该用户shell为/bin/sh,需要改为/bin/bash 

 4.1 设置环境变量

postgres@hwz-VMware-Virtual-Platform:~$ vim .bash_profile
export PGDATA=/pgdata/16/data
export LANG=en_US.utf8
export PGHOME=/usr/local/pgsql16
export
LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export PATH=$PGHOME/bin:$PATH:.
export MANPATH=$PGHOME/share/man:$MANPATH
export PGUSER=postgres

测试是否成功

postgres@hwz-VMware-Virtual-Platform:~$ psql --version
psql (PostgreSQL) 16.

 4.2 初始化

postgres@hwz-VMware-Virtual-Platform:~$ initdb -D /pgdata/16/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.initdb: error: invalid locale settings; check LANG and LC_* environment variables

如果出现这个错误是因为 当前用户环境使用的编码和系统编码不一致

postgres@hwz-VMware-Virtual-Platform:~$ locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.utf8
LANGUAGE=
LC_CTYPE="en_US.utf8"
LC_NUMERIC="en_US.utf8"
LC_TIME="en_US.utf8"
LC_COLLATE="en_US.utf8"
LC_MONETARY="en_US.utf8"
LC_MESSAGES="en_US.utf8"
LC_PAPER="en_US.utf8"
LC_NAME="en_US.utf8"
LC_ADDRESS="en_US.utf8"
LC_TELEPHONE="en_US.utf8"
LC_MEASUREMENT="en_US.utf8"
LC_IDENTIFICATION="en_US.utf8"
LC_ALL=

 查看系统编码

postgres@hwz-VMware-Virtual-Platform:~$ vim /etc/locale.conf

LANG=zh_CN.UTF-8

系统用的CN的UTF-8,用户环境是US的UTF-8

现在修改用户环境的编码为CN UTF-8

postgres@hwz-VMware-Virtual-Platform:~$ vim .bashrc

 后面添加

export LC_ALL="zh_CN.UTF-8"

postgres@hwz-VMware-Virtual-Platform:~$ source .bashrc 
postgres@hwz-VMware-Virtual-Platform:~$ locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_CTYPE="zh_CN.UTF-8"
LC_NUMERIC="zh_CN.UTF-8"
LC_TIME="zh_CN.UTF-8"
LC_COLLATE="zh_CN.UTF-8"
LC_MONETARY="zh_CN.UTF-8"
LC_MESSAGES="zh_CN.UTF-8"
LC_PAPER="zh_CN.UTF-8"
LC_NAME="zh_CN.UTF-8"
LC_ADDRESS="zh_CN.UTF-8"
LC_TELEPHONE="zh_CN.UTF-8"
LC_MEASUREMENT="zh_CN.UTF-8"
LC_IDENTIFICATION="zh_CN.UTF-8"
LC_ALL=zh_CN.UTF-8

 重新初始化成功

postgres@hwz-VMware-Virtual-Platform:~$ initdb -D /pgdata/16/data/
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.The database cluster will be initialized with locale "zh_CN.UTF-8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF-8"
The default text search configuration will be set to "simple".Data page checksums are disabled.fixing permissions on existing directory /pgdata/16/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Asia/Shanghai
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... okinitdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.Success. You can now start the database server using:pg_ctl -D /pgdata/16/data/ -l logfile start

 5.启动数据库

postgres@hwz-VMware-Virtual-Platform:~$ pg_ctl -D/pgdata/16/data/ -l logfile start
waiting for server to start.... done
server started

 查看运行状态

postgres@hwz-VMware-Virtual-Platform:~$ pg_ctl status
pg_ctl: server is running (PID: 94176)
/usr/local/pgsql16/bin/postgres "-D" "/pgdata/16/data"

 6.测试

postgres@hwz-VMware-Virtual-Platform:~$ createdb test
postgres@hwz-VMware-Virtual-Platform:~$ psql test
psql (16.6)
Type "help" for help.test=# \lList of databasesName    |  Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |   Access privileges   
-----------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------hwz2      | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | postgres  | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | template0 | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +|          |          |                 |             |             |            |           | postgres=CTc/postgrestemplate1 | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +|          |          |                 |             |             |            |           | postgres=CTc/postgrestest      | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | 
(5 rows)test=# create table user(id int, name varchar(255));
ERROR:  syntax error at or near "user"
LINE 1: create table user(id int, name varchar(255));^
test=# create table user1(id int, name varchar(255));
CREATE TABLE
test=# insert into user1 values(1,'hwz'),(2,'www');
INSERT 0 2
test=# select * from user1
test-# ;id | name 
----+------1 | hwz2 | www
(2 rows)test=# \q
postgres@hwz-VMware-Virtual-Platform:~$

7.关闭数据库

postgres@hwz-VMware-Virtual-Platform:~$ pg_ctl -D /pgdata/16/data/ stop
waiting for server to shut down.... done
server stopped

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/15345.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

音频进阶学习十一——离散傅里叶级数DFS

文章目录 前言一、傅里叶级数1.定义2.周期信号序列3.表达式DFSIDFS参数含义 4.DFS公式解析1)右边解析 T T T、 f f f、 ω \omega ω的关系求和公式N的释义求和公式K的释义 e j ( − 2 π k n N ) e^{j(\frac{-2\pi kn}{N})} ej(N−2πkn​)的释义 ∑ n 0 N − 1 e…

【kafka系列】Topic 与 Partition

Kafka 的 Topic(主题) 和 Partition(分区) 是数据组织的核心概念,它们的映射关系及在 Broker 上的分布直接影响 Kafka 的性能、扩展性和容错能力。以下是详细解析: 一、Topic 与 Partition 的映射关系 Top…

卷积神经网络CNN如何处理语音信号

卷积神经网络(CNN)在处理语音数据时通常不直接处理原始的一维波形信号,而是处理经过预处理的二维语音特征图。以下是CNN处理语音数据时的常见数据类型和步骤: 1. 语音信号预处理 语音信号通常是一维的时间序列(波形信…

【MQ】Spring3 中 RabbitMQ 的使用与常见场景

一、初识 MQ 传统的单体架构,分布式架构的同步调用里,无论是方法调用,还是 OpenFeign 难免会有以下问题: 扩展性差(高耦合,需要依赖对应的服务,同样的事件,不断有新需求&#xff0…

GB/T 43698-2024 《网络安全技术 软件供应链安全要求》标准解读

一、43698-2024标准图解 https://mmbiz.qpic.cn/sz_mmbiz_png/rwcfRwCticvgeBPR8TWIPywUP8nGp4IMFwwrxAHMZ9Enfp3wibNxnfichT5zs7rh2FxTZWMxz0je9TZSqQ0lNZ7lQ/640?wx_fmtpng&fromappmsg 标准在线预览: 国家标准|GB/T 43698-2024 相关标准: &a…

Linux系统-centos防火墙firewalld详解

Linux系统-centos7.6 防火墙firewalld详解 1 firewalld了解 CentOS 7.6默认的防火墙管理工具是firewalld,它取代了之前的iptables防火墙。firewalld属于典型的包过滤防火墙或称之为网络层防火墙,与iptables一样,都是用来管理防火墙的工具&a…

Gitlab中如何进行仓库迁移

需求:之前有一个自己维护的新仓库A,现在需要将这个仓库提交并覆盖另一个旧的仓库B,需要保留A中所有的commit信息。 1.方法一:将原有仓库A导出后再导入到新的仓库B中 适用场景:新的仓库B是一个待建仓库,相当…

微信点餐系统小程序ssm+论文源码调试讲解

第4章 系统设计 一个成功设计的系统在内容上必定是丰富的,在系统外观或系统功能上必定是对用户友好的。所以为了提升系统的价值,吸引更多的访问者访问系统,以及让来访用户可以花费更多时间停留在系统上,则表明该系统设计得比较专…

01单片机上电后没有正常运行怎么办

单片机上电后没有运转, 首先要检查什么? 1、单片机供电是否正常? &电路焊接检查 如果连最基本的供电都没有,其它都是空谈啊!检查电路断路了没有?短路了没有?电源合适吗?有没有虚焊? 拿起万用表之前,预想一下测量哪里?供电电压应该是多少?对PCB上电压测量点要…

【Java基础】为什么不支持多重继承?方法重载和方法重写之间区别、Exception 和 Error 区别?

Hi~!这里是奋斗的明志,很荣幸您能阅读我的文章,诚请评论指点,欢迎欢迎 ~~ 🌱🌱个人主页:奋斗的明志 🌱🌱所属专栏:Java基础面经 📚本系列文章为个…

c++ haru生成pdf输出饼图

#define PI 3.14159265358979323846 // 绘制饼图的函数 void draw_pie_chart(HPDF_Doc pdf, HPDF_Page page, float *data, int data_count, float x, float y, float radius) { float total 0; int i; // 计算数据总和 for (i 0; i < data_count; i) { tot…

Linux 创建进程 fork()、vfork() 与进程管理

Linux 创建进程 fork、vfork、进程管理 一、Linux的0号、1号、2号进程二、Linux的进程标识三、fork() 函数1、基本概念2、函数特点3、用法以及应用场景&#xff08;1&#xff09;父子进程执行不同的代码&#xff08;2&#xff09;进程执行另一个程序 4、工作原理 四、vfork() 函…

【漫话机器学习系列】082.岭回归(或脊回归)中的α值(alpha in ridge regression)

岭回归&#xff08;Ridge Regression&#xff09;中的 α 值 岭回归&#xff08;Ridge Regression&#xff09;是一种 带有 L2​ 正则化 的线性回归方法&#xff0c;用于处理多重共线性&#xff08;Multicollinearity&#xff09;问题&#xff0c;提高模型的泛化能力。其中&am…

电脑重启后vscode快捷方式失效,找不到code.exe

今天打开电脑发现vscode的快捷方式失效了&#xff0c;提示code.exe被删除或移动。 解决方法 查看vscode安装目录&#xff0c;发现多了一个_文件夹&#xff0c;包括code.exe在内的其他文件都被移动到了这个文件夹下。 将里面内容都移动到microsoft vs code文件夹下&#xff0c…

[权限提升] Linux 提权 维持 — 系统错误配置提权 - Sudo 滥用提权

关注这个专栏的其他相关笔记&#xff1a;[内网安全] 内网渗透 - 学习手册-CSDN博客 0x01&#xff1a;Sudo 滥用提权原理 Sudo 是一个 Linux 系统管理命令&#xff0c;它允许系统管理员授予普通用户以指定身份执行指定命令的权限。该命令不仅减少了 Root 用户的登录时间和管理时…

激活函数篇 04 —— softmax函数

将模型的输出转换为概率分布&#xff0c;使得模型能够输出每个类别的概率值。 Softmax ( a i ) e a i ∑ j 1 n e a j \text{Softmax}(a_i)\frac{e^{a_i}}{\sum_{j1}^n e^{a_j}} Softmax(ai​)∑j1n​eaj​eai​​ 其中&#xff0c; a i a_i ai​ 是输入向量中的第 i i i 个…

【韩顺平linux】部分上课笔记整理

整理一下一些韩顺平老师上课时候的笔记 课程&#xff1a;【小白入门 通俗易懂】韩顺平 一周学会Linux linux环境&#xff1a;使用阿里云服务器 笔记参考 &#xff1a; [学习笔记]2021韩顺平一周学会Linux 一、自定义函数 基本语法 应用实例&#xff1a; 计算两个参数的和…

redis底层数据结构——简单动态字符串

文章目录 概述什么时候用C里面的字符串什么时候使用SDS使用场景 SDS定义SDS与C语言的字符串差异常数时间复杂度获取字符串长度杜绝缓冲区溢出减少修改字符串时带来的内存重分配次数1.空间预分配2.情性空间释放 二进制安全兼容部分C字符串函数总结 开始讲述动态字符串前我们先问…

使用 POI-TL 和 JFreeChart 动态生成 Word 报告

文章目录 前言一、需求背景二、方案分析三、 POI-TL JFreeChart 实现3.1 Maven 依赖3.3 word模板设置3.2 实现代码 踩坑 前言 在开发过程中&#xff0c;我们经常需要生成包含动态数据和图表的 Word 报告。本文将介绍如何结合 POI-TL 和 JFreeChart&#xff0c;实现动态生成 W…

VLLM历次会议(2024.1)

Azure官宣支持VLLM VLLM支持AMD芯片 支持Mixtral MoE&#xff0c;支持DeepSeek MoE 性能优化 &#xff08;以下4招&#xff0c;总共将吞吐量提升50%&#xff0c;延迟降低40%&#xff09; 1. PageAttention V2 &#xff08;同一个Q&#xff0c;和不同的KV的计算&#xff0c…