软件版本: CentOS 7.3 elasticsearch5.0.0 jdk 1.8.0_111
vim /etc/profile // 添加java的环境变量
set java environment 设置Javax环境变量
JAVA_HOME=/usr/java/jdk1.8.0_111
JRE_HOME=/usr/java/jdk1.8.0_111/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
进入es 目录 ,bin/elasticsearch
elasticsearch5.0启动失败,出现如下提示:
1、Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000085330000, 2060255232, 0) failed; error='Cannot allocate memory' (errno=12)
root 不能登,换个用户
先给权限 chown -R user elasticsearch-5.2.2
进elasticsearch安装目录,启动 bin/elasticsearch
curl http://127.0.0.1:9200/?pretty
{
"name" : "8h277dG",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "aX4J-UcHQXizLKVqPIbxvg",
"version" : {
"number" : "5.0.0",
"build_hash" : "253032b",
"build_date" : "2016-10-26T04:37:51.531Z",
"build_snapshot" : false,
"lucene_version" : "6.2.0"
},
"tagline" : "You Know, for Search"
}
要让外网可以访问,
修改配置文件 config/elasticsearch.yml
修改network.hostnetwork.host: 0.0.0.0
这个时候必须重启服务器,再次启动可能还会报错。
image.png切换到 root
打开/etc/security/limits.conf
添加如下配置
#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4
kael - nofile 65536 # add this line
# End of file
sudo sysctl -w vm.max_map_count=262144 // 普通用户环境运行
再次重启服务器,再启动es,这下就可以外网访问了!
访问成功页面用阿里云的童鞋注意下 安全组规则的设置,要打开9200端口。
参考链接
https://es.xiaoleilu.com/index.html
http://www.jianshu.com/p/975326e65f65
http://kael-aiur.com/elk/ES%E9%85%8D%E7%BD%AE%E7%BB%99%E5%A4%96%E9%83%A8%E6%9C%BA%E5%99%A8%E9%80%9A%E8%BF%87ip%E8%AE%BF%E9%97%AE.html
网友评论