一:前言相關
環境:Red Hat 8.3.1-5
安裝程序:PostgreSQL 14.1,TimescaleDB 2.5.1,cmake3.22.1
PostgreSQL編譯安裝需要cmake3.4以上的版本
TimescaleDB目前只支持PostgreSQL 9.6.3+,10.9+或11.4+
二、postgresql11部署
1、安裝cmake

下載Cmake 安裝gcc++ 后,再安裝cmake [root@TimescaleDB apps]# yum install -y gcc* [root@TimescaleDB apps]# wget https://cmake.org/files/v3.22/cmake-3.22.1.tar.gz [root@TimescaleDB cmake]# tar -zxvf cmake-3.22.1.tar.gz 編譯安裝cmake [root@TimescaleDB cmake]# ./bootstrap && make && makeinstal 建立軟連接 [root@TimescaleDB cmake-v3.8.2]# ln -s/usr/local/bin/cmake /usr/bin/cmake 查看版本 [root@TimescaleDB cmake-3.22.1]# cmake --version
2、安裝postgresql

[root@TimescaleDB apps]# wget https://ftp.postgresql.org/pub/source/v14.1/postgresql-14.1.tar.gz [root@TimescaleDB apps]# tar -zxvf postgresql-14.1.tar.gz 安裝依賴包 [root@TimescaleDB postgresql]# yum install -y zlib [root@TimescaleDB postgresql]# ./configure --prefix=/usr/local/postgresql --with-readline --with-zlib [root@TimescaleDB postgresql]# make && make install
問題:安裝postgreSQL出現configure:error:readline library not found
轉自:https://www.cnblogs.com/shuaixf/archive/2011/11/29/2268292.html

要安裝 readline, readline-dev開發包,要么使用 --without-readline選項關閉 readline 功能。 #yum install readline; #yum install readline-dev; readline 也就是命令行編輯,關閉的話,你直接用psql 就不能編輯命令行,如果輸錯指令,不能回滾命令歷史記錄,只能手工重新輸入 例如:[root@TimescaleDB postgresql]# yum -y install -y readline-devel

在/etc/profile最后,添加以下內容 這一步很關鍵,如果不設置的話,postgresql的安裝命令就不能使用 [root@TimescaleDB postgresql]#vi/etc/profile exportPG_CONFIG=/usr/local/postgresql/bin/pg_config:$PG_CONFIG exportPGDATA=/usr/local/postgresql/data:$PGDATA export PATH=/usr/local/postgresql/bin:$PATH exportLD_LIBRARY_PATH=/usr/local/postgresql/lib:$LD_LIBRARY_PATH [root@TimescaleDB postgresql]#source /etc/profile

[root@TimescaleDB postgresql]# groupadd postgres [root@TimescaleDB postgresql]# useradd -g postgres postgres [root@TimescaleDB postgresql]# passwd postgres [root@TimescaleDB postgresql]# mkdir /usr/local/postgresql/data [root@TimescaleDB postgresql]# chown postgres /usr/local/postgresql/data [root@TimescaleDB postgresql]# chgrp postgres /usr/local/postgresql/data
4.初始化數據庫並修改配置

切換用戶,初始化數據庫(如果不切換賬戶直接用root進行初始化,會報錯)
[root@TimescaleDB postgresql]# su postgres
[postgres@TimescaleDB postgresql]$ /usr/local/postgresql/bin/initdb -D /usr/local/postgresql/data

配置訪問權限 [postgres@TimescaleDB postgresql]$ vi /usr/local/postgresql/data/pg_hba.conf host all all 0.0.0.0/0 md5 配置監控地址,連接端口號 [postgres@TimescaleDB ~]$ vi /usr/local/postgresql/data/postgresql.conf listen_addresses配置監聽地址范圍,改為*則為所有 listen_addresses = '*' port = 5432 # (change requires restart)
5.啟動數據庫
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile start
6.修改數據庫密碼
postgres@TimescaleDB ~]$ psql
postgres=# \password postgres
三、安裝timescaledb(把postgres 改成 timescaledb時序庫)
軟件包鏈接https://codeload.github.com/timescale/timescaledb/zip/master

從源安裝自托管 TimescaleDB(官網https://docs.timescale.com/install/latest/self-hosted/installation-source/#configuring-postgresql-after-installing-from-source) git clone https://github.com/timescale/timescaledb.git cd timescaledb 查看最新版本。您可以在我們的發布頁面上找到最新的發布標簽:https://github.com/timescale/timescaledb/releases git checkout 2.5.1 引導構建系統: ./bootstrap -DUSE_OPENSSL=0 -DREGRESS_CHECKS=OFF 構建擴展: cd build && make 安裝 TimescaleDB: make install

編輯postgresql.conf文件,添加timescaledb庫 [root@TimescaleDB postgresql]# su postgres [postgres@TimescaleDB postgresql]$ vim /usr/local/postgresql/data/postgresql.conf shared_preload_libraries = 'timescaledb' # (change requires restart)
3.重啟postgresql數據庫
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile restart
4.添加timescaledb擴展
postgres@TimescaleDB ~]$ psql
postgres=# create extension timescaledb;

5、驗證timescaleDB擴展安裝完成 postgres@TimescaleDB ~]$ psql postgres=# create database tutorial; postgres=# \c tutorial tutorial=# create extension if not exists timescaledb cascade; 驗證完成,timescaleDB擴展安裝成功
四、其他

1.查看版本號和系統類別:cat /etc/redhat-realease; 2.如果是redhat:(yum install) a.yum 刪除軟件包: rpm -qa | grep postgresql yum remove postgresql* b.刪除相關目錄文件: rm -rf /var/lib/pgsql rm -rf /usr/pgsql* c.刪除pg相關用戶組/用戶 userdel -r postgres groupdel postgres 如果是ubuntu /centos:(暫時沒實踐,做個筆記備用)(apt-get install) 如果在運行,默認的5432端口就能被監聽到,請運行 sudo service postgresql stop 暫停服務。 在命令行輸入sudo apt-get --purge remove postgresql 刪除postgresql安裝包,安裝刪除后還有刪除對應的配置sudo rm -r /etc/postgresql/ sudo rm -r /etc/postgresql-common/ sudo rm -r /var/lib/postgresql/ sudo userdel -r postgres sudo groupdel postgres 最后刪除用戶/用戶組
2.遠程連接方式
2.1 navicat(這里不做說明)
2.2 pgAdmin
下載地址:https://www.pgadmin.org/download/pgadmin-4-windows/
總結:
1、安裝cmake
2、安裝postgresql
3、安裝timescaledb(把postgres 改成 timescaledb時序庫)
啟動命令:
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile restart
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl -D /usr/local/postgresql/data -l /usr/local/postgresql/data/logfile start
postgres@TimescaleDB ~]$/usr/local/postgresql/bin/pg_ctl stop -D /usr/local/postgresql/data
轉自:
https://www.qedev.com/linux/180450.html
https://docs.timescale.com/install/latest/self-hosted/installation-source/#configure-postgresql-after-installing-from-source
https://blog.csdn.net/yang_z_1/article/details/113560107
https://blog.csdn.net/youngwxy/article/details/100163822
https://www.cnblogs.com/june-/articles/14276416.html
https://blog.csdn.net/weixin_29228203/article/details/116691715