Elasticsearch入门安装

380232950 6年前

来自: http://www.begincode.net/blog/82


一、下载,目前最新版本是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用户;

   如果用其他用户需要有相关文件的权限,如bin,logs,data文件夹的权限

   这也是之前为什么说下载后解压安装等操作尽量不要用root用户来做的原因,

   因为用root用户可能需要你对执行elasticsearch 的用户的权限进行授权


以上为个人在安装使用中的一些浅显的认识,如果不足之处忘指正