12
12
13
13
``` shell
14
14
15
- docker run -d --rm --net=host \
15
+ docker run -d --net=host --restart=always \
16
16
-e TARS_OPEN_FRAMEWORK=true \
17
17
-e TARS_LOCATOR=" tcp -h $ip1 -p $port1 :tcp -h $ip2 -p $port2 :tcp -h $ip3 -p $port3 " \
18
18
-e TARS_NODENAME=" $nodename " \
19
19
-e TARS_REGISTRY=" tcp -h $ip1 -p 7891" \
20
20
-e TARS_LOCALIP=" $localip " \
21
- -e TARS_OPEN_WEB=true \
22
21
-e TARS_START_PORT=9999 \
22
+ -e TARS_MODE=cluster \
23
23
-v /data/tars:/data/tars \
24
24
--name framework-pro \
25
- ruanshudong /framework-pro
25
+ docker.tarsyun.com/tars-pro /framework-pro
26
26
```
27
27
28
28
说明:
29
29
- 至少需要启动三个容器, 组成framework集群
30
- - ` TARS_LOCATOR ` 指定了每个framework的地址, 需要自己配置好ip, port
31
- - ` TARS_REGISTRY ` 指定了当前启动的这个容器的tarsregistry地址, 必须是` TARS_LOCATOR ` 中的一个
32
- - ` TARS_LOCALIP ` 指定本机的ip, 如果支持多网卡, 可以使用"0.0.0.0"
33
- - ` TARS_NODENAME ` 指定当前节点的名称, 注意nodename必须不同, 而且唯一
34
- - ` TARS_OPEN_WEB ` 是否启动web管理平台
35
- - ` TARS_START_PORT ` 组件启用的起始端口, 如果不指定则随机分配端口
30
+ - ` TARS_OPEN_FRAMEWORK ` : 部署framework, 如果设置为false, 则只启动节点(请参考后续)
31
+ - ` TARS_LOCATOR ` : 多节点的framework的tarsregistry.QueryObj的地址, 需要自己配置ip: port
32
+ - ` TARS_REGISTRY ` : :当前框架的的tarsregistry地址, 必须是` TARS_LOCATOR ` 中的一个
33
+ - ` TARS_LOCALIP ` : 本机的ip, 如果支持多网卡, 可以使用"0.0.0.0"
34
+ - ` TARS_NODENAME ` : 当前节点的名称, 注意nodename必须不同, 而且唯一
35
+ - ` TARS_START_PORT ` : 组件启用的起始端口, 如果不指定则随机分配端口, 否则从这个端口开始分配端口
36
+ - ` TARS_MODE ` : 运行模式, 默认是集群模式(cluster), 也可以设置为单节点方式(single)
36
37
- 可以在同一机器上启动三个容器, 注意自己控制好地址接口
37
38
- 除了核心组件` tars.tarsregistry.QueryObj ` 的端口是分配的, 这里是: port1, port2, port3, 其他端口都是随机分配的
39
+ - 每台节点, 都启动了web管理平台, 你可以通过: ` http://${框架ip}:3000 ` , 打开管理平台
38
40
39
- ## 示例
41
+ ### 示例
40
42
41
- - 在三台机器上启动容器
43
+ - 在三台机器上启动容器, 并且三台容器构建成一个集群
42
44
43
45
比如在ip分别为: ` 192.168.11.1, 192.168.11.2, 192.168.11.3 ` 上部署容器, 你可以分别在三台机器上启动
44
46
45
47
在节点` 192.168.11.1 ` 上启动:
46
48
``` shell
47
- docker run -d --rm --net=host \
49
+ docker run -d --net=host --restart=always \
48
50
-e TARS_OPEN_FRAMEWORK=true \
49
51
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.2 -p 7890:tcp -h 192.168.11.3 -p 7890" \
50
52
-e TARS_NODENAME=" tarsnode-1" \
51
53
-e TARS_REGISTRY=" tcp -h 192.168.11.1 -p 7890" \
52
54
-e TARS_LOCALIP=" 192.168.11.1" \
53
- -e TARS_OPEN_WEB=true \
54
55
-e TARS_START_PORT=9000 \
55
56
-v /data/tars:/data/tars \
56
57
-v /etc/localtime:/etc/localtime \
57
58
--name framework-pro \
58
- ruanshudong /framework-pro
59
+ docker.tarsyun.com/tars-pro /framework-pro
59
60
```
60
61
61
62
在节点` 192.168.11.2 ` 上启动:
62
63
``` shell
63
- docker run -d --rm --net=host \
64
+ docker run -d --net=host --restart=always \
64
65
-e TARS_OPEN_FRAMEWORK=true \
65
66
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.2 -p 7890:tcp -h 192.168.11.3 -p 7890" \
66
67
-e TARS_NODENAME=" tarsnode-2" \
67
68
-e TARS_REGISTRY=" tcp -h 192.168.11.2 -p 7890" \
68
69
-e TARS_LOCALIP=" 192.168.11.2" \
69
- -e TARS_OPEN_WEB=true \
70
70
-e TARS_START_PORT=9100 \
71
71
-v /data/tars:/data/tars \
72
72
-v /etc/localtime:/etc/localtime \
73
73
--name framework-pro \
74
- ruanshudong /framework-pro
74
+ docker.tarsyun.com/tars-pro /framework-pro
75
75
```
76
76
77
77
在节点` 192.168.11.3 ` 上启动:
78
78
``` shell
79
- docker run -d --rm --net=host \
79
+ docker run -d --net=host --restart=always \
80
80
-e TARS_OPEN_FRAMEWORK=true \
81
81
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.2 -p 7890:tcp -h 192.168.11.3 -p 7890" \
82
82
-e TARS_NODENAME=" tarsnode-3" \
83
83
-e TARS_REGISTRY=" tcp -h 192.168.11.3 -p 7890" \
84
84
-e TARS_LOCALIP=" 192.168.11.3" \
85
- -e TARS_OPEN_WEB=true \
86
85
-e TARS_START_PORT=9200 \
87
86
-v /data/tars:/data/tars \
88
87
-v /etc/localtime:/etc/localtime \
89
88
--name framework-pro \
90
- ruanshudong /framework-pro
89
+ docker.tarsyun.com/tars-pro /framework-pro
91
90
```
92
91
93
- - 在一台机器上启动三个容器
92
+ - 在一台机器上启动三个容器, 并且构建成集群
94
93
95
94
比如在ip为` 192.168.11.1 ` 的机器上启动三个容器:
96
95
97
96
``` shell
98
- docker run -d --rm --net=host \
97
+ docker run -d --net=host --restart=always \
99
98
-e TARS_OPEN_FRAMEWORK=true \
100
99
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.1 -p 7891:tcp -h 192.168.11.1 -p 7892" \
101
100
-e TARS_NODENAME=" tarsnode-1" \
102
101
-e TARS_REGISTRY=" tcp -h 192.168.11.1 -p 7890" \
103
102
-e TARS_LOCALIP=" 192.168.11.1" \
104
- -e TARS_OPEN_WEB=true \
105
103
-e TARS_START_PORT=9000 \
106
104
-v /data/tars:/data/tars \
107
105
-v /etc/localtime:/etc/localtime \
108
106
--name framework-pro-1 \
109
- ruanshudong /framework-pro
107
+ docker.tarsyun.com/tars-pro /framework-pro
110
108
```
111
109
112
110
``` shell
113
- docker run -d --rm --net=host \
111
+ docker run -d --net=host --restart=always \
114
112
-e TARS_OPEN_FRAMEWORK=true \
115
113
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.1 -p 7891:tcp -h 192.168.11.1 -p 7892" \
116
114
-e TARS_NODENAME=" tarsnode-2" \
@@ -120,12 +118,12 @@ docker run -d --rm --net=host \
120
118
-v /data/tars:/data/tars \
121
119
-v /etc/localtime:/etc/localtime \
122
120
--name framework-pro-2 \
123
- ruanshudong /framework-pro
121
+ docker.tarsyun.com/tars-pro /framework-pro
124
122
```
125
123
126
124
127
125
``` shell
128
- docker run -d --rm --net=host \
126
+ docker run -d --net=host --restart=always \
129
127
-e TARS_OPEN_FRAMEWORK=true \
130
128
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.1 -p 7891:tcp -h 192.168.11.1 -p 7892" \
131
129
-e TARS_NODENAME=" tarsnode-3" \
@@ -135,7 +133,7 @@ docker run -d --rm --net=host \
135
133
-v /data/tars:/data/tars \
136
134
-v /etc/localtime:/etc/localtime \
137
135
--name framework-pro-3 \
138
- ruanshudong /framework-pro
136
+ docker.tarsyun.com/tars-pro /framework-pro
139
137
140
138
```
141
139
@@ -144,31 +142,46 @@ ruanshudong/framework-pro
144
142
docker exec ${containid} tarsctl framework status
145
143
```
146
144
147
- 注意:
148
- - 以上例子中只有framework-pro-1才启动了TARS_OPEN_WEB, 因为如果都启动, 会导致端口冲突, 因为在启动了三个容器, 且使用了--net=host模式
145
+ 可以通过` http://192.168.11.1:3000 ` , ` http://192.168.11.2:3000 ` ,` http://192.168.11.3:3000 ` , 打开管理平台!
149
146
150
- # 增加节点
147
+ - 在一台机器上以单节模式启动容器
148
+
149
+ ``` shell
150
+ docker run -d --net=host --restart=always \
151
+ -e TARS_OPEN_FRAMEWORK=true \
152
+ -e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890" \
153
+ -e TARS_NODENAME=" master" \
154
+ -e TARS_LOCALIP=" 192.168.11.1" \
155
+ -e TARS_START_PORT=9200 \
156
+ -e TARS_MODE=single \
157
+ -v /data/tars:/data/tars \
158
+ -v /etc/localtime:/etc/localtime \
159
+ --name framework-pro \
160
+ docker.tarsyun.com/tars-pro/framework-pro
161
+
162
+ ```
163
+
164
+ ## 增加节点
151
165
当部署框架以后, 我们可以增加节点, 也以容器方式增加节点, 命令如下:
152
166
153
167
``` shell
154
168
155
- docker run -d --rm --net=host \
169
+ docker run -d --net=host --restart=always \
156
170
-e TARS_OPEN_FRAMEWORK=false \
157
171
-e TARS_LOCATOR=" tcp -h $ip1 -p $port1 :tcp -h $ip2 -p $port2 :tcp -h $ip3 -p $port3 " \
158
172
-e TARS_NODENAME=" $nodename " \
159
173
-e TARS_LOCALIP=" $localip " \
160
- -e TARS_OPEN_WEB=true \
161
174
-v /data/tars:/data/tars \
162
175
-v /etc/localtime:/etc/localtime \
163
176
--name $nodename \
164
- ruanshudong /framework-pro
177
+ docker.tarsyun.com/tars-pro /framework-pro
165
178
```
166
179
167
180
例如:
168
181
169
182
``` shell
170
183
171
- docker run -d --rm --net=host \
184
+ docker run -d --net=host --restart=always \
172
185
-e TARS_OPEN_FRAMEWORK=false \
173
186
-e TARS_LOCATOR=" tcp -h 192.168.11.1 -p 7890:tcp -h 192.168.11.1 -p 7891:tcp -h 192.168.11.1 -p 7892" \
174
187
-e TARS_NODENAME=" tarsnode-4" \
@@ -177,5 +190,7 @@ docker run -d --rm --net=host \
177
190
-v /data/tars:/data/tars \
178
191
-v /etc/localtime:/etc/localtime \
179
192
--name tarsnode-4 \
180
- ruanshudong/framework-pro
181
- ```
193
+ docker.tarsyun.com/tars-pro/framework-pro
194
+ ```
195
+
196
+
0 commit comments