閱讀570 返回首頁    go 京東網上商城


Greenplum 如何直連segment節點

直連greenplum segment節點的方法, utility模式 : 
使用這種方式,不與其他節點通訊,隻操作當前節點。也沒有數據分布的概念。
如果使用utility模式連接的是master節點,寫入數據時,數據不會分布到segment,使用正常模式連接後,寫入master的數據也查不出來。

$  PGOPTIONS='-c gp_session_role=utility' psql -p 40005
psql (8.2.15)
Type "help" for help.

postgres=# \dt
             List of relations
 Schema | Name | Type  |  Owner   | Storage 
--------+------+-------+----------+---------
 public | t    | table | digoal | heap
 public | test | table | digoal | heap
(2 rows)

postgres=# select * from pg_locks;
   locktype    | database | relation | page | tuple | transactionid | classid | objid | objsubid | transaction |  pid   |      mode       | granted | mppsessionid | mppiswriter | gp_segment_id 
---------------+----------+----------+------+-------+---------------+---------+-------+----------+-------------+--------+-----------------+---------+--------------+-------------+---------------
 transactionid |          |          |      |       |        136604 |         |       |          |      136604 | 130724 | ExclusiveLock   | t       |            6 | t           |            -1
 relation      |    10899 |    10333 |      |       |               |         |       |          |      136604 | 130724 | AccessShareLock | t       |            6 | t           |            -1
(2 rows)

注意使用PGOPTIONS='-c gp_session_role=utility'後,隻操作本地節點

$psql -p # master
psql (8.2.15)
Type "help" for help.
postgres=# select count(*) from test;
 count 
-------
     0
(1 row)
postgres=# \q


$psql -p 40001 # segment
psql (8.2.15)
Type "help" for help.
postgres=# select count(*) from test;
  count  
---------
 4166801
(1 row)

最後更新:2017-04-01 13:44:33

  上一篇:go PG數據庫之間的導入導出
  下一篇:go Greenplum 添加或刪除standby master節點