KylinV10 环境源码编译安装postgres12.11-上
操作系统 | CPU | Glibc |
---|---|---|
麒麟V10 | 鲲鹏920 | 2.28 |
1、前置:编译安装操作已完成
可参考上一篇 《CentOS7.9源码编译安装postgres12.11》
[root@host12-arm postgresql-12.11]# ll
总用量 1240
-rw-r--r-- 1 1107 1107 445 5月 10 2022 aclocal.m4
drwxrwxrwx 2 1107 1107 4096 5月 10 2022 config
-rw-r--r-- 1 root root 435230 10月 18 20:20 config.log
-rwxr-xr-x 1 root root 40143 10月 18 20:20 config.status
-rwxr-xr-x 1 1107 1107 581932 5月 10 2022 configure
-rw-r--r-- 1 1107 1107 86602 5月 10 2022 configure.in
drwxrwxrwx 56 1107 1107 4096 5月 10 2022 contrib
-rw-r--r-- 1 1107 1107 1192 5月 10 2022 COPYRIGHT
drwxrwxrwx 3 1107 1107 87 5月 10 2022 doc
-rw-r--r-- 1 root root 4284 10月 18 20:20 GNUmakefile
-rw-r--r-- 1 1107 1107 4284 5月 10 2022 GNUmakefile.in
-rw-r--r-- 1 1107 1107 284 5月 10 2022 HISTORY
-rw-r--r-- 1 1107 1107 62466 5月 10 2022 INSTALL
-rw-r--r-- 1 1107 1107 1665 5月 10 2022 Makefile
-rw-r--r-- 1 1107 1107 1212 5月 10 2022 README
drwxrwxrwx 16 1107 1107 4096 10月 18 20:20 src
[root@host12-arm postgresql-12.11]# cd ../
[root@host12-arm u01]# ll
总用量 26944
drwxr-xr-x 3 root root 16 10月 18 20:27 postgresql
drwxrwxrwx 6 1107 1107 4096 10月 18 20:20 postgresql-12.11
-rw-r--r-- 1 root root 27583446 10月 18 20:19 postgresql-12.11.tar.gz
[root@host12-arm u01]# cd postgresql
[root@host12-arm postgresql]# ll
总用量 0
drwxr-xr-x 6 root root 56 10月 18 20:27 12
2、创建postgres用户、赋权
[root@host12-arm postgresql]# useradd -m postgres -d /home/postgres -s /bin/bash
[root@host12-arm postgresql]# mkdir -p /u01/postgresql/12/data
[root@host12-arm postgresql]# chown -R postgres:postgres /u01/postgresql
[root@host12-arm postgresql]# chmod 0700 /u01/postgresql/12/data
[root@host12-arm postgresql]#
3、切换到postgres用户,添加环境变量
echo ‘’’
export PATH=/u01/postgresql/12/bin:$PATH
export PGDATA=/u01/postgresql/12/data
export PGHOME=/u01/postgresql/12
export LANG=zh_CN.UTF-8
export PGPORT=5432
‘’’ >> ~/.bash_profile
[root@host12-arm postgresql]# su - postgres
[postgres@host12-arm ~]$ echo '''
> export PATH=/u01/postgresql/12/bin:$PATH
> export PGDATA=/u01/postgresql/12/data
> export PGHOME=/u01/postgresql/12
> export LANG=zh_CN.UTF-8
> export PGPORT=5432
> ''' >> ~/.bash_profile
[postgres@host12-arm ~]$ source ~/.bash_profile
4、初始化数据库
[postgres@host12-arm ~]$ initdb -D /u01/postgresql/12/data --locale=zh_CN.UTF8
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.UTF8".
The default database encoding has accordingly been set to "UTF8".
initdb: could not find suitable text search configuration for locale "zh_CN.UTF8"
The default text search configuration will be set to "simple".
Data page checksums are disabled.
fixing permissions on existing directory /u01/postgresql/12/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
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 /u01/postgresql/12/data -l logfile start
[postgres@host12-arm ~]$
5、启动数据库
[postgres@host12-arm ~]$ pg_ctl -D /u01/postgresql/12/data -l logfile start
waiting for server to start.... done
server started
[postgres@host12-arm ~]$
6、查看数据库进程、端口
[postgres@host12-arm ~]$ ps -ef|grep postgres
root 372988 372941 0 22:06 pts/1 00:00:00 su - postgres
postgres 372989 372988 0 22:06 pts/1 00:00:00 -bash
postgres 373051 1 0 22:07 ? 00:00:00 /u01/postgresql/12/bin/postgres -D /u01/postgresql/12/data
postgres 373053 373051 0 22:07 ? 00:00:00 postgres: checkpointer
postgres 373054 373051 0 22:07 ? 00:00:00 postgres: background writer
postgres 373055 373051 0 22:07 ? 00:00:00 postgres: walwriter
postgres 373056 373051 0 22:07 ? 00:00:00 postgres: autovacuum launcher
postgres 373057 373051 0 22:07 ? 00:00:00 postgres: stats collector
postgres 373058 373051 0 22:07 ? 00:00:00 postgres: logical replication launcher
postgres 373059 372989 0 22:07 pts/1 00:00:00 ps -ef
postgres 373060 372989 0 22:07 pts/1 00:00:00 grep postgres
[postgres@host12-arm ~]$
[postgres@host12-arm ~]$ netstat -nlp|grep postgres
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 371654/postgres
tcp6 0 0 ::1:5432 :::* LISTEN 371654/postgres
unix 2 [ ACC ] STREAM LISTENING 7883433 371654/postgres /tmp/.s.PGSQL.5432
[postgres@host12-arm ~]$
7、测试连接数据库
[postgres@host12-arm ~]$ psql -Upostgres -dpostgres
psql (12.11)
Type "help" for help.
postgres=# create user tpcc with password 'Test@1234';
CREATE ROLE
postgres=# create database tpcc owner tpcc;
CREATE DATABASE
postgres=#
postgres=# \q
[postgres@host12-arm ~]$ psql -Utpcc -dtpcc
psql (12.11)
Type "help" for help.
tpcc=> create schema tpcc;
CREATE SCHEMA
tpcc=>
tpcc=> \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+-----------------------
postgres | postgres | UTF8 | zh_CN.UTF8 | zh_CN.UTF8 |
template0 | postgres | UTF8 | zh_CN.UTF8 | zh_CN.UTF8 | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | zh_CN.UTF8 | zh_CN.UTF8 | =c/postgres +
| | | | | postgres=CTc/postgres
tpcc | tpcc | UTF8 | zh_CN.UTF8 | zh_CN.UTF8 |
(4 rows)
tpcc=> \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
tpcc | | {}
tpcc=> \dn
List of schemas
Name | Owner
--------+----------
public | postgres
tpcc | tpcc
(2 rows)
tpcc=> exit
[postgres@host12-arm ~]$
8、停止数据库
[postgres@host12-arm ~]$ pg_ctl -D /u01/postgresql/12/data -l logfile stop
waiting for server to shut down.... done
server stopped
[postgres@host12-arm ~]$
9、打包已安装好的postgres实例,方便可复制安装
[postgres@host12-arm ~]$ exit
注销
[root@host12-arm postgresql]#
[root@host12-arm postgresql]# cd ..
[root@host12-arm u01]# ll
总用量 26944
drwxr-xr-x 3 postgres postgres 16 10月 18 20:27 postgresql
drwxrwxrwx 6 1107 1107 4096 10月 18 20:20 postgresql-12.11
-rw-r--r-- 1 root root 27583446 10月 18 20:19 postgresql-12.11.tar.gz
[root@host12-arm u01]#
[root@host12-arm u01]# tar -czf postgresql12-arm-glibc-2.28.tar.gz postgresql
[root@host12-arm u01]# ll
总用量 40696
drwxr-xr-x 3 postgres postgres 16 10月 18 20:27 postgresql
drwxrwxrwx 6 1107 1107 4096 10月 18 20:20 postgresql-12.11
-rw-r--r-- 1 root root 27583446 10月 18 20:19 postgresql-12.11.tar.gz
-rw-r--r-- 1 root root 14079993 10月 18 20:32 postgresql12-arm-glibc-2.28.tar.gz
[root@host12-arm u01]#