zoukankan      html  css  js  c++  java
  • PostgreSQL—安装使用timescale时序数据库

    安装 TimescaleDB

    1、制作 timescaledb.repo 文件

    [root@localhost ~]# vim /etc/yum.repos.d/timescaledb.repo                        # 方式一    
    [root@localhost ~]# tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL        # 方式二
    [root@localhost ~]# cat > /etc/yum.repos.d/timescale_timescaledb.repo <<EOL      # 方式三
    [timescale_timescaledb]
    name=timescale_timescaledb
    baseurl=https://packagecloud.io/timescale/timescaledb/el/7/$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、更新源,有时可以省略这一步

    [root@localhost ~]# yum update -y

    3、安装 timescaledb-postgresql-12

    [root@localhost ~]# yum install -y timescaledb-postgresql-12        # 安装的版本是1.7.4,使用可能有点问题。
    [root@localhost ~]# yum install -y timescaledb-2-postgresql-12      # 安装的版本是2.0.1,推荐这个版本。

    4、配置 postgresql.conf 文件,使用 postgres 启动时加载 'timescaledb'

    [root@localhost ~]# vim /var/lib/pgsql/12/data/postgresql.conf                                                 # 方式一
    shared_preload_libraries = 'timescaledb'  # 不区分大小写,也可以写timescaleDB。
    
    [root@localhost ~]# echo "shared_preload_libraries='timescaledb'">>/var/lib/pgsql/12/data/postgresql.conf      #  方式二  
    
    [root@localhost ~]# sudo timescaledb-tune --pg-config=/usr/pgsql-12/bin/pg_config                              #  方式三
    [root@localhost ~]# sudo timescaledb-tune --pg-config=/usr/pgsql-12/bin/pg_config --quiet --yes                #  方式三,如果使用默认配置,可直接使用该命令

    5、重启数据库服务

    [root@localhost ~]# service postgresql-12 restart
    [root@localhost ~]# systemctl restart postgresql-12.service

    6、安装检验

    [root@localhost ~]# su - postgres   # 切换到 postgres 用户。
    -bash-4.2$ psql                     # 进入到 postgres 的命令行,即命令窗口。
               
    postgres=# CREATE DATABASE timeseries;   # 创建数据库 timeseries
    postgres=# l                            # 查看数据库
    postgres=# c timeseries                 # 进入创建的数据库 timeseries
    
    
    timeseries=# create extension timescaledb;                            # 方式一,添加 TimescaleDB 插件             
    timeseries=# CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;      # 方式二,使用 TimescaleDB 扩展数据库

    7、查看 TimescaleDB 版本

    timeseries=# dx;
    timeseries=# SELECT default_version, installed_version FROM pg_available_extensions WHERE name = 'timescaledb';

    使用 TimescaleDB

    1、创建标准表:conditions

    2、创建超级表:时序表

    3、删除超级表

    timeseries=# drop table conditions;

    4、

  • 相关阅读:
    十代雅阁广东车友群,雅阁广州车友群,深圳雅阁车友群,雅阁微信群、雅阁车友群、十代雅阁交流微信QQ群
    雅阁微信群、雅阁车友群、十代雅阁交流微信QQ群
    [MySQL]快速解决"Table '.sjzlfzbp_post' is marked as crashed and should be repaired"故障
    雅阁微信群、雅阁车友群、十代雅阁交流微信QQ群
    node调试工具--nodemon使用简介
    IIS7.5 URL文件名有加号或空格显示404错误的解决办法
    Mysql CPU使用率长期100%的解决思路备忘
    Windows下通过CMD命令行程序操作MySQL数据库
    软技能:十步学习法
    Linux 文件系统的基本结构
  • 原文地址:https://www.cnblogs.com/liuhaidon/p/14294837.html
Copyright © 2011-2022 走看看