-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtiflash.yaml
534 lines (477 loc) · 19.1 KB
/
tiflash.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
# 0. The tiflash image needs to be pushed to a Docker registry, and the following `image` field need to be adjusted to the registry address.
# 1. helm install pingcap/tidb-cluster --name=${TIDB_CLUSTER_NAME} --namespace=${MY-NAMESPACE} --version=v1.0.2 --set pd.image=tiflash,tikv.image=tiflash,tidb.image=tiflash
# 2. Replace the following TIDB_CLUSTER_NAME with the real tidb cluster name.
# 3. kubectl apply -f tiflash.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: rngine
spec:
selector:
matchLabels:
app: rngine
serviceName: rngine
replicas: 1
template:
metadata:
labels:
app: rngine
spec:
containers:
- name: rngine
image: tiflash
command:
- /tikv-server-rngine
- --addr=0.0.0.0:20160
- --advertise-addr=${MY_POD_NAME}.rngine.${MY_NAMESPACE}.svc:20160
- --data-dir=/data/rngine
- --pd=TIDB_CLUSTER_NAME-pd.${MY_NAMESPACE}.svc:2379
- --config=/etc/rngine/rngine.toml
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: data
mountPath: /data
- name: config
mountPath: /etc/rngine
volumes:
- name: config
configMap:
name: tiflash
items:
- key: rngine.toml
path: rngine.toml
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "local-storage"
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: tiflash
spec:
selector:
matchLabels:
app: tiflash
serviceName: tiflash
replicas: 1
template:
metadata:
labels:
app: tiflash
spec:
containers:
- name: tiflash
image: tiflash
command:
- /tiflash
- server
- --config-file=/etc/tiflash/config.xml
volumeMounts:
- name: data
mountPath: /data
- name: config
mountPath: /etc/tiflash
- name: logs
mountPath: /logs
# TODO: decide if flash-cluster-manager should be deployed along side with tiflash
- name: flash-cluster-manager
image: tiflash
command:
- /flash-cluster-manager
- /etc/tiflash/config.xml
volumeMounts:
- name: data
mountPath: /data
- name: config
mountPath: /etc/tiflash
# To better support k8s, allow normal log to output stdout,
# so only the error log tailer is needed
- name: tiflash-log
image: busybox
command:
- /bin/sh
- -c
- |
touch /logs/tiflash-server.log
tail -n0 -F /logs/tiflash-server.log
volumeMounts:
- name: logs
mountPath: /logs
- name: error-log
image: busybox
command:
- /bin/sh
- -c
- |
touch /logs/tiflash-error.log
tail -n0 -F /logs/tiflash-error.log
volumeMounts:
- name: logs
mountPath: /logs
- name: flash-cluster-manager-log
image: busybox
# TODO: The log directory is weird, can we just log to stdout?
command:
- /bin/sh
- -c
- |
touch /data/tiflash/tmp/flash_cluster_manager.log
tail -n0 -F /data/tiflash/tmp/flash_cluster_manager.log
volumeMounts:
- name: logs
mountPath: /logs
volumes:
- name: logs
emptyDir: {}
- name: config
configMap:
name: tiflash
items:
- key: config.xml
path: config.xml
- key: users.xml
path: users.xml
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "local-storage"
resources:
requests:
storage: 10Gi
---
apiVersion: v1
kind: Service
metadata:
name: rngine
labels:
app: rngine
spec:
ports:
- port: 20160
clusterIP: None
selector:
app: rngine
---
apiVersion: v1
kind: Service
metadata:
name: tiflash
labels:
app: tiflash
spec:
ports:
- port: 3930 # TODO: what the 8123, 9000 and 9009 port for, which type of service should we use for these service port?
clusterIP: None
selector:
app: tiflash
---
apiVersion: v1
kind: ConfigMap
metadata:
name: tiflash
data:
rngine.toml: |
[readpool.storage]
[readpool.coprocessor]
[server]
labels = { "engine" = "tiflash", "tiflash_http_port" = "8123" }
# TODO: does tiflash support multiple instances, how should we configure the engine-addr if there are multiple tiflash instance
# Replace the MY_NAMESPACE with the real namespace
engine-addr = "tiflash-0.tiflash.MY_NAMESPACE.svc:3930" # tics address
[storage]
[pd]
# This section will be overwritten by command line parameters
[metric]
#address = "172.16.30.31:9531"
#interval = "15s"
#job = "tikv"
[raftstore]
raftdb-path = ""
sync-log = true
max-leader-missing-duration = "22s"
abnormal-leader-missing-duration = "21s"
peer-stale-state-check-interval = "20s"
[coprocessor]
[rocksdb]
wal-dir = ""
[rocksdb.defaultcf]
block-cache-size = "10GB"
[rocksdb.lockcf]
block-cache-size = "4GB"
[rocksdb.writecf]
block-cache-size = "4GB"
[raftdb]
[raftdb.defaultcf]
block-cache-size = "1GB"
[security]
ca-path = ""
cert-path = ""
key-path = ""
[import]
# To better support K8s, the related address needs to be configured from command line arguments.
# eg. raft.pd_addr, flash.service_addr, flash.tidb_status_addr
tiflash-config.xml: |
<?xml version="1.0"?>
<yandex>
<application>
<runAsDaemon>true</runAsDaemon>
</application>
<logger>
<level>trace</level>
<log>/logs/tiflash-server.log</log>
<errorlog>/logs/tiflash-error.log</errorlog>
<size>1000M</size>
<count>10</count>
<!-- <console>1</console> --> <!-- Default behavior is autodetection (log to console if not daemon mode and is tty) -->
</logger>
<display_name>the flash</display_name>
<raft>
<kvstore_path>/data/tiflash/kvstore</kvstore_path>
<pd_addr>TIDB_CLUSTER_NAME-pd:2379</pd_addr>
<ignore_databases>system</ignore_databases>
<learner_key>engine</learner_key>
<learner_value>tiflash</learner_value>
</raft>
<flash>
<service_addr>tiflash-0.tiflash.MY_NAMESPACE.svc:3930</service_addr> <!--tics address-->
<flash_cluster>
<master_ttl>60</master_ttl>
<refresh_interval>20</refresh_interval>
<update_rule_interval>5</update_rule_interval>
</flash_cluster>
<tidb_status_addr>TIDB_CLUSTER_NAME-tidb:10080</tidb_status_addr>
</flash>
<http_port>8123</http_port>
<tcp_port>9000</tcp_port>
<interserver_http_port>9009</interserver_http_port>
<!--listen_host>::1</listen_host-->
<listen_host>0.0.0.0</listen_host>
<!-- Don't exit if ipv6 or ipv4 unavailable, but listen_host with this protocol specified -->
<!-- <listen_try>0</listen_try> -->
<!-- Allow listen on same address:port -->
<!-- <listen_reuse_port>0</listen_reuse_port> -->
<!-- <listen_backlog>64</listen_backlog> -->
<max_connections>4096</max_connections>
<keep_alive_timeout>3</keep_alive_timeout>
<!-- Maximum number of concurrent queries. -->
<max_concurrent_queries>100</max_concurrent_queries>
<!-- Set limit on number of open files (default: maximum). This setting makes sense on Mac OS X because getrlimit() fails to retrieve
correct maximum value. -->
<!-- <max_open_files>262144</max_open_files> -->
<!-- Size of cache of uncompressed blocks of data, used in tables of MergeTree family.
In bytes. Cache is single for server. Memory is allocated only on demand.
Cache is used when 'use_uncompressed_cache' user setting turned on (off by default).
Uncompressed cache is advantageous only for very short queries and in rare cases.
-->
<uncompressed_cache_size>8589934592</uncompressed_cache_size>
<!-- Approximate size of mark cache, used in tables of MergeTree family.
In bytes. Cache is single for server. Memory is allocated only on demand.
You should not lower this value.
-->
<mark_cache_size>5368709120</mark_cache_size>
<!-- Path of persisted mapping cache in fast(er) disk device.
Empty means disabled.
Seperated with ';' if there are more than one path.
-->
<persisted_mapping_cache_path></persisted_mapping_cache_path>
<!-- Quota size in bytes of persisted mapping cache, in bytes. 0 means unlimited. -->
<persisted_mapping_cache_size>0</persisted_mapping_cache_size>
<!-- Path to data directory, with trailing slash. -->
<path>/data/tiflash/db</path>
<!-- Path to temporary data for processing hard queries. -->
<tmp_path>/data/tiflash/tmp</tmp_path>
<l0_optimize>false</l0_optimize>
<!-- Path to configuration file with users, access rights, profiles of settings, quotas. -->
<users_config>/etc/tiflash/users.xml</users_config>
<!-- Default profile of settings. -->
<default_profile>default</default_profile>
<!-- System profile of settings. This settings are used by internal processes (Buffer storage, Distibuted DDL worker and so on). -->
<!-- <system_profile>default</system_profile> -->
<!-- Default database. -->
<default_database>default</default_database>
<!-- Server time zone could be set here.
Time zone is used when converting between String and DateTime types,
when printing DateTime in text formats and parsing DateTime from text,
it is used in date and time related functions, if specific time zone was not passed as an argument.
Time zone is specified as identifier from IANA time zone database, like UTC or Africa/Abidjan.
If not specified, system time zone at server startup is used.
Please note, that server could display time zone alias instead of specified name.
Example: W-SU is an alias for Europe/Moscow and Zulu is an alias for UTC.
-->
<!-- <timezone></timezone> -->
<!-- You can specify umask here (see "man umask"). Server will apply it on startup.
Number is always parsed as octal. Default umask is 027 (other users cannot read logs, data files, etc; group can only read).
-->
<!-- <umask>022</umask> -->
<!-- Reloading interval for embedded dictionaries, in seconds. Default: 3600. -->
<builtin_dictionaries_reload_interval>3600</builtin_dictionaries_reload_interval>
<!-- Maximum session timeout, in seconds. Default: 3600. -->
<max_session_timeout>3600</max_session_timeout>
<!-- Default session timeout, in seconds. Default: 60. -->
<default_session_timeout>600</default_session_timeout>
<!-- Query log. Used only for queries with setting log_queries = 1. -->
<query_log>
<!-- What table to insert data. If table is not exist, it will be created.
When query log structure is changed after system update,
then old table will be renamed and new table will be created automatically.
-->
<database>system</database>
<table>query_log</table>
<!--
PARTITION BY expr https://clickhouse.yandex/docs/en/table_engines/custom_partitioning_key/
Example:
event_date
toMonday(event_date)
toYYYYMM(event_date)
toStartOfHour(event_time)
-->
<partition_by>toYYYYMM(event_date)</partition_by>
<!-- Interval of flushing data. -->
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>
<!-- Uncomment if use part_log
<part_log>
<database>system</database>
<table>part_log</table>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</part_log>
-->
<dictionaries_config>*_dictionary.xml</dictionaries_config>
<!-- Uncomment if you want data to be compressed 30-100% better.
Don't do that if you just started using ClickHouse.
-->
<compression>
<!--
<!- - Set of variants. Checked in order. Last matching case wins. If nothing matches, lz4 will be used. - ->
<case>
<!- - Conditions. All must be satisfied. Some conditions may be omitted. - ->
<min_part_size>10000000000</min_part_size> <!- - Min part size in bytes. - ->
<min_part_size_ratio>0.01</min_part_size_ratio> <!- - Min size of part relative to whole table size. - ->
<!- - What compression method to use. - ->
<method>zstd</method>
</case>
-->
</compression>
<!-- Settings to fine tune MergeTree tables. See documentation in source code, in MergeTreeSettings.h -->
<!--
<merge_tree>
<max_suspicious_broken_parts>5</max_suspicious_broken_parts>
</merge_tree>
-->
<!-- Protection from accidental DROP.
If size of a MergeTree table is greater than max_table_size_to_drop (in bytes) than table could not be dropped with any DROP query.
If you want do delete one table and don't want to restart clickhouse-server, you could create special file <clickhouse-path>/flags/force_drop_table and make DROP once.
By default max_table_size_to_drop is 50GB, max_table_size_to_drop=0 allows to DROP any tables.
Uncomment to disable protection.
-->
<max_table_size_to_drop>0</max_table_size_to_drop>
</yandex>
tiflash-user.xml: |
<?xml version="1.0"?>
<yandex>
<!-- Profiles of settings. -->
<profiles>
<!-- Default settings. -->
<default>
<!-- Maximum memory usage for processing single query, in bytes. -->
<max_memory_usage>4000000000</max_memory_usage>
<!-- Use cache of uncompressed blocks of data. Meaningful only for processing many of very short queries. -->
<use_uncompressed_cache>0</use_uncompressed_cache>
<!-- How to choose between replicas during distributed query processing.
random - choose random replica from set of replicas with minimum number of errors
nearest_hostname - from set of replicas with minimum number of errors, choose replica
with minumum number of different symbols between replica's hostname and local hostname
(Hamming distance).
in_order - first live replica is choosen in specified order.
-->
<load_balancing>random</load_balancing>
</default>
<!-- Profile that allows only read queries. -->
<readonly>
<readonly>1</readonly>
</readonly>
</profiles>
<!-- Users and ACL. -->
<users>
<!-- If user name was not specified, 'default' user is used. -->
<default>
<!-- Password could be specified in plaintext or in SHA256 (in hex format).
If you want to specify password in plaintext (not recommended), place it in 'password' element.
Example: <password>qwerty</password>.
Password could be empty.
If you want to specify SHA256, place it in 'password_sha256_hex' element.
Example: <password_sha256_hex>65e84be33532fb784c48129675f9eff3a682b27168c0ea744b2cf58ee02337c5</password_sha256_hex>
How to generate decent password:
Execute: PASSWORD=$(base64 < /dev/urandom | head -c8); echo "$PASSWORD"; echo -n "$PASSWORD" | sha256sum | tr -d '-'
In first line will be password and in second - corresponding SHA256.
-->
<password></password>
<!-- List of networks with open access.
To open access from everywhere, specify:
<ip>::/0</ip>
To open access only from localhost, specify:
<ip>::1</ip>
<ip>127.0.0.1</ip>
Each element of list has one of the following forms:
<ip> IP-address or network mask. Examples: 213.180.204.3 or 10.0.0.1/8 or 2a02:6b8::3 or 2a02:6b8::3/64.
<host> Hostname. Example: server01.yandex.ru.
To check access, DNS query is performed, and all received addresses compared to peer address.
<host_regexp> Regular expression for host names. Example, ^server\d\d-\d\d-\d\.yandex\.ru$
To check access, DNS PTR query is performed for peer address and then regexp is applied.
Then, for result of PTR query, another DNS query is performed and all received addresses compared to peer address.
Strongly recommended that regexp is ends with $
All results of DNS requests are cached till server restart.
-->
<networks>
<ip>::/0</ip>
</networks>
<!-- Settings profile for user. -->
<profile>default</profile>
<!-- Quota for user. -->
<quota>default</quota>
</default>
<!-- Example of user with readonly access. -->
<readonly>
<password></password>
<networks>
<ip>::1</ip>
<ip>127.0.0.1</ip>
</networks>
<profile>readonly</profile>
<quota>default</quota>
</readonly>
</users>
<!-- Quotas. -->
<quotas>
<!-- Name of quota. -->
<default>
<!-- Limits for time interval. You could specify many intervals with different limits. -->
<interval>
<!-- Length of interval. -->
<duration>3600</duration>
<!-- No limits. Just calculate resource usage for time interval. -->
<queries>0</queries>
<errors>0</errors>
<result_rows>0</result_rows>
<read_rows>0</read_rows>
<execution_time>0</execution_time>
</interval>
</default>
</quotas>
</yandex>