赞
踩
本环境在Centos7.5采用编译安装的方式,主要介绍PostgreSQL 11.7,TimescaleDB 1.6.1,cmake3.8.2
PostgreSQL编译安装需要cmake3.4以上的版本
TimescaleDB目前只支持PostgreSQL 9.6.3 +,10.9 +或11.4+
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
添加环境变量
在/etc/profile最后,添加以下内容
[root@TimescaleDB postgresql-11.7]#vi/etc/profile
exportPG_CONFIG=/usr/local/postgresql/bin/pg_config:
P
G
C
O
N
F
I
G
e
x
p
o
r
t
P
G
D
A
T
A
=
/
u
s
r
/
l
o
c
a
l
/
p
o
s
t
g
r
e
s
q
l
/
d
a
t
a
:
PG_CONFIG exportPGDATA=/usr/local/postgresql/data:
PGCONFIGexportPGDATA=/usr/local/postgresql/data:PGDATA
export PATH=/usr/local/postgresql/bin:
P
A
T
H
e
x
p
o
r
t
L
D
L
I
B
R
A
R
Y
P
A
T
H
=
/
u
s
r
/
l
o
c
a
l
/
p
o
s
t
g
r
e
s
q
l
/
l
i
b
:
PATH exportLD_LIBRARY_PATH=/usr/local/postgresql/lib:
PATHexportLDLIBRARYPATH=/usr/local/postgresql/lib:LD_LIBRARY_PATH
[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
配置访问权限
[postgres@TimescaleDB ~]$ vi/usr/local/postgresql/data/pg_hba.conf
配置监控地址,连接端口号
[postgres@TimescaleDB ~]$ vi/usr/local/postgresql/data/postgresql.conf
listen_addresses配置监听地址范围,改为*则为所有
启动数据库,修改数据库密码
[postgres@TimescaleDB ~]
/
u
s
r
/
l
o
c
a
l
/
p
o
s
t
g
r
e
s
q
l
/
b
i
n
/
p
g
c
t
l
−
D
/
u
s
r
/
l
o
c
a
l
/
p
o
s
t
g
r
e
s
q
l
/
d
a
t
a
−
l
/
u
s
r
/
l
o
c
a
l
/
p
o
s
t
g
r
e
s
q
l
/
d
a
t
a
/
l
o
g
f
i
l
e
s
t
a
r
t
!
[
]
(
h
t
t
p
s
:
/
/
i
m
g
c
o
n
v
e
r
t
.
c
s
d
n
i
m
g
.
c
n
/
a
H
R
0
c
H
M
6
L
y
9
z
N
C
41
M
W
N
0
b
y
5
j
b
20
v
a
W
1
h
Z
2
V
z
L
2
J
s
b
2
c
v
M
j
A
y
M
D
A
z
L
z
I
y
L
z
A
4
Z
D
V
j
Z
G
M
y
M
T
I
3
Z
j
N
m
M
2
N
l
N
G
I
4
Y
2
E
z
N
j
c
x
M
T
U
y
O
W
E
5
L
n
B
u
Z
w
?
x
−
o
s
s
−
p
r
o
c
e
s
s
=
i
m
a
g
e
/
f
o
r
m
a
t
,
p
n
g
)
[
p
o
s
t
g
r
e
s
@
T
i
m
e
s
c
a
l
e
D
B
]
/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) [postgres@TimescaleDB ~]
/usr/local/postgresql/bin/pgctl−D/usr/local/postgresql/data−l/usr/local/postgresql/data/logfilestart![](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9zNC41MWN0by5jb20vaW1hZ2VzL2Jsb2cvMjAyMDAzLzIyLzA4ZDVjZGMyMTI3ZjNmM2NlNGI4Y2EzNjcxMTUyOWE5LnBuZw?x−oss−process=image/format,png)[postgres@TimescaleDB ] psql
postgres=# \password postgres
软件包链接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
[root@TimescaleDB timescaledb-master]# cd./build && make
[root@TimescaleDB build]# make install
2、配置timescaledb
1、编辑postgresql.conf文件,添加timescaledb库
[root@TimescaleDB build]# su – postgres
[postgres@TimescaleDB ~]$ vi/usr/local/postgresql/data/postgresql.conf
重启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扩展
[postgres@TimescaleDB ~]$ psql
postgres=# create extension timescaledb;
3、验证timescaleDB扩展安装完成
现在创建一个新的空数据库
postgres=# CREATE database tutorial;
进入tutorial库
\c tutorial
把tutorial库转换为使用TimescaleDB扩展数据库
tutorial=# CREATE EXTENSION IF NOT EXISTStimescaledb CASCADE;
验证完成,timescaleDB扩展安装成功
技术交流欢迎加入Q群:177428068
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。