• centos8 安装 时序数据库 TimescaleDB


    q使用管理员账号连接并进入centos8系统

    1、执行以下命令

    sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-$(rpm -E %{rhel})-x86_64/pgdg-redhat-repo-latest.noarch.rpm

    2、完成后执行

    sudo tee /etc/yum.repos.d/timescale_timescaledb.repo <<EOL

    3、然后复制以下内容并保存

    1. [timescale_timescaledb]
    2. name=timescale_timescaledb
    3. baseurl=https://packagecloud.io/timescale/timescaledb/el/$(rpm -E %{rhel})/\$basearch
    4. repo_gpgcheck=1
    5. gpgcheck=0
    6. enabled=1
    7. gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
    8. sslverify=1
    9. sslcacert=/etc/pki/tls/certs/ca-bundle.crt
    10. metadata_expire=300
    11. EOL

    4、然后执行更新,这边需要等待比较长的时间

    sudo yum update -y

    5、完成之后需要禁用系统原有的pgsql的包,执行如下命令

    if command -v dnf; then sudo dnf -qy module disable postgresql; fi

    6、查询可安装的版本

    sudo yum search timescaledb

    7、找到 timescaledb-2-postgresql-xx 的最高可用版本,或者你想安装的版本。例如我当前最高可用的版本是  timescaledb-2-postgresql-14  ,然后执行如下命令

    sudo yum install -y timescaledb-2-postgresql-14

    8、到这边就安装好了,之后,需要执行初始化数据库操作

    sudo /usr/pgsql-13/bin/postgresql-13-setup initdb

    9、到这边就操作完成了,然后下面是开启远程连接的了,需要的 继续往下看

       修改/var/lib/pgsql/版本/data/postgresql.conf 例如我的/var/lib/pgsql/14/data/postgresql.conf

           #port=5432前面的#删除

           将#listen_addresses = 'localhost'改成listen_addresses = '*'

    第二步,修改/var/lib/pgsql/版本/data/pg_hba.conf 在最后面添加一行如下代码,然后保存

     host    all             all             0.0.0.0/0               trust

    10、Pgsq服务启动

    1. systemctl enable postgresql-xx
    2. systemctl start postgresql-xx

    xx为你安装的版本,例如我的是14,则xx替换成14

    11、查看运行状态

    systemctl status postgresql-xx

    xx为你安装的版本,例如我的是14,则xx替换成14

    12、修改postgres账号的密码

    切换到postgres用户

    su - postgres
    psql

    进入psql之后执行修改操作

    alter user postgres password '新的密码';

    13、最后我们执行timescaledb配置

    sudo timescaledb-tune --pg-config=/usr/pgsql-13/bin/pg_config --quiet --yes

    14、执行完成之后,重新启动服务

    sudo systemctl restart postgresql-14.service

    14替换成你对应的版本

    15、然后你就可以连接上你的数据库了,创建好新数据库,然后建好需要的表。

    然后执行以下SQL命令来实现。

            15.1、先初始化时序数据库

    create extension timescaledb;

            15.2、然后你可以绑定相关的表了

    SELECT create_hypertable('需要使用时序数据库的表名', '时间索引字段');

    至此大功告成,你可以正常的使用了。

    ps:代码均为我亲自多次实战并且成功执行,借鉴了各种搜索引擎和多个博文以及资料。感谢各大网友大神的付出。

  • 相关阅读:
    代码随想录算法训练营第四十九天| LeetCode 139 单词拆分、多重背包理论基础、背包问题总结篇
    Python学习笔记——存储容器
    初级查找算法
    棱镜七彩受邀参加“数字政府建设暨数字安全技术研讨会”
    两数相加(leetcode 2)
    Python 提高篇学习笔记(一):深拷贝和浅拷贝
    SpringBoot系列——SpringBoot整合mybatis+Druid
    编程-设计模式 3:单例模式
    【系统开发】简易信息管理系统开发
    都2022年了 你还不了解什么是性能测试?
  • 原文地址:https://blog.csdn.net/qq279202647/article/details/125880909