EnterpriseDB: 无人值守安装

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

内容简介:上篇博客介绍了EDB 交互式命令行安装方式,EDB同时支持无人值守安装,极大提升了部署效率。EDB 的无人值守安装是通过预先定义安装配置文件实现的,本文简单演示下。创建配置文件如下

上篇博客介绍了EDB 交互式命令行安装方式,EDB同时支持无人值守安装,极大提升了部署效率。

EDB 的无人值守安装是通过预先定义安装配置文件实现的,本文简单演示下。

定义安装配置文件

创建配置文件如下

touch /opt/edb/config_edb.conf

给配置文件 /opt/edb/config_edb.conf 加入以下内容:

mode=unattended
superpassword=xxxxxx
prefix=/opt/edb
datadir=/opt/edb/data
serverport=5444

参数解释如下:

  • mode: 指定 unattended 模式,表示无人值守安装模式。
  • superpassword: 设置数据库超级用户密码,默认密码为 enterprisedb。
  • prefix: 设置EDB的软件安装目录。
  • datadir: 设置EDB的数据文件目录,对应的环境变量为$PGDATA。
  • serverport: 设置EDB的监听端口号,默认为5444。

其它参数根据需要设置。

无人值守安装 EDB

执行安装脚本 edb-as10-server-10.5.12-1-linux-x64.run ,并使用 optionfile 指定安装配置文件,如下:

[root@pghost6 soft_bak]# ./edb-as10-server-10.5.12-1-linux-x64.run --optionfile /opt/edb/config_edb.conf

无人值守安装无输出结果,验证EDB是否已安装成功。

查看EDB安装文件,如下:

[root@pghost6 edb]# ll /opt/edb
total 8200
drwxr-xr-x  3 root         root              18 Jan 16 10:07 as10
drwxr-xr-x  2 root         daemon          4096 Jan 16 10:07 bin
-rw-r--r--  1 root         root              97 Jan 16 10:06 config_edb.conf
drwx------ 20 enterprisedb enterprisedb    4096 Jan 16 10:07 data
drwxr-xr-x  4 root         daemon            38 Jan 16 10:06 doc
-rw-r--r--  1 root         daemon         72341 Aug 17 14:09 edb-as10-server_commandlinetools_3rd_party_licenses.txt
-r--r--r--  1 root         daemon         15216 Aug 17 14:09 edb-as10-server_license.txt
drwxr-xr-x  3 root         daemon            23 Jan 16 10:06 etc
drwxr-xr-x  6 root         daemon          4096 Jan 16 10:06 include
-rw-r--r--  1 root         root             612 Jan 16 10:07 installation_summary.log
drwxr-xr-x  5 root         daemon            55 Jan 16 10:06 installer
drwxr-xr-x  4 root         daemon          8192 Jan 16 10:07 lib
drwxr-xr-x 10 root         daemon           164 Jan 16 10:06 pgAdmin4
-rwxr-xr-x  1 root         daemon           915 Jan 16 10:07 pgplus_env.sh
drwxr-xr-x  5 root         daemon            73 Jan 16 10:06 scripts
drwxr-xr-x 10 root         daemon          4096 Jan 16 10:06 share
drwxr-xr-x  7 root         daemon           136 Jan 16 10:06 stackbuilderplus
-rwx------  1 root         daemon       8118363 Jan 16 10:07 uninstall-edb-as10-server
-rw-------  1 root         root          141150 Jan 16 10:07 uninstall-edb-as10-server.dat

目录的权限为root,权限需要调整(安装过程中默认创建了 enterprisedb 操作系统用户)

[root@pghost6 ~]# chown -R enterprisedb:enterprisedb /opt/edb

查看EDB数据库进程,如下:

