目录

http://blog.csdn.net/fenglailea/article/details/52486471

老版本

http://blog.csdn.net/fenglailea/article/details/52471254

介绍

Elasticsearch一个开源的搜索引擎框架(支持群集架构方式)

JAVA版本说明

必须是 java 1.8.0_73 以上 安装 Java 版本 ,根据教程下载相应的版本 http://blog.csdn.net/fenglailea/article/details/26006647

0.Elasticsearch 简介或其他

http://kibana.logstash.es/content/elasticsearch/ https://es.xiaoleilu.com/

官方文档:https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html 风来了.fox

1.下载和安装

下载地址

https://www.elastic.co/downloads/elasticsearch

目前最新版本 5.2.1 这里选择 LINUX 即方式一 方式一:源码

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.1.tar.gz
tar -zxvf elasticsearch-5.2.1.tar.gz

不要用root用户,这里使用hadoop用户

这里是 方式一后续步骤: >不要用root用户,不要用root用户,不要用root用户

不要用root用户,如果已使用root用户解压缩了,先改文件夹所属用户组和用户 root用户是无法启动elasticsearch

chown hadoop:hadoop -R elasticsearch-2.4.0

2.配置elasticsearch

2.1配置

编辑config/elasticsearch.yml

vim config/elasticsearch.yml

修改为

network.host: 0.0.0.0
cluster.name: es

…其他部分没有改动,不需要修改

2.2 说明

3.启动

kibana 4 可以单独启动 命令

cd elasticsearch目录
bin/elasticsearch     #前台运行
bin/elasticsearch -d  #后台运行

访问

http://10.1.5.66:9200/

10.1.5.66 安装elasticsearch的服务器IP 如果在局域网中访问 修改

vim config/elasticsearch.yml

增加

network.host: 0.0.0.0

3.3停止

查找进程 ID

ps -ef |grep elasticsearch

KILL他

kill -9  id

3.X Elasticsearch设置

4. 插件

执行命令 自动下载安装

4.1 x-pack

bin/elasticsearch-plugin install x-pack

此插件下载速度相当的慢,可以happy几小时回来再看。(如果你有代理那另当别论)

X-Pack是一个Elastic Stack的扩展,将安全,警报,监视,报告和图形功能包含在一个易于安装的软件包中。 在Elasticsearch 5.0.0之前,您必须安装单独的Shield,Watcher和Marvel插件才能获得在X-Pack中所有的功能。 注意,安装之后,所有对ES的访问,增加了security机制,即需要用户名和密码,默认分别为: elastic 和changeme ,使用sense插件访问的时候可以输入,如果你是使用curl等方式访问,则需要在http 的header中增加 Authentication 参数。 验证X-Pack 在浏览器上输入: http://localhost:5601/

4.1 head

此插件已独立运行。新的安装方式

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
#先要安装 npm   http://blog.csdn.net/fenglailea/article/details/56484144
npm install
grunt server

访问地址

http://localhost:9100/

4.2 bigdesk

bin/plugin install lukas-vlcek/bigdesk

访问地址

http://localhost:9200/_plugin/bigdesk/

中文分词插件

https://github.com/medcl/elasticsearch-analysis-ik/releases

下载,当前版本 v5.2.1,elasticsearch-analysis-ik-5.2.1.zip

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.2.1/elasticsearch-analysis-ik-5.2.1.zip
unzip elasticsearch-analysis-ik-5.2.1.zip -d elasticsearch-analysis-ik-5.2.1

复制到插件目录

mv elasticsearch-analysis-ik-5.2.1 elasticsearch安装目录/plugins/analysis-ik

这个时候需要重启 elasticsearch 插件才能生效

分词测试

curl -XPUT "http://localhost:9200/index"

测试分词效果:

http://10.1.5.101:9200/index/_analyze?analyzer=ik_max_word&text=中华人民共和国

结果

