houyinke opened a new issue #4196: URL: https://github.com/apache/apisix/issues/4196
### 环境:Centos7 ### 以下是安装步骤和问题 adduser admin yum install wget -y yum install vim -y yum install unzip -y wget https://releases.hashicorp.com/consul/1.7.3/consul_1.7.3_linux_amd64.zip sudo unzip consul_1.7.3_linux_amd64.zip -d /usr/bin sudo vim /lib/systemd/system/consul.service [Unit] Description=consul [Service] ExecStart=/usr/bin/consul agent -config-dir /etc/consul KillSignal=SIGINT sudo mkdir /etc/consul/ sudo vim /etc/consul/server.json { "data_dir": "/var/consul", "log_level": "INFO", "node_name": "test", "server": true, "ui": true, "bootstrap_expect": 1, "client_addr": "0.0.0.0", "advertise_addr": "127.0.0.1", "ports": { "dns": 53 }, "advertise_addr_wan": "127.0.0.1" } sudo systemctl start consul wget https://dl.google.com/go/go1.13.linux-amd64.tar.gz tar -C /usr/local -xzf go1.13.linux-amd64.tar.gz echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile source /etc/profile go version git clone https://github.com/api7/consul-test-golang.git cd consul-test-golang nohup go run main.go & sudo yum install etcd nohup /usr/bin/etcd --enable-v2=true & wget https://openresty.org/package/centos/openresty.repo sudo mv openresty.repo /etc/yum.repos.d/ sudo yum install openresty -y wget https://github.com/apache/incubator-apisix/releases/download/1.3/apisix-1.3-0.el7.noarch.rpm sudo yum install apisix-1.3-0.el7.noarch.rpm -y vi /usr/local/apisix/conf/config.yaml add consul address to `dns_resolver`: dns_resolver: - 127.0.0.1 sudo apisix start [admin@apisix consul-test-golang]$ ps -ef|grep consul root 429 1 0 10:59 ? 00:00:48 /usr/bin/consul agent -config-dir /etc/consul admin 1267 927 0 17:12 pts/0 00:00:00 grep --color=auto consul [admin@apisix consul-test-golang]$ ps -ef|grep etcd admin 615 1 0 11:05 pts/0 00:03:02 /usr/bin/etcd --enable-v2=true admin 1269 927 0 17:12 pts/0 00:00:00 grep --color=auto etcd [admin@apisix consul-test-golang]$ ps -ef|grep go root 1015 927 0 11:25 pts/0 00:00:00 sudo go run main.go admin 1271 927 0 17:12 pts/0 00:00:00 grep --color=auto go [admin@apisix consul-test-golang]$ ps -ef|grep apisix root 993 1 0 11:20 ? 00:00:00 nginx: master process openresty -p /usr/local/apisix -c /usr/local/apisix/conf/nginx.conf admin 1273 927 0 17:12 pts/0 00:00:00 grep --color=auto apisix dig @127.0.0.1 go-consul-test.service.consul #没有关联上 ; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.5 <<>> @127.0.0.1 go-consul-test.service.consul ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 48770 ;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1 ;; WARNING: recursion requested but not available ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 4096 ;; QUESTION SECTION: ;go-consul-test.service.consul. IN A ;; AUTHORITY SECTION: consul. 0 IN SOA ns.consul. hostmaster.consul. 1620378703 3600 600 86400 0 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: 五 5月 07 17:11:43 CST 2021 ;; MSG SIZE rcvd: 108 curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -i -d ' { "uri": "/healthz", "upstream": { "type": "roundrobin", "nodes": { "go-consul-test.service.consul:8080": 1 } } }' 返回201 HTTP/1.1 201 Created Date: Fri, 07 May 2021 09:10:58 GMT Content-Type: text/plain Transfer-Encoding: chunked Connection: keep-alive Access-Control-Allow-Origin: * Access-Control-Allow-Credentials: true Access-Control-Expose-Headers: * Access-Control-Max-Age: 3600 Server: APISIX web server {"node":{"createdIndex":38,"key":"\/apisix\/routes\/1","value":{"uri":"\/healthz","priority":0,"upstream":{"type":"roundrobin","hash_on":"vars","nodes":{"go-consul-test.service.consul:8080":1}}},"modifiedIndex":38},"action":"set"} curl http://127.0.0.1:9080/healthz <html> <head><title>500 Internal Server Error</title></head> <body> <center><h1>500 Internal Server Error</h1></center> <hr><center>openresty</center> </body> </html> -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected]