[root@pghost6 soft_bak]# ps -ef | grep post
root      1232     1  0  2018 ?        00:00:18 /usr/libexec/postfix/master -w
postfix   1240  1232  0  2018 ?        00:00:04 qmgr -l -t unix -u
postfix   6373  1232  0 08:37 ?        00:00:00 pickup -l -t unix -u
enterpr+ 12677     1  0 10:07 ?        00:00:00 /opt/edb/bin/edb-postgres -D /opt/edb/data
enterpr+ 12678 12677  0 10:07 ?        00:00:00 postgres: logger process
enterpr+ 12680 12677  0 10:07 ?        00:00:00 postgres: checkpointer process
enterpr+ 12681 12677  0 10:07 ?        00:00:00 postgres: writer process
enterpr+ 12682 12677  0 10:07 ?        00:00:00 postgres: wal writer process
enterpr+ 12683 12677  0 10:07 ?        00:00:00 postgres: autovacuum launcher process
enterpr+ 12684 12677  0 10:07 ?        00:00:00 postgres: stats collector process
enterpr+ 12685 12677  0 10:07 ?        00:00:00 postgres: bgworker: dbms_aq launcher
enterpr+ 12686 12677  0 10:07 ?        00:00:00 postgres: bgworker: logical replication launcher
enterpr+ 12698 12677  0 10:07 ?        00:00:00 postgres: bgworker: dbms_aq worker[postgres]   idle
enterpr+ 12704 12677  0 10:07 ?        00:00:00 postgres: bgworker: dbms_aq worker[edb]   idle
root     12713 22990  0 10:07 pts/0    00:00:00 grep --color=auto post

说明 EDB 已安装并且数据库已启动。

设置环境变量

安装完成后自动生成环境变量文件 /opt/edb/pgplus_env.sh , 脚本内容如下:

# EnterpriseDB shell environment loader
#
#  Instructions:
#   This file contains additions to the user environment
#  that make accessing EDB Postgres Advanced Server
#  executables easier.
#
#  To load the environment for a single user:
#     cp pgplus_env.sh /home/<username>
#     chown <username> /home/<username>/pgplus_env.sh
#     vi /home/<username>/.bash_profile
#      At the bottom, add the line:
#       . /home/<username>/pgplus_env.sh
#          ( Note the '.' followed by a space )

#  To load the environment for all users:
#     cp pgplus_env.sh /etc
#     vi /etc/profile
#     At the bottom, add the line:
#       . /etc/pgplus_env.sh
#        ( Note the '.' followed by a space )

# Environment

export PATH=/opt/edb/bin:$PATH
export EDBHOME=/opt/edb
export PGDATA=/opt/edb/data
export PGDATABASE=edb
# export PGUSER=enterprisedb
export PGPORT=5444
export PGLOCALEDIR=/opt/edb/share/locale

将整个文件内容或尾部的环境变量加到系统用户 enterprisedb 环境变量文件 .bash_profile 中,如下:

[root@pghost6 ~]# su - enterprisedb
Last login: Tue Jan 15 11:00:16 CST 2019 on pts/1

-bash-4.2$  cp /opt/edb/pgplus_env.sh /opt/edb/.bash_profile

登录EDB验证

登录 EDB 数据库,如下:

-bash-4.2$ psql -h 127.0.0.1 -p 5444 edb enterprisedb
Password for user enterprisedb:
psql.bin (10.5.12)
Type "help" for help.

edb=# \l
                                           List of databases
   Name    |    Owner     | Encoding |   Collate   |    Ctype    | ICU |       Access privileges
-----------+--------------+----------+-------------+-------------+-----+-------------------------------
 edb       | enterprisedb | UTF8     | en_US.UTF-8 | en_US.UTF-8 |     |
 postgres  | enterprisedb | UTF8     | en_US.UTF-8 | en_US.UTF-8 |     |
 template0 | enterprisedb | UTF8     | en_US.UTF-8 | en_US.UTF-8 |     | =c/enterprisedb              +
           |              |          |             |             |     | enterprisedb=CTc/enterprisedb
 template1 | enterprisedb | UTF8     | en_US.UTF-8 | en_US.UTF-8 |     | =c/enterprisedb              +
           |              |          |             |             |     | enterprisedb=CTc/enterprisedb
(4 rows)

edb=# SELECT version();
                                                   version
--------------------------------------------------------------------------------------------------------------
 EnterpriseDB 10.5.12 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18), 64-bit
(1 row)

参考


以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持 码农网

查看所有标签

猜你喜欢:

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

可伸缩架构

可伸缩架构

【美】Lee Atchison / 张若飞、张现双 / 电子工业出版社 / 2017-7 / 65

随着互联网的发展越来越成熟,流量和数据量飞速增长,许多公司的关键应用程序都面临着伸缩性的问题,系统变得越来越复杂和脆弱,从而导致风险上升、可用性降低。《可伸缩架构:面向增长应用的高可用》是一本实践指南,让IT、DevOps和系统稳定性管理员能够了解到,如何避免应用程序在发展过程中变得缓慢、数据不一致或者彻底不可用等问题。规模增长并不只意味着处理更多的用户,还包括管理更多的风险和保证系统的可用性。作......一起来看看 《可伸缩架构》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具