{
    "tokens": [
        {
            "token": "中华人民共和国",
            "start_offset": 0,
            "end_offset": 7,
            "type": "CN_WORD",
            "position": 0
        },
        {
            "token": "中华人民",
            "start_offset": 0,
            "end_offset": 4,
            "type": "CN_WORD",
            "position": 1
        },
        {
            "token": "中华",
            "start_offset": 0,
            "end_offset": 2,
            "type": "CN_WORD",
            "position": 2
        },
        {
            "token": "华人",
            "start_offset": 1,
            "end_offset": 3,
            "type": "CN_WORD",
            "position": 3
        },
        {
            "token": "人民共和国",
            "start_offset": 2,
            "end_offset": 7,
            "type": "CN_WORD",
            "position": 4
        },
        {
            "token": "人民",
            "start_offset": 2,
            "end_offset": 4,
            "type": "CN_WORD",
            "position": 5
        },
        {
            "token": "共和国",
            "start_offset": 4,
            "end_offset": 7,
            "type": "CN_WORD",
            "position": 6
        },
        {
            "token": "共和",
            "start_offset": 4,
            "end_offset": 6,
            "type": "CN_WORD",
            "position": 7
        },
        {
            "token": "国",
            "start_offset": 6,
            "end_offset": 7,
            "type": "CN_CHAR",
            "position": 8
        }
    ]
}

Mysql数据库同步 logstash-input-jdbc

6.高级配置说明

http://rockelixir.iteye.com/blog/1883373

http://kibana.logstash.es/content/elasticsearch/

x.其他说明

x.1 bin/elasticsearch命令运行后,出现java.lang.RuntimeException: don’t run elasticsearch as root异常

解决方法:不要使用root用户,使用其他用户,并且要把 elasticsearch 文件夹的所属用户和用户组更改为该用户

每次修改elasticsearch配置,重启elasticsearch才能生效

X.2 max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

[2017-02-17T00:20:16,210][INFO ][o.e.b.BootstrapChecks    ] [l4x7kR2] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] 

修改

sudo vim /etc/sysctl.conf

加入

vm.max_map_count=655360

修改

sudo vim /etc/security/limits.conf

加入

hadoop hard nofile 65536  
hadoop soft nofile 65536 

hadoop这里为用户名 然后重启启动elasticsearch即可

如果以上设置好了,还是报错,请重启服务器即可解决

x.3 Exception in thread “main” ElasticsearchParseException[malformed, expected settings to start with ‘object’, instead was [VALUE_STRING]]

Exception in thread "main" ElasticsearchParseException[malformed, expected settings to start with 'object', instead was [VALUE_STRING]]
        at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:73)
        at org.elasticsearch.common.settings.loader.XContentSettingsLoader.load(XContentSettingsLoader.java:52)
        at org.elasticsearch.common.settings.loader.YamlSettingsLoader.load(YamlSettingsLoader.java:50)
        at org.elasticsearch.common.settings.Settings$Builder.loadFromStream(Settings.java:925)
        at org.elasticsearch.common.settings.Settings$Builder.loadFromPath(Settings.java:914)
        at org.elasticsearch.node.internal.InternalSettingsPreparer.prepareEnvironment(InternalSettingsPreparer.java:102)
        at org.elasticsearch.bootstrap.Bootstrap.initialEnvironment(Bootstrap.java:257)
        at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:297)
        at org.elasticsearch.bootstrap.Elasticsearch.init(Elasticsearch.java:121)
        at org.elasticsearch.bootstrap.Elasticsearch.execute(Elasticsearch.java:112)
        at org.elasticsearch.cli.SettingCommand.execute(SettingCommand.java:54)
        at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:122)
        at org.elasticsearch.cli.Command.main(Command.java:88)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:89)
        at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:82)
Refer to the log for complete error details. 

原因 **参数的冒号前后没有加空格** 部分来源: http://kibana.logstash.es/content/elasticsearch/ http://www.cnblogs.com/jiu0821/p/5624908.html

http://blog.csdn.net/wuxiao5570/article/details/54407618 http://blog.csdn.net/laoyang360/article/details/51694519

我的CSDN地址:http://blog.csdn.net/fenglailea/article/details/55506775

 Tags : Elasticsearch

Donate:| 文章有帮助,可以 请我喝杯咖啡

Powered by foxwho.com 浙ICP备19037334号-1