1 安装java 环境
2安装elasticsearch
安装包下载地址 https://www.elastic.co/downloads/past-releases/elasticsearch-2-4-3
wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.4.3/elasticsearch-2.4.3.tar.gz
解压到/usr/local/elastic
tar -zxvf elasticsearch-2.4.3.tar.gz -C /usr/local/elastic
运行Elasticsearch
Elasticsearch 要求不能使用超级用户root运行,所以我们建立一个testuser账号
# 创建testuser账户
adduser elastic
# 修改密码
passwd elastic
然后,给testuser用户elasticsearch目录的授权。
chown -R testuser /usr/local/elastic/elasticsearch-2.4.3/
切换至elasticsearch目录,并以elastic用户运行
cd /usr/local/elastic/elasticsearch-2.4.3/
su elastic
运行elasticsearch,如果想后台运行后面加 -d,不报错error就是正常
[elastic@szxx elasticsearch-2.4.3]$ ./bin/elasticsearch
[2018-10-30 11:26:50,799][INFO ][node ] [Tyrak] version[2.4.3], pid[25218], build[d38a34e/2016-12-07T16:28:56Z]
[2018-10-30 11:26:50,799][INFO ][node ] [Tyrak] initializing ...
[2018-10-30 11:26:51,244][INFO ][plugins ] [Tyrak] modules [reindex, lang-expression, lang-groovy], plugins [], sites []
[2018-10-30 11:26:51,260][INFO ][env ] [Tyrak] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [27.5gb], net total
_space [39.2gb], spins? [unknown], types [rootfs]
[2018-10-30 11:26:51,261][INFO ][env ] [Tyrak] heap size [990.7mb], compressed ordinary object pointers [true]
[2018-10-30 11:26:51,261][WARN ][env ] [Tyrak] max file descriptors [65535] for elasticsearch process likely too low, consider i
ncreasing to at least [65536]
[2018-10-30 11:26:52,700][INFO ][node ] [Tyrak] initialized
[2018-10-30 11:26:52,701][INFO ][node ] [Tyrak] starting ...
[2018-10-30 11:26:52,767][INFO ][transport ] [Tyrak] publish_address {172.17.135.72:9300}, bound_addresses {0.0.0.0:9300}
[2018-10-30 11:26:52,773][INFO ][discovery ] [Tyrak] elasticsearch/O6f7o_JNRKOB19Pdc784jA
[2018-10-30 11:26:55,809][INFO ][cluster.service ] [Tyrak] new_master {Tyrak}{O6f7o_JNRKOB19Pdc784jA}{172.17.135.72}{172.17.135.72:9300}, re
ason: zen-disco-join(elected_as_master, [0] joins received)
[2018-10-30 11:26:55,825][INFO ][http ] [Tyrak] publish_address {172.17.135.72:9200}, bound_addresses {0.0.0.0:9200}
[2018-10-30 11:26:55,825][INFO ][node ] [Tyrak] started
[2018-10-30 11:26:55,847][INFO ][gateway ] [Tyrak] recovered [0] indices into cluster_state
配置目录:
vim ./config/elasticsearch.yml
修改:network.host: [_local_, 172.30.6.1] 指定ip访问 ---network.host: 0.0.0.0 允许所有ip访问
测试:
curl http://localhost:9200/?pretty
常见错误
1. max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]
解决方案
1、vi /etc/sysctl.conf
设置fs.file-max=655350
保存之后sysctl -p使设置生效
2、vim /etc/security/limits.conf 新增
* soft nofile 655350
* hard nofile 655350
3、重新使用SSH登录,再次启动elasticsearch即可。
2. max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
1, 切换到root用户修改配置sysctl.conf :
vim /etc/sysctl.conf
2, 添加下面配置:
vm.max_map_count=655360
3, 并执行命令:
sysctl -p
4、重新使用SSH登录,再次启动elasticsearch即可。