安装JDK1.8+
$ java -version
java version"1.8.0_66"
下载安装linkerd
$ tar -xzf linkerd-1.3.4.tgz
$ cd linkerd-1.3.4
解压后的目录如下:
- config/linkerd.yaml — config file defining routers, servers, protocols, and ports
- disco/ — file-based service discovery config
- docs/ — documentation
- linkerd-1.3.4-exec — Linkerd executable
- logs/ — default location where Linkerd logs are written
运行linkerd
$ ./linkerd-1.3.4-exec config/linkerd.yaml
用python运行一个简单的web服务
$ echo 'It works!' > index.html
$ python -m SimpleHTTPServer 9999
效果
$ curl -I -H "Host: foo" http://localhost:4140/
HTTP/1.1 502 Bad Gateway
基于文件的服务发现
在linkerd安装目录下有一个disco目录,这是服务发现的定义目录,你可以随时增加、或移除,而无需重启服务。
$ head disco/*
==> disco/thrift-buffered <==
127.0.0.1 9997
==> disco/thrift-framed <==
127.0.0.1 9998
==> disco/web <==
127.0.0.1 9999
网友评论