三、openldap整合greenplum

一、配置greenplum用戶

編輯greenplum用戶配置文件,導入到openldap中:

#添加greenplum分支,用於存放greenplum相關用戶和組信息
dn: ou=greenplum,dc=bigdata,dc=ly
ou: greenplum
objectClass: top
objectClass: organizationalUnit
​
#添加greenplum用戶分組
dn: cn=People,ou=greenplum,dc=bigdata,dc=ly
cn: People
objectClass: organizationalRole
​
#添加greenplum用戶信息
#admin賬戶
dn: uid=admin,cn=People,ou=greenplum,dc=bigdata,dc=ly
objectClass: inetOrgPerson
uid: admin
sn: admin
cn: admin
userPassword: {SSHA}yuSYmdRGPsfCx4R5LfBLPHPCn+uhtG2B
​
#train賬戶
dn: uid=train,cn=People,ou=greenplum,dc=bigdata,dc=ly
objectClass: inetOrgPerson
uid: train
sn: train
cn: train
userPassword: {SSHA}yuSYmdRGPsfCx4R5LfBLPHPCn+uhtG2B
​
#添加system分組,用戶存儲系統用戶,提供外界訪問的openldap用戶
dn: cn=System,ou=greenplum,dc=bigdata,dc=ly
cn: System
objectClass: organizationalRole
​
#添加gp分組的只讀權限
dn: uid=gp_read,cn=System,ou=greenplum,dc=bigdata,dc=ly
objectClass: inetOrgPerson
uid: gp_read
sn: gp_read
cn: gp_read
userPassword: {SSHA}yuSYmdRGPsfCx4R5LfBLPHPCn+uhtG2B
​
#添加gp分組的讀寫權限
dn: uid=gp_write,cn=System,ou=greenplum,dc=bigdata,dc=ly
objectClass: inetOrgPerson
uid: gp_write
sn: gp_write
cn: gp_write
userPassword: {SSHA}yuSYmdRGPsfCx4R5LfBLPHPCn+uhtG2B

執行如下命令,將gp的賬戶信息導入到openldap中:

ldapadd -x -D "cn=admin,dc=bigdata,dc=ly" -w 1234 -f gp_user.ldif -H ldap://10.100.203.117:18888

配置ou=greenplum,dc=bigdata,dc=ly條目數據的訪問權限,編輯文件kylin_acl.ldif文件,添加內容如下,設置用戶uid=gp_read,cn=System,ou=kylin,dc=bigdata,dc=ly對ou=greenplum,dc=bigdata,dc=ly只用只讀權限,uid=gp_write,cn=System,ou=kylin,dc=bigdata,dc=ly有讀寫權限。

dn: olcDatabase={2}mdb,cn=config
changetype: modify
add: olcAccess
olcAccess: to dn.subtree="ou=greenplum,dc=bigdata,dc=ly"
    by dn.base="uid=gp_read,cn=System,ou=greenplum,dc=bigdata,dc=ly" read
    by dn.base="uid=gp_write,cn=System,ou=greenplum,dc=bigdata,dc=ly" write
    by * auth

執行如下命令,將配置導入到配置文件中去:

ldapmodify -x -D "cn=config" -w 1234 -f gp_acl.ldif -H ldap://10.100.203.117:18888

二、配置整合greenplum

配置greenplum整合openldap有兩種方式,一種方式將登錄的用戶名作爲dn的一部分,另外一種是用戶名不在dn中,這樣更加靈活,如下便是兩種配置方式。推薦使用方式二進行配置greenplum整合openldap。

  • 方式一:在master的postgresql上修改配置/data/greenplum/master/gpseg-1/pg_hba.conf,添加如下內容:
host     all all  0.0.0.0/0 ldap ldapserver=10.100.203.117 ldapport=18888  ldapprefix="uid=" ldapsuffix=",cn=People,ou=greenplum,dc=bigdata,dc=ly"
  • 方式二:在master的postgresql上修改配置/data/greenplum/master/gpseg-1/pg_hba.conf,添加如下內容:
host     all all  0.0.0.0/0 ldap ldapserver=10.100.203.117 ldapport=18888  ldapbasedn="cn=People,ou=greenplum,dc=bigdata,dc=ly" ldapbinddn="uid=gp_read,cn=System,ou=greenplum,dc=bigdata,dc=ly" ldapbindpasswd="1234" ldapsearchattribute="uid"

不管採用方式一還是方式二配置greenplum整合openldap,均需要重新加載配置:

pg_ctl reload -D /data/greenplum/master/gpseg-1/

當openldap用戶連接greenplum時,需要事先在greenplum創建相應的用戶,否則無法連接到greenplum。

psql
#創建用戶角色,並賦給登入權限
create role admin with login
#爲該角色賦表的權限
grant all on table foo to admin
#退出greenplum
\q
#登入greenplum
psql -d gptest -h 10.100.203.140 -p 5432 -U admin -W
#查詢所有的表
\dt
#執行查詢操作
select * from foo limit 10;
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章