ZABBIX6.0+TSDB+psql+grafana出图+微信报警使用时序数据库(基于ubtun20.04)

环境:

ubtun20.04+ zabbix6.05

postgresql-14 + timescaledb-2-postgresql-14

 配置文件位置

pspl 远程连接配置文件:

vim /etc/postgresql/14/main/pg_hba.conf

psql主配置文件:

vim /etc/postgresql/14/main/postgresql.conf

zabbix后端日志目录

后端日志查看目录:cat /var/log/zabbix/zabbix_server.log 

前端日志查看目录:

TSDB官网配置:https://www.zabbix.com/documentation/current/zh/manual/appendix/install/timescaledb

1. 安装配置pgsql

 1.创建文件库配置 / Create the file repository configuration:
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
 
2.导入仓库签名密钥(GPG 密钥) / Import the repository signing key:
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
 
3.更新套餐列表 / Update the package lists:
sudo apt update

注:此处要给执行权限
root@gegewu1:/etc/apt/sources.list.d# ls
docker.list  docker.list.save  pgdg.list  zabbix.list  zabbix.list.dpkg-old
root@gegewu1:/etc/apt/sources.list.d# chmod a+x pgdg.list 
root@gegewu1:/etc/apt/sources.list.d# ls
docker.list  docker.list.save  pgdg.list  zabbix.list  zabbix.list.dpkg-old

否则会提示网络不可达......
 
4.安装最新版本的 PostgreSQL / Install the latest version of PostgreSQL.
# 如果您想要特定的版本,请使用‘PostgreSQL-12’或类似版本代替‘PostgreSQL’ / If you want a specific version, use 'postgresql-12' or similar instead of 'postgresql':
sudo apt -y install postgresql

显示绑定依赖关系就是源有问题换源即可。
推荐换源:中科大
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse

(1)备份原镜像源文件:mv /etc/apt/sources.list /etc/apt/sources.list.bak;
(2)创建编辑/etc/apt/sources.list新文件: sudo vim /etc/apt/sources.list ;
(3)选择上面任一镜像源地址粘贴,保存退出

2. 安装详情:

oot@gegewu1:/etc/apt# sudo apt -y install postgresql
正在读取软件包列表... 完成
正在分析软件包的依赖关系树       
正在读取状态信息... 完成       
将会同时安装下列软件:
  libffi6 libjson-perl libllvm10 libpq5 libtinfo5 pgdg-keyring postgresql-14 postgresql-client-14 postgresql-client-common postgresql-common sysstat
建议安装:
  postgresql-doc postgresql-doc-14 isag
推荐安装:
  libjson-xs-perl
下列【新】软件包将被安装:
  libffi6 libjson-perl libllvm10 libpq5 libtinfo5 pgdg-keyring postgresql postgresql-14 postgresql-client-14 postgresql-client-common postgresql-common
  sysstat
