AdSense

網頁

2022/5/13

Mac 安裝Liquibase by Homebrew

Mac使用Homebrew安裝Liquibase。


範例環境:

  • macOS BigSur version 10.15.5
  • Homebrew 3.4.4


安裝Liquibase

在終端機執行brew install liquibase開始安裝。

~$ brew install liquibase
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/manifests/18.0.1
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/openjdk/blobs/sha256:a70f028a2a
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/liquibase/manifests/4.10.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/liquibase/blobs/sha256:3db0f7af
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Installing dependencies for liquibase: openjdk
==> Installing liquibase dependency: openjdk
==> Pouring openjdk--18.0.1.big_sur.bottle.tar.gz
🍺  /usr/local/Cellar/openjdk/18.0.1: 641 files, 307.8MB
==> Installing liquibase
==> Pouring liquibase--4.10.0.all.bottle.tar.gz
==> Caveats
You should set the environment variable LIQUIBASE_HOME to
  /usr/local/opt/liquibase/libexec
==> Summary
🍺  /usr/local/Cellar/liquibase/4.10.0: 64 files, 37.3MB
==> Running `brew cleanup liquibase`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
==> Caveats
==> liquibase
You should set the environment variable LIQUIBASE_HOME to
  /usr/local/opt/liquibase/libexe


設定環境變數

若終端機是bash,安裝好後在~/.bash_profile設定export LIQUIBASE_HOME=/usr/local/opt/liquibase/libexe

若終端機是zsh,執行export LIQUIBASE_HOME=/usr/local/opt/liquibase/libexec


確認安裝

在終端機輸入liquibase --version檢視版本資訊確認已安裝成功。範例為4.10版。

~$ liquibase --version
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ##
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ##
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 21:41:35 (version 4.10.0 #2501 built at 2022-05-04 14:27+0000)
Running Java under /usr/local/Cellar/openjdk/18.0.1/libexec/openjdk.jdk/Contents/Home (Version 18.0.1)

Liquibase Version: 4.10.0
Liquibase Community 4.10.0 by Liquibase


H2資料庫

安裝好的liquibase內含H2資料庫,為一支援標準SQL的in-memory關聯資料庫,為下面liquibase範例的操作對象。

H2的安裝目錄在/usr/local/Cellar/liquibase/4.10.0/libexec/lib

在命令列輸入liquibase init start-h2啟動H2資料庫,啟動後會自動在瀏覽器開啟管理介面。

啟動時可在命令列看到:

  • H2資料庫Dev的JDBC URL:jdbc:h2:tcp://localhost:9090/mem:dev
  • H2資料庫Dev的Username:dbuser
  • H2資料庫Dev的Password:letmein
  • 資料庫圖形管理工具的網址:http://localhost:8090/frame.jsp?jsessionid=4152cf20299ebf04a35b6d52977d891c

~$ liquibase init start-h2
####################################################
##   _     _             _ _                      ##
##  | |   (_)           (_) |                     ##
##  | |    _  __ _ _   _ _| |__   __ _ ___  ___   ##
##  | |   | |/ _` | | | | | '_ \ / _` / __|/ _ \  ##
##  | |___| | (_| | |_| | | |_) | (_| \__ \  __/  ##
##  \_____/_|\__, |\__,_|_|_.__/ \__,_|___/\___|  ##
##              | |                               ##
##              |_|                               ##
##                                                ##
##  Get documentation at docs.liquibase.com       ##
##  Get certified courses at learn.liquibase.com  ##
##  Free schema change activity reports at        ##
##      https://hub.liquibase.com                 ##
##                                                ##
####################################################
Starting Liquibase at 17:14:01 (version 4.10.0 #2501 built at 2022-05-04 14:27+0000)
Liquibase Version: 4.10.0
Liquibase Community 4.10.0 by Liquibase
Starting Example H2 Database...
NOTE: The database does not persist data, so stopping and restarting this process will reset it back to a blank database

Connection Information:
  Dev database:
    JDBC URL: jdbc:h2:tcp://localhost:9090/mem:dev
    Username: dbuser
    Password: letmein
  Integration database:
    JDBC URL: jdbc:h2:tcp://localhost:9090/mem:integration
    Username: dbuser
    Password: letmein

Opening Database Console in Browser...
  Dev Web URL: http://localhost:8090/frame.jsp?jsessionid=4152cf20299ebf04a35b6d52977d891c
  Integration Web URL: http://localhost:8090/frame.jsp?jsessionid=d24512d4c737e6a35d9be1a1a9c1b3a9

H2資料庫圖形管理工具頁面。




在H2安裝目錄執行java -cp h2*.jar org.h2.tools.Shell可進入H2 Shell,在這可執行SQL。

/usr/local/Cellar/liquibase/4.10.0/libexec/lib$ java -cp h2*.jar org.h2.tools.Shell

Welcome to H2 Shell 2.1.212 (2022-04-09)
Exit with Ctrl+C
[Enter]   jdbc:h2:tcp://localhost:9090/mem:dev
URL
[Enter]   org.h2.Driver
Driver
[Enter]   dbuser
User
Password
Connected
Commands are case insensitive; SQL statements end with ';'
help or ?      Display this help
list           Toggle result list / stack trace mode
maxwidth       Set maximum column width (default is 100)
autocommit     Enable or disable autocommit
history        Show the last 20 statements
quit or exit   Close the connection and exit

sql>


沒有留言:

AdSense