美文网首页
Linux 下搭建ES

Linux 下搭建ES

作者: 武小寺 | 来源:发表于2017-12-05 11:47 被阅读88次

一 .下载

# 下载, 获取不成功可直接从官网下载
curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.0/elasticsearch-2.4.0.tar.gz
# 解压
sudo tar -xvf elasticsearch-2.4.0.tar.gz
# 进入目录
cd elasticsearch-2.4.4/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.
//这是出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑, 
//建议创建一个单独的用户用来运行ElasticSearch


// 创建用户
创建elsearch用户组及else arch用户
grouped else arch
useradd elsearch -g elsearch -p elastic search
更改elasticsearch文件夹及内部文件的所属用户及组为else arch:else arch

cd /opt
chown -R elsearch:else arch  elastic search
切换到elsearch用户再启动

su elsearch cd elasticsearch/bin
// 正常启动了
./elasticsearch
// 后台启动运行
./elasticsearch -d

这个时间你就可以访问了

curl http://localhost:9200/

如果需要外部ip访问

// 修改配置文件
cd /elasticsearch/config
vim elasticsearch.yml 
// 如下图,解开host 跟 端口,这样就可以根据ip访问了
curl http://{服务器外网ip}:9200/
配置修改

三. 安装head 插件

// 在bin目录下
./plugin install mobz/elasticsearch-head
// 重启ES,即可在浏览器中访问
http://{服务器IP}:9200/_plugin/head/
// 启动成功如下图
WechatIMG28265.jpeg

相关文章

网友评论

      本文标题:Linux 下搭建ES

      本文链接:https://www.haomeiwen.com/subject/friqixtx.html