备注:本案例是elasticsearch6.2.2
(一)官网下载tar包 wget.....
(二)解压
(三)配置
在config目录下有一个elasticsearch.yml,配置:
#集群名
cluster.name: my-application
#节点名
node.name: ${HOSTNAME}
#
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
#访问ip,下面表示谁都可以访问
network.host: 0.0.0.0
#http端口,通过该端口,可以网页访问
http.port: 9200
#取消自动创建索引
action.auto_create_index: false
(四)测试启动
备注:elasticsearch6.*不容许root用户启动!!!!!!!!
./elasticsearch
若出现以下错误:
看起来root不允许直接启动。因为这个原因,那我们需要新建一个用户来启动es,具体操作如下:
# 以root用户来创建新的用户 , groupadd 添加一个用户组
[root@localhost home]# groupadd elk
# 添加一个用户,-g是在用户组下 -p是密码
[root@localhost home]# useradd elk -g elk -p elk
# 进入es的安装目录
[root@localhost home]# cd /home/elasticsearch
# 给用户elk授权
[root@localhost home]# chown -R elk:elk elasticsearch-6.3.1/
# 切换到 elk用户
[root@localhost elasticsearch]# su elk
到这里新的用户也创建好了,也授权了,接下来我们重新启动一下,需要等待一段时间,才能启动完毕。启动时,若出现如下错误:
ERROR: [3] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3795] for user [pc] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案如下:
1、则需要在elasticsearch.yml配置文件中添加如下配置:
bootstrap.memory_lock: false
bootstrap.system_call_filter: false
2、切换到root用户模式
su root
3、报错 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]是因为操作系统vm.max_map_count参数设置太小导致的,至于设置多大的数值,我这里就直接参照报错信息的建议直接设置为262144
vim /etc/sysctl.conf
# 尾部添加下面的配置
vm.max_map_count=262144
# 然后执行命令
sysctl -p
4、报错max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]和max number of threads [3795] for user [pc] is too low, increase to at least [4096]是因为操作系统安全检测配置影响的,我们需要切换到root用户下做如下配置:
vim /etc/security/limits.conf
然后编辑limits.conf增加如下配置:
# elasticsearch config start
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
# elasticsearch config end
(四)正式启动
#首先切换成非root用户
su elk
//后台启动
./elasticsearch -d
(五)浏览器访问
备注:要想浏览器访问,得开启 9200端口,如何开启,参见前面系列文章。
浏览器中访问:http://192.168.10.133:9200/,出现如下信息,才代表安装成功
{
"name": "administrator",
"cluster_name": "spring-boot",
"cluster_uuid": "fagUrzLtTsKhoXIHkyBseQ",
"version": {
"number": "6.2.2",
"build_hash": "10b1edd",
"build_date": "2018-02-16T19:01:30.685723Z",
"build_snapshot": false,
"lucene_version": "7.2.1",
"minimum_wire_compatibility_version": "5.6.0",
"minimum_index_compatibility_version": "5.0.0"
},
"tagline": "You Know, for Search"
}
(四)安装出错及问题解决
参见elasticsearch安装问题总结