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)
原文地址:https://www.cnblogs.com/xibuhaohao/p/11119169.html