PostgreSQL 10.23 二進位制安裝
介質下載:
官網
下載安裝
download/linux/redhat/
原始碼包
ftp/source/v15.1/
postgresql-15.1.tar.gz
二進位制包
Binaries from installer Version 10.23
[root@cjc-db-01 pg]# ls -lrth postgresql-10.23-1-linux-x64-binaries.tar.gz -rw-r--r-- 1 root root 156M Jan 13 14:28 postgresql-10.23-1-linux-x64-binaries.tar.gz [root@cjc-db-01 pg]# md5sum postgresql-10.23-1-linux-x64-binaries.tar.gz bbfd9452247ec92cd8cd32d23d922f2f postgresql-10.23-1-linux-x64-binaries.tar.gz
安裝前配置:
檢查是否已經存在postgresql
[root@cjc-db-01 pg]# ps -ef|grep postg root 3602 3388 0 14:29 pts/0 00:00:00 grep --color=auto postg [root@cjc-db-01 pg]# rpm -qa|grep -i postg postgresql-libs-9.2.24-4.el7_8.x86_64 postgresql-server-9.2.24-4.el7_8.x86_64 postgresql-9.2.24-4.el7_8.x86_64
解除安裝
rpm -e postgresql-libs-9.2.24-4.el7_8.x86_64 --nodeps rpm -e postgresql-server-9.2.24-4.el7_8.x86_64 --nodeps rpm -e postgresql-9.2.24-4.el7_8.x86_64 --nodeps
建立使用者組
groupadd -g 1500 postgres useradd -g 1500 -u 1500 postgres passwd postgres
配置環境變數
vi /home/postgres/.bash_profile export PGHOME=/pg/app/10/pgsql export PATH=$PATH:$PGHOME/bin export PGDATA=/pg/data export PGLOG=/pg/log [postgres@cjc-db-01 ~]$ source .bash_profile
建立目錄並授權
mkdir -p /pg/{app/10,data,log,conf} chown postgres.postgres /pg -R
解壓
tar -zxvf postgresql-10.23-1-linux-x64-binaries.tar.gz -C /pg/app/10
授權
chown postgres.postgres /pg -R
解壓後大小
[root@cjc-db-01 10]# du -sh * 423Mpgsql
檔案
[root@cjc-db-01 10]# ls pgsql/ bin doc include lib pgAdmin 4 share stackbuilder
安裝:
su - posgres
檢視幫助資訊
[postgres@cjc-db-01 ~]$ initdb --help
初始化
initdb -D /pg/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 "en_US.UTF-8". The default database encoding has accordingly been set to "UTF8". The default text search configuration will be set to "english". Data page checksums are disabled. fixing permissions on existing directory /pg/data ... ok creating subdirectories ... ok selecting default max_connections ... 100 selecting default shared_buffers ... 128MB selecting default timezone ... Asia/Shanghai selecting dynamic shared memory implementation ... posix creating configuration files ... ok running bootstrap script ... ok performing post-bootstrap initialization ... ok syncing data to disk ... ok WARNING: enabling "trust" authentication for local connections 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 /pg/data -l logfile start
目錄大小
[postgres@cjc-db-01 pg]$ du -sh data/ 43Mdata/
目錄檔案
[postgres@cjc-db-01 pg]$ ls -lrth data/ total 48K drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_twophase drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_tblspc drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_stat_tmp drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_stat drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_snapshots drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_serial drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_replslot drwx------ 4 postgres postgres 36 Jan 13 14:42 pg_multixact drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_dynshmem drwx------ 2 postgres postgres 6 Jan 13 14:42 pg_commit_ts -rw------- 1 postgres postgres 3 Jan 13 14:42 PG_VERSION -rw------- 1 postgres postgres 23K Jan 13 14:42 postgresql.conf -rw------- 1 postgres postgres 88 Jan 13 14:42 postgresql.auto.conf -rw------- 1 postgres postgres 1.6K Jan 13 14:42 pg_ident.conf -rw------- 1 postgres postgres 4.5K Jan 13 14:42 pg_hba.conf drwx------ 2 postgres postgres 18 Jan 13 14:42 pg_xact drwx------ 3 postgres postgres 60 Jan 13 14:42 pg_wal drwx------ 2 postgres postgres 18 Jan 13 14:42 pg_subtrans drwx------ 2 postgres postgres 18 Jan 13 14:42 pg_notify drwx------ 2 postgres postgres 4.0K Jan 13 14:42 global drwx------ 5 postgres postgres 41 Jan 13 14:42 base drwx------ 4 postgres postgres 68 Jan 13 14:42 pg_logical
修改引數檔案
[postgres@cjc-db-01 data]$ ls -lrth *.conf -rw------- 1 postgres postgres 23K Jan 13 14:42 postgresql.conf -rw------- 1 postgres postgres 88 Jan 13 14:42 postgresql.auto.conf -rw------- 1 postgres postgres 1.6K Jan 13 14:42 pg_ident.conf -rw------- 1 postgres postgres 4.5K Jan 13 14:42 pg_hba.conf [postgres@cjc-db-01 data]$ vi /pg/data/postgresql.conf #listen_addresses = 'localhost' # what IP address(es) to listen on; listen_addresses = '*' # what IP address(es) to listen on; #port = 5432 # (change requires restart) port = 5678
啟動資料庫
[postgres@cjc-db-01 ~]$ pg_ctl --help pg_ctl is a utility to initialize, start, stop, or control a PostgreSQL server. Usage: pg_ctl init[db] [-D DATADIR] [-s] [-o OPTIONS] pg_ctl start [-D DATADIR] [-l FILENAME] [-W] [-t SECS] [-s] [-o OPTIONS] [-p PATH] [-c] pg_ctl stop [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s] pg_ctl restart [-D DATADIR] [-m SHUTDOWN-MODE] [-W] [-t SECS] [-s] [-o OPTIONS] [-c] pg_ctl reload [-D DATADIR] [-s] pg_ctl status [-D DATADIR] pg_ctl promote [-D DATADIR] [-W] [-t SECS] [-s] pg_ctl kill SIGNALNAME PID Common options: -D, --pgdata=DATADIR location of the database storage area -s, --silent only print errors, no informational messages -t, --timeout=SECS seconds to wait when using -w option -V, --version output version information, then exit -w, --wait wait until operation completes (default) -W, --no-wait do not wait until operation completes -?, --help show this help, then exit If the -D option is omitted, the environment variable PGDATA is used. Options for start or restart: -c, --core-files allow postgres to produce core files -l, --log=FILENAME write (or append) server log to FILENAME -o, --options=OPTIONS command line options to pass to postgres (PostgreSQL server executable) or initdb -p PATH-TO-POSTGRES normally not necessary Options for stop or restart: -m, --mode=MODE MODE can be "smart", "fast", or "immediate" Shutdown modes are: smart quit after all clients have disconnected fast quit directly, with proper shutdown (default) immediate quit without complete shutdown; will lead to recovery on restart Allowed signal names for kill: ABRT HUP INT QUIT TERM USR1 USR2 Report bugs to <pgsql-bugs@postgresql.org>.
啟動
[postgres@cjc-db-01 data]$ pg_ctl -D /pg/data start
啟動日誌如下:
waiting for server to start....2023-01-13 15:06:56.195 CST [6267] LOG: listening on IPv4 address "0.0.0.0", port 5678 2023-01-13 15:06:56.195 CST [6267] LOG: listening on IPv6 address "::", port 5678 2023-01-13 15:06:56.657 CST [6267] LOG: listening on Unix socket "/tmp/.s.PGSQL.5678" 2023-01-13 15:06:56.719 CST [6269] LOG: database system was shut down at 2023-01-13 14:42:08 CST 2023-01-13 15:06:56.749 CST [6267] LOG: database system is ready to accept connections done server started
登入資料庫
檢視psql幫助資訊
[postgres@cjc-db-01 ~]$ psql --help psql is the PostgreSQL interactive terminal. Usage: psql [OPTION]... [DBNAME [USERNAME]] General options: -c, --command=COMMAND run only single command (SQL or internal) and exit -d, --dbname=DBNAME database name to connect to (default: "postgres") -f, --file=FILENAME execute commands from file, then exit -l, --list list available databases, then exit -v, --set=, --variable=NAME=VALUE set psql variable NAME to VALUE (e.g., -v ON_ERROR_STOP=1) -V, --version output version information, then exit -X, --no-psqlrc do not read startup file (~/.psqlrc) -1 ("one"), --single-transaction execute as a single transaction (if non-interactive) -?, --help[=options] show this help, then exit --help=commands list backslash commands, then exit --help=variables list special variables, then exit Input and output options: -a, --echo-all echo all input from script -b, --echo-errors echo failed commands -e, --echo-queries echo commands sent to server -E, --echo-hidden display queries that internal commands generate -L, --log-file=FILENAME send session log to file -n, --no-readline disable enhanced command line editing (readline) -o, --output=FILENAME send query results to file (or |pipe) -q, --quiet run quietly (no messages, only query output) -s, --single-step single-step mode (confirm each query) -S, --single-line single-line mode (end of line terminates SQL command) Output format options: -A, --no-align unaligned table output mode -F, --field-separator=STRING field separator for unaligned output (default: "|") -H, --html HTML table output mode -P, --pset=VAR[=ARG] set printing option VAR to ARG (see \pset command) -R, --record-separator=STRING record separator for unaligned output (default: newline) -t, --tuples-only print rows only -T, --table-attr=TEXT set HTML table tag attributes (e.g., width, border) -x, --expanded turn on expanded table output -z, --field-separator-zero set field separator for unaligned output to zero byte -0, --record-separator-zero set record separator for unaligned output to zero byte Connection options: -h, --host=HOSTNAME database server host or socket directory (default: "local socket") -p, --port=PORT database server port (default: "5432") -U, --username=USERNAME database user name (default: "postgres") -w, --no-password never prompt for password -W, --password force password prompt (should happen automatically) For more information, type "\?" (for internal commands) or "\help" (for SQL commands) from within psql, or consult the psql section in the PostgreSQL documentation. Report bugs to <pgsql-bugs@postgresql.org>.
本地登入
[postgres@cjc-db-01 ~]$ psql psql.bin: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
新增環境變數
[postgres@cjc-db-01 ~]$ vi /home/postgres/.bash_profile export PGPORT=5678 [postgres@cjc-db-01 ~]$ source .bash_profile
再次登入
[postgres@cjc-db-01 ~]$ psql psql.bin (10.23) Type "help" for help. postgres=# help You are using psql, the command-line interface to PostgreSQL. Type: \copyright for distribution terms \h for help with SQL commands \? for help with psql commands \g or terminate with semicolon to execute query \q to quit postgres=# \q [postgres@cjc-db-01 ~]$
遠端登入
[postgres@cjc-db-01 ~]$ psql -h 172.16.6.137 -p 5678 2023-01-13 15:28:19.452 CST [7676] FATAL: no pg_hba.conf entry for host "172.16.6.137", user "postgres", database "postgres", SSL off psql.bin: FATAL: no pg_hba.conf entry for host "172.16.6.137", user "postgres", database "postgres", SSL off
修改pg_hba.conf
[postgres@cjc-db-01 ~]$ cd /pg/data/ [postgres@cjc-db-01 data]$ vi pg_hba.conf # IPv4 local connections: host all all 0.0.0.0/0 trust
其中:0代表所有ip地址都允許訪問
重啟資料庫
[postgres@cjc-db-01 data]$ pg_ctl -D /pg/data restart
記錄日誌
[postgres@cjc-db-01 data]$ pg_ctl -D /pg/data -l /pg/log/pg.log restart
檢視日誌
[postgres@cjc-db-01 data]$ cat ../log/pg.log 2023-01-13 15:44:04.484 CST [8752] LOG: listening on IPv4 address "0.0.0.0", port 5678 2023-01-13 15:44:04.484 CST [8752] LOG: listening on IPv6 address "::", port 5678 2023-01-13 15:44:05.201 CST [8752] LOG: listening on Unix socket "/tmp/.s.PGSQL.5678" 2023-01-13 15:44:05.337 CST [8754] LOG: database system was shut down at 2023-01-13 15:43:53 CST 2023-01-13 15:44:05.366 CST [8752] LOG: database system is ready to accept connections
遠端登入
[postgres@cjc-db-01 data]$ psql -h 172.16.6.137 -p 5678 psql.bin (10.23) Type "help" for help. postgres=#
建立資料庫
postgres=# create database cjcdb; CREATE DATABASE
檢視資料庫
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+-------------+-------------+----------------------- cjcdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres + | | | | | postgres=CTc/postgres (4 rows)
###chenjuchao 20230117 14:45###
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29785807/viewspace-2932433/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- PostgreSQL二進位制安裝流程SQL
- Postgresql13.1-1 win10二進位制安裝SQLWin10
- MySQL 安裝指南 二進位制安裝MySql
- Mysql二進位制包安裝MySql
- MySQL linux二進位制安裝MySqlLinux
- 二進位制檔案安裝安裝etcd
- mysql安裝-----二進位制包安裝及解除安裝MySql
- Mysql for Linux安裝配置之——二進位制安裝MySqlLinux
- centos 7 二進位制安裝mysql 5.7.25CentOSMySql
- 使用二進位制包來安裝MySQLMySql
- ubuntu mysql5.6二進位制安裝UbuntuMySql
- MySQL5.7 windows二進位制安裝MySqlWindows
- 二進位制方式安裝mysql 5.6.15MySql
- 03二進位制包安裝與介紹
- 二進位制方式安裝 k8sK8S
- RHEL 7.2 安裝二進位制MySQL 5.7.18MySql
- Linux安裝二進位制PHP7.2LinuxPHP
- yum安裝nginx-php-mysql二進位制NginxPHPMySql
- MySQL5.7 linux二進位制安裝MySqlLinux
- (OEL 6.3) Mysql6.5二進位制安裝MySql
- 二進位制安裝 Docker 以及 Docker ComposeDocker
- centos7二進位制方式安裝rabbitmqCentOSMQ
- Ubuntu 24.04 二進位制安裝 MySQL 8.0.20UbuntuMySql
- CentOS7 安裝 MySQL8.0(二進位制)CentOSMySql
- mysql5.7 for windows二進位制安裝及配置MySqlWindows
- 二進位制發行包還是編譯安裝編譯
- 二進位制與二進位制運算
- 進位制詳解:二進位制、八進位制和十六進位制
- JavaScript 二進位制、八進位制與十六進位制JavaScript
- MySQL 5.7 原始碼安裝、Yum倉庫安裝、RPM安裝、二進位制安裝MySql原始碼
- centos7搭建lnmp安裝二進位制mysql【三】CentOSLNMPMySql
- Windows11二進位制方式安裝MySQL5.7.44WindowsMySql
- Ubuntu24 二進位制包安裝mysql5.7UbuntuMySql
- (二進位制)
- 二進位制
- 十進位制——二 (八、十六 )進位制
- 二進位制,八進位制,十進位制,十六進位制的相互轉換
- 【進位制轉換】二進位制、十六進位制、十進位制、八進位制對應關係