Getting Started
安装和配置
TIPC内核模块在主要Linux发行版中默认是可用的。只要做“modprobe tipc”
您可以在单节点模式下运行。
如果要在集群模式下运行,还必须为每个节点提供唯一的标识和
附加要使用的接口:
$ tipc node set addr 1.1.2 (e.g.) (This step can be omitted from Linux 4.17)
$ tipc bearer enable media eth dev eth0
如果您想要更好的冗余和性能,可以附加第二个接口:
$ tipc bearer enable media eth dev eth1
如果要在UDP上运行而不是直接在以太网上运行,请使用以下命令:
$ tipc link list
$ tipc bearer enable media udp name UDP1 localip 192.168.123.102 (e.g.)
$ tipc bearer enable media udp name UDP2 localip 192.168.124.102 (e.g.)
如果您以相同的方式设置了另一个节点,则现在可以列出指向该节点的链接:
$ tipc link list
broadcast-link: up
1001002:eth0-1001001:eth0: up
1001002:eth1-1001001:eth1: up
在此阶段,您还可以查看服务绑定表:
$ tipc nametable show
Type Lower Upper Scope Port Node
0 16781313 16781313 cluster 0 1001001
0 16781314 16781314 cluster 0 1001002
1 1 1 node 2535696389 1001002
2 16781313 16781313 node 0 1001002
2 16781313 16781313 node 65537 1001002
- 服务类型为0的两个条目显示集群中有两个节点:1001和1001。1001002(即自己的节点)。
- 服务类型为1的条目表示内置拓扑(服务跟踪)服务。
- 服务类型为2的两个条目显示了这两个链接,从发出(自己的)节点1002可以看到。范围限制16781313以十进制格式表示对等端点的地址(1001001)。
Running a Program
从项目页面下载并解包 tipcutils包。程序包附带了二进制文件,
但如果需要,很容易重建。
在一个shell中,执行以下操作:
$ ./tipcutils/demos/hello_world/hello_server
****** TIPC hello world server started *****
现在可以再看一眼地址绑定表:
$ tipc nametable show
Type Lower Upper Scope Port Node
0 16781313 16781313 cluster 0 1001001
0 16781314 16781314 cluster 0 1001002
1 1 1 node 2535696389 1001002
2 16781313 16781313 node 0 1001002
2 16781313 16781313 node 65537 1001002
18888 17 17 cluster 1697554572 1001002
服务器已将自己绑定到服务类型18888和实例17,并使自己可见
在整个集群中。
在另一个shell中,在同一节点或对等节点上,现在可以执行以下操作:
$ ./tipcutils/demos/hello_world/hello_client
****** TIPC hello world client started ******
Client: sent message: Hello World!!
Client: received response: Uh ?
****** TIPC hello client finished ******
如果您现在重做这个练习,但是在服务器之前启动客户机,您将看到一个简单的利用服务跟踪功能启动同步的示例。
Downloading the Code
内核源代码可以从以下位置签出:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
用于配置和管理tipc的“tipc”工具作为iproute2包的标准部分提供,在所有发行版中也可以使用。源代码可以从以下位置签出:
$ git clone git://git.kernel.org/pub/scm/network/iproute2/iproute2.git
“tipcutils”包包含一组演示和测试程序。可下载的.zip文件已完成
但它只是一个快照,因此它可能并不总是与git存储库中的最新版本保持同步。
可以从以下位置检出:
$ git clone git://git.code.sf.net/p/tipc/tipcutils