前置條件:
1、操作系統ubuntu2204
2、已經通過apt的方式安裝了pg14
當然其他的操作系統,官方文檔中也有說明。
一、安裝
https://docs.timescale.com/self-hosted/latest/install/installation-linux/
Installing self-hosted TimescaleDB on Debian-based systems
# 1、安裝相關倉庫
apt install gnupg postgresql-common apt-transport-https lsb-release wget
# 2、運行倉庫安裝腳本
/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh
# 3、安裝TimescaleDB 第三方倉庫
echo "deb https://packagecloud.io/timescale/timescaledb/ubuntu/ $(lsb_release -c -s) main" | sudo tee /etc/apt/sources.list.d/timescaledb.list# 4、安裝TimescaleDB GPG key(Ubuntu21.10以后)
wget --quiet -O - https://packagecloud.io/timescale/timescaledb/gpgkey | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/timescaledb.gpg# 5、更新倉庫
apt update# 6、安裝TimescaleDB
apt install timescaledb-2-postgresql-14# 7、Configure your database by running the timescaledb-tune script, which is included with the timescaledb-tools package. Run the timescaledb-tune script using the sudo timescaledb-tune command. For more information, see the configuration section.
這一段沒看懂,我也啥也沒做,不過后面的步驟就報錯了
最后解決問題的方法也很簡單:
修改postgresql配置文件:
root@odoo-pc:~# vi /etc/postgresql/14/main/postgresql.conf
在文件底部增加一行
shared_preload_libraries = 'timescaledb'保存文件,重啟postgresql
root@odoo-pc:~# systemctl restart postgresql
Set up the TimescaleDB extension
# 升級psql
apt-get update
apt-get install postgresql-client
安裝TimeScaleDB
# 修改postgres密碼
sudo -u postgres psql
\password postgres
\q
psql -U postgres -h localhost
# 創建時序數據庫
CREATE database tsdb;
# 連接到tsdb
\c tsdb
# 增加TimescaleDB擴展
CREATE EXTENSION IF NOT EXISTS timescaledb;
# 看看是否安裝成功
\dx已安裝擴展列表名稱 | 版本 | 架構模式 | 描述
-------------+--------+------------+---------------------------------------------------------------------------------------plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural languagetimescaledb | 2.13.0 | public | Enables scalable inserts and complex queries for time-series data (Community Edition)
(2 行記錄)