新人第一贴:关于启动TIDB,无法导入grafana 初始化模板

各位大神: 本人刚开始接触TIDB,在使用ansible模式部署了TIDB集群,但在启动过程中,导入grafana模板失败,由于本人能力有限,无法排除此故障,故劳烦论坛的兄弟们协助处理,万分感谢,以下为报错信息。 操作系统: RedHat Linux 7.3 TIDB版本:V2.1.15 TASK [import grafana dashboards - run import script] ************************************************************************************************************************************************************************************************************************* fatal: [10.70.218.32 -> localhost]: FAILED! => {“changed”: true, “cmd”: “./grafana-config-copy.py”, “delta”: “0:01:15.165188”, “end”: “2019-10-08 16:19:03.193828”, “msg”: “non-zero return code”, “rc”: 1, “start”: “2019-10-08 16:17:48.028640”, “stderr”: “Traceback (most recent call last): File “./grafana-config-copy.py”, line 145, in ret = import_dashboard_via_user_pass(dest[‘url’], dest[‘user’], dest[‘password’], dashboard) File “./grafana-config-copy.py”, line 127, in import_dashboard_via_user_pass resp = urllib2.urlopen(req) File “/usr/lib64/python2.7/urllib2.py”, line 154, in urlopen return opener.open(url, data, timeout) File “/usr/lib64/python2.7/urllib2.py”, line 431, in open response = self._open(req, data) File “/usr/lib64/python2.7/urllib2.py”, line 449, in _open ‘_open’, req) File “/usr/lib64/python2.7/urllib2.py”, line 409, in _call_chain result = func(*args) File “/usr/lib64/python2.7/urllib2.py”, line 1244, in http_open return self.do_open(httplib.HTTPConnection, req) File “/usr/lib64/python2.7/urllib2.py”, line 1217, in do_open r = h.getresponse(buffering=True) File “/usr/lib64/python2.7/httplib.py”, line 1089, in getresponse response.begin() File “/usr/lib64/python2.7/httplib.py”, line 444, in begin version, status, reason = self._read_status() File “/usr/lib64/python2.7/httplib.py”, line 408, in _read_status raise BadStatusLine(line) httplib.BadStatusLine: ‘’”, “stderr_lines”: [“Traceback (most recent call last):”, " File “./grafana-config-copy.py”, line 145, in “, " ret = import_dashboard_via_user_pass(dest[‘url’], dest[‘user’], dest[‘password’], dashboard)”, " File “./grafana-config-copy.py”, line 127, in import_dashboard_via_user_pass", " resp = urllib2.urlopen(req)", " File “/usr/lib64/python2.7/urllib2.py”, line 154, in urlopen", " return opener.open(url, data, timeout)", " File “/usr/lib64/python2.7/urllib2.py”, line 431, in open", " response = self._open(req, data)", " File “/usr/lib64/python2.7/urllib2.py”, line 449, in _open", " ‘_open’, req)", " File “/usr/lib64/python2.7/urllib2.py”, line 409, in _call_chain", " result = func(*args)", " File “/usr/lib64/python2.7/urllib2.py”, line 1244, in http_open", " return self.do_open(httplib.HTTPConnection, req)", " File “/usr/lib64/python2.7/urllib2.py”, line 1217, in do_open", " r = h.getresponse(buffering=True)", " File “/usr/lib64/python2.7/httplib.py”, line 1089, in getresponse", " response.begin()", " File “/usr/lib64/python2.7/httplib.py”, line 444, in begin", " version, status, reason = self._read_status()", " File “/usr/lib64/python2.7/httplib.py”, line 408, in _read_status", " raise BadStatusLine(line)", “httplib.BadStatusLine: ‘’”], “stdout”: “[load] from <node.json>:node [import] <Tidb-Cluster-Node_exporter> to [Tidb-Cluster] … “, “stdout_lines”: [”[load] from <node.json>:node”, "[import] <Tidb-Cluster-Node_exporter> to [Tidb-Cluster] … "]}

tidb-ansible 的 inventory.ini 配置文件中的grafana_admin_user、 grafana_admin_password 这两个配置的是什么?

admin,默认的。grafana 服务能够起来。但导入脚本就是出错。

ansible 的版本多少?

2.5.0

尝试过重复执行 ansible-playbook start.yml 吗?

尝试了很多次了,甚至重新安装了,还是不行。

将 start.yml 文件中的import grafana dashboards 对应的命令改成如下试试:

- name: import grafana dashboards - run import script
  delegate_to: localhost
  shell: "python grafana-config-copy.py"
  args:
    chdir: "{{ playbook_dir }}/scripts"
  vars:
    - ansible_become: false
    - ansible_connection: local

cd tidb-ansible/scripts python grafana-config-copy.py

手动执行下,看看输出呢

你好,结果是一样的。路径是没有问题的。

cd tidb-ansible/scripts python grafana-config-copy.py

手动执行后,输出也是一样的吗?如果不是,贴一下看看

这是执行信息 [load] from <node.json>:node [import] <Tidb-Cluster-Node_exporter> to [Tidb-Cluster] … Traceback (most recent call last): File “grafana-config-copy.py”, line 145, in ret = import_dashboard_via_user_pass(dest[‘url’], dest[‘user’], dest[‘password’], dashboard) File “grafana-config-copy.py”, line 127, in import_dashboard_via_user_pass resp = urllib2.urlopen(req) File “/usr/lib64/python2.7/urllib2.py”, line 154, in urlopen return opener.open(url, data, timeout) File “/usr/lib64/python2.7/urllib2.py”, line 431, in open response = self._open(req, data) File “/usr/lib64/python2.7/urllib2.py”, line 449, in _open ‘_open’, req) File “/usr/lib64/python2.7/urllib2.py”, line 409, in _call_chain result = func(*args) File “/usr/lib64/python2.7/urllib2.py”, line 1244, in http_open return self.do_open(httplib.HTTPConnection, req) File “/usr/lib64/python2.7/urllib2.py”, line 1217, in do_open r = h.getresponse(buffering=True) File “/usr/lib64/python2.7/httplib.py”, line 1089, in getresponse response.begin() File “/usr/lib64/python2.7/httplib.py”, line 444, in begin version, status, reason = self._read_status() File “/usr/lib64/python2.7/httplib.py”, line 408, in _read_status raise BadStatusLine(line) httplib.BadStatusLine: ‘’

感觉像是 网络问题,python 脚本执行就是报错的,

cd tidb-ansible/scripts cat dests.json 根据 url 中的 ip port ,在 ansible 机器上执行下 telnet ip port ,看看网络是否正常

如果不行,抛开 tidb 不看,单独调试下这个 python 脚本看看?

问题已经解决,感谢. 是代理的问题.

我的网络也是通过代理上网的,你是咋解决的