How to run PostgreSQL 11 in Linux on ARM

栏目: 数据库 · 发布时间: 5年前

内容简介:我们选择的系统是一个运行在AArch64芯片架构上的CentOS 7.5。这台服务器拥有8颗ARMv8(Huawei Kunpeng 916 2.4GHz)的芯片,和29GB的内存,并不是很大的机器。这台服务器有两块磁盘,一块是系统盘vda,一块是超高IO的数据盘vdb。vdb还没有创建文件系统,自然也没有挂载点。

我们选择的系统是一个运行在AArch64芯片架构上的CentOS 7.5。

[root@ecs-arm-0005 ~]# uname -a
Linux ecs-arm-0005 4.14.0-49.el7a.aarch64 #1 SMP Tue Apr 10 17:22:26 UTC 2018 aarch64 aarch64 aarch64 GNU/Linux

[root@ecs-arm-0005 ~]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (AltArch)

这台服务器拥有8颗ARMv8(Huawei Kunpeng 916 2.4GHz)的芯片,和29GB的内存,并不是很大的机器。

[root@ecs-arm-0005 ~]# cat /proc/cpuinfo | grep processor|wc -l
8

[root@ecs-arm-0005 ~]# cat /proc/meminfo | grep MemTotal
MemTotal:       29756224 kB

这台服务器有两块磁盘,一块是系统盘vda,一块是超高IO的数据盘vdb。vdb还没有创建文件系统,自然也没有挂载点。

[root@ecs-arm-0005 ~]# lsblk
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vdb    253:16   0  100G  0 disk
vda    253:0    0   40G  0 disk
├─vda2 253:2    0 39.8G  0 part /
└─vda1 253:1    0  244M  0 part /boot/efi

将vdb格式化为ext4格式的文件系统,挂载到/data目录中。作为后续Pg数据库的数据文件存储位置。

[root@ecs-arm-0005 ~]# mkfs -t ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
    32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
    4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done
Writing inode tables: done

[root@ecs-arm-0005 ~]# mkdir /data
[root@ecs-arm-0005 ~]# mount /dev/vdb /data
[root@ecs-arm-0005 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs         15G     0   15G   0% /dev
tmpfs            15G     0   15G   0% /dev/shm
tmpfs            15G   22M   15G   1% /run
tmpfs            15G     0   15G   0% /sys/fs/cgroup
/dev/vda2        40G  1.6G   36G   5% /
/dev/vda1       244M  8.6M  236M   4% /boot/efi
tmpfs           2.9G     0  2.9G   0% /run/user/0
/dev/vdb         99G   61M   94G   1% /data

如果要保证在操作系统重新启动的时候,vdb还会自动挂载到/data目录下,还需要修改/etc/fstab文件,此处不赘述。

因为Pg for ARM的版本并没有发布实现编译好的二进制安装包(实际上也有,但是是比较古老的9.2版本),因此首先我们下载 PostgreSQL数据库最新版本11.3的源码 。通过编译源码手动安装。

如果在下述过程中发现报错: configure: error: no acceptable C compiler found in $PATH ,则表示没有安装gcc编译器,需要通过 yum install gcc gcc-c++ 命令来事先安装。

如果在下述过程中发现报错: configure: error: readline library not found ,则表示没有安装readline-devel包,需要通过 yum install readline-devel 命令来事先安装。

如果在下述过程中发现报错: configure: error: zlib library not found ,则表示没有安装zlib-devel包,需要通过 yum install zlib-devel 命令来事先安装。

从configure到make install都是标准的 Linux 下编译源码安装的步骤。如果一切正常,在第一步时不会显示任何error,在第二步最后会显示:All of PostgreSQL successfully made. Ready to install.字样。

$ ./configure
$ make
$ su
# make install

成功安装完毕以后,因为我们使用的是默认配置,因此PostgreSQL软件被安装到/usr/local/pgsql目录中。

[root@ecs-arm-0005 postgresql-11.3]# ls -l /usr/local/pgsql
total 16
drwxr-xr-x 2 root root 4096 Jun  4 16:01 bin
drwxr-xr-x 6 root root 4096 Jun  4 16:01 include
drwxr-xr-x 4 root root 4096 Jun  4 16:01 lib
drwxr-xr-x 6 root root 4096 Jun  4 16:01 share

接下来创建postgres用户,而不要使用root用户管理数据库。

# adduser postgres
# passwd postgres

之前我们在/data目录下挂载了100GB的高速IO数据盘,所以下面我们将PostgreSQL数据库的数据文件存储位置指定到/data目录下,并初始化数据库。

# mkdir /data/pgsql/data
# chown postgres /data/pgsql/data
# su - postgres
$ /usr/local/pgsql/bin/initdb -D /data/pgsql/data

初始化数据库的正常显示如下。

[postgres@ecs-arm-0005 ~]$ /usr/local/pgsql/bin/initdb -D /data/pgsql/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 /data/pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
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:

    /usr/local/pgsql/bin/pg_ctl -D /data/pgsql/data -l logfile start

数据库初始化结束以后显示的最后一条命令,告知了如果要启动数据库应该使用的命令。

[postgres@ecs-arm-0005 ~]$ /usr/local/pgsql/bin/pg_ctl -D /data/pgsql/data -l logfile start
waiting for server to start.... done
server started

至此,PostgreSQL 11.3在CentOS 7.5 on ARM上的安装和运行宣告完成。

[postgres@ecs-arm-0005 ~]$ psql
psql (11.3)
Type "help" for help.

postgres=# \db
       List of tablespaces
    Name    |  Owner   | Location
------------+----------+----------
 pg_default | postgres |
 pg_global  | postgres |
(2 rows)

以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

奈飞文化手册

奈飞文化手册

[美] 帕蒂·麦考德 / 范珂 / 浙江教育出版社 / 2018-10-1 / 69

一本对奈飞文化进行深入解读的力作。2009年,奈飞公开发布了一份介绍企业文化的PPT文件,在网上累计下载量超过1500万次,被Facebook的CFO谢丽尔·桑德伯格称为“硅谷重要文件”。本书是奈飞前CHO,PPT的主要创作者之一帕蒂·麦考德对这份PPT文件的深度解读。 本书系统介绍奈飞文化准则,全面颠覆20世纪的管人理念。在这本书中,帕蒂·麦考德归纳出8条奈飞文化准则,从多个角度揭示了奈飞......一起来看看 《奈飞文化手册》 这本书的介绍吧!

Base64 编码/解码
Base64 编码/解码

Base64 编码/解码

html转js在线工具
html转js在线工具

html转js在线工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具