当前位置: 首页 > news >正文

武汉做网站建设镇江网页设计

武汉做网站建设,镇江网页设计,做网站开发工具哪个好,网站的程序怎么做文章目录 一、时序数据库二、TimescaleDB部署1、repository yum仓库配置2、yum在线安装3、插件配置4、TimescaleDB使用登录pg创建插件使用超表 一、时序数据库 什么是时序数据库?顾名思义,用于处理按照时间变化顺序的数据的数据库即为时序数据库&#x…

文章目录

  • 一、时序数据库
  • 二、TimescaleDB部署
    • 1、repository yum仓库配置
    • 2、yum在线安装
    • 3、插件配置
    • 4、TimescaleDB使用
      • 登录pg
      • 创建插件
      • 使用超表

一、时序数据库

什么是时序数据库?顾名思义,用于处理按照时间变化顺序的数据的数据库即为时序数据库(time-series database),时序数据库专门优化处理带时间标签的数据,为什么会衍生时序数据库这一种新趋势呢?我们知道像PostgreSQL和MySQL这种关系型数据库对于短期需求不大的情况下下还是可以满足的,但是一旦数据量增长,其性能不足以支持频繁的添加和读取需求。运用时间模型来构造的应用非常需要时序数据库的加持,包括未来大数据的趋势,时序数据库必然会成为一个新潮流。

TimescaleDB简介:
对于TimescaleDB来说,在功能的丰富程度上战胜了排名更靠前的几位选手,但是对于性能上可能处于下风,因此TimescaleDB如何持续地发展下去、如何发展地更好,除了探寻在性能等综合素质方面的提升外,在PostgreSQL的肩膀上怎么样更好地适应现代化需求才是重中之重。

二、TimescaleDB部署

1、repository yum仓库配置

tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL

2、yum在线安装

# pg源码安装
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# 这里是因为我是红帽8所以安装下面这个,这里如果安装错误后边安装TimescaleDB会报错
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpmyum install epel-releaseyum repolist all | grep pgdg
yum repolist enabled | grep pgdg

在这里插入图片描述

# 更新本地存储库列表
yum update --skip-broken --nobest# 安装TimescaleDB:这里要注意安装后边要对应pg版本,这里是pg14
yum install timescaledb-2-postgresql-14# 报错内容如下
timescale_timescaledb                                                                                                                                                                                                                       132  B/s | 833  B     00:06    
Error: Problem: package timescaledb-2-postgresql-14-2.17.2-0.el8.x86_64 from timescale_timescaledb requires postgresql14-server >= 14.0, but none of the providers can be installed- cannot install the best candidate for the job- package postgresql14-server-14.0-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.1-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.10-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.10-2PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.11-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.12-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.12-3PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.13-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.13-2PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.2-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.2-4PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.3-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.4-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.5-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.6-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.7-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.8-1PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.8-2PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering- package postgresql14-server-14.9-2PGDG.rhel8.x86_64 from pgdg14 is filtered out by modular filtering
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)
原因以及解决:
在Red Hat Enterprise Linux 8上安装时,需要使用:
sudo dnf module disable postgresql
命令禁用系统中内置的PostgreSQL模块。

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3、插件配置

yum install -y postgresql14 postgresql14-server# 修改postgresql config文件,使timescaledb这个插件能正常工作,通过调优脚本来配置数据库
[root@TimescaleDB ~]# find / -name pg_config
/usr/pgsql-14/bin/pg_configsudo timescaledb-tune --pg-config=/usr/pgsql-14/bin/pg_config
报错:
[root@TimescaleDB ~]# sudo timescaledb-tune --pg-config=/usr/pgsql-14/bin/pg_config
exit: could not find postgresql.conf at any of these locations:
/etc/postgresql/14/main/postgresql.conf
/var/lib/pgsql/14/data/postgresql.conf
/var/lib/postgres/data/postgresql.conf
/var/lib/postgresql/data/postgresql.conf
原因:因为我们是yum源配置的,所以没有环境变量也没用进行initdb
解决方法:
su - postgres
cd /usr/pgsql-14/bin/
./initdb
./pg_ctl -D /var/lib/pgsql/14/data start
然后再次执行
su - root
sudo timescaledb-tune --pg-config=/usr/pgsql-14/bin/pg_config

