ElasticSearch搭建社工库-环境搭建

2016-8-18 小屿 ElasticSearch

最近突然想用公开数据整理个社工库,然后了解到了ElasticSearch,并开始学习和尝试,简单总结记录下。

系统: centos7

安装ElasticSearch java运行环境:

yum install java-1.8.0-openjdk

在 https://www.elastic.co/downloads/elasticsearch 获取最新版本,生产环境可安装rpm,测试学习所以就下载压缩包

wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.3.5/elasticsearch-2.3.5.zip

yum install unzip

unzip elasticsearch-2.3.5.zip

mv elasticsearch-2.3.5 /opt/es

切换目录执行 ./bin/elasticsearch 尝试前台启动 

[root@xiaoyu ~]# cd /opt/es

[root@xiaoyu es]# ./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:270)

at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35)

Refer to the log for complete error details.

报错反馈不能用root用户启动

创建es用户

groupadd elsearch

useradd elsearch -g elsearch -p pass

设置文件所属

cd /opt

chown -R elsearch:elsearch  es

切换用户

su elsearch

进入es目录

./bin/elasticsearch

成功启动,默认除了本机无法访问,新建一个命令窗口

[root@vultr ~]# curl -XGET localhost:9200/

{

  "name" : "Genis-Vell",

  "cluster_name" : "elasticsearch",

  "version" : {

    "number" : "2.3.5",

    "build_hash" : "90f439ff60a3c0f497f91663701e64ccd01edbb4",

    "build_timestamp" : "2016-07-27T10:36:52Z",

    "build_snapshot" : false,

    "lucene_version" : "5.5.0"

  },

  "tagline" : "You Know, for Search"

}

ElasticSearch成功在前台启动

为方便测试学习设置允许外网访问,进入es文件夹

vi config/elasticsearch.yml

修改

# network.host: 192.168.0.1  为  network.host: 0.0.0.0

设置iptables允许访问端口

iptables -I INPUT -p tcp --dport 9200 -j ACCEPT

ElasticSearch测试环境成功搭建,如果想在后台以守护进程模式运行,添加-d参数  ./bin/elasticsearch -d



为了方便学习可下载集群管理插件head

wget https://github.com/mobz/elasticsearch-head/archive/master.zip

解压并移动到elaticsearch

unzip master.zip

plugins文件夹在初次运行es后才生成

mv elasticsearch-head-master /opt/es/plugins/head

然后启动ElasticSearch,访问http://ip:9200/_plugin/head/

可以看到很直观的集群概况等

2F1AA84A-E58F-473A-A26F-7030381DA9C8.png

标签: ElasticSearch

发表评论:

Powered by xia0yu