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

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

相关文章:

postgreSQL16.6源码安装

1.获取源码 从PostgreSQL: File Browser获取tar.bz2或者tar.gz源码 2.解压 tar xf postgresql-version.tar.bz2 roothwz-VMware-Virtual-Platform:/usr/local# tar xf postgresql-16.6.tar.bz2 roothwz-VMware-Virtual-Platform:/usr/local# ll 总计 24324 drwxr-xr-x 12 ro…...

寒假2.5

题解 web:[网鼎杯 2020 朱雀组]phpweb 打开网址,一直在刷新,并有一段警告 翻译一下 查看源码 每隔五秒钟将会提交一次form1,index.php用post方式提交了两个参数func和p,func的值为date,p的值为Y-m-d h:i:s a 执行fu…...

定期删除一周前的数据,日志表的表空间会增长吗?

即使定期删除一周前的数据,日志表的表空间仍可能持续增长。原因如下: 删除操作不释放空间:DELETE 操作只会标记数据为删除状态,并不会立即释放空间。这些空间可以被后续的 INSERT 操作重用,但不会自动缩减表的总大小。…...

yum 安装mysql

sudo yum install mysql-server sudo systemctl start mysqld sudo systemctl enable mysqld 获取临时 root 密码并登录 MySQL 安装完成后,MySQL 会生成一个临时的 root 密码。你可以通过查看日志文件来找到这个密码: sudo grep ‘temporary password’…...

Servlet笔记(下)

HttpServletRequest对象相关API 获取请求行信息相关(方式,请求的url,协议及版本) | API | 功能解释 | | ----------------------------- | ------------------------------ | | StringBuffer getRequestURL(); | 获取客户端…...

Windows 中学习Docker环境准备3、在Ubuntu中安装Docker

Windows 中学习Docker环境准备1、Win11安装Docker Desktop Windows 中学习Docker环境准备2、Docker Desktop中安装ubuntu Windows 中学习Docker环境准备3、在Ubuntu中安装Docker 需要更多Docker学习视频和资料,请文末联系 步骤 1:更新系统并安装依赖…...

【centOS】搭建公司内网git环境-GitLab 社区版(GitLab CE)

1. 安装必要的依赖 以 CentOS 7 系统为例,安装必要的依赖包: sudo yum install -y curl policycoreutils openssh-server openssh-clients postfix sudo systemctl start postfix sudo systemctl enable postfix2. 添加 GitLab 仓库 curl -sS https:/…...

Unity DoTween使用文档

DoTween 使用文档 DoTween 是 Unity 中非常流行的动画补间插件。它通过链式调用方式,让开发者可以快速创建平滑、自然的动画效果。本文将介绍 DoTween 的基础用法、缓动曲线原理(包含常见缓动曲线的数学公式与参数说明)、案例演示以及一些常…...

【办公类-99-01】20250201学具PDF打印会缩小一圈——解决办法:换一个PDF阅读器

背景需求: 2024年1月13日,快要放寒假了,组长拿着我们班的打印好的一叠教案来调整。 “前面周计划下面的家园共育有调整,你自己看批注。” “还有你这个教案部分的模版有问题,太小(窄)了。考虑…...

组合总和II(力扣40)

这道题的难点就在于题目所给的集合中有重复的数字,我们需要进行去重操作。首先明确去重指的是去重哪一部分。注意并不是对递归的集合去重,而是对当前集合的遍历进行去重。这么说可能有点抽象,举个例子:假设集合为1,1,2,3,4&#x…...

基于HTML生成网页有什么优势

在互联网时代,网页是人们获取信息、交流互动的重要窗口,而基于HTML生成网页,是搭建网络大厦的关键。HTML语法简洁直观,标签和属性语义明确,新手也能迅速上手,创建包含基础元素的网页,极大降低了…...

php 接入扣子的 token获取