在这里插入图片描述

##重启
systemctl restart postgresql-14
su - postgres
cd /usr/pgsql-14/bin/
./pg_ctl restart

4、TimescaleDB使用

登录pg

su - postgres
psql
create database timescaledb;
\c timescaledb

在这里插入图片描述

创建插件

CREATE EXTENSION IF NOT EXISTS timescaledb;
\dx 
psql -U postgres -d timescaledb 

在这里插入图片描述

使用超表

1、创建普通测试表

CREATE TABLE conditions (
time        TIMESTAMPTZ       NOT NULL,
location    TEXT              NOT NULL,
temperature DOUBLE PRECISION  NULL,
humidity    DOUBLE PRECISION  NULL
);

2、基于time分区将上一步创建的普通表转换为超表

SELECT create_hypertable('conditions', 'time');create_hypertable    
-------------------------(1,public,conditions,t)
(1 row)

在这里插入图片描述

超表(hypertable)是具有特殊功能的PostgreSQL表,可以很容易地处理时间序列数据。与它们交互就像与普通PostgreSQL表交互一样,但在幕后,超表会自动按时间将数据划分为块。在TimescaleDB中,超表与普通PostgreSQL表可以一起存在。超表用来存储时序数据,这样可以提高插入和查询的性能,而且可以访问一些有用的时间序列特性。普通PostgreSQL表用来存储其它关系型数据。

3、插入数据并查询

INSERT INTO conditions(time, location, temperature, humidity)
SELECT now(), to_char(i, 'FM0000'), random()*i, random()*i FROM generate_series(1,10000) i;

4.针对过去3小时的数据,每15分钟采集度量一次,按照时间和温度降序排序

SELECT time_bucket('15 minutes', time) AS fifteen_min,
location, COUNT(*),
MAX(temperature) AS max_temp,
MAX(humidity) AS max_hum
FROM conditions
WHERE time > NOW() - interval '3 hours'
GROUP BY fifteen_min, location
ORDER BY fifteen_min DESC, max_temp DESC;

5.更改现有超表上的块间隔长度

SELECT set_chunk_time_interval('conditions', INTERVAL '24 hours');SELECT h.table_name, c.interval_lengthFROM _timescaledb_catalog.dimension cJOIN _timescaledb_catalog.hypertable hON h.id = c.hypertable_id;

在这里插入图片描述
ok完成。

http://www.mmbaike.com/news/84780.html

相关文章:

  • 网站建设推广语言百度合伙人官网app
  • 如何做网站宣传网络关键词排名软件
  • 如何制作网站和软件高明搜索seo
  • 做外贸网站 自杀营销型高端网站建设
  • 凡科论坛网站制作郑州制作网站公司
  • 多少钱以上构成诈骗网络seo哈尔滨
  • 怎么看网站建设时间长沙网络营销哪家平台专业
  • 乌鲁木齐中高端网站建设设计做app的网站
  • 网站先做前端还是后端推广产品的方法
  • 广州最好的网站建设seo推广优化方案
  • 网站架构师的工作内容推广平台的方式有哪些
  • 中国 生产商全国客服热线:0511一个专门做 生意的网站电子商务营销策划方案
  • 山东建设厅官方网站网站搜索排名优化价格
  • 万网网站空间学企业管理培训班
  • 开发个app需要多少钱?吉林seo关键词
  • wordpress爆路径跨境电商seo什么意思
  • h5素材做多的网站广告联盟接广告
  • 南通网站推广优化公司短视频精准获客系统
  • 网站优化简历模板seo优化排名推广
  • 广告设计师工作内容排名优化哪家好
  • 微站是什么关键词优化推广公司
  • 网站顶级域名百度打广告多少钱
  • art2008cms网站开发网站收录怎么做
  • 做网站选择虚拟主机好是服务器东莞网络排名优化
  • wordpress total搜索引擎优化指南
  • 做网站 使用权 所有权网络优化是做啥的
  • 网站建设武清游戏如何在网上推广
  • 广州人社app怎么下载百度怎么优化排名
  • CMS网站建设实战试题单页网站设计
  • 西安做公司网站百度搜索