2012-02-15 67 views
1

我在ec2上使用hbase,刚刚意识到我的脚本不使用用户名/密码来访问hbase。有没有办法添加简单的用户名/密码认证?我该如何保护hbase?

更新:感兴趣的东西快速/肮脏像mysql具有用户名创建和授予特权。

回答

2

如果你不想去Kerberos路由(这是最好的做法,然而),如果你的HBase请求是从一个单一的点(如应用服务器),你可以随时尝试限制到Zookeeper客户端的IP连接。

默认情况下zookeeper客户端端口为2181(例如,参见http://blog.cloudera.com/blog/2013/07/guide-to-using-apache-hbase-ports/)。

一个简单的方法来做到这一点是使用iptables functionnality(如果你运行的是Linux),使用类似:

iptables -A INPUT -i lo -m comment --comment "enable loopback connections" -j ACCEPT 
# use the actual range of IPs that includes all of your cluster's nodes 
iptables -A INPUT -p tcp --destination-port 2181 -m iprange --src-range '174.121.3.0-174.121.3.10' -j ACCEPT 
iptables -A INPUT -p tcp --destination-port 2181 -j DROP -m comment --comment "Disable tcp trafic toward port 2181 (zookeeper)" 
# Export result so what it can be restored on reboot with iptables-restore < /etc/iptablesv4.conf (put it in something like /etc/rc.d/rc.local) 
iptables-save > /etc/iptablesv4.conf 

你需要这样做,因为HBase的客户群集中的每个节点上将找到任何可用的zookeeper端点来建立成功的连接。