【KylinV10 +Arm 环境源码编译安装postgres12.11】上

KylinV10 环境源码编译安装postgres12.11-上

操作系统CPUGlibc
麒麟V10鲲鹏9202.28

1、前置:编译安装操作已完成

可参考上一篇 《CentOS7.9源码编译安装postgres12.11》

[root@host12-arm postgresql-12.11]# ll
总用量 1240
-rw-r--r--  1 1107 1107    445  510  2022 aclocal.m4
drwxrwxrwx  2 1107 1107   4096  510  2022 config
-rw-r--r--  1 root root 435230 1018 20:20 config.log
-rwxr-xr-x  1 root root  40143 1018 20:20 config.status
-rwxr-xr-x  1 1107 1107 581932  510  2022 configure
-rw-r--r--  1 1107 1107  86602  510  2022 configure.in
drwxrwxrwx 56 1107 1107   4096  510  2022 contrib
-rw-r--r--  1 1107 1107   1192  510  2022 COPYRIGHT
drwxrwxrwx  3 1107 1107     87  510  2022 doc
-rw-r--r--  1 root root   4284 1018 20:20 GNUmakefile
-rw-r--r--  1 1107 1107   4284  510  2022 GNUmakefile.in
-rw-r--r--  1 1107 1107    284  510  2022 HISTORY
-rw-r--r--  1 1107 1107  62466  510  2022 INSTALL
-rw-r--r--  1 1107 1107   1665  510  2022 Makefile
-rw-r--r--  1 1107 1107   1212  510  2022 README
drwxrwxrwx 16 1107 1107   4096 1018 20:20 src
[root@host12-arm postgresql-12.11]# cd ../
[root@host12-arm u01]# ll
总用量 26944
drwxr-xr-x  3 root  root        16 1018 20:27 postgresql
drwxrwxrwx  6  1107  1107     4096 1018 20:20 postgresql-12.11
-rw-r--r--  1 root  root  27583446 1018 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 1018 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 1018 20:27 postgresql
drwxrwxrwx  6     1107     1107     4096 1018 20:20 postgresql-12.11
-rw-r--r--  1 root     root     27583446 1018 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 1018 20:27 postgresql
drwxrwxrwx  6     1107     1107     4096 1018 20:20 postgresql-12.11
-rw-r--r--  1 root     root     27583446 1018 20:19 postgresql-12.11.tar.gz
-rw-r--r--  1 root     root     14079993 1018 20:32 postgresql12-arm-glibc-2.28.tar.gz
[root@host12-arm u01]# 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值