ElasticSearch安装
来自: http://www.open-open.com/lib/view/open1455955282167.html
一、下载,目前最新版本是2.2.0
下载地址:https://www.elastic.co/downloads/elasticsearch
提供了四个类型的安装包,选择自己需要的,我下载的是tar类型
二、安装
1、首先要安装jdk,官方建议用1.7及以上版本,先要确认jdk安装成功,并配置好环境变量
2、将下载后的文件 elasticsearch-2.2.0.tar 解压到你想要的位置。此处注意:linux系统最好用非root用户来操作 一会说明原因
3、解压完成后可以简单进行做一些配置,配置文件位置在config目录下。
elasticsearch.yml是elasticsearch的配置文件logging.yml是日志文件的配置。
修改 elasticsearch.yml 配置文件如下内容,默认是被#注释掉的,去掉#即可
node.name:节点名称(自定义)
path.data: /home/yang/elasticsearch-2.2.0/data 数据文件存放路径(自定义)
path.logs: /home/yang/elasticsearch-2.2.0/logs 日志文件存放路径(自定义)
4、启动
运行bin目录下的elasticsearch 即可。运行后显示如下提示信息:
[yang@localhost elasticsearch-2.2.0]$ ./bin/elasticsearch
[2016-02-20 05:56:51,419][INFO ][node ] [node-1] version[2.2.0], pid[2666], build[8ff36d1/2016-01-27T13:32:39Z]
[2016-02-20 05:56:51,421][INFO ][node ] [node-1] initializing ...
[2016-02-20 05:56:54,734][INFO ][plugins ] [node-1] modules [lang-expression, lang-groovy], plugins [], sites []
[2016-02-20 05:56:54,886][INFO ][env ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [16gb], net total_space [17.4gb], spins? [unknown], types [rootfs]
[2016-02-20 05:56:54,886][INFO ][env ] [node-1] heap size [1015.6mb], compressed ordinary object pointers [true]
[2016-02-20 05:57:04,513][INFO ][node ] [node-1] initialized
[2016-02-20 05:57:04,514][INFO ][node ] [node-1] starting ...
[2016-02-20 05:57:04,765][INFO ][transport ] [node-1] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2016-02-20 05:57:04,812][INFO ][discovery ] [node-1] elasticsearch/KCweQyr1T2yIfCk2V1VoRw
[2016-02-20 05:57:08,273][INFO ][cluster.service ] [node-1] new_master {node-1}{KCweQyr1T2yIfCk2V1VoRw}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-02-20 05:57:08,432][INFO ][http ] [node-1] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2016-02-20 05:57:08,433][INFO ][node ] [node-1] started
[2016-02-20 05:57:08,476][INFO ][gateway ] [node-1] recovered [0] indices into cluster_state
三、测试
测试返回以下信息即表示成功:
[root@localhost elasticsearch-2.2.0]# curl -X get http://localhost:9200
{
"name" : "node-1",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.2.0",
"build_hash" : "8ff36d139e16f8720f2947ef62c8167a888992fe",
"build_timestamp" : "2016-01-27T13:32:39Z",
"build_snapshot" : false,
"lucene_version" : "5.4.1"
},
"tagline" : "You Know, for Search"
}
四、注意
- 运行elasticsearch 不能使用root用户。使用root用户可能会遇到很多权限的问题。附:新建用户
- 要从外网访问的需要修改elasticsearch.yml的访问配置。将network.host为0.0.0.0,并去掉前面的#,结果如下:
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
# http.port: 9200