确保环境已安装Java,最好>=jdk7,本人使用的是jdk8
[elsearch@localhost elasticsearch-5.2.0]$ java -version java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02,mixed mode)
下载elasticsearch:
sudo wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.0.tar.gz
tar -zxvf elasticsearch-5.2.0.tar.gz -C /usr/local
默认不允许root权限的用户允许elasticsearch,所以这里新建一个用户组elsearch及该组下的用户elsearch:
cd /usr/local/ groupadd elsearch useradd elsearch -g elsearch -p elasticsearch chown -R elsearch:elsearch elasticsearch-5.2.0/
PS:如果需要root权限用户执行,则有如下两种方法(未测试!):
A.在运行elasticsearch时加参-Des.insecure.allow.root=true:
./elasticsearch -Des.insecure.allow.root=true
B.修改elasticsearch启动文件,添加ES_JAVA_OPTS="-Des.insecure.allow.root=true"
修改config/elasticsearch.yml
取消注释的配置有:
cluster.name: my-application node.name: node-1 bootstrap.memory_lock: false network.host: 172.16.18.23 http.port: 9200 discovery.zen.ping.unicast.hosts: ["172.16.18.23"] discovery.zen.minimum_master_nodes: 1 #注意,因为本人目前是单节点,这里必须为1 新增如下配置: bootstrap.system_call_filter: false
启动过程中,我这里遇到了不少问题,主要参考了如下解决:
http://www.cnblogs.com/honeybee/p/6283623.html或http://blog.csdn.net/gebitan505/article/details/54709515或http://blog.csdn.net/feifantiyan/article/details/54614614或http://blog.csdn.net/cardinalzbk/article/details/54924511
遇到org.elasticsearch.bootstrap.StartupException: java.lang.IllegalStateException: Failed to obtain node locks,tried [[/usr/local/elasticsearch-5.2.0/data/my-application]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing
则:
cd /usr/local/elasticsearch-5.2.0/data
rm -rf nodes/
把/etc/security/limits.conf最后修改成如下: ... elsearch hard nofile 65536 elsearch soft nofile 65536 elsearch hard nproc 2048 elsearch soft nproc 2048
启动完成后,正常则显示大致如下:
浏览器访问:http://172.16.18.23:9200/_all?pretty
这时可以测试基本的用法:索引增删查改。
接着可以安装x-pack
执行:
bin/elasticsearch-plugin install x-pack
耐心等待,最后提示确认安装即可。
[elsearch@localhost plugins]$ pwd
/usr/local/elasticsearch-5.2.0/plugins
[elsearch@localhost plugins]$ ls
x-pack
关于x-pack的作用,后续会专门介绍。
同样接下来开始安装kibana,
wget https://artifacts.elastic.co/downloads/kibana/kibana-5.0.0-linux-x86_64.tar.gz
PS:机器是centos 6.5 64位,最开始下载了32位版本报错后,没办法重新下载了64位的。
tar -zxvf kibana-5.0.0-linux-x86_64.tar.gz -C /usr/local
接着再在/usr/local/
kibana-5.0.0-linux-x86_64目录下安装kibana的x-pack
bin/kibana-plugin install x-pack
耐心等待即可。
配置kibana对应的elastic服务器地址:
vi config/kibana.yml 修改的配置如下: ... server.port: 5601 server.host: "172.16.18.23" server.name: "mort-kibana" elasticsearch.url: "http://172.16.18.23:9200" ...
启动后打开浏览器这时需要用户密码验证,默认的用户名是elastic,密码是changeme。
打开后可见页面:
注意这时可以在DevTools,编辑RESTFUL的参数来操作elastic了。
如果想通过curl命令行去操作elastic,必须加参如下数:
}
zxf$ curl -u elastic -XPUT 'http://172.16.18.23:9200/hello?pretty' Enter host password for user 'elastic': { "acknowledged" : true,"shards_acknowledged" : true }
原文链接:https://www.f2er.com/centos/378717.html