本身逻辑只是个api,但是官方不提供php的sdk 扎心了老铁,这下php 狗都不用了,主要麻烦的是如何获取access_token,代码如下 protected function get_jwt(): string{$header [alg > RS256,typ > JWT,kid > $this->kid];…...

Redis02 - 持久化

Redis持久化 文章目录 Redis持久化一:持久化简介1:Redis为什么要进行持久化2:Redis持久化的方式 二:RDB持久化介绍1:手动触发RDB2:自动触发RDB3:redis.conf中进行RDB的配置4:RDB优缺…...

【力扣】240.搜索二维矩阵 II

题目 我的代码 class Solution { public:bool searchMatrix(vector<vector<int>>& matrix, int target) {for(int i0;i<matrix.size();i){for(int j0;j<matrix[0].size();j){if(targetmatrix[i][j]){return true;}else if(target<matrix[i][j]){brea…...

RabbitMQ 从入门到精通:从工作模式到集群部署实战(二)

接上篇&#xff1a;《RabbitMQ 从入门到精通&#xff1a;从工作模式到集群部署实战&#xff08;一&#xff09;》 链接 文章目录 4.安装RabbitMQ Messaging Topology Operator 裸金属环境部署RabbitMQ部署单实例部署集群 4.安装RabbitMQ Messaging Topology Operator 使用 cer…...

编程AI深度实战:大模型哪个好? Mistral vs Qwen vs Deepseek vs Llama

随着开源 LLM 的发展&#xff0c;越来越多的模型变得专业化&#xff0c;“代码”LLM 变得非常流行。这些 LLM 旨在比其 “常识” 对应物更小&#xff0c;但旨在超越更大的通用模型的编码性能。 这些模型以极低的成本提供大型模型的功能&#xff0c;进一步使本地 LLM 空间民主化…...

11.kafka开启jmx

方式一: 1.进入/opt/kafka_2.13-3.3.2/bin目录 命令: cd /opt/kafka_2.13-3.3.2/bin [root@rhel77 ~]# cd /opt/kafka_2.13-3.3.2/bin [root@rhel77 bin]# pwd /opt/kafka_2.13-3.3.2/bin [root@rhel77 bin]# 2.备份kafka-run-class.sh 命令: cp kafka-run-class.sh …...

基于钉钉API的连接器实现:企业数据集成与自动化管理

文章目录 概要背景与需求钉钉API概述连接器实现小结 概要 在当今数字化时代&#xff0c;企业面临着海量数据的管理与整合挑战。钉钉作为国内广泛使用的办公协作平台&#xff0c;提供了丰富的API接口&#xff0c;支持企业进行数据集成与自动化管理。本文将介绍如何通过钉钉API实…...

JAVA 二维列表的基础操作与异常

在Java中创建二维 ArrayList&#xff08;即嵌套列表&#xff09;的方法有多种&#xff0c;下面我将详细介绍常用的几种方式&#xff0c;并分析它们的区别和适用场景。 1. 使用嵌套 ArrayList 创建二维列表 方法一&#xff1a;直接嵌套 ArrayList 这是最常用的方法&#xff0c…...

将仓库A分支同步到仓库B分支,并且同步commit提交

一、 问题 有一仓库A 和 一仓库B&#xff0c; 需要将仓库A分支a1所有提交同步推送到仓库B分支b1上 二、 解决 2.1、 首先需要仓库A、仓库B的权限&#xff0c; 2.2、将仓库A clone到本地&#xff0c; 进入A目录&#xff0c;并且切换到a1分支 cd A ## A 为A仓库clone到本地代…...

SVC对500kv系统的电压调节功能及无功功率调节特性仿真模拟

静态无功补偿器(SVC)仿真模型 采用静态无功补偿器(SVC)对一个500kv, 3000mva的系统进行电压调节。 (1)当系统电压较低时&#xff0c;SVC产生无功功率(SVC电容性)。 (2)当系统电压较高时&#xff0c;吸收无功功率(SVC感应)。 SVC的额定电容值为200 Mvar&#xff0c;电感值为100 …...

AI净界RMBG-1.4实战案例:一张图搞定电商、设计、教学三种需求

AI净界RMBG-1.4实战案例&#xff1a;一张图搞定电商、设计、教学三种需求 1. 从PS到AI&#xff1a;抠图技术的革命性突破 传统抠图工具如Photoshop需要复杂的操作流程&#xff1a;钢笔工具绘制路径、魔棒工具调整选区、边缘羽化处理...整个过程不仅耗时耗力&#xff0c;而且对…...

避免碰撞的编队控制:分布式线性二次离散时间博弈方法

26.避免碰撞的编队控制分布式线性二次离散时间博弈方法在多智能体系统的编队控制中&#xff0c;避免碰撞是一个至关重要的问题。想象一下&#xff0c;一群无人机在空中编队飞行&#xff0c;如果它们之间没有有效的避免碰撞机制&#xff0c;那很可能会发生“空中交通事故”。今天…...

Qwen-Image定制镜像开源实操:RTX4090D环境下Qwen-VL微调与推理一体化

Qwen-Image定制镜像开源实操&#xff1a;RTX4090D环境下Qwen-VL微调与推理一体化 1. 镜像概述与环境准备 Qwen-Image定制镜像是专为RTX4090D显卡优化的多模态大模型开发环境&#xff0c;预装了完整的CUDA 12.4工具链和Qwen-VL模型依赖库。这个镜像最大的特点是开箱即用&#…...

Linux嵌入式网络监控工具实战指南:从命令行到图形化

1. Linux网络监控工具全景解析&#xff1a;从命令行到图形化实践指南在嵌入式Linux系统开发与运维实践中&#xff0c;网络状态的可观测性是保障系统稳定性、定位通信异常、优化带宽分配的核心能力。当一个基于ARM Cortex-A系列处理器的工业网关设备出现TCP连接频繁重传、HTTP响…...

PHP 高级版本特性解析第三篇章

PHP 高级版本特性解析 PHP 8.x 系列引入了多项重大改进&#xff0c;包括 JIT 编译器、类型系统增强、新语法糖等。以下从核心技术点进行剖析&#xff1a; JIT 编译器实现原理 PHP 8.0 引入的 JIT&#xff08;Just-In-Time&#xff09;通过动态编译热点代码为机器码&#xff0…...

互联网隐私保卫战:多维度防跟踪策略解析

浏览器&#xff1a;隐私防护的第一道防线 在互联网世界&#xff0c;浏览器是我们上网的入口&#xff0c;然而大多数浏览器允许侵入性的 cookie 和跟踪行为&#xff0c;还可能与第三方合作利用用户信息投放个性化广告。而安全浏览器通常会默认阻止广告、指纹识别和跟踪器&#x…...

数据中台数据权限体系:基于RBAC的精细控制

数据中台数据权限体系:基于RBAC的精细控制 关键词:数据中台、数据权限、RBAC、访问控制、数据安全、权限管理、数据治理 摘要:本文深入探讨了数据中台环境下基于RBAC(基于角色的访问控制)的数据权限体系设计与实现。文章首先介绍了数据中台权限管理的核心挑战,然后详细解析…...

程序员效率提升:IDEA 神级插件 + 配置,开发速度翻倍

从"重复搬砖"到"高效编码"&#xff1a;IDEA 神级插件配置&#xff0c;开发速度直接翻倍 作为常年和IDEA打交道的后端开发者&#xff0c;我太懂那种被重复代码、格式问题、API调试拖慢节奏的痛苦。本文整理了我实测半年、能直接落地的7个神级插件6项核心配置…...

【DiT视频生成技术】第一章:DiT基础架构与视频化扩展

第一章:DiT基础架构与视频化扩展 目录 第一章:DiT基础架构与视频化扩展 视频扩散模型的架构演进 位置编码机制 脚本实现 视频扩散模型的架构演进 在视频扩散模型的架构演进中,时空维度的联合建模构成了从图像生成向视频生成迁移的核心技术挑战。不同于图像数据的静态二…...