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 ... ok

initdb: 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=# \l
                                                       List of databases
   Name    |  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/postgres
 template1 | postgres | UTF8     | libc            | zh_CN.UTF-8 | zh_CN.UTF-8 |            |           | =c/postgres          +
           |          |          |                 |             |             |            |           | postgres=CTc/postgres
 test      | 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 | hwz
  2 | 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

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

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Machine Learning:Introduction

文章目录 Machine LearningTrainingStep 1.Contract Function with Unknown ParametersStep 2.Define Loss from Training DataStep 3.Optimization Linear ModelPiecewise Linear CurveBeyond Piecewise Liner?FunctionLossOptimization Model Deformation Machine Learning …

【Java】多线程和高并发编程(三):锁(下)深入ReentrantReadWriteLock

文章目录 4、深入ReentrantReadWriteLock4.1 为什么要出现读写锁4.2 读写锁的实现原理4.3 写锁分析4.3.1 写锁加锁流程概述4.3.2 写锁加锁源码分析4.3.3 写锁释放锁流程概述&释放锁源码 4.4 读锁分析4.4.1 读锁加锁流程概述4.4.1.1 基础读锁流程4.4.1.2 读锁重入流程4.4.1.…

使用redis实现 令牌桶算法 漏桶算法

流量控制算法,用于限制请求的速率。 可以应对缓存雪崩 令牌桶算法 核心思想是: 有一个固定容量的桶,里面存放着令牌(token)。每过一定时间(如 1 秒),桶中会自动增加一定数量的令牌…

金媒婚恋交友系统V10.5的CRM操作提示:“您没有权限执行此操作”解决方法

大家都知道新年2.5日新版10.5已经升级了,这次升级相对以前更新内容相当重量级!最突出的就是CRM系统的更新和UI改观吐槽的内容都改进了我愿意和大家分享代码和新得~关注我昵称就能知道我哦!! 出现原因:是这个红娘账号没…

ubuntu使用最佳流程2:ubuntu20.04安装cuda(多版本切换),cudnn,显卡驱动

cuda安装(多版本cuda安装:可切换) 查看系统硬件配置 查询Linux系统的版本号 lsb_release -a查询显卡型号 待更新下载 CUDA官方传送门 找到适合自己的命令行下载安装即可 安装 accept 第一个driver去掉(点击enter&#xff…

Crowdin 在线本地化平台调用硅基流动AI预翻译

平台介绍 硅基流动(AI服务平台) 官网:https://siliconflow.cn/zh-cn/ 官方介绍 我主要使用:云服务平台 SilliconCloud 此平台已经将热门的开源大语言模型部署,花钱买额度,就能使用 API 最近有上线 Deep…

二、通义灵码插件保姆级教学-IDEA(使用篇)

一、IntelliJ IDEA 中使用指南 1.1、代码解释 选择需要解释的代码 —> 右键 —> 通义灵码 —> 解释代码 解释代码很详细,感觉很强大有木有,关键还会生成流程图,对程序员理解业务非常有帮忙,基本能做到哪里不懂点哪里。…

游戏引擎学习第97天

回顾昨天并计划今天 在这期节目中,主要讲解了光照的概念,并进一步讨论了法线贴图光照的实现。节目的内容大致分为几个部分: 光照的基础概述:讨论了光的工作原理以及如何在编程图形时需要考虑光照问题。尽管这些概念并没有深入到…

python+unity落地方案实现AI 换脸融合

先上效果再说技术结论,使用的是自行搭建的AI人脸融合库,可以离线不受限制无限次生成,有需要的可以后台私信python ai换脸融合。 TODO 未来的方向:3D人脸融合和AI数据训练 这个技术使用的是openvcinsighface,openvc…

Python——批量图片转PDF(GUI版本)

目录 专栏导读1、背景介绍2、库的安装3、核心代码4、完整代码总结专栏导读 🌸 欢迎来到Python办公自动化专栏—Python处理办公问题,解放您的双手 🏳️‍🌈 博客主页:请点击——> 一晌小贪欢的博客主页求关注 👍 该系列文章专栏:请点击——>Python办公自动化专…

AutoMQ 如何实现没有写性能劣化的极致冷读效率

前言 追赶读(Catch-up Read,冷读)是消息和流系统常见和重要的场景。 削峰填谷:对于消息来说,消息通常用作业务间的解耦和削峰填谷。削峰填谷要求消息队列能将上游发送的数据堆积住,让下游在容量范围内消费…

[AI]Mac本地部署Deepseek R1模型 — — 保姆级教程

[AI]Mac本地部署DeepSeek R1模型 — — 保姆级教程 DeepSeek R1是中国AI初创公司深度求索(DeepSeek)推出大模型DeepSeek-R1。 作为一款开源模型,R1在数学、代码、自然语言推理等任务上的性能能够比肩OpenAI o1模型正式版,并采用MI…

MariaDB *MaxScale*实现mysql8读写分离

1.MaxScale 是干什么的? MaxScale是maridb开发的一个mysql数据中间件,其配置简单,能够实现读写分离,并且可以根据主从状态实现写库的自动切换,对多个从服务器能实现负载均衡。 2.MaxScale 实验环境 中间件192.168.12…

Ollama 简单 好用 好玩

简介 Ollama https://github.com/ollama/ollama/ 是一个基于 Go 语言 的 本地大语言模型运行框架,专注于本地化运行大型语言模型(LLM)的开源工具。 类 Docker 产品(支持 list,pull,push,run 等命令),更好玩…

存储可靠性:从基于磁盘的RAID到分布式纠删码(EC),多副本

文章目录 0.简介1.RAID1.1 RAID 01.2 RAID 11.3 RAID 51.4 RAID 61.5 RAID 10 2.EC(纠删码)2.1 概念2.2 原理 3.多副本4. 总结和优缺点比较 0.简介 在选择数据存储方案时,一个绕不开的话题就是数据存储的可靠性(面对故障时的应对…

【自然语言处理】利用Memory Layer替换Transformer中的FFN

论文地址:https://arxiv.org/pdf/2412.09764 相关博客 【自然语言处理】利用Memory Layer替换Transformer中的FFN 【自然语言处理】【大模型】BitNet:用1-bit Transformer训练LLM 【自然语言处理】BitNet b1.58:1bit LLM时代 【自然语言处理】…

Redis持久化的两种方式:RDB和AOF

redis中的数据存储在缓存中,如果没有持久化的策略,Redis一旦宕机,那么将会导致数据丢失;因此redis提供了以下两种持久化方式:RDB和AOF 一般来说,大部分公司对这两种方式都是同时开启的 一、RDB RDB策略全…

linux查看所有程序占用的本地端口

sudo ss -tulwnp ss是Socket Statistics的缩写,用来替代旧的netstat工具,功能更强大,执行更快。它用于查看系统的网络连接情况,包括TCP、UDP等协议的信息。 查阅ss的帮助文档(man ss),发现选项…

组件库选择:ElementUI 还是 Ant Design

🤍 前端开发工程师、技术日更博主、已过CET6 🍨 阿珊和她的猫_CSDN博客专家、23年度博客之星前端领域TOP1 🕠 牛客高级专题作者、打造专栏《前端面试必备》 、《2024面试高频手撕题》 🍚 蓝桥云课签约作者、上架课程《Vue.js 和 E…

9 数据流图

9 数据流图 9.1数据平衡原则 子图缺少处理后的数据操作结果返回前端应用以及后端数据库返回操作结果到数据管理中间件。 9.2解题技巧 实件名 存储名 加工名 数据流