升级了 0 个软件包,新安装了 12 个软件包,要卸载 0 个软件包,有 3 个软件包未被升级。
需要下载 33.8 MB 的归档。
解压缩后会消耗 137 MB 的额外空间。
获取:1 https://mirrors.ustc.edu.cn/ubuntu bionic-updates/main amd64 libtinfo5 amd64 6.1-1ubuntu1.18.04 [80.3 kB]
获取:2 https://mirrors.ustc.edu.cn/ubuntu bionic/main amd64 libffi6 amd64 3.2.1-8 [17.9 kB]
获取:3 https://mirrors.ustc.edu.cn/ubuntu bionic/universe amd64 libjson-perl all 2.97001-1 [73.3 kB]
获取:4 https://mirrors.ustc.edu.cn/ubuntu bionic-updates/main amd64 libllvm10 amd64 1:10.0.0-4ubuntu1~18.04.2 [15.4 MB]
获取:5 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 libpq5 amd64 14.3-1.pgdg20.04+1 [171 kB]
获取:6 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 pgdg-keyring all 2018.2 [10.7 kB]
获取:7 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 postgresql-client-common all 241.pgdg20.04+1 [92.1 kB]
获取:8 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 postgresql-client-14 amd64 14.3-1.pgdg20.04+1 [1,621 kB]
获取:9 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 postgresql-common all 241.pgdg20.04+1 [230 kB]
获取:10 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 postgresql-14 amd64 14.3-1.pgdg20.04+1 [15.8 MB]
获取:11 http://apt.postgresql.org/pub/repos/apt focal-pgdg/main amd64 postgresql all 14+241.pgdg20.04+1 [66.7 kB]                                         
获取:12 https://mirrors.ustc.edu.cn/ubuntu bionic-updates/main amd64 sysstat amd64 11.6.1-1ubuntu0.1 [295 kB]                                             
已下载 33.8 MB,耗时 16秒 (2,051 kB/s)                                                                                                                    
正在预设定软件包 ...
正在选中未选择的软件包 libtinfo5:amd64。
(正在读取数据库 ... 系统当前共安装有 78940 个文件和目录。)
准备解压 .../00-libtinfo5_6.1-1ubuntu1.18.04_amd64.deb  ...
正在解压 libtinfo5:amd64 (6.1-1ubuntu1.18.04) ...
正在选中未选择的软件包 libffi6:amd64。
准备解压 .../01-libffi6_3.2.1-8_amd64.deb  ...
正在解压 libffi6:amd64 (3.2.1-8) ...
正在选中未选择的软件包 libjson-perl。
准备解压 .../02-libjson-perl_2.97001-1_all.deb  ...
正在解压 libjson-perl (2.97001-1) ...
正在选中未选择的软件包 libllvm10:amd64。
准备解压 .../03-libllvm10_1%3a10.0.0-4ubuntu1~18.04.2_amd64.deb  ...
正在解压 libllvm10:amd64 (1:10.0.0-4ubuntu1~18.04.2) ...
正在选中未选择的软件包 libpq5:amd64。
准备解压 .../04-libpq5_14.3-1.pgdg20.04+1_amd64.deb  ...
正在解压 libpq5:amd64 (14.3-1.pgdg20.04+1) ...
正在选中未选择的软件包 pgdg-keyring。
准备解压 .../05-pgdg-keyring_2018.2_all.deb  ...
正在解压 pgdg-keyring (2018.2) ...
正在选中未选择的软件包 postgresql-client-common。
准备解压 .../06-postgresql-client-common_241.pgdg20.04+1_all.deb  ...
正在解压 postgresql-client-common (241.pgdg20.04+1) ...
正在选中未选择的软件包 postgresql-client-14。
准备解压 .../07-postgresql-client-14_14.3-1.pgdg20.04+1_amd64.deb  ...
正在解压 postgresql-client-14 (14.3-1.pgdg20.04+1) ...
正在选中未选择的软件包 postgresql-common。
准备解压 .../08-postgresql-common_241.pgdg20.04+1_all.deb  ...
正在添加 通过 postgresql-common 从 /usr/bin/pg_config 到 /usr/bin/pg_config.libpq-dev 的转移
正在解压 postgresql-common (241.pgdg20.04+1) ...
正在选中未选择的软件包 postgresql-14。
准备解压 .../09-postgresql-14_14.3-1.pgdg20.04+1_amd64.deb  ...
正在解压 postgresql-14 (14.3-1.pgdg20.04+1) ...
正在选中未选择的软件包 postgresql。
准备解压 .../10-postgresql_14+241.pgdg20.04+1_all.deb  ...
正在解压 postgresql (14+241.pgdg20.04+1) ...
正在选中未选择的软件包 sysstat。
准备解压 .../11-sysstat_11.6.1-1ubuntu0.1_amd64.deb  ...
正在解压 sysstat (11.6.1-1ubuntu0.1) ...
正在设置 pgdg-keyring (2018.2) ...
Removing apt.postgresql.org key from trusted.gpg: OK
正在设置 libpq5:amd64 (14.3-1.pgdg20.04+1) ...
正在设置 libffi6:amd64 (3.2.1-8) ...
正在设置 libjson-perl (2.97001-1) ...
正在设置 libtinfo5:amd64 (6.1-1ubuntu1.18.04) ...
正在设置 sysstat (11.6.1-1ubuntu0.1) ...

