本环境在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
[root@TimescaleDB tmp]# unzip cmake-v3.8.2.zip
[root@TimescaleDB tmp]# cd cmake-v3.8.2
安装gcc++ 后,再安装cmake
[root@TimescaleDB cmake-v3.8.2]# yuminstall -y gcc*
[root@TimescaleDB cmake-v3.8.2]# ./bootstrap && make && makeinstall
[root@TimescaleDB 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
[root@TimescaleDB tmp]# tar -zxvfpostgresql-11.7.tar.gz
[root@TimescaleDB tmp]# cd postgresql-11.7
安装依赖包
[root@TimescaleDB postgresql-11.7]# yuminstall -y zlib readline
安装postgresql
[root@TimescaleDB postgresql-11.7]#./configure --prefix=/usr/local/postgresql --with-readline --with-zlib
[root@TimescaleDB postgresql-11.7]#make&& make install![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/f8fc39100c1e69a18e2443c542d1f470.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
添加环境变量
在/etc/profile最后,添加以下内容
[root@TimescaleDB postgresql-11.7]#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 ![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/f71ec6b0503f35274f4dca72e382a21c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
[root@TimescaleDB postgresql-11.7]#source /etc/profile
创建用户和用户组,创建数据库文件目录
[root@TimescaleDB postgresql-11.7]# useraddpostgres
[root@TimescaleDB postgresql-11.7]#groupadd postgres
[root@TimescaleDB postgresql-11.7]# mkdir/usr/local/postgresql/data
[root@TimescaleDB postgresql-11.7]# chownpostgres /usr/local/postgresql/data
[root@TimescaleDB postgresql-11.7]# chgrppostgres /usr/local/postgresql/data
切换用户,初始化数据库
[root@TimescaleDB postgresql-11.7]# su -postgres
[postgres@TimescaleDB ~]$ /usr/local/postgresql/bin/initdb -D/usr/local/postgresql/data![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/1fbbd032a5827d68aeda0eb5bfb26e5c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
配置访问权限
[postgres@TimescaleDB ~]$ vi/usr/local/postgresql/data/pg_hba.conf![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/e8fc93d0875552232f96aac9bf9d5cb2.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
配置监控地址,连接端口号
[postgres@TimescaleDB ~]$ vi/usr/local/postgresql/data/postgresql.conf
listen_addresses配置监听地址范围,改为*则为所有![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/056300e1c3bab5d82ede4c822d9af82a.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
启动数据库,修改数据库密码
[postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l/usr/local/postgresql/data/logfile start![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/08d5cdc2127f3f3ce4b8ca36711529a9.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
[postgres@TimescaleDB ~]$ psql
postgres=# \password postgres![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/6e17c2b8b2149ef2276ebc39259b1ebd.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
二、timescaledb安装
软件包链接https://codeload.github.com/timescale/timescaledb/zip/master
1、安装timescaledb
解压并授权
[root@TimescaleDB tmp]# unziptimescaledb-master.zip
[root@TimescaleDB tmp]# chown -Rpostgres:postgres timescaledb-master
[root@TimescaleDB tmp]# chmod -R 775 timescaledb-master
编译安装
[root@TimescaleDB tmp]# cdtimescaledb-master
[root@TimescaleDB tmp]# ./bootstrap-DUSE_OPENSSL=0 -DREGRESS_CHECKS=OFF![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/f0f2df2bb90eee5364e703037023235e.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
[root@TimescaleDB timescaledb-master]# cd./build && make![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/0aa9c00ba4fd10958553649f0619fefe.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
[root@TimescaleDB build]# make install![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/4d985d8aaa67a99f633b2c9b1d94c11c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
2、配置timescaledb
1、编辑postgresql.conf文件,添加timescaledb库
[root@TimescaleDB build]# su – postgres
[postgres@TimescaleDB ~]$ vi/usr/local/postgresql/data/postgresql.conf![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/069a15b8835040209419486e41b8286b.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/14e54572b4ad34bc8901e3780168ac44.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
重启postgresql数据库
[root@TimescaleDBbuild]# su – postgres
[postgres@TimescaleDB~]$ /usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfilerestart![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/79b52f0471e5ef125945c55ee290981c.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
添加timescaledb扩展
[postgres@TimescaleDB ~]$ psql
postgres=# create extension timescaledb;![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/a8e7a56b29f9f9950669aa722538cfee.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
3、验证timescaleDB扩展安装完成
现在创建一个新的空数据库
postgres=# CREATE database tutorial;
进入tutorial库
\c tutorial
把tutorial库转换为使用TimescaleDB扩展数据库
tutorial=# CREATE EXTENSION IF NOT EXISTStimescaledb CASCADE;![[技术干货] 时序数据库timescaleDB安装](https://s4.51cto.com/images/blog/202003/22/e3c49761822eb6835ef17caa8f2cb634.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
验证完成,timescaleDB扩展安装成功
来源:51CTO
作者:Zabbix_Z大叔
链接:https://blog.51cto.com/14483703/2480819