由于我司有一部分windows的业务,我在agent安装时遇到了很多的坑,由于目前windows服务比较少,所以社区相关的资料比较少,很多都是自己到处查资料研究及蓝鲸大神的协助解决,为了避免大家踩坑,特将我这边的解决方案和大家分享。
根据蓝鲸的求,部署前,服务器必须满足以下条件:
检查文件共享相关服务,确认以下服务均已开启
Function Discovery Resource Publication
SSDP Discovery
UPnP Device Host
Server
NetLogon // 如果没有加入域,可以不启动这个
TCP/IP NetBIOS Helper
开启网卡 Net BOIS
开启文件共享 Net share
检查防火墙是否有放开 139/135/445 端口
必须打开admin$和c$的隐式共享,并且授予超级管理员权限
为了方便大家快速的开启以上服务, 我将我的方案理成BAT批处理脚本, 将内容复制并保存到.bat文件,并且用管理员权限运行即可设置好所有权限
:: 开启 Function Discovery Resource Publication sc config FDResPub start= demand sc start FDResPub :: 开启 SSDP Discovery sc config SSDPSRV start= demand sc start SSDPSRV :: 开启UPnP Device Host sc config upnphost start= demand sc start upnphost :: 开启TCP/IP NetBIOS Helper sc config lmhosts start= demand sc start lmhosts :: 开启Server sc start LanmanServer :: 设置OPENSSL环境变量 wmic ENVIRONMENT create name="OPENSSL_ia32cap",username="<system>",VariableValue=0x1000000000000000:0 :: 开启admin$和c$的隐式共享,并且授予超级管理员权限, 其中adminbf为计算机的超级管理员账号,根据实际情况修改。 net share /delete admin$ net share admin$ /unlimited /grant:adminbf,full net share /delete c$ net share c$=c: /unlimited /grant:adminbf,full :: 开启防火墙策略 :: 需要对remotip(中控机或proxy的内网IP)放通60020-60030的TCP, UDP端口, 安装时要放通TCP 139,135,445,1024-65535 端口 :: 以windows高级防火墙管理为例: netsh advfirewall firewall add rule name="for blueking-agent tcp" protocol=TCP dir=in localport=60020-60030 action=allow remoteip=10.0.0.0/8 netsh advfirewall firewall add rule name="for blueking-agent udp" protocol=UDP dir=in localport=60020-60030 action=allow remoteip=10.0.0.0/8 :: 以下规则仅安装时用,安装成功后可以删除 netsh advfirewall firewall add rule name="for blueking-agent install" protocol=TCP dir=in localport=139,135,445,1024-65535 action=allow remoteip=10.0.0.0/8
脚本运行完成后,可根据 官方指引进行检查,若无问题即可以开始安装
445端口不通
我遇到过这个情况, 445端口监听在了0.0.0.0:445, 但却只有127.0.0.1可以通, 排除了所有的防火墙及安全规则的问题, 该问题原因我排查了很久,主要原因是由于网卡的NetBOIS没有开启, 具体开启方式:开启NETBOIS
开启后需要重启服务器才能生效, 如果不方便重启的,只能选择纯属手动部署.
安装出现字符集编码错误
现象:
[2022-04-18 10:41:45 ERROR] [proxy] proxy_fail FAILED Traceback (most recent call last): File "/opt/py36/lib/python3.6/cmd.py", line 214, in onecmd func = getattr(self, 'do_' + cmd) AttributeError: 'RemoteShell' object has no attribute 'do_del' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/tmp/wmiexec.py", line 122, in run result = self.shell.onecmd(self.__command) File "/opt/py36/lib/python3.6/cmd.py", line 216, in onecmd return self.default(line) File "/tmp/wmiexec.py", line 270, in default return self.send_data(line) File "/tmp/wmiexec.py", line 339, in send_data print(self.__outputBuffer) UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/tmp/setup_pagent.py", line 880, in <module> main() File "/tmp/setup_pagent.py", line 485, in main login_ip, construct_cmd[_os], user, int(port), identity, args.download_url, tmp_dir, File "/tmp/setup_pagent.py", line 196, in windows_cmd execute_win_commands(commands, login_ip, user, identity, download_url) File "/tmp/setup_pagent.py", line 204, in execute_win_commands res = execute_cmd(cmd, login_ip, user, identity, download_url, noOutput=noOutput) File "/tmp/setup_pagent.py", line 324, in execute_cmd result_data = executor.run(ipaddr) File "/tmp/wmiexec.py", line 136, in run raise Exception(str(e)) Exception: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
原因: proxy或中控机的字集不符合要求, 到中控机或proxy运行 locale命令查看,需要设置成en_us.UTF-8
[root@localhost OFS_Prop]# locale LANG=en_US.UTF-8 LC_CTYPE="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_PAPER="en_US.UTF-8" LC_NAME="en_US.UTF-8" LC_ADDRESS="en_US.UTF-8" LC_TELEPHONE="en_US.UTF-8" LC_MEASUREMENT="en_US.UTF-8" LC_IDENTIFICATION="en_US.UTF-8" LC_ALL=
解决方案:
修改系统默认字符集
修改/etc/sysconfig/i18n, 将LANG改成"en_US.UTF-8",如: LANG=“en_US.UTF-8”
执行命令 source /etc/sysconfig/i18n 使生效
重启proxy(必须要在字符集调整生效后重启一次)
部署,问题解决
如果上术方法均未能安装成功,可以选择手动部署,本人亲测可以安装成功,步骤如下:
先用节点管理尝试安装,忽略失败,目的就是为了注册节点管理和CMDB
下载windows的 gse程序包,可以到节点管理中下载。 如: https://nodeman.domain.com/download/gse_client-windows-x86_64.tgz
创建C:\gse目录,并将文件解压至该目录下
修改agent/etc/agnet.conf
– 确认目标机器需要注册到配置平台的内网 IP 地址以及本机的网卡地址,这里涉及到 agent.conf 配置文件的修改。大多数情况下这两个 ip 地址都是一样的。
– 注册到配置平台的内网 ip 地址(填入 identityip):日后在蓝鲸平台上,无论是作业平台,还是监控平台,都会用该 ip 地址来指代这台主机。
– 本机网卡地址(填入 agentip):通过 ip addr 命令能看到的 ip 地址
启动并注册 agent
C:\gse\agent\bin\gse_agent_daemon.exe --file C:\gse\agent\etc\agent.conf --name gse_agent_daemon_gse
确认 agent 启动正常,并和 gse server 成功建立连接
# 任务管理器中观察进程状态 tasklist | findstr gse_ ## 输出有 gse_agent_daemon.exe 和 gse_agent.exe # 确认建立了连接 netstat -an | findstr 48533 ## 输出有一个ESTABLISHED
使用“节点管理”升级功能,恢复 agent 功能
使用“节点管理”托管“插件”
我们公司windows服务器比较多,环境差异也比较大,本人已经踩过很多的坑, 按这个步骤执行下来,基本上都能安装成功。
联系客服