Creating config file /etc/default/sysstat with new version
update-alternatives: 使用 /usr/bin/sar.sysstat 来在自动模式中提供 /usr/bin/sar (sar)
Created symlink /etc/systemd/system/multi-user.target.wants/sysstat.service → /lib/systemd/system/sysstat.service.
正在设置 postgresql-client-common (241.pgdg20.04+1) ...
正在设置 postgresql-client-14 (14.3-1.pgdg20.04+1) ...
update-alternatives: 使用 /usr/share/postgresql/14/man/man1/psql.1.gz 来在自动模式中提供 /usr/share/man/man1/psql.1.gz (psql.1.gz)
正在设置 libllvm10:amd64 (1:10.0.0-4ubuntu1~18.04.2) ...
正在设置 postgresql-common (241.pgdg20.04+1) ...
Adding user postgres to group ssl-cert

Creating config file /etc/postgresql-common/createcluster.conf with new version
Building PostgreSQL dictionaries from installed myspell/hunspell packages...
Removing obsolete dictionary files:
Created symlink /etc/systemd/system/multi-user.target.wants/postgresql.service → /lib/systemd/system/postgresql.service.
正在设置 postgresql-14 (14.3-1.pgdg20.04+1) ...
Creating new PostgreSQL cluster 14/main ...
/usr/lib/postgresql/14/bin/initdb -D /var/lib/postgresql/14/main --auth-local peer --auth-host scram-sha-256 --no-instructions
属于此数据库系统的文件宿主为用户 "postgres".
此用户也必须为服务器进程的宿主.
数据库簇将使用本地化语言 "en_US.UTF-8"进行初始化.
默认的数据库编码已经相应的设置为 "UTF8".
缺省的文本搜索配置将会被设置到"english"

禁止为数据页生成校验和.

修复已存在目录 /var/lib/postgresql/14/main 的权限 ... 成功
正在创建子目录 ... 成功
选择动态共享内存实现 ......posix
选择默认最大联接数 (max_connections) ... 100
选择默认共享缓冲区大小 (shared_buffers) ... 128MB
选择默认时区 ... Asia/Shanghai
创建配置文件 ... 成功
正在运行自举脚本 ...成功
正在执行自举后初始化 ...成功
同步数据到磁盘...成功
update-alternatives: 使用 /usr/share/postgresql/14/man/man1/postmaster.1.gz 来在自动模式中提供 /usr/share/man/man1/postmaster.1.gz (postmaster.1.gz)
正在设置 postgresql (14+241.pgdg20.04+1) ...
正在处理用于 systemd (245.4-4ubuntu3.11) 的触发器 ...
正在处理用于 man-db (2.9.1-1) 的触发器 ...
正在处理用于 libc-bin (2.31-0ubuntu9.2) 的触发器 ...

 3. 安装方式2

通过 Ubuntu 存储库安装 PostgreSQL

在 shell 终端中采用如下命令安装: 

  1. sudo apt show postgresql  查看版本

 

1. sudo apt update
2. sudo apt install postgresql postgresql-contrib
 根据提示输入你的密码,依据于你的网速情况,程序将在几秒到几分钟安装完成。说到这一点,随时检查 Ubuntu 中的各种网络带宽。

什么是 postgresql-contrib ?

postgresql-contrib 或者说 contrib 包,包含一些不属于 PostgreSQL 核心包的实用工具和功能。在大多数情况下,最好将 contrib 包与 PostgreSQL 核心一起安装。

或者
1.查看 ubuntu提供的 PostgreSQL 版本:apt-cache show postgresql
2.安装:sudo apt-get install postgresql
3.或者: sudo apt install postgresql postgresql-contrib

验证安装:sudo -u postgres psql -c "SELECT version();"

一旦安装完成, PostgreSQL 服务将会自动启动。使用 psql工具通过连接 PostgreSQL 数据库并且打印它的版本来验证安装

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值