Docker在构建镜像阶段无法配置免密码sudo。但是在实际需求场景中会遇到需要使用sudo的场景。所以,我的解决思路是镜像构建及CMD使用root,在CMD的脚本中执行需要sudo的部分,然后使用普通用户启动服务进程。

当然,基于root使用普通用户启动进程可以选择su或者runuser。我使用的是su:

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

cd `dirname $0`

${RANGER_HOME}/enable-hive-plugin.sh
if [ $? -ne 0 ];then
echo "启用ranger plugin错误!"
exit 1
fi

su -mp -c '/opt/hive/bin/hiveserver2' hive
阅读全文 »

Creating MySQL user ranger2 failed

1
2
2021-07-01 18:44:53,480  [E] Creating MySQL user ranger2 failed..
2021-07-01 18:44:53,496 [E] DB schema setup failed! Please contact Administrator.

原因是Ranger安装程序默认会使用MySQL的root账号创建所需要的账号,也就是DBA过程。如果不需要安装程序自动创建,则将install.properties中的以下配置前的#号去掉:

阅读全文 »

如果变量值中包含斜杠(/)特殊字符,在使用sed命令的做行内字符串替换时可以使用井号(#)做为sed语法分隔符,如下:

1
2
GITLAB_PROJECT_CLONE_URL=ssh://git@192.168.1.10:50022/test/Documentation.git
sed -i "11s#GITLAB_PROJECT_CLONE_URL#$GITLAB_PROJECT_CLONE_URL#" config.xml

shell -c {string}:表示命令从-c后的字符串读取。在需要使用管道或者重定向需要sudo时很有用,如下:

1
2
$ sudo find ../*/exportFiles -mtime +15 -name "*" | xargs -I {} rm -rf {}
rm: cannot remove `i_20201108_CONTENTINFO_xy_001.dat': Permission denied

按照以下方式处理即可:

阅读全文 »

异常信息如下:

1
2
3
4
5
org.apache.ranger.plugin.client.HadoopException: Unable to connect to Hive Thrift Server instance..
Unable to connect to Hive Thrift Server instance..
Could not open client transport with JDBC Uri: jdbc:hive2://192.168.72.212:10000: Could not establish connection to jdbc:hive2://192.168.72.212:10000: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default}).
Could not establish connection to jdbc:hive2://192.168.72.212:10000: Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default}).
Required field 'client_protocol' is unset! Struct:TOpenSessionReq(client_protocol:null, configuration:{set:hiveconf:hive.server2.thrift.resultset.default.fetch.size=1000, use:database=default}).

百度后是因为Hive版本不匹配导致的。我的测试环境Hive版本是2.1.1,通过下面的命令发现确实版本不一致:

阅读全文 »

告警信息及如何解决见我的另外一篇博客:MySQL JDBC连接异常:javax.net.ssl.SSLException: closing inbound before receiving peer’s close_notify

但是Ranger的安装配置install.properties中未启用ssl,配置信息如下:

1
2
3
4
5
6
7
8
9
10
#SSL config
db_ssl_enabled=false
db_ssl_required=false
db_ssl_verifyServerCertificate=false
#db_ssl_auth_type=1-way|2-way, where 1-way represents standard one way ssl authentication and 2-way represents mutual ssl authentication
db_ssl_auth_type=2-way
javax_net_ssl_keyStore=
javax_net_ssl_keyStorePassword=
javax_net_ssl_trustStore=
javax_net_ssl_trustStorePassword=
阅读全文 »

关于Iptables的介绍个人强烈推荐:http://www.zsythink.net/archives/tag/iptables/page/2/。这位兄弟介绍的很详细。

我个人的需求是在同一个网络内从网络上把测试主机与正式环境主机间的网络进行隔离。我的思路是采用OUTPUT filter表,采用黑名单方式禁用正式环境网络的访问。如果确实需要访问正式环境的某个IP和端口,则添加特殊规则放行。根据Iptables的规则匹配顺序原则,放行特定IP和端口的规则要在网段禁用规则之前。以下是我的名列列表:

1
2
3
4
5
iptables -t filter -P OUTPUT ACCEPT
iptables -F OUTPUT
iptables -t filter -I OUTPUT -d 192.168.72.0/24 -j DROP
iptables -t filter -I OUTPUT -d 192.168.72.1/32 -j ACCEPT
service iptables save
阅读全文 »
0%