ubuntu系统
docker search Elasticsearch
docker pull docker.elastic.co/elasticsearch/elasticsearch:7.1.0
version: '2.2'
services:
cerebro:
image: lmenezes/cerebro:0.8.3
container_name: cerebro
ports:
- "9000:9000"
command:
- -Dhosts.0.host=http://elasticsearch:9200
kibana:
image: docker.elastic.co/kibana/kibana:7.1.0
container_name: kibana7
environment:
- I18N_LOCALE=zh-CN
- XPACK_GRAPH_ENABLED=true
- TIMELION_ENABLED=true
- XPACK_MONITORING_COLLECTION_ENABLED="true"
ports:
- "5601:5601"
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
container_name: es7_01
environment:
- cluster.name=xttblog
- node.name=es7_01
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es7_01
- cluster.initial_master_nodes=es7_01,es7_02
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es7data1:/usr/share/elasticsearch/data
ports:
- 9200:9200
elasticsearch2:
image: docker.elastic.co/elasticsearch/elasticsearch:7.1.0
container_name: es7_02
environment:
- cluster.name=xttblog
- node.name=es7_02
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
- discovery.seed_hosts=es7_01
- cluster.initial_master_nodes=es7_01,es7_02
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- es7data2:/usr/share/elasticsearch/data
volumes:
es7data1:
driver: local
es7data2:
driver: local
## JVM configuration
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms1g #改成512m
-Xmx1g #改成512m
################################################################
进入到elasticsearch官网下载和elasticsearch同版本的logstash
解压logstash:
tar -zxvf logstash-7.1.0.tar.gz
apt-get install openjdk-8-jdk
/opt/elk
文件夹下:在logstash的bin目录下新建配置文件
input {
file {
path => "/opt/elk/ml-latest-small/movies.csv"
start_position => "beginning"
sincedb_path => "/dev/null"
}
}
filter {
csv {
separator => ","
columns => ["id","content","genre"]
}
mutate {
split => { "genre" => "|"}
remove_field => ["path", "host", "@timestamp","message"]
}
mutate {
split => ["content", "("]
add_field => {"title" => "%{[content][0]}"}
add_field => {"year" => "%{[content][1]}"}
}
mutate {
convert => {
"year" => "integer"
}
strip => ["title"]
remove_field => ["path", "host", "@timestamp","message","content"]
}
}
output {
elasticsearch {
hosts => ["http://192.168.8.109:9200"]
index => "movies"
document_id => "%{id}"
}
stdout {}
}
在logstash 的bin目录下启动
cd /opt/elk/logstash-7.1.0/bin && ./logstash -f logstash.conf
通过日志,我们可以看到数据被导入到elasticsearch中,我们同样可以在kibana中看到数据已经被导入elasticsearch。
微信公众号:海哥python