Elastic Search学习笔记1——安装elasticsearch2.4.6

Elastic Search

简介
1.基于Apache Lucene的开源搜索引擎
2.采用Java编写 RESTful API风格
3.较容易的横向扩展

应用场景
1.海量数据分析引擎
2.数据搜索引擎
3.数据仓库

官网
https://www.elastic.co/

下载地址
https://www.elastic.co/downloads/elasticsearch

https://www.elastic.co/downloads/past-releases

安装步骤
1.Download and unzip Elasticsearch
Elasticsearch can also be installed from our package repositories using apt or yum, or installed on Windows using an MSI installer package. See Repositories in the Guide.
2.Run bin/elasticsearch (or bin\elasticsearch.bat on Windows)
3.Run curl http://localhost:9200/ or Invoke-RestMethod http://localhost:9200 with PowerShell
4.Dive into the getting started guide and video.
https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-started.html
https://www.elastic.co/webinars/getting-started-elasticsearch


解压
···

配置
打开config/elasticsearch.yml

#集群名称
cluster.name: menges
# 单节点名称
node.name: master/slave1
#设置绑定的ip地址
network.host: 127.0.0.1
#端口
http.port: 8200
# 找到master节点
discovery.zen.ping.unicast.hosts: ["127.0.0.1"]


启动
执行bin/elasticsearch.bat or

./bin/elasticsearch
./bin/elasticsearch -d          #后台运行

tail -f logs/elasticsearch.log           #查看日志

 


当看到提示
publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
started
表示启动成功

 

启动报错

java.lang.RuntimeException: don't run elasticsearch as root.
    at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:94)
    at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:160)
    at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:286)
    at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:45)

即不允许root启动

2.X解决方案


./bin/elasticsearch -Des.insecure.allow.root=true

停止服务

第一种

ps -ef | grep elastic

root     25531     1  0 May24 ?        01:53:55 /usr/java/jdk1.7.0_79/bin/java -Xms256m -Xmx1g -Djava.awt.headless=true -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+HeapDumpOnOutOfMemoryError -XX:+DisableExplicitGC -Dfile.encoding=UTF-8 -Djna.nosys=true -Des.path.home=/usr/local/src/elasticsearch-2.4.6 -cp /usr/local/src/elasticsearch-2.4.6/lib/elasticsearch-2.4.6.jar:/usr/local/src/elasticsearch-2.4.6/lib/* org.elasticsearch.bootstrap.Elasticsearch start -Des.insecure.allow.root=true -d

第二种

jps

25531 Elasticsearch

5.X+版本
注:ES有执行脚本的能力,因安全因素,不能在root用户下运行,强行运行会报如下错误:
org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root

groupadd es          #增加es组
useradd es -g es -p pwd          #增加es用户并附加到es组
chown -R es:es elasticsearch-5.1.1          #给目录权限
su es          #使用es用户
./bin/elasticsearch -d          #后台运行es
 


启动参数参考:
Option                Description
------                -----------
-E <KeyValuePair>     Configure a setting
-V, --version         Prints elasticsearch version information and exits
-d, --daemonize       Starts Elasticsearch in the background
-h, --help            show help
-p, --pidfile <Path>  Creates a pid file in the specified path on start
-q, --quiet           Turns off standard ouput/error streams logging in console
-s, --silent          show minimal output
-v, --verbose         show verbose output


测试
打开浏览器输入 127.0.0.1:8200
则可以看到输出了类似下面的信息
{
    name: "GG9WPj_",
    cluster_name: "elasticsearch",
    cluster_uuid: "4ZrTtRADRaCtnb84OxAbFg",
    version: {
        number: "5.6.0",
        build_hash: "781a835",
        build_date: "2017-09-07T03:09:58.087Z",
        build_snapshot: false,
        lucene_version: "6.6.0"
    },
    tagline: "You Know, for Search"
}

转载于:https://my.oschina.net/mengzhang6/blog/1632133

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值