Ubuntu:PostgreSql安装PostGis、TimeScaleDB插件
Ubuntu:PostgreSql安装PostGis、TimeScaleDB插件
https://docs.timescale.com/self-hosted/latest/install/installation-linux/
-
At the command prompt, as root, add the PostgreSQL third party repository to get the latest PostgreSQL packages:
-
Run the PostgreSQL repository setup script:
-
Add the TimescaleDB third party repository:
-
-
Install TimescaleDB GPG key
-
note
For Ubuntu 21.10 and later use this command to install TimescaleDB GPG key
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg
-
Update your local repository list:
-
Install TimescaleDB:
-
note
If you want to install a specific version of TimescaleDB, instead of the most recent, you can specify the version like this:
apt-get install timescaledb-2-postgresql-12='2.6.0*' timescaledb-2-loader-postgresql-12='2.6.0*'
You can see the full list of TimescaleDB releases by visiting the releases page. Note that older versions of TimescaleDB don't always support all the OS versions listed above.
-
Configure your database by running the
timescaledb-tune
script, which is included with thetimescaledb-tools
package. Run thetimescaledb-tune
script using thesudo timescaledb-tune
command. For more information, see the configuration section.
When you have PostgreSQL and TimescaleDB installed, you can connect to it from your local system using the psql
command-line utility.
You can use the apt
on Debian-based systems, yum
on Red Hat-based systems, and pacman
package manager to install the psql
tool.
-
Make sure your
apt
repository is up to date:
-
Install the
postgresql-client
package:DebianRed HatArchLinuxRestart PostgreSQL and create the TimescaleDB extension:
-
Restart the service after enabling TimescaleDB with
timescaledb-tune
:
-
On your local system, at the command prompt, open the
psql
command-line utility as thepostgres
superuser:
If your connection is successful, you'll see a message like this, followed by the
psql
prompt:-
Set the password for the
postgres
user: -
Exit from PostgreSQL:
Use
psql
client to connect to PostgreSQL:-
At the
psql
prompt, create an empty database. Our database is calledtsdb
: -
Connect to the database you created:
-
Add the TimescaleDB extension:
-
Check that the TimescaleDB extension is installed by using the
\dx
command at thepsql
prompt. Output is similar to:
After you have created the extension and the database, you can connect to your database directly using this command:
apt install postgresql-14
1
启动pg
service postgresql start
apt install postgresql-14-postgis-3
apt install timescaledb-2-2.5.1-postgresql-14
create databases test;
\c test
create extension postgis;
create extension timescaledb;
创建timescaledb扩展时会报一下错误
FATAL: extension "timescaledb" must be preloaded
HINT: Please preload the timescaledb library via shared_preload_libraries.This can be done by editing the config file at: /etc/postgresql/14/main/postgresql.conf
and adding 'timescaledb' to the list in the shared_preload_libraries config.
# Modify postgresql.conf:
shared_preload_libraries = 'timescaledb'Another way to do this, if not preloading other libraries, is with the command:
echo "shared_preload_libraries = 'timescaledb'" >> /etc/postgresql/14/main/postgresql.conf(Will require a database restart.)
If you REALLY know what you are doing and would like to load the library without preloading, you can disable this check with:
SET timescaledb.allow_install_without_preload = 'on';
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Succeeded.根据提示修改配置文件
echo "shared_preload_libraries = 'timescaledb'" >> /etc/postgresql/14/main/postgresql.conf
重启pg
service postgresql restart
再次建立扩展
create extension timescaledb;
查看已安装好的扩展
\dx
-