Elasticsearch基础安装以及可视化插件head安装--linux

 

下载后在 elasticsearch  根目录下启动。

elasticsearch-2.2.0]# ./bin/elasticsearch

提示错误:

Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.
        at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93)
        at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:285)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
Refer to the log for complete error details.

因为版本的问题,最新的版本安全级别提高了,不允许采用root帐号启动,所以我们要添加一个用户。

#添加一个用户:elasticsearch
$useradd elasticsearch
#给用户elasticsearch设置密码,连续输入2次
$passwd elasticsearch

#创建一个用户组 es
groupadd es

#分配 elasticsearch 到 es 组
usermod -G elasticsearch es
#这里注意下,如果提示用户“es”不存在,那么是因为服务器版本问题,你可以换成 usermod -G es elasticsearch ,也就是用户和用户组对调一下使用。
#这里感谢【武汉|Java|竹木鸟】发现这个问题,并告知我。

#在elasticsearch 根目录下,给定用户权限。-R表示逐级(N层目录) , * 表示 任何文件
chown  -R elasticsearch.es *

#切换到elasticsearch用户
su elasticsearch
如果不按上面的给用户 elasticsearch  分配权限目录。那么会报下面的错。
java.io.FileNotFoundException: /home/es/elasticsearch-2.2.0/logs/elasticsearch.log (Permission denied)
        at java.io.FileOutputStream.open(Native Method)
        at java.io.FileOutputStream.(FileOutputStream.java:221)
        at java.io.FileOutputStream.(FileOutputStream.java:142)
        at org.apache.log4j.FileAppender.setFile(FileAppender.java:294)
        at org.apache.log4j.FileAppender.activateOptions(FileAppender.java:165)
        at org.apache.log4j.DailyRollingFileAppender.activateOptions(DailyRollingFileAppender.java:223)
        at org.apache.log4j.config.PropertySetter.activate(PropertySetter.java:307)
        at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:172)
        at org.apache.log4j.config.PropertySetter.setProperties(PropertySetter.java:104)
        at org.apache.log4j.PropertyConfigurator.parseAppender(PropertyConfigurator.java:842)
        at org.apache.log4j.PropertyConfigurator.parseCategory(PropertyConfigurator.java:768)
        at org.apache.log4j.PropertyConfigurator.configureRootCategory(PropertyConfigurator.java:648)
        at org.apache.log4j.PropertyConfigurator.doConfigure(PropertyConfigurator.java:514)
        at org.apache.log4j.PropertyConfigurator.configure(PropertyConfigurator.java:440)
        at org.elasticsearch.common.logging.log4j.LogConfigurator.configure(LogConfigurator.java:128)
        at org.elasticsearch.bootstrap.Bootstrap.setupLogging(Bootstrap.java:204)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:258)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)
log4j:ERROR Either File or DatePattern options are not set for appender [file].
log4j:ERROR setFile(null,true) call failed.

修改配置文件:

$ vi config/elasticsearch.yml

#cluster name
cluster.name: sojson-application
#节点名称
node.name: node-1
#绑定IP和端口
network.host: 123.88.88.88
http.port: 9200

安装  head   插件。

进入
$ cd elasticsearch/bin

目录,输入命令

$ ./plugin –install mobz/elasticsearch-head

安装head插件。

上面是错误的,新版本安装的方式是这样的。

$ ./plugin install mobz/elasticsearch-head

注意到没,–install 是不用 - 的,直接 install 。

head  插件的安装,以及具体的介绍,请查看后面写的博客:Elasticsearch安装(四), elasticsearch head 插件安装和使用。

启动 elasticsearch  

$ ./bin/elasticsearch

再访问http://{es-host}:9200/_plugin/head/

如下图就对了。



Elasticsearch基础安装以及可视化插件head安装--linux

三、Elasticsearch-head 插件界面介绍。

1.界面介绍

Elasticsearch基础安装以及可视化插件head安装--linux

因为我是单点的,所以健康度直接是yellow,黄色不影响使用,红色就有问题了,不过具体看问题是什么问题。

我这个不知道怎么回事,直接是中文的,是根据地区IP默认识别安装的。所以其他功能我不讲了,我就直说一下看索引(index)的 Mapping  在哪看。

Elasticsearch基础安装以及可视化插件head安装--linux

 

这个可以看到当前索引(index)下所有类型(Type) 的 Mapping  ,当然你不创建,就会根据你数据类型来自动生成 Mapping  ,我后面会讲到 Mapping  生成的方式方法。

2.数据浏览

Elasticsearch基础安装以及可视化插件head安装--linux

 

查看命中数据详情。

Elasticsearch基础安装以及可视化插件head安装--linux

 

3.基本查询

Elasticsearch基础安装以及可视化插件head安装--linux

 

4.复合查询。

Elasticsearch基础安装以及可视化插件head安装--linux

其他功能,自己去探索。

转载于:https://www.cnblogs.com/pypua/articles/9414834.html