postgresql源码编译

news/2024/7/9 22:12:11 标签: postgresql

一、环境说明

$ lsb_release  -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.6 LTS
Release:	18.04
Codename:	bionic
  • 安装docker
$ sudo apt install docker.io

$ sudo docker  -v
Docker version 20.10.7, build 20.10.7-0ubuntu5~18.04.3
  • 获取ubuntu镜像
$ sudo docker pull ubuntu

二、编译

2.1 获取源码

  • 从官网上下载源码
$ wget https://ftp.postgresql.org/pub/source/v14.2/postgresql-14.2.tar.bz2
  • 解压
$ tar xf postgresql-14.2.tar.bz2

2.2 编译源码

  • 启动容器
$ sudo docker run -it  -v /home/trevor/桌面/postgresql-14.2:/code --name build-pg ubuntu /bin/bash

root@2f9d6ce41c2b:/# cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammy

  • 安装编译工具
root@2f9d6ce41c2b:/# apt update && apt install -y gcc libreadline-dev zlib1g-dev make
  • 编译
root@2f9d6ce41c2b:/# cd /code
root@2f9d6ce41c2b:/# ./configure 
root@2f9d6ce41c2b:/# make 
root@2f9d6ce41c2b:/# make install

2.3 初始化

  • 创建postgres用户
root@2f9d6ce41c2b:/# adduser postgres
root@2f9d6ce41c2b:/# mkdir /usr/local/pgsql/data
root@2f9d6ce41c2b:/# chown postgres /usr/local/pgsql/data
root@2f9d6ce41c2b:/# su - postgres
  • 初始化db
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data
  • 启动服务器
postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/pg_ctl -D /usr/local/pgsql/data -l logfile start

三、验证

3.1 创建数据库

postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/createdb test

3.2 使用数据库

postgres@2f9d6ce41c2b:~$ /usr/local/pgsql/bin/psql test
psql (14.2)
Type "help" for help.

test=# select version();
 version                            
--------------------------------------------------------------------------------------------------
 PostgreSQL 14.2 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 11.2.0-19ubuntu1) 11.2.0, 64-bit
(1 row)

http://www.niftyadmin.cn/n/1830038.html

相关文章

weka中算法说明[转]

1) 数据输入和输出WOW():查看Weka函数的参数。Weka_control():设置Weka函数的参数。read.arff():读Weka Attribute-Relation File Format (ARFF)格式的数据。write.arff:将数据写入Weka Attribute-Relation File Format (ARFF)格式…

Java GC垃圾回收

Java的内存分配和回收也主要在Java的堆上进行的,Java的堆中存储了大量的对象实例,所以Java的堆也叫GC堆。 Java在垃圾收集的过程中,主要用到了分代收集算法,具体有复制、标记清除、标记压缩三种实现算法 1. 标记 - 清除算法 标记清…

postgresql创建数据库

一、环境 docker中编译的postgreSQL14.2 postgres2f9d6ce41c2b:~$ /usr/local/pgsql/bin/psql psql (14.2) Type "help" for help.postgres# select version();version -----------------------------------------…

ASP.NET MVC+EF框架+EasyUI实现权限管理系列之开篇

原文:ASP.NET MVCEF框架EasyUI实现权限管理系列之开篇前言:博客又有一段时间没有更新了,心里感觉这段时间空空的,好像什么都没有学下,所以就想写博客,所以就有了这个系列,这里当然也要感谢大家了&#xff0…

postgresql创建表

一、环境 postgres2f9d6ce41c2b:~$ cat /etc/os-release PRETTY_NAME"Ubuntu 22.04 LTS" NAME"Ubuntu" VERSION_ID"22.04" VERSION"22.04 LTS (Jammy Jellyfish)" VERSION_CODENAMEjammy IDubuntu ID_LIKEdebian HOME_URL"http…

数据库SQL语句学习--view

1.新建一个view create view view_name as select * from table_name where... 2.删除一个view drop view view_name 3.新增一列 ALTER TABLE table_name ADD column_name column_type 4.删除一列: COLUMN 是关键字 ALTER TABLE table_name drop COLUMN column_name…

LeetCode Kth Largest Element in an Array

原题链接在这里:https://leetcode.com/problems/kth-largest-element-in-an-array/ 题目: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For exam…

Objective-C学习——中文URL编码和解码

发现NSString类中有内置的方法可以实现。他们分别是: - (NSString *)stringByAddingPercentEscapesUsingEncoding:(NSStringEncoding)encoding - (NSString *)stringByReplacingPercentEscapesUsingEncoding:(NSStringEncoding)encoding 只要传入相应的编码即可以进…