您好,登錄后才能下訂單哦!
在Linux服務器上安裝Docker以后,Pull相關(guān)的官方Docker鏡像:
docker pull docker.elastic.co/elasticsearch/elasticsearch:5.5.1 docker pull docker.elastic.co/kibana/kibana:5.5.1 docker pull docker.elastic.co/logstash/logstash:5.5.1
啟動Elastic Search容器:
docker run -p 9200:9200 -e "http.host=0.0.0.0" -e "transport.host=127.0.0.1" \ --name my-elastic -d docker.elastic.co/elasticsearch/elasticsearch:5.5.1
啟動Kibana容器:
docker run -p 5601:5601 -e "ELASTICSEARCH_URL=http://localhost:9200" --name my-kibana \ --network host -d docker.elastic.co/kibana/kibana:5.5.1
創(chuàng)建logstash/logstash.yml,配置xpack對于logstash的監(jiān)控:
http.host: "0.0.0.0" path.config: /usr/share/logstash/pipeline xpack.monitoring.elasticsearch.url: http://localhost:9200 xpack.monitoring.elasticsearch.username: elastic xpack.monitoring.elasticsearch.password: changeme
創(chuàng)建logstash/conf.d/logstash.conf,配置logstash的輸入輸出:
input { file { path => "/tmp/access_log" start_position => "beginning" } } output { elasticsearch { hosts => ["localhost:9200"] user => "elastic" password => "changeme" } }
啟動Logstash容器:
docker run -v /home/ubuntu/logstash/conf.d:/usr/share/logstash/pipeline/:ro -v /tmp:/tmp:ro \ -v /home/ubuntu/logstash/logstash.yml:/usr/share/logstash/config/logstash.yml:ro --name my-logstash \ --network host -d docker.elastic.co/logstash/logstash:5.5.1
測試一下,在/tmp/access.log中添加兩行信息:
echo "Hello World!" >> /tmp/access_log echo "Hello ELK!" >> /tmp/access_log
打開kibana的鏈接http://yourhost:5601,使用用戶名/密碼: elastic/changeme登錄。在”Configure an index pattern”頁面點擊Create按鈕。點擊菜單Monitor即可查看ELK節(jié)點的狀態(tài)
在Kibana點擊Discover菜單,可以看到相關(guān)的日志信息:
使用Elastic Search集群部署
Elastic官方提供了用docker-compose啟動Elastic Search集群的方法,首先安裝docker-compose
curl -L https://github.com/docker/compose/releases/download/1.15.0/docker-compose-Linux-x86_64 \ > /usr/local/bin/docker-compose sudo chmod +x /usr/local/bin/docker-compose docker-compose --version
創(chuàng)建一個elasticsearch/docker-compose.yml文件:
version: '2' services: elasticsearch2: image: docker.elastic.co/elasticsearch/elasticsearch:5.5.1 container_name: elasticsearch2 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata1:/usr/share/elasticsearch/data ports: - 9200:9200 networks: - esnet elasticsearch3: image: docker.elastic.co/elasticsearch/elasticsearch:5.5.1 environment: - cluster.name=docker-cluster - bootstrap.memory_lock=true - "ES_JAVA_OPTS=-Xms512m -Xmx512m" - "discovery.zen.ping.unicast.hosts=elasticsearch2" ulimits: memlock: soft: -1 hard: -1 mem_limit: 1g volumes: - esdata2:/usr/share/elasticsearch/data networks: - esnet volumes: esdata1: driver: local esdata2: driver: local networks: esnet:
在/etc/sysctl.conf文件中追加一行
vm.max_map_count = 262144
執(zhí)行命令應用變更:
sudo sysctl -p
在docker-compose.yml所在的目錄執(zhí)行以下命令,啟動elastic search集群:
docker stop my-elastic && docker rm my-elastic docker-compose up &
在Kibana中Monitor菜單中可以看到,Elastic Search集群已經(jīng)正常工作:
修改默認密碼
Elastic Docker Images的默認賬號密碼是elastic/changeme,使用默認密碼是不安全的,假設(shè)要把密碼改為elastic0。在Docker所在服務器上執(zhí)行命令,修改用戶elastic的密碼:
curl -XPUT -u elastic 'localhost:9200/_xpack/security/user/elastic/_password' -H "Content-Type: application/json" \ -d '{ "password" : "elastic0" }'
設(shè)置密碼,重啟Kibana:
docker stop my-kibana && docker rm my-kibana docker run -p 5601:5601 -e "ELASTICSEARCH_URL=http://localhost:9200" -e "ELASTICSEARCH_PASSWORD=elastic0" \ --name my-kibana --network host -d docker.elastic.co/kibana/kibana:5.5.1
修改logstash/logstash.yml,logstash/conf.d/logstash.conf中的密碼,然后重啟logstash服務
docker restart my-logstash
測試一下,在/tmp/access.log中添加兩行信息:
echo "Hello World!" >> /tmp/access_log echo "Hello ELK!" >> /tmp/access_log
打開kibana的鏈接http://yourhost:5601,使用用戶名/密碼: elastic/elastic0登錄。在”Configure an index pattern”頁面點擊Create按鈕。點擊菜單Monitor即可查看ELK節(jié)點的狀態(tài),默認密碼已經(jīng)修改成功。
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持億速云。
免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。