• ubuntu部署TimescaleDB


    系统环境: ubuntu16.04
    PostgreSQL 版本: 12


    注意:TimescaleDB 需要PostgreSQL 11.4+或12.0+。不再支持PostgreSQL 9.6.3+和10.9+,并将在以后的版本中删除。

    一. 部署TimescaleDB

    1. Add PostgreSQL's third party repository to get the latest PostgreSQL packages
    ubuntu@VM-0-12-ubuntu:~# sudo echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -c -s)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list 
    ubuntu@VM-0-12-ubuntu:~# sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - 
    ubuntu@VM-0-12-ubuntu:~# sudo apt-get update
    
    
    1. Add PPA
    ubuntu@VM-0-12-ubuntu:~# sudo add-apt-repository ppa:timescale/timescaledb-ppa 
    ubuntu@VM-0-12-ubuntu:~# sudo apt-get update 
    
    1. Install appropriate package for PG version
    ubuntu@VM-0-12-ubuntu:~# sudo apt install timescaledb-postgresql-12
    
    1. Run 'timescaledb-tune' (installed as part of the
      timescaledb-tools package, a recommended dependency) to update your config settings for TimescaleDB
    ubuntu@VM-0-12-ubuntu:~# sudo timescaledb-tune --quiet --yes
    ubuntu@VM-0-12-ubuntu:~# sudo service postgresql restart
    
    1. 为postgres用户设置密码
    ubuntu@VM-0-12-ubuntu:~$ sudo -u postgres   psql postgres
    psql (12.2 (Ubuntu 12.2-2.pgdg16.04+1))
    Type "help" for help.
    
    postgres=# password postgres 
    Enter new password:  #输入密码
    Enter it again:  #确认密码
    postgres=# q #退出
    
    
    1. 修改登录权限设置
    ubuntu@VM-0-12-ubuntu:~# sudo vim /etc/postgresql/12/main/pg_hba.conf
    ...
    # Database administrative login by Unix domain socket
    # local   all             postgres                                md5  
    local   all             postgres                                peer #peer 方式允许管理员账号通过socket连接,用-h 指定socket目录,(default: "/var/run/postgresql")
    
    # TYPE  DATABASE        USER            ADDRESS                 METHOD
    
    # "local" is for Unix domain socket connections only
    local   all             all                                     peer
    
    # IPv4 local connections:
    host    all             all             10.0.0.1/16            md5
    host    all             all             127.0.0.1/32            md5
    ...
    
    ubuntu@VM-0-12-ubuntu:~# sudo vim /etc/postgresql/12/main/postgresql.conf 
    ...
    listen_addresses = '*'          # what IP address(es) to listen on;
    ...
    
    1. 登录测试
    ubuntu@VM-0-12-ubuntu:~$ psql  -h /var/run/postgresql -U postgres -W
    Password:  #输入密码
    psql (12.2 (Ubuntu 12.2-2.pgdg16.04+1))
    Type "help" for help.
    
    postgres=# q
    
    

    二. 安装pg_prometheus拓展

    1. 安装postgresql-server-dev-12
    ubuntu@VM-0-12-ubuntu:~# sudo apt install postgresql-server-dev-12
    
    1. 下载并解压最新 pg_prometheus's release安装包 (v0.2.2) 并解压
    ubuntu@VM-0-12-ubuntu:~#  cd /usr/local/src/prometheus/ && 
    sudo wget https://github.com/timescale/pg_prometheus/archive/0.2.2.tar.gz  && 
    sudo tar -xf 0.2.2.tar.gz && 
    cd pg_prometheus-0.2.2
    
    1. 编译
    ubuntu@VM-0-12-ubuntu:/usr/local/src/prometheus/pg_prometheus-0.2.2# sudo make install
    
    1. 编辑 postgresql.conf 加入pg_prometheus 扩展
    ubuntu@VM-0-12-ubuntu:~#   sudo vim /etc/postgresql/12/main/postgresql.conf
    ...
    # - Shared Library Preloading -
    
    shared_preload_libraries = 'timescaledb,pg_prometheus'  # (change requires restart)
    ...
    
    1. 重启postgresql
    ubuntu@VM-0-12-ubuntu:~# sudo service postgresql restart
    
    1. 创建pg_prometheus拓展
    ubuntu@VM-0-12-ubuntu:~# psql  -h /var/run/postgresql -U postgres -W
    Password: 
    psql (12.2 (Ubuntu 12.2-2.pgdg16.04+1))
    Type "help" for help.
    
    postgres=# CREATE EXTENSION IF NOT EXISTS pg_prometheus;
    CREATE EXTENSION
    postgres=# q
    

    参考:

    1. https://docs.timescale.com/latest/getting-started/installation/ubuntu/installation-apt-ubuntu
    2. https://github.com/timescale/pg_prometheus/issues/31
  • 相关阅读:
    flask总结02
    flask总结01
    恩智浦Freescale Cortex-A9 迅为IMX6开发板平台初体验
    [分享] IMX6嵌入式开发板linux QT挂载U盘及TF卡
    迅为4412嵌入式安卓开发板兼容3G网络|4G网络
    迅为嵌入式4412平台兼容3G/4G模块的安卓开发板
    飞思卡尔开发板-迅为IMX6开兼容单核 双核 四核Plus开发板
    物联网初学者智能家居必备迅为iTOP-4412开发板
    【分享】4412开发板POP烧写ubuntu出错,如何挂载emmc分区解决方法
    [安卓开发板]迅为IMX6 四核Android开发板
  • 原文地址:https://www.cnblogs.com/guoew/p/12872981.html
Copyright © 2020-2023  润新知