概述
TimescaleDB是由PostgreSQL支持 的开源时间序列数据库,昨晚PG插件的形式存在,如果要使用到相关时序的功能,需要安装上此插件。安装方法有以下两种
YUM安装
如果你的PG是使用YUM网络安装,则可以同样使用该方法安装TimescaleDB插件
就根据官网上给出的方法,方便简洁
创建yum源
TimescaleDB官方给出了一个yum源,添加这个repo文件之后即可使用
# Add our repo
sudo cat > /etc/yum.repos.d/timescale_timescaledb.repo <<EOL
[timescale_timescaledb]
name=timescale_timescaledb
baseurl=https://packagecloud.io/timescale/timescaledb/el/7/\$basearch
repo_gpgcheck=1
gpgcheck=0
enabled=1
gpgkey=https://packagecloud.io/timescale/timescaledb/gpgkey
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300
EOL
选择版本安装
更新yum源之后,安装插件,注意相关版本
sudo yum update -y
# Now install appropriate package for PG version
sudo yum install -y timescaledb-postgresql-10
安装完成之后直接创建拓展使用即可
编译安装
有时数据库不是使用yum源,而是自己编译安装的,这时配置的环境和yum源上的都不一致。就推荐使用源码安装就可以,不是很麻烦
使用yum方法失败
有时会失败,如下。就只能只用源码安装了
[root@jh_test build]# yum install -y timescaledb-postgresql-10
Error: Package: timescaledb-postgresql-10-1.2.2-0.el7.x86_64 (timescale_timescaledb)
Requires: postgresql10-devel >= 10.2
Error: Package: timescaledb-postgresql-10-1.2.2-0.el7.x86_64 (timescale_timescaledb)
Requires: postgresql10-server >= 10.2
Error: Package: timescaledb-postgresql-10-1.2.2-0.el7.x86_64 (timescale_timescaledb)
Requires: postgresql10 >= 10.2
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
安装好cmake 3.4+
TimescaleDB的编译是基于 cmake 3.4以上的版本
安装好依赖:
yum install gcc-c++
安装cmake:
选择合适的版本安装 https://cmake.org/download/
解压后进入解压包内,执行如下
./bootstrap
gmake
gmake install
完成之后查看一下版本
[root@jh_test build]# cmake --version
cmake version 3.14.0
CMake suite maintained and supported by Kitware (kitware.com/cmake).
下载源码
[root@jh_test ~]# git clone https://github.com/timescale/timescaledb.git
Cloning into 'timescaledb'...
remote: Enumerating objects: 1, done.
remote: Counting objects: 100% (1/1), done.
remote: Total 14983 (delta 0), reused 1 (delta 0), pack-reused 14982
Receiving objects: 100% (14983/14983), 5.26 MiB | 959.00 KiB/s, done.
Resolving deltas: 100% (11724/11724), done.
[root@jh_test ~]# cd timescaledb/
[root@jh_test timescaledb]#
[root@jh_test timescaledb]# ls
appveyor.yml bootstrap.bat CMakeLists.txt docs LICENSE-APACHE README.md sql test tsl
bootstrap CHANGELOG.md CONTRIBUTING.md LICENSE NOTICE scripts src timescaledb.control.in version.config
将源码的版本改为自己的PG适配的版本
[root@jh_test timescaledb]# git checkout 1.2.1
Note: checking out '1.2.1'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b new_branch_name
HEAD is now at b334e10... Release 1.2.1
执行bootstrap
[root@jh_test timescaledb]# ./bootstrap
-- The C compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- TimescaleDB version 1.2.1. Can be updated from version 1.2.0
-- Build type is Release
-- Install method is 'source'
-- Performing Test CC_SUPPORTS_VISIBILITY_HIDDEN
-- Performing Test CC_SUPPORTS_VISIBILITY_HIDDEN - Success
-- Using compiler GNU
-- Found Git: /usr/bin/git (found version "1.8.3.1")
-- Using pg_config /usr/pgsql/bin/pg_config
-- Compiling against PostgreSQL version 10.6
-- Using docker based clang-format
-- Found OpenSSL: /usr/lib64/libcrypto.so (found version "1.0.2k")
-- Using OpenSSL version 1.0.2k
-- Using nm /usr/bin/nm
-- Using pg_regress /usr/pgsql-10/lib/pgxs/src/test/regress/pg_regress
-- Using pg_isolation_regress PG_ISOLATION_REGRESS-NOTFOUND
-- Configuring done
-- Generating done
-- Build files have been written to: /root/timescaledb/build
TimescaleDB build system initialized in ./build. To compile, do:
cd ./build && make
[root@jh_test timescaledb]# cd build/
[root@jh_test build]# ls
CMakeCache.txt CMakeFiles cmake_install.cmake Makefile scripts sql src test timescaledb.control tsl version.config
[root@jh_test build]#
[root@jh_test build]# make
Scanning dependencies of target sqlupdatescripts
[ 1%] Generating /root/timescaledb/build/sql/timescaledb--1.2.0--1.2.1.sql
[ 2%] Generating /root/timescaledb/build/sql/timescaledb--1.1.1--1.2.1.sql
[ 3%] Generating /root/timescaledb/build/sql/timescaledb--1.1.0--1.2.1.sql
[ 4%] Generating /root/timescaledb/build/sql/timescaledb--1.0.1--1.2.1.sql
[ 5%] Generating /root/timescaledb/build/sql/timescaledb--1.0.0--1.2.1.sql
[ 5%] Generating /root/timescaledb/build/sql/timescaledb--1.0.0-rc3--1.2.1.sql
[ 6%] Generating /root/timescaledb/build/sql/timescaledb--1.0.0-rc2--1.2.1.sql
[ 7%] Generating /root/timescaledb/build/sql/timescaledb--1.0.0-rc1--1.2.1.sql
[ 8%] Generating /root/timescaledb/build/sql/timescaledb--0.12.1--1.2.1.sql
[ 9%] Generating /root/timescaledb/build/sql/timescaledb--0.12.0--1.2.1.sql
[ 10%] Generating /root/timescaledb/build/sql/timescaledb--0.11.0--1.2.1.sql
.....(省略)
[ 92%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/planner.c.o
[ 93%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/bgw_policy/reorder_api.c.o
[ 94%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/bgw_policy/drop_chunks_api.c.o
[ 94%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/bgw_policy/job.c.o
[ 95%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/gapfill/gapfill.c.o
[ 96%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/gapfill/planner.c.o
[ 97%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/gapfill/exec.c.o
[ 98%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/gapfill/locf.c.o
[ 99%] Building C object tsl/src/CMakeFiles/timescaledb-tsl.dir/gapfill/interpolate.c.o
[100%] Linking C shared module timescaledb-tsl-1.2.1.so
[100%] Built target timescaledb-tsl
检查当前当前安装用户下的PG环境是否是自己想要的,无误后执行make install
[root@jh_test build]# pg_config
[root@jh_test build]# make install
[ 24%] Built target sqlupdatescripts
[ 24%] Built target sqlfile
[ 83%] Built target timescaledb
[ 88%] Built target timescaledb-loader
[100%] Built target timescaledb-tsl
Install the project...
-- Install configuration: "Release"
-- Installing: /usr/pgsql-10/share/extension/timescaledb.control
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.2.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.1.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.1.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.0.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.0.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.0.0-rc3--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.0.0-rc2--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--1.0.0-rc1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.12.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.12.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.11.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.10.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.10.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.9.2--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.9.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.9.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.8.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.7.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.7.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.6.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.6.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.5.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.4.2--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.4.1--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.4.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.3.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.2.0--1.2.1.sql
-- Installing: /usr/pgsql-10/share/extension/timescaledb--0.1.0--1.2.1.sql
-- Installing: /usr/pgsql-10/lib/timescaledb-1.2.1.so
-- Installing: /usr/pgsql-10/lib/timescaledb.so
-- Installing: /usr/pgsql-10/lib/timescaledb-tsl-1.2.1.so
[root@jh_test build]#
添加动态库参数
打开postgresql.conf 文件添加一行参数 shared_preload_libraries = ‘timescaledb’
完成后重启
[postgres@jh_test pgdata]$ vi postgresql.conf
[postgres@jh_test pgdata]$ pg_ctl restart
waiting for server to shut down.... done
server stopped
waiting for server to start....2019-03-15 19:10:16.796 CST [15613] LOG: listening on IPv4 address "0.0.0.0", port 5432
2019-03-15 19:10:16.796 CST [15613] LOG: listening on IPv6 address "::", port 5432
2019-03-15 19:10:16.803 CST [15613] LOG: listening on Unix socket "/tmp/.s.PGSQL.5432"
2019-03-15 19:10:16.956 CST [15613] LOG: redirecting log output to logging collector process
2019-03-15 19:10:16.956 CST [15613] HINT: Future log output will appear in directory "pg_log".
done
server started
创建拓展
[postgres@jh_test pgdata]$ psql
psql (10.6)
Type "help" for help.
postgres=# CREATE EXTENSION timescaledb;
WARNING:
WELCOME TO
_____ _ _ ____________
|_ _(_) | | | _ \ ___ \
| | _ _ __ ___ ___ ___ ___ __ _| | ___| | | | |_/ /
| | | | _ ` _ \ / _ \/ __|/ __/ _` | |/ _ \ | | | ___ \
| | | | | | | | | __/\__ \ (_| (_| | | __/ |/ /| |_/ /
|_| |_|_| |_| |_|\___||___/\___\__,_|_|\___|___/ \____/
Running version 1.2.1
For more information on TimescaleDB, please visit the following links:
1. Getting started: https://docs.timescale.com/getting-started
2. API reference documentation: https://docs.timescale.com/api
3. How TimescaleDB is designed: https://docs.timescale.com/introduction/architecture
Note: TimescaleDB collects anonymous reports to better understand and assist our users.
For more information and how to disable, please see our docs https://docs.timescaledb.com/using-timescaledb/telemetry.
CREATE EXTENSION
本站文章,未经作者同意,请勿转载,如需转载,请邮件customer@csudata.com.
0 评论
添加一条新评论