liquibase 經過pgoneproxy來管理數據庫版本

  最近有客戶反應liquibase經過pgoneproxy來管理數據庫版本時,發現不能創建數據庫表。這讓我有點難理解,因而我直接下載了一個liquibase來測試,發現是pgoneproxy的權限管理的問題。如今說說測試的過程。sql

   先從http://www.liquibase.org/網站下載對應的liquibase,加壓後,在目錄下有以下文件:數據庫

liquibase.jar
README.txt
liquibase.spec
liquibase.bat
liquibase
LICENSE.txt
sdk
lib

爲了建立數據庫表,先增長建立表的配置文件,配置文件的內容以下所示:安全

<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <changeSet id="3" author="db_user">
        <createTable tableName="bigaaa">
            <column name="id" type="int" autoIncrement="true">
                <constraints primaryKey="true" nullable="false"/>
            </column>
            <column name="firstname" type="varchar(50)"/>
            <column name="lastname" type="varchar(50)">
                <constraints nullable="false"/>
            </column>
            <column name="state" type="char(2)"/>
        </createTable>
    </changeSet>
</databaseChangeLog>

  上面配置文件中,要求建立bigaaa表。在使用下面的命令來運行:bash

./liquibase --driver=org.postgresql.Driver --changeLogFile=db.changelog.xml --url=jdbc:postgresql://172.30.12.10:2000/pgbench --username=db_user --password=1234 --logLevel=debug --logFile=log.txt update

測試發現報錯了:post

Unexpected error running Liquibase: ERROR: Access denied due to security policy, DDL disabled or DML restricted! [Failed SQL: CREATE TABLE public.databasechangeloglock (ID INT NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TIMESTAMP WITHOUT TIME ZONE, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID))]

看見錯誤後,知道是pgoneproxy的安全策略,致使建立表失敗的。測試

在pgoneproxy中有--proxy-group-security=<servergroup:level>,--proxy-security-level=<level> --proxy-table-security=<table:level> 。其中後面兩個安全策略都是默認狀況下是沒有設置的。而proxy_group_security默認狀況下是設置爲1的。不支持DDL。故須要在配置文件中增長--proxy-group-security=data0:0的配置。其中data0爲組名稱。網站

相關文章
相關標籤/搜索