本环境在Centos7.5采用编译安装的方式,主要介绍PostgreSQL 11.7,TimescaleDB 1.6.1,cmake3.8.2
PostgreSQL编译安装需要cmake3.4以上的版本
TimescaleDB目前只支持PostgreSQL 9.6.3 +,10.9 +或11.4+

一、postgresql11部署

1、安装cmake
解压cmake-v3.8.2.zip
[[email protected] tmp]# unzip cmake-v3.8.2.zip
[[email protected] tmp]# cd cmake-v3.8.2
安装gcc++ 后,再安装cmake
[[email protected] cmake-v3.8.2]# yuminstall -y gcc*
[[email protected] cmake-v3.8.2]# ./bootstrap && make && makeinstall
[[email protected] cmake-v3.8.2]# ln -s/usr/local/bin/cmake /usr/bin/cmake

2、安装postgresq
软件包链接:https://ftp.postgresql.org/pub/source/v11.7/
解压postgresql-11.7.tar.gz
[[email protected] tmp]# tar -zxvfpostgresql-11.7.tar.gz
[[email protected] tmp]# cd postgresql-11.7
安装依赖包
[[email protected] postgresql-11.7]# yuminstall -y zlib* readline*
安装postgresql
[[email protected] postgresql-11.7]#./configure --prefix=/usr/local/postgresql --with-readline --with-zlib
[[email protected] postgresql-11.7]#make&& make install
时序数据库timescaleDB安装

添加环境变量
在/etc/profile最后,添加以下内容
[[email protected] postgresql-11.7]#vi/etc/profile
exportPG_CONFIG=/usr/local/postgresql/bin/pg_config:PGCONFIGexportPGDATA=/usr/local/postgresql/data:PG_CONFIG exportPGDATA=/usr/local/postgresql/data:PGDATA
export PATH=/usr/local/postgresql/bin:PATHexportLDLIBRARYPATH=/usr/local/postgresql/lib:PATH exportLD_LIBRARY_PATH=/usr/local/postgresql/lib:LD_LIBRARY_PATH
时序数据库timescaleDB安装
[[email protected] postgresql-11.7]#source /etc/profile
创建用户和用户组,创建数据库文件目录
[[email protected] postgresql-11.7]# useraddpostgres
[[email protected] postgresql-11.7]#groupadd postgres
[[email protected] postgresql-11.7]# mkdir/usr/local/postgresql/data
[[email protected] postgresql-11.7]# chownpostgres /usr/local/postgresql/data
[[email protected] postgresql-11.7]# chgrppostgres /usr/local/postgresql/data
切换用户,初始化数据库
[[email protected] postgresql-11.7]# su -postgres
[[email protected] ~]$ /usr/local/postgresql/bin/initdb -D/usr/local/postgresql/data
时序数据库timescaleDB安装
配置访问权限
[[email protected] ~]$ vi/usr/local/postgresql/data/pg_hba.conf
时序数据库timescaleDB安装
配置监控地址,连接端口号
[[email protected] ~]$ vi/usr/local/postgresql/data/postgresql.conf
listen_addresses配置监听地址范围,改为*则为所有
时序数据库timescaleDB安装
启动数据库,修改数据库密码
[[email protected] ~]/usr/local/postgresql/bin/pgctlD/usr/local/postgresql/datal/usr/local/postgresql/data/logfilestart![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9zNC41MWN0by5jb20vaW1hZ2VzL2Jsb2cvMjAyMDAzLzIyLzA4ZDVjZGMyMTI3ZjNmM2NlNGI4Y2EzNjcxMTUyOWE5LnBuZw?xossprocess=image/format,png)[postgres@TimescaleDB ]/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l/usr/local/postgresql/data/logfile start ![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9zNC41MWN0by5jb20vaW1hZ2VzL2Jsb2cvMjAyMDAzLzIyLzA4ZDVjZGMyMTI3ZjNmM2NlNGI4Y2EzNjcxMTUyOWE5LnBuZw?x-oss-process=image/format,png) [[email protected] ~] psql
postgres=# \password postgres
时序数据库timescaleDB安装

二、timescaledb安装

软件包链接https://codeload.github.com/timescale/timescaledb/zip/master
1、安装timescaledb
解压并授权
[[email protected] tmp]# unziptimescaledb-master.zip
[[email protected] tmp]# chown -Rpostgres:postgres timescaledb-master
[[email protected] tmp]# chmod -R 775 timescaledb-master
编译安装
[[email protected] tmp]# cdtimescaledb-master
[[email protected] tmp]# ./bootstrap-DUSE_OPENSSL=0 -DREGRESS_CHECKS=OFF
时序数据库timescaleDB安装
[[email protected] timescaledb-master]# cd./build && make
时序数据库timescaleDB安装
[[email protected] build]# make install
时序数据库timescaleDB安装

2、配置timescaledb
1、编辑postgresql.conf文件,添加timescaledb库
[[email protected] build]# su – postgres
[[email protected] ~]$ vi/usr/local/postgresql/data/postgresql.conf
时序数据库timescaleDB安装
时序数据库timescaleDB安装

重启postgresql数据库
[[email protected]]# su – postgres
[[email protected]~]$ /usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfilerestart
时序数据库timescaleDB安装
添加timescaledb扩展
[[email protected] ~]$ psql
postgres=# create extension timescaledb;
时序数据库timescaleDB安装

3、验证timescaleDB扩展安装完成
现在创建一个新的空数据库
postgres=# CREATE database tutorial;
进入tutorial库
\c tutorial
把tutorial库转换为使用TimescaleDB扩展数据库
tutorial=# CREATE EXTENSION IF NOT EXISTStimescaledb CASCADE;
时序数据库timescaleDB安装
验证完成,timescaleDB扩展安装成功
技术交流欢迎加入Q群:177428068

相关文章:

  • 2022-02-09
  • 2022-12-23
  • 2022-12-23
  • 2021-06-02
  • 2022-12-23
  • 2021-12-13
  • 2021-08-30
  • 2022-01-15
猜你喜欢
  • 2021-06-27
  • 2022-01-27
  • 2021-09-27
  • 2022-12-23
  • 2021-04-10
  • 2021-06-17
相关资源
相似解决方案