如何将HGDB安全版(RPM包形式)安装在非root用户下

文章目录

环境

系统平台:中标麒麟(海光)7

版本:4.3.4.6

文档用途

本文以自建系统用户highgo为例,介绍如何将HGDB安装于非root用户下。

详细信息

1、创建highgo用户及用户组

sql 复制代码
[root@localhost opt]# groupadd -g 5866 highgo                        
[root@localhost opt]# useradd -u 5866 -g highgo highgo            
[root@localhost opt]# passwd highgo                                          
Changing password for user highgo.

2、在root用户下安装HGDB

sql 复制代码
[root@localhost opt]# rpm -ivh hgdb4.3.4.6-see-nkyl7-hygon-64-20190808.rpm
Preparing...                          ################################# [100%]
Updating / installing...
   1:highgodb-4.3.4.6-1.el7           ################################# [100%]
2020-02-12 11:13:21.174 CST [39010] LOG:  data encryption performed by pgcrypto
Note: Forwarding request to 'systemctl enable hgdb-se4.3.4.6.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/hgdb-se4.3.4.6.service to /usr/lib/systemd/system/hgdb-se4.3.4.6.service.
Created symlink from /etc/systemd/system/graphical.target.wants/hgdb-se4.3.4.6.service to /usr/lib/systemd/system/hgdb-se4.3.4.6.service.
[root@localhost opt]#

3、关闭数据库服务,修改数据库目录属主

sql 复制代码
[root@localhost opt]# source ~/.bash_profile
[root@localhost opt]# pg_ctl stop -D /opt/HighGoDB-4.3.4.6/data
waiting for server to shut down.... done
server stopped
[root@localhost opt]# ll
total 172432
-rw-r--r--.  1 root root 176566496 Feb 12 11:09 hgdb4.3.4.6-see-nkyl7-hygon-64-20190808.rpm
drwxr-xr-x. 10 root root       108 Feb 12 11:13 HighGoDB-4.3.4.6
drwxr-xr-x.  2 root root         6 Aug  4  2017 rh
[root@localhost opt]# chown -R highgo:highgo HighGoDB-4.3.4.6/
[root@localhost opt]# ll
total 172432
-rw-r--r--.  1 root   root   176566496 Feb 12 11:09 hgdb4.3.4.6-see-nkyl7-hygon-64-20190808.rpm
drwxr-xr-x. 10 highgo highgo       108 Feb 12 11:13 HighGoDB-4.3.4.6
drwxr-xr-x.  2 root   root           6 Aug  4  2017 rh
[root@localhost opt]#

4、修改highgo用户下的环境变量配置文件

sql 复制代码
[root@localhost opt]# su - highgo
[highgo@localhost ~]$ vi .bashrc

增加以下内容:

sql 复制代码
export PATH
export LD_LIBRARY_PATH=/opt/HighGoDB-4.3.4.6/lib:$LD_LIBRARY_PATH
export PATH=$PATH:/opt/HighGoDB-4.3.4.6/bin
export PGHOME=/opt/HighGoDB-4.3.4.6/
export   PGUSER=highgo
export   PGPORT=5866
export PGDATA=$PGHOME/data
export   PATH=$PGHOME/bin:$PATH:$HOME/bin
export   LD_LIBRARY_PATH=$PGHOME/lib:$LD_LIBRARY_PATH

5、使配置文件生效,在highgo用户下启动数据库

sql 复制代码
[highgo@localhost ~]$ source .bashrc
[highgo@localhost ~]$ pg_ctl start
waiting for server to start....2020-02-12 11:31:22.697 CST [39141] LOG:  data encryption performed by pgcrypto
2020-02-12 11:31:22.714 CST [39141] LOG:  listening on IPv6 address "::1", port 5866
2020-02-12 11:31:22.714 CST [39141] LOG:  listening on IPv4 address "127.0.0.1", port 5866
2020-02-12 11:31:22.724 CST [39141] LOG:  listening on Unix socket "/tmp/.s.PGSQL.5866"
2020-02-12 11:31:22.818 CST [39141] LOG:  This is a trial edition, validate until 2020-03-13 11:13:18, database will not be able to start up after that time,please apply an official license by that time.
2020-02-12 11:31:22.820 CST [39141] LOG:  redirecting log output to logging collector process
2020-02-12 11:31:22.820 CST [39141] HINT:  Future log output will appear in directory "log".
 done
