Remember Centos7 postgresql v11 to install TimescaleDB

One, database installation

Choose to install according to your own environment

1, yum specified directory installation

https://blog.csdn.net/llwy1428/article/details/105143053

2, yum install directly

https://blog.csdn.net/llwy1428/article/details/102486414

3. Compile and install

https://blog.csdn.net/llwy1428/article/details/95444151

4. PostgreSql basic operation

https://blog.csdn.net/llwy1428/article/details/102598732

5. Centos7 yum installation, configuration PgAdmin4

https://blog.csdn.net/llwy1428/article/details/102486511

6, Centos7 PostgreSql database installation extension

https://blog.csdn.net/llwy1428/article/details/105167524

7. Centos7 PostgreSql database uses FDW extension

https://blog.csdn.net/llwy1428/article/details/106291669

Two, TimescaleDB installation and configuration

1. Install the database:

https://blog.csdn.net/llwy1428/article/details/102486414

2. Make timescaledb.repo file

[root@localhost ~]# sudo vi /etc/yum.repos.d/timescaledb.repo
[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

3. Install timescaledb-postgresql-11 

[root@localhost ~]# sudo yum install -y timescaledb-postgresql-11

4. Configure the database

[root@localhost ~]# sudo timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config 

Note: If you use the default configuration, you can directly use the following command

[root@localhost ~]# sudo timescaledb-tune --pg-config=/usr/pgsql-11/bin/pg_config --quiet --yes

5. Restart the database service

[root@localhost ~]# sudo systemctl restart postgresql-11.service

6. Test:

Switch user:

[root@localhost ~]# su - postgres

Enter the command window:

-bash-4.2$ psql

Create database timeseries

postgres=# CREATE DATABASE timeseries;
postgres=# \l

Enter the created database timeseries

postgres=# \c timeseries
timeseries=# CREATE EXTENSION IF NOT EXISTS timescaledb CASCADE;

Create a table:

timeseries=# CREATE TABLE conditions (time TIMESTAMP WITH TIME ZONE NOT NULL,device_id TEXT,temperature NUMERIC,humidity NUMERIC);
timeseries=# SELECT create_hypertable('conditions', 'time');

Insert data:

timeseries=# INSERT INTO conditions(time, device_id, temperature, humidity) VALUES (NOW(), 'weather-pro-000000', 84.1, 84.1);
timeseries=# INSERT INTO conditions VALUES (NOW(), 'weather-pro-000002', 71.0, 51.0),(NOW(), 'weather-pro-000003', 70.5, 50.5),(NOW(), 'weather-pro-000004', 70.0, 50.2);


Query data

timeseries=# SELECT * FROM conditions LIMIT 10;

Query data

timeseries=# SELECT * FROM conditions ORDER BY time DESC LIMIT 3;

 

Reference address:

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-timescaledb-on-centos-7

 

 

At this point, Centos7 postgresql v11 installation timescale database TimescaleDB operation is complete!

Guess you like

Origin blog.csdn.net/llwy1428/article/details/106357900