加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

AVAYA AEP运维之PostgreSQL数据库相关

发布时间:2020-12-13 17:07:04 所属栏目:百科 来源:网络整理
导读:由于AEP EPM所有相关的报表数据(应用运行日志,呼叫清单,会话清单),配置信息等都存在本地PostgreSQL上,了解PostgreSQL的相关基本使用方法,有助于日常运维能力的提升。本篇主要总结如何开启本地登陆,开启远端登陆,基本命令,数据备份和清理。 如何开

由于AEP EPM所有相关的报表数据(应用运行日志,呼叫清单,会话清单),配置信息等都存在本地PostgreSQL上,了解PostgreSQL的相关基本使用方法,有助于日常运维能力的提升。本篇主要总结如何开启本地登陆,开启远端登陆,基本命令,数据备份和清理。

  • 如何开启本地和远端登陆

在EPM安装的过程中,会把PostgreSQL也一并安装掉,过程中会提示输入用户名postgres的密码,以及创建一个报表用户。当时当你本地使用PostgreSQL去登陆数据库时,始终登陆不上;通过PostgreSQL客户端也始终登陆不上,需要进行如下操作来开启本地和远端登陆。

[root@vp142VP-Tools]#su-postgres
-bash-4.1$ls
9.0datapgstartup.logSQLscripts
-bash-4.1$cddata/
-bash-4.1$vipg_hba.conf//找到如下部分,修改第一条记录(运行本地登陆)以及新增一条记录(运行远端登陆,记得先备份该配置文件)

wKioL1cd1qqD1Sd-AADRaBNkM5s660.jpg

改完后:wq保存,然后重启PostgreSQL服务。

-bash-4.1$exit
logout
[root@vp142VP-Tools]#servicepostgresqlrestart


  • 本地和远端登陆验证

[root@vp142VP-Tools]#psql-h127.0.0.1-Upostgres-dVoicePortal
Passwordforuserpostgres:
psql(9.0.15)
Type"help"forhelp.

VoicePortal=#//本地登陆成功

远端登陆:下载PostgreSQL客户端,配置

wKiom1cd2IDR_lQEAABctO_taDo748.jpg

登陆成功:

wKioL1cd2UjAFC2hAADLYhEcnLs896.jpg

  • PostgreSQL 常用命令

VoicePortal-#l//输出所有数据库
Listofdatabases
Name|Owner|Encoding|Collation|Ctype|Accessprivil
eges
-------------+----------+----------+-------------+-------------+----------------
-------
VoicePortal|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|
postgres|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|
template0|postgres|UTF8|en_US.UTF-8|en_US.UTF-8|=c/postgres
VoicePortal-#cpostgres//切换到postgres库
Youarenowconnectedtodatabase"postgres".
postgres-#
VoicePortal-#d//显示当前库有哪些表
Listofrelations
Schema|Name|Type|Owner
--------+-------------------------------+----------+----------
public|alarmcode|table|postgres
public|alarmcodelistenerlink|table|postgres
public|alarmcodelistenerlinkdefault|table|postgres
public|alarmhistory|table|postgres
public|alarmlistener|table|postgres
public|alarmnotify|table|postgres
。。。。。。
VoicePortal-#dcdr//查看cdr表的结构
Table"public.cdr"
Column|Type|Modifi
ers
--------------------+-----------------------------+-----------------------------
---------------------------
calltimestamp|timestampwithouttimezone|
recordid|integer|
sessionid|charactervarying|
callid|charactervarying|
ucid|charactervarying|
portid|integer|

创建数据库:
createdatabase[数据库名];
删除数据库:
dropdatabase[数据库名];
*重命名一个表:
altertable[表名A]renameto[表名B];
*删除一个表:
droptable[表名];
*在已有的表里添加字段:
altertable[表名]addcolumn[字段名][类型];
*删除表中的字段:
altertable[表名]dropcolumn[字段名];
*重命名一个字段:
altertable[表名]renamecolumn[字段名A]to[字段名B];
*给一个字段设置缺省值:
altertable[表名]altercolumn[字段名]setdefault[新的默认值];
*去除缺省值:
altertable[表名]altercolumn[字段名]dropdefault;
在表中插入数据:
insertinto表名([字段名m],[字段名n],......)values([列m的值],[列n的值],......);
修改表中的某行某列的数据:
update[表名]set[目标字段名]=[目标值]where[该行特征];
删除表中某行数据:
deletefrom[表名]where[该行特征];
deletefrom[表名];--删空整个表
创建表:
createtable([字段名1][类型1];,[字段名2][类型2],......<,primarykey(字段名m,字段名n,...)>;);
copyright显示PostgreSQL的使用和发行条款
encoding[字元编码名称]
显示或设定用户端字元编码
h[名称]SQL命令语法上的说明,用*显示全部命令
prompt[文本]名称
提示用户设定内部变数
password[USERNAME]
securelychangethepasswordforauser
q退出psql


  • 数据库备份与恢复

PostgreSQL数据备份:
[root@vp142VP-Tools]#pg_dump-UpostgresVoicePortal>/cpic/craft/postgresdata
.20160425.sql
Password://输入完密码后,等待备份完毕。
[root@vp142VP-Tools]#ll/cpic/craft/postgresdata.20160425.sql//查看备份文件
-rw-r--r--1rootroot4007564Apr2516:57/cpic/craft/postgresdata.20160425.sql

PostgreSQL数据恢复:
先清空数据库:
[root@vp142VP-Tools]#bashPurgeReportDataLocalDB

Doyouwishtopurgeallyourreportdata?

Pressentertocontinue,orpresscontrol-Ctoabortthisutility

PurgingSDRtable...
PurgingCDRtable...
PurgingVPAppLogtable...
PurgingVPPerformancetable...
Purgingcompleted!
-----------------------------------------------------
开始恢复数据:
[root@vp142VP-Tools]#psql-UpostgresVoicePortal</cpic/craft/postgresdata.20160425.sql
Passwordforuserpostgres:
lowrite
---------
535
(1row)

lo_close
----------
0
(1row)

COMMIT
。。。。。。

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读