中标麒麟7,ARM aarch64 源码安装postgresql

中标麒麟7,ARM aarch64源码安装postgresql

准备阶段

查看操作系统

[root@xc-v-ct-shjy-xqjy-db-06 init.d]# uname -a
Linux xc-v-ct-shjy-xqjy-db-06.novalocal 4.14.0-115.26.1.el7a.02.aarch64 #1 SMP Sat Jan 23 23:59:23 CST 2021 aarch64 aarch64 aarch64 GNU/Linux

下载postgresql源码
选择需要的版本下载,并上传到服务器(本篇选择11.14),使用其他版本操作流程一样
在这里插入图片描述
解压源码文件到指定目录

[root@xc-v-ct-shjy-xqjy-db-06 /]# tar -zxvf postgresql-11.14.tar.gz /datahome/

安装编译运行需要的组件

[root@xc-v-ct-shjy-xqjy-db-06 /]# yum install gcc gcc-c++ -y 
[root@xc-v-ct-shjy-xqjy-db-06 /]# yum install readline-devel -y

编译源码安装

检测配置

[root@xc-v-ct-shjy-xqjy-db-06 /]# cd /datahome/postgresql-11.14
[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# ./configure

在这里插入图片描述

编译安装

[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# make & make install

在这里插入图片描述
创建用户,并且修改默认安装目录的权限

[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# useradd postgres
[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# chown -R postgres:postgres /usr/local/pgsql/

配置环境变量

[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# vim /etc/profile
		# 最下面增加
		export PATH=/usr/local/pgsql/bin:$PATH
		export LD_LIBRARY_PATH=/usr/local/pgsql/lib:$LD_LIBRARY_PATH

创建数据目录,并赋予权限

[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# mkdir /datahome/postgresql11/data
[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# chown postgres /datahome/postgresql11/data/
[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# chgrp postgres /datahome/postgresql11/data/

切换用户初始化数据库

[postgres@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# su postgres
[postgres@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# /usr/local/pgsql/bin/initdb -D /datahome/postgresql-11/data/

切换用户修改配置

[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# vim /datahome/postgresql-11/data/pg_hba.conf

在这里插入图片描述

[root@xc-v-ct-shjy-xqjy-db-06 postgresql-11.14]# vim /datahome/postgresql-11/data/postgresql.conf

在这里插入图片描述
创建系统服务,并开启启动

[root@xc-v-ct-shjy-xqjy-db-06 ~]# cd /datahome/postgresql-11.14/contrib/start-scripts/
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# ll
total 8
-rw-r--r-- 1 1107 1107 1467 Nov  9  2021 freebsd
-rwxr-xr-x 1 1107 1107 3552 Nov  9  2021 linux
drwxrwxrwx 2 1107 1107   84 Nov  9  2021 macos
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# chmod a+x linux
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# cp linux /etc/init.d/postgresql
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# vi /etc/init.d/postgresql
		# Installation prefix
		prefix=/usr/local/pgsql # 安装目录,默认是/usr/local/pgsql 

		# Data directory
		PGDATA="/datahome/postgresql-11/data" # 数据库初始化目录,本篇是/datahome/postgresql-11/data

		# Who to run the postmaster as, usually "postgres".  (NOT "root")
		PGUSER=postgres

		# Where to keep a log file
		PGLOG="$PGDATA/serverlog"

		# It's often a good idea to protect the postmaster from being killed by the
		# OOM killer (which will tend to preferentially kill the postmaster because
		# of the way it accounts for shared memory).  To do that, uncomment these
		# three lines:
		#PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
		#PG_MASTER_OOM_SCORE_ADJ=-1000
		#PG_CHILD_OOM_SCORE_ADJ=0
		# Older Linux kernels may not have /proc/self/oom_score_adj, but instead
		# /proc/self/oom_adj, which works similarly except for having a different
		# range of scores.  For such a system, uncomment these three lines instead:
		#PG_OOM_ADJUST_FILE=/proc/self/oom_adj
		#PG_MASTER_OOM_SCORE_ADJ=-17
		#PG_CHILD_OOM_SCORE_ADJ=0

在这里插入图片描述
启动服务等操作

[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# service postgresql start
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# service postgresql status
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# service postgresql restart
[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# service postgresql stop

设置开机启动

[root@xc-v-ct-shjy-xqjy-db-06 start-scripts]# chkconfig --add postgresql
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值