Skip to content

Commit aeb304d

Browse files
committed
add file
1 parent 68a5962 commit aeb304d

File tree

8 files changed

+164
-0
lines changed

8 files changed

+164
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
3+
# zk servers, 192.168.88.70:2181,192.168.88.71:2181,192.168.88.72:2181/kafka/0.10.0.1
4+
urls=$1
5+
6+
bin/kafka-topics.sh --create --zookeeper ${urls} --replication-factor 3 --partitions 3 --topic app-log
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/usr/bin/python198
2+
# -*- coding: UTF-8 -*-
3+
4+
import sys
5+
import datetime
6+
from pyelasticsearch import ElasticSearch
7+
from pyelasticsearch import bulk_chunks
8+
9+
def main(argv):
10+
index = argv[1]
11+
doc_type = 'log'
12+
url = []
13+
urls = argv[2].strip().split(',')
14+
for u in urls:
15+
url.append(u)
16+
17+
es = ElasticSearch(urls = url, timeout = 60, max_retries = 0)
18+
create_mapping(es, index, doc_type)
19+
20+
def create_mapping(es, index, doc_type):
21+
mapping = {
22+
'settings': {
23+
'index': {
24+
'number_of_replicas': 1,
25+
'number_of_shards': 6,
26+
'refresh_interval': '5s'
27+
}
28+
},
29+
'mappings': {
30+
'_default_': {
31+
'_all': {
32+
'enabled': False
33+
}
34+
},
35+
doc_type : {
36+
'properties' : {
37+
'day': { 'type': 'string', 'index': 'not_analyzed'},
38+
'time': { 'type': 'string', 'index': 'not_analyzed'},
39+
'nanoTime': { 'type': 'string', 'index': 'not_analyzed'},
40+
'created': { 'type': 'date', 'index': 'not_analyzed'},
41+
'app': { 'type': 'string', 'index': 'not_analyzed'},
42+
'host': { 'type': 'string', 'index': 'not_analyzed'},
43+
'thread': { 'type': 'string', 'index': 'not_analyzed'},
44+
'level': { 'type': 'string', 'index': 'not_analyzed'},
45+
'eventType': { 'type': 'string', 'index': 'not_analyzed'},
46+
'pack': { 'type': 'string', 'index': 'not_analyzed'},
47+
'clazz': { 'type': 'string', 'index': 'not_analyzed'},
48+
'line': { 'type': 'string', 'index': 'not_analyzed'},
49+
'messageSmart': { 'type': 'string', 'analyzer': 'ik_smart', 'search_analyzer': 'ik_smart', 'include_in_all': 'true', 'boost': 8},
50+
'messageMax': { 'type': 'string', 'analyzer': 'ik_max_word', 'search_analyzer': 'ik_max_word', 'include_in_all': 'true', 'boost': 8}
51+
}
52+
}
53+
}
54+
}
55+
es.create_index(index = index, settings = mapping)
56+
57+
58+
if __name__ == '__main__':
59+
main(sys.argv)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
echo "--> install python-pip module"
4+
sudo apt-get install python-pip
5+
echo "--> install elasticsearch module"
6+
sudo pip install pyelasticsearch
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# 索引
4+
# urls http://192.168.88.70:9200,http://192.168.88.71:9200,http://192.168.88.72:9200
5+
# call: bash start.sh app-log http://192.168.88.70:9200,http://192.168.88.71:9200,http://192.168.88.72:9200
6+
7+
index=$1
8+
urls=$2
9+
10+
echo '创建索引开始'
11+
python create-index.py ${index} ${urls}
12+
echo '创建索引结束'
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/python198
2+
# -*- coding: UTF-8 -*-
3+
4+
import sys
5+
import datetime
6+
from pyelasticsearch import ElasticSearch
7+
from pyelasticsearch import bulk_chunks
8+
9+
def main(argv):
10+
index = argv[1]
11+
doc_type = 'log'
12+
url = []
13+
urls = argv[2].strip().split(',')
14+
for u in urls:
15+
url.append(u)
16+
17+
es = ElasticSearch(urls = url, timeout = 60, max_retries = 0)
18+
create_mapping(es, index, doc_type)
19+
20+
def create_mapping(es, index, doc_type):
21+
mapping = {
22+
'settings': {
23+
'index': {
24+
'number_of_replicas': 1,
25+
'number_of_shards': 6,
26+
'refresh_interval': '5s'
27+
}
28+
},
29+
'mappings': {
30+
'_default_': {
31+
'_all': {
32+
'enabled': False
33+
}
34+
},
35+
doc_type : {
36+
'properties' : {
37+
'created': { 'type': 'date', 'index': 'not_analyzed'},
38+
'time': { 'type': 'string', 'index': 'not_analyzed'},
39+
'day': { 'type': 'string', 'index': 'not_analyzed'},
40+
'week': { 'type': 'string', 'index': 'not_analyzed'},
41+
'month': { 'type': 'string', 'index': 'not_analyzed'},
42+
'year': { 'type': 'string', 'index': 'not_analyzed'},
43+
'app': { 'type': 'string', 'index': 'not_analyzed'},
44+
'host': { 'type': 'string', 'index': 'not_analyzed'},
45+
'eventType': { 'type': 'string', 'index': 'not_analyzed'},
46+
'account': { 'type': 'string', 'index': 'not_analyzed'},
47+
'uniqueName': { 'type': 'string', 'index': 'not_analyzed'},
48+
'cost': { 'type': 'long', 'index': 'not_analyzed'},
49+
'status': { 'type': 'string', 'index': 'not_analyzed'},
50+
'messageSmart': { 'type': 'string', 'analyzer': 'ik_smart', 'search_analyzer': 'ik_smart', 'include_in_all': 'true', 'boost': 8},
51+
'messageMax': { 'type': 'string', 'analyzer': 'ik_max_word', 'search_analyzer': 'ik_max_word', 'include_in_all': 'true', 'boost': 8}
52+
}
53+
}
54+
}
55+
}
56+
es.create_index(index = index, settings = mapping)
57+
58+
59+
if __name__ == '__main__':
60+
main(sys.argv)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
echo "--> install python-pip module"
4+
sudo apt-get install python-pip
5+
echo "--> install elasticsearch module"
6+
sudo pip install pyelasticsearch
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# 索引
4+
# urls http://192.168.88.70:9200,http://192.168.88.71:9200,http://192.168.88.72:9200
5+
# call: bash start.sh event-log http://192.168.88.70:9200,http://192.168.88.71:9200,http://192.168.88.72:9200
6+
7+
index=$1
8+
urls=$2
9+
10+
echo '创建索引开始'
11+
python create-index.py ${index} ${urls}
12+
echo '创建索引结束'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
create 'trace', {NAME => 'span', VERSIONS => 1, COMPRESSION => 'SNAPPY'}, {NUMREGIONS => 3, SPLITALGO => 'HexStringSplit'}
2+
create 'time_consume', {NAME => 'trace', VERSIONS => 1, COMPRESSION => 'SNAPPY'}, {NUMREGIONS => 3, SPLITALGO => 'HexStringSplit'}
3+
create 'annotation', {NAME => 'trace', VERSIONS => 1, COMPRESSION => 'SNAPPY'}, {NUMREGIONS => 3, SPLITALGO => 'HexStringSplit'}

0 commit comments

Comments
 (0)