server started
[highgo@localhost ~]$

6、数据库自启动

数据库在安装后已经开启开机自启服务,由于数据库启动用户已经改变,需要对自启动服务文件进行修改,必须在root用户下修改。

sql 复制代码
[root@localhost ~]$ vi /usr/lib/systemd/system/hgdb-se4.3.4.6.service
[Unit]
Description=hgdb-se4.3.4.6
After=syslog.target
After=network.target
[Service]
Type=forking
User=highgo
OOMScoreAdjust=-1000
ExecStart=/opt/HighGoDB-4.3.4.6/bin/pg_ctl start -D /opt/HighGoDB-4.3.4.6/data
ExecStop=/opt/HighGoDB-4.3.4.6/etc/hgdb-se4.3.4.6 stop
ExecReload=/opt/HighGoDB-4.3.4.6/etc/hgdb-se4.3.4.6 reload
TimeoutSec=300
[Install]
WantedBy=multi-user.target graphical.target

7、状态检测

保存后重启系统,查看系统后台进程,可以看到highgo用户下已经有数据源库进程,服务启动正常

sql 复制代码
[root@localhost ~]# reboot

[root@localhost ~]# ps -ef|grep postgres
highgo     1182      1  1 11:39 ?        00:00:00 /opt/HighGoDB-4.3.4.6/bin/postgres -D /opt/HighGoDB-4.3.4.6/data
highgo     1231   1182  0 11:39 ?        00:00:00 postgres: logger process  
highgo     1238   1182  0 11:39 ?        00:00:00 postgres: checkpointer process  
highgo     1240   1182  0 11:39 ?        00:00:00 postgres: writer process  
highgo     1241   1182  0 11:39 ?        00:00:00 postgres: wal writer process  
highgo     1242   1182  0 11:39 ?        00:00:00 postgres: autovacuum launcher process  
highgo     1244   1182  0 11:39 ?        00:00:00 postgres: stats collector process  
highgo     1246   1182  0 11:39 ?        00:00:00 postgres: bgworker: logical replication launcher  
root       1679   1627  0 11:40 pts/0    00:00:00 grep --color=auto postgres
相关推荐
tianyuanwo1 分钟前
深入理解iptables:规则管理与匹配机制深度解析
网络·安全·web安全
·云扬·1 分钟前
Linux系统下MySQL服务器关键配置优化指南
linux·服务器·mysql
TG:@yunlaoda360 云老大27 分钟前
如何使用华为云国际站代理商WSA配置与架构交付中的安全策略?
网络·架构·华为云
一念一花一世界27 分钟前
降本增效,安全可控:Arbess如何加速软件发布周期
安全·cicd·arbess
同聘云31 分钟前
阿里云云服务器云备份满了可以删除吗?不小心把备份删除了怎么办
服务器·阿里云·云计算
打码人的日常分享34 分钟前
企业数据资产管控和数据治理解决方案
大数据·运维·网络·人工智能·云计算
阿华hhh35 分钟前
Linux系统编程(网络udp)
linux·服务器·c语言·网络·网络协议·udp
驱动探索者38 分钟前
[缩略语大全]之[内存管理]篇
java·网络·算法·内存管理
鹿野素材屋1 小时前
技术闲聊:为什么网游会在固定时间点,刷出固定的道具?
前端·网络·unity
TG:@yunlaoda360 云老大2 小时前
华为云国际站代理商TaurusDB的读写分离可以应用于哪些场景?
服务器·网络·数据库·华为云