ELK日志管理之——elasticsearch部署
1、配置官方yum源
[root@localhost ~]# rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch
[root@localhost ~]# cat > /etc/yum.repos.d/elasticsearch.repo <<EOF
[elasticsearch-1.7]
name=Elasticsearch repository for 1.7.x packages
baseurl=http://packages.elastic.co/elasticsearch/1.7/centos
gpgcheck=1
gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch
enabled=1
EOF
2、安装elasticsearch
[root@localhost ~]# yum install elasticsearch
3、如果服务器无法上外网进行yum安装,可下载rpm包上传安装
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.1.noarch.rpm
4、elasticsearch文件所在目录
[root@logstash]# whereis elasticsearch
elasticsearch: /etc/elasticsearch /usr/share/elasticsearch
5、配置文件
[root@MiWiFi-R1CM ~]# vi /etc/elasticsearch/elasticsearch.yml
cluster.name: elasticsearch #集群名称
node.name: "Franz Kafka" #集群节点名称,默认自动获取
path.data: /path/to/data #集群数据文件存放路径
path.logs: /path/to/logs #日志路径
path.work: /path/to/work #临时文件路径
transport.tcp.port: 9300 #集群间通信端口
http.port: 9200 #集群对外端口
discovery.zen.ping.unicast.hosts: ["host1", "host2:port"] #如果集群不是在同一网段中,是没法自动加进集群的,需要在这里配置节点的ip和端口
6、查看elasticsearch集群状态常用命令
1、检查elasticsearch集群状态:
[root@iZ25w09spb2Z logs]# curl -XGET 127.0.0.1:9200/_cluster/health?pretty
[root@localhost ~]# curl -XGET 'http://localhost:9200/_cluster/state?pretty'
2、elasticsearch集群详细信息:
[root@localhost ~]# curl 'http://127.0.0.1:9200/_cluster/stats?pretty'
3、查看数据:
[root@localhost ~]# curl 'localhost:9200/_cat/indices?v'
4、删除存储的uustore-nginx索引:
[root@localhost ~]# curl -XDELETE 'localhost:9200/uustore-nginx'
5、创建索引(.kibana索引如果删除需要自己创建):
[root@localhost ~]# curl -XPUT 'localhost:9200/.kibana?pretty' -d'
{
"index.mapper.dynamic": true
}'
博客同步地址:http://blog.csdn.net/u010917843