当前位置:网站首页>Use source code compilation to install postgresql13.3 database
Use source code compilation to install postgresql13.3 database
2022-07-06 23:53:00 【Hua Weiyun】
1、 Installation Overview
PG There are many ways to install , and MySQL similar , Give users a lot of choice . Such as :RPM Package installation ( On-line 、 offline )、 Source code compilation and installation 、 System comes with 、 Binary system 、NDB Installation, etc .
https://yum.postgresql.org/rpmchart.php
https://yum.postgresql.org/11/redhat/rhel-6-x86_64/repoview/postgresqldbserver11.group.html
https://www.postgresql.org/ftp/source/
open PostgreSQL Official website https://www.postgresql.org/, Click... On the menu bar Download , As you can see, there are many installation packages for the platform , Include Linux、Windows、Mac OS etc. .
Each installation package :https://www.postgresql.org/ftp/source/
Linux We can see support Ubuntu and Red Hat And so on , Click on the specific platform link , You can see the installation method :
Click on the image above file browser, We can also download PostgreSQL The latest source code .
Download address :
https://www.postgresql.org/download
https://yum.postgresql.org/repopackages.php
file :https://www.postgresql.org/download/linux/redhat/
rpm download :https://yum.postgresql.org/rpmchart/
It is recommended to install the source code of the production library , The following methods have been used in 9.6 To 13 Version tested .
2、 Download source package
Source code download address :https://www.postgresql.org/ftp/source/
-- Download source package wget https://ftp.postgresql.org/pub/source/v13.3/postgresql-13.3.tar.gzwget https://ftp.postgresql.org/pub/source/v13.2/postgresql-13.2.tar.gzwget https://ftp.postgresql.org/pub/source/v12.6/postgresql-12.6.tar.gzwget https://ftp.postgresql.org/pub/source/v11.11/postgresql-11.11.tar.gzwget https://ftp.postgresql.org/pub/source/v10.16/postgresql-10.16.tar.gzwget https://ftp.postgresql.org/pub/source/v9.6.21/postgresql-9.6.21.tar.gzwget https://ftp.postgresql.org/pub/source/v9.4.26/postgresql-9.4.26.tar.gz
3、 Create user and installation directories
-- Create user groupadd -g 60000 pgsqluseradd -u 60000 -g pgsql pgsqlecho "lhr" | passwd --stdin pgsql-- Create directory mkdir -p /postgresql/{pgdata,archive,scripts,backup,pg13,soft}chown -R pgsql:pgsql /postgresqlchmod -R 775 /postgresql
4、 compile PG
-- Install some dependency packages yum install -y cmake make gcc zlib gcc-c++ perl readline readline-devel zlib zlib-devel \perl python36 tcl openssl ncurses-devel openldap pam-- compile su - pgsqlcd /postgresql/softtar zxvf postgresql-13.3.tar.gzcd postgresql-13.3./configure --prefix=/postgresql/pg13 --without-readlinemake -j 8 && make install
5、 Configure environment variables
-- Configure environment variables cat >> ~/.bash_profile <<"EOF"export LANG=en_US.UTF-8export PS1="[\[email protected]\h \W]\$ "export PGPORT=5432export PGDATA=/postgresql/pgdataexport PGHOME=/postgresql/pg13export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATHexport PATH=$PGHOME/bin:$PATH:.export DATE=`date +"%Y%m%d%H%M"`export MANPATH=$PGHOME/share/man:$MANPATHexport PGHOST=$PGDATAexport PGUSER=postgresexport PGDATABASE=postgresalias psql='rlwrap psql' EOFsource ~/.bash_profile
6、 Initialize database
-- initialization su - pgsql/postgresql/pg13/bin/initdb -D /postgresql/pgdata -E UTF8 --locale=en_US.utf8 -U postgres
7、 Configure remote login
-- Modify the parameters cat >> /postgresql/pgdata/postgresql.conf <<"EOF"listen_addresses = '*'port=5432unix_socket_directories='/postgresql/pgdata'logging_collector = onlog_directory = 'pg_log'log_filename = 'postgresql-%a.log'log_truncate_on_rotation = onEOFcat > /postgresql/pgdata/pg_hba.conf << EOF# TYPE DATABASE USER ADDRESS METHODlocal all all trusthost all all 127.0.0.1/32 trusthost all all 0.0.0.0/0 md5host replication all 0.0.0.0/0 md5EOF-- start-up su - pgsqlpg_ctl startpg_ctl statuspg_ctl stop-- or :nohup /postgresql/pg13/bin/postgres -D /postgresql/pgdata > /postgresql/pg13/pglog.out 2>&1 &
8、 Configure system services
-- Configure system services cat > /etc/systemd/system/PG13.service <<"EOF"[Unit]Description=PostgreSQL database serverDocumentation=man:postgres(1)After=network.target[Service]Type=forkingUser=pgsqlGroup=pgsqlEnvironment=PGPORT=5432Environment=PGDATA=/postgresql/pgdataOOMScoreAdjust=-1000ExecStart=/postgresql/pg13/bin/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300ExecStop=/postgresql/pg13/bin/pg_ctl stop -D ${PGDATA} -s -m fastExecReload=/postgresql/pg13/bin/pg_ctl reload -D ${PGDATA} -sKillMode=mixedKillSignal=SIGINTTimeoutSec=0[Install]WantedBy=multi-user.targetEOF
Use systemctl start-up PG:
systemctl daemon-reloadsystemctl enable PG13systemctl start PG13systemctl status PG13
Started :
[root@lhrpg postgresql]# systemctl status PG13● PG13.service - PostgreSQL database server Loaded: loaded (/etc/systemd/system/PG13.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2021-05-26 21:32:26 CST; 1s ago Docs: man:postgres(1) Process: 12473 ExecStart=/postgresql/pg13/bin/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0/SUCCESS) Main PID: 12475 (postgres) CGroup: /docker/ea25b97cfa732f1ec6f188098898e8f26b64cd1bf1e9b408898d722c8a5917fb/system.slice/PG13.service ├─12475 /postgresql/pg13/bin/postgres -D /postgresql/pgdata -p 5433 ├─12476 postgres: logger ├─12478 postgres: checkpointer ├─12479 postgres: background writer ├─12480 postgres: walwriter ├─12481 postgres: autovacuum launcher ├─12482 postgres: stats collector └─12483 postgres: logical replication launcher May 26 21:32:26 lhrpg systemd[1]: Starting PostgreSQL database server...May 26 21:32:26 lhrpg pg_ctl[12473]: 2021-05-26 21:32:26.617 CST [12475] LOG: redirecting log output to logging collector processMay 26 21:32:26 lhrpg pg_ctl[12473]: 2021-05-26 21:32:26.617 CST [12475] HINT: Future log output will appear in directory "pg_log".May 26 21:32:26 lhrpg systemd[1]: Started PostgreSQL database server.
9、 Login test
-- Remote login psql -U postgres -h 192.168.66.35 -d postgres -p5432-- from Postgresql 9.2 Start , You can also use URI Format for remote connection :psql postgresql://myuser:[email protected]:5432/mydbpsql postgresql://postgres:[email protected]:5432/postgres
among -h Parameter specifies the server address , The default is 127.0.0.1, It is not specified by default ,-d Specify the database selected after connection , The default is postgres,-U Designated user , The default is the current user ,-p Specify port number , The default is "5432", More parameter options are available : ./bin/psql --help see .
C:\Users\lhrxxt>psql -U postgres -h 192.168.66.35 -d postgres -p5432Password for user postgres:psql (13.3)Type "help" for help.postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges-----------+----------+----------+-------------------+-------------------+----------------------- postgres | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | template0 | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | Chinese_China.936 | Chinese_China.936 | =c/postgres + | | | | | postgres=CTc/postgres(3 rows)postgres=# CREATE DATABASE lhrdb WITH OWNER=postgres ENCODING='UTF-8';CREATE DATABASEpostgres=# \c lhrdbYou are now connected to database "lhrdb" as user "postgres".lhrdb=#lhrdb=# create table student (lhrdb(# id integer not null,lhrdb(# name character(32),lhrdb(# number char(5),lhrdb(# constraint student_pkey primary key (id)lhrdb(# );CREATE TABLElhrdb=#lhrdb=# \d student Table "public.student" Column | Type | Collation | Nullable | Default--------+---------------+-----------+----------+--------- id | integer | | not null | name | character(32) | | | number | character(5) | | |Indexes: "student_pkey" PRIMARY KEY, btree (id)lhrdb=#lhrdb=# INSERT INTO student (id, name, number) VALUES (1, ' Zhang San ', '1023');INSERT 0 1lhrdb=# SELECT * FROM student WHERE id=1; id | name | number----+------------------------------------+-------- 1 | Zhang San | 1023(1 row)
Installation configuration completed , If you don't understand , You can chat with Mr. Mai privately .
边栏推荐
- vector的使用方法_vector指针如何使用
- 达晨史上最大单笔投资,今天IPO了
- How does crmeb mall system help marketing?
- 氢创未来 产业加速 | 2022氢能专精特新创业大赛报名通道开启!
- Why is bat still addicted to 996 when the four-day working system is being tried out in Britain?
- The best sister won the big factory offer of 8 test posts at one go, which made me very proud
- Tourism Management System Based on jsp+servlet+mysql framework [source code + database + report]
- 17、 MySQL - high availability + read / write separation + gtid + semi synchronous master-slave replication cluster
- Oracle中使用包FY_Recover_Data.pck来恢复truncate误操作的表
- matplotlib画柱状图并添加数值到图中
猜你喜欢
STM32通过串口进入和唤醒停止模式
快讯 l Huobi Ventures与Genesis公链深入接洽中
The method of reinstalling win10 system is as simple as that
How to find out if the U disk file of the computer reinstallation system is hidden
【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码
Every year, 200 billion yuan is invested in the chip field, and "China chip" venture capital is booming
11 preparations for Web3 and Decentralization for traditional enterprises
Why is bat still addicted to 996 when the four-day working system is being tried out in Britain?
Experiment 4: installing packages from Gui
基础图表解读“东方甄选”爆火出圈数据
随机推荐
【2022全网最细】接口测试一般怎么测?接口测试的流程和步骤
谁说新消费品牌大溃败?背后有人赢麻了
Automatic test tool katalon (WEB) test operation instructions
How does crmeb mall system help marketing?
短链的设计
【通信】两层无线 Femtocell 网络上行链路中的最优功率分配附matlab代码
[communication] optimal power allocation in the uplink of two-layer wireless femtocell network with matlab code
leetcode:236. The nearest common ancestor of binary tree
Computer reinstallation system teaching, one click fool operation, 80% of people have learned
JS import excel & Export Excel
openresty ngx_lua子请求
Scholar doctor hahaha
DAY FIVE
Wasserstein slim gain with gradient poverty (wsgain-gp) introduction and code implementation -- missing data filling based on generated countermeasure network
Win11怎么恢复传统右键菜单?Win11右键改回传统模式的方法
There are only two TXT cells in the ArrayExpress database. Can you only download the sequencing run matrix from line to ENA?
吴恩达2022机器学习课程评测来了!
【向量检索研究系列】产品介绍
Newsletter L Huobi ventures is in-depth contact with genesis public chain
Interface joint debugging test script optimization v4.0