ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

时序数据库timescaleDB安装

2022-01-23 10:00:24  阅读:435  来源: 互联网

标签:postgresql postgres root 数据库 timescaleDB 时序 TimescaleDB usr local


一:前言相关

环境:Red Hat 8.3.1-5
安装程序:PostgreSQL 14.1,TimescaleDB 2.5.1,cmake3.22.1
PostgreSQL编译安装需要cmake3.4以上的版本
TimescaleDB目前只支持PostgreSQL 9.6.3+,10.9+或11.4+

  

二、postgresql11部署

1、安装cmake

下载Cmake
安装gcc++ 后,再安装cmake
[root@TimescaleDB apps]# yum install -y gcc*
[root@TimescaleDB apps]# wget https://cmake.org/files/v3.22/cmake-3.22.1.tar.gz
[root@TimescaleDB cmake]# tar -zxvf cmake-3.22.1.tar.gz
编译安装cmake
[root@TimescaleDB cmake]# ./bootstrap && make && makeinstal
建立软连接
[root@TimescaleDB cmake-v3.8.2]# ln -s/usr/local/bin/cmake /usr/bin/cmake

查看版本
[root@TimescaleDB cmake-3.22.1]# cmake --version
安装cmake

2、安装postgresql

1.安装postgresql

问题:安装postgreSQL出现configure:error:readline library not found

转自:https://www.cnblogs.com/shuaixf/archive/2011/11/29/2268292.html

要安装 readline, readline-dev开发包,要么使用 --without-readline选项关闭 readline 功能。
#yum install readline;
#yum install readline-dev;
readline 也就是命令行编辑,关闭的话,你直接用psql 就不能编辑命令行,如果输错指令,不能回滚命令历史记录,只能手工重新输入
例如:[root@TimescaleDB postgresql]#  yum -y install -y readline-devel
解决方法

 

 

 

在/etc/profile最后,添加以下内容
这一步很关键,如果不设置的话,postgresql的安装命令就不能使用
[root@TimescaleDB postgresql]#vi/etc/profile
exportPG_CONFIG=/usr/local/postgresql/bin/pg_config:$PG_CONFIG
exportPGDATA=/usr/local/postgresql/data:$PGDATA
export PATH=/usr/local/postgresql/bin:$PATH
exportLD_LIBRARY_PATH=/usr/local/postgresql/lib:$LD_LIBRARY_PATH   

[root@TimescaleDB postgresql]#source /etc/profile
2.设置环境变量并保存执行

 

 

 

[root@TimescaleDB postgresql]#  groupadd postgres
[root@TimescaleDB postgresql]#  useradd -g postgres postgres
[root@TimescaleDB postgresql]#  passwd postgres
[root@TimescaleDB postgresql]# mkdir /usr/local/postgresql/data
[root@TimescaleDB postgresql]# chown postgres /usr/local/postgresql/data
[root@TimescaleDB postgresql]# chgrp postgres /usr/local/postgresql/data
3.创建用户和用户组,创建数据库文件目录

4.初始化数据库并修改配置

切换用户,初始化数据库(如果不切换账户直接用root进行初始化,会报错)
[root@TimescaleDB postgresql]# su postgres
[postgres@TimescaleDB postgresql]$ /usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data
4.1切换用户,初始化数据库
配置访问权限
[postgres@TimescaleDB postgresql]$ vi /usr/local/postgresql/data/pg_hba.conf
host all all 0.0.0.0/0 md5

配置监控地址,连接端口号
[postgres@TimescaleDB ~]$ vi /usr/local/postgresql/data/postgresql.conf
listen_addresses配置监听地址范围,改为*则为所有 
listen_addresses = '*'
port = 5432                             # (change requires restart)
4.2配置访问权限、监听地址及端口

 

 

 

 

 

 5.启动数据库

postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile start

 

 

 

6.修改数据库密码

postgres@TimescaleDB ~]$ psql
postgres=# \password postgres

 

 

 

三、安装timescaledb(把postgres 改成 timescaledb时序库)

软件包链接https://codeload.github.com/timescale/timescaledb/zip/master

从源安装自托管 TimescaleDB(官网https://docs.timescale.com/install/latest/self-hosted/installation-source/#configuring-postgresql-after-installing-from-source)
git clone https://github.com/timescale/timescaledb.git
cd timescaledb
查看最新版本。您可以在我们的发布页面上找到最新的发布标签:https://github.com/timescale/timescaledb/releases
git checkout 2.5.1
引导构建系统:
./bootstrap -DUSE_OPENSSL=0 -DREGRESS_CHECKS=OFF
构建扩展:
cd build && make
安装 TimescaleDB:
make install
1、安装timescaledb

 

 

 

 

  

编辑postgresql.conf文件,添加timescaledb库 
[root@TimescaleDB postgresql]# su postgres
[postgres@TimescaleDB postgresql]$ vim /usr/local/postgresql/data/postgresql.conf 
shared_preload_libraries = 'timescaledb'        # (change requires restart)
2、配置timescaledb

3.重启postgresql数据库
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile restart

 

 

 4.添加timescaledb扩展

postgres@TimescaleDB ~]$ psql
postgres=# create extension timescaledb;

 

 

 

5、验证timescaleDB扩展安装完成 
postgres@TimescaleDB ~]$ psql
postgres=# create database tutorial;
postgres=# \c tutorial 
tutorial=# create extension if not exists timescaledb cascade;

验证完成,timescaleDB扩展安装成功 
5、验证timescaleDB扩展安装完成

 

 

 四、其他

 

 

总结:

1、安装cmake

2、安装postgresql

3、安装timescaledb(把postgres 改成 timescaledb时序库)

启动命令:

postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile restart
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile start
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl stop -D /usr/local/postgresql/data

 

转自:

https://www.qedev.com/linux/180450.html

https://docs.timescale.com/install/latest/self-hosted/installation-source/#configure-postgresql-after-installing-from-source

 

 

 

https://www.cnblogs.com/june-/articles/14276416.html

https://blog.csdn.net/weixin_29228203/article/details/116691715

 

标签:postgresql,postgres,root,数据库,timescaleDB,时序,TimescaleDB,usr,local
来源: https://www.cnblogs.com/zt007/p/15835772.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有