ES Docs-1:Installation Elasticsearch-2.3.1

installation

Elasticsearch requires at least Java 7. Specifically as of this writing, it is recommended that you use the Oracle JDK version 1.8.0_73.

java -version
echo $JAVA_HOME

下载(Linux版本)

curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.1/elasticsearch-2.3.1.tar.gz

解压

tar -xvf elasticsearch-2.3.1.tar.gz

运行

cd elasticsearch-2.3.1/bin
./elasticsearch

若不能使用root运行,需要建立普通用户,并在用户目录(如/home/es/)下解压运行elasticSearch。

root@qiandu1-yuwencai:/opt/cluster/elasticsearch-2.3.1/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@qiandu1-yuwencai:~# adduser es
Adding user `es' ...
Adding new group `es' (1001) ...
Adding new user `es' (1001) with group `es' ...
Creating home directory `/home/es' ...
Copying files from `/etc/skel' ...
Enter new UNIX password: 
Retype new UNIX password: 
passwd: password updated successfully
Changing the user information for es
Enter the new value, or press ENTER for the default
	Full Name []: 
	Room Number []: 
	Work Phone []: 
	Home Phone []: 
	Other []: 
Is the information correct? [Y/n] y
root@qiandu1-yuwencai:~# su es
es@qiandu1-yuwencai:/root$ 

运行结果

es@qiandu1-yuwencai:~/cluster/elasticsearch-2.3.1$ bin/elasticsearch
[2016-04-18 13:13:57,815][INFO ][node                     ] [Two-Gun Kid] version[2.3.1], pid[17929], build[bd98092/2016-04-04T12:25:05Z]
[2016-04-18 13:13:57,815][INFO ][node                     ] [Two-Gun Kid] initializing ...
[2016-04-18 13:13:58,497][INFO ][plugins                  ] [Two-Gun Kid] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2016-04-18 13:13:58,522][INFO ][env                      ] [Two-Gun Kid] using [1] data paths, mounts [[/ (/dev/vda1)]], net usable_space [27gb], net total_space [39.2gb], spins? [possibly], types [ext4]
[2016-04-18 13:13:58,522][INFO ][env                      ] [Two-Gun Kid] heap size [990.7mb], compressed ordinary object pointers [true]
[2016-04-18 13:13:58,522][WARN ][env                      ] [Two-Gun Kid] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
[2016-04-18 13:14:01,473][INFO ][node                     ] [Two-Gun Kid] initialized
[2016-04-18 13:14:01,473][INFO ][node                     ] [Two-Gun Kid] starting ...
[2016-04-18 13:14:01,653][INFO ][transport                ] [Two-Gun Kid] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2016-04-18 13:14:01,675][INFO ][discovery                ] [Two-Gun Kid] elasticsearch/LVk2-D3hSgWWSZJx6PooDA
[2016-04-18 13:14:04,794][INFO ][cluster.service          ] [Two-Gun Kid] new_master {Two-Gun Kid}{LVk2-D3hSgWWSZJx6PooDA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-04-18 13:14:04,824][INFO ][http                     ] [Two-Gun Kid] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2016-04-18 13:14:04,824][INFO ][node                     ] [Two-Gun Kid] started
[2016-04-18 13:14:04,870][INFO ][gateway                  ] [Two-Gun Kid] recovered [0] indices into cluster_state

指定cluster和node名称:

./elasticsearch --cluster.name es_cluster --node.name es_node_1
[2016-04-18 13:46:51,572][INFO ][node                     ] [es_node_1] version[2.3.1], pid[18186], build[bd98092/2016-04-04T12:25:05Z]
[2016-04-18 13:46:51,573][INFO ][node                     ] [es_node_1] initializing ...
[2016-04-18 13:46:52,211][INFO ][plugins                  ] [es_node_1] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2016-04-18 13:46:52,235][INFO ][env                      ] [es_node_1] using [1] data paths, mounts [[/ (/dev/vda1)]], net usable_space [27gb], net total_space [39.2gb], spins? [possibly], types [ext4]
[2016-04-18 13:46:52,236][INFO ][env                      ] [es_node_1] heap size [990.7mb], compressed ordinary object pointers [true]
[2016-04-18 13:46:52,236][WARN ][env                      ] [es_node_1] max file descriptors [4096] for elasticsearch process likely too low, consider increasing to at least [65536]
[2016-04-18 13:46:54,104][INFO ][node                     ] [es_node_1] initialized
[2016-04-18 13:46:54,104][INFO ][node                     ] [es_node_1] starting ...
[2016-04-18 13:46:54,209][INFO ][transport                ] [es_node_1] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}
[2016-04-18 13:46:54,215][INFO ][discovery                ] [es_node_1] es_cluster/7PCeI9T4QfqJzA-B8eCYig
[2016-04-18 13:46:57,345][INFO ][cluster.service          ] [es_node_1] new_master {es_node_1}{7PCeI9T4QfqJzA-B8eCYig}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-04-18 13:46:57,366][INFO ][http                     ] [es_node_1] publish_address {127.0.0.1:9200}, bound_addresses {[::1]:9200}, {127.0.0.1:9200}
[2016-04-18 13:46:57,366][INFO ][node                     ] [es_node_1] started
[2016-04-18 13:46:57,390][INFO ][gateway                  ] [es_node_1] recovered [0] indices into cluster_state

Also note the line marked http with information about the HTTP address (127.0.0.1) and port (9200) that our node is reachable from. By default, Elasticsearch uses port 9200 to provide access to its REST API. This port is configurable if necessary.

参考资料

【1】来源: https://www.elastic.co/guide/en/elasticsearch/reference/current/_installation.html

【2】
-----------茂帅------------
java的版本要求是jdk 1.7 update 55之后 。推荐使用jdk 1.8

在root用户下的Linux需要创建一个新的用户,因为es不允许在root用户下面启动。如下操作:
1. Groupadd 组名称
2. Useradd -d 用户目录 -g 组名称 -G 其他组(如:root) 用户名称
3. 切换到新建的用户 su 用户名

下载es
curl -L -O https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.1/elasticsearch-2.3.1.tar.gz

启动es
./elasticsearch

启动es之后,es回给当前的node随机的命名一个英文名。可以通过以下命令来修改这个名字
./elasticsearch --cluster.name my_cluster_name --node.name my_node_name

es的默认的对外端口是9200

原文地址:https://www.cnblogs.com/myitroad/p/5405478.html