【ELK】ElasticSearch简单安装测试
xixuefeng
ElasticSearch, ELK
2018-01-03 17:46:25
1,155 次浏览
elasticsearch
【ELK】ElasticSearch简单安装测试已关闭评论
1)Elasticsearch需要运行在Java环境,首先在CentOS7下安装JDK1.8
jdk安装在/usr/local/jdk1.8.0_151目录下
2)下载Elasticsearch并上传到Linux操作系统(本测试上传至/soft目录下)
地址:https://www.elastic.co/downloads/elasticsearch
3)Linux下创建用户
因为Elasticsearch可以接收用户输入的脚本并且执行它,为了安全考虑,Elasticsearch不允许使用root启动,所以,我们需要创建一个单独的用户用于启动Elasticsearch。
1 2 3 4 5 6 7 |
## 组和用户的名字可以自定义,本人习惯oracle用户,所以,本测试使用的是oracle用户 [root@es ~]# groupadd -g 1000 oinstall [root@es ~]# groupadd -g 1001 dba [root@es ~]# groupadd -g 1002 oper [root@es ~]# useradd -u 1001 -d /home/oracle -g oinstall -G dba,oper oracle ## 修改oracle用户口令 [root@es ~]# passwd oracle |
4)修改oracle用户的环境变量
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[root@es ~]# su - oracle Last login: Thu Jan 4 00:31:34 CST 2018 on pts/1 [oracle@es ~]$ [oracle@es ~]$ [oracle@es ~]$ vi .bash_profile ## 环境变量里添加如下内容 export JAVA_HOME=/usr/local/jdk1.8.0_151 export PATH=$JAVA_HOME/bin:$PATH ## 保存退出 ## 应用环境变量,使其在当前会话生效 [oracle@es ~]$ . .bash_profile [oracle@es ~]$ |
5)利用root用户解压Elasticsearch至/usr/local/目录下,并修改属主、属组
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
## 解tar包 [root@es ~]# cd /soft/ [root@es soft]# tar -xzvf elasticsearch-6.1.1.tar.gz -C /usr/local/ ...... [root@es soft]# ## 修改 elasticsearch-6.1.1 属主、属组 [root@es soft]# cd /usr/local/ [root@es local]# ls -l |grep el drwxr-xr-x. 9 root root 155 Jan 3 23:36 elasticsearch-6.1.1 [root@es local]# [root@es local]# chown -R oracle:oinstall elasticsearch-6.1.1/ [root@es local]# [root@es local]# ls -l |grep el drwxr-xr-x. 9 oracle oinstall 155 Jan 3 23:36 elasticsearch-6.1.1 [root@es local]# |
6)修改配置文件
1 2 3 |
[oracle@es ~]$ vi /usr/local/elasticsearch-6.1.1/config/elasticsearch.yml ## 增加如下记录,否则无法通过浏览器访问,IP地址为本机IP network.host: 192.168.10.95 |
7)修改Linux操作系统配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
## 修改/etc/hosts,增加当前服务器IP及主机名 [root@es ~]# vi /etc/hosts 192.168.10.95 es [root@es ~]# ## 修改Linux安全限制,增加如下信息 [root@es ~]# vi /etc/security/limits.conf * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 [root@es ~]# ## 修改内核参数 [root@es ~]# vi /etc/sysctl.conf vm.max_map_count=655360 [root@es ~]# ## 使修改生效 [root@es ~]# /sbin/sysctl -p ## 注意,修改上面的参数,也许并未生效,可以考虑重启下Linux操作系统 |
如果不做上述修改,那么elasticsearch在启动时会报如下错误
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[oracle@es ~]$ cd /usr/local/elasticsearch-6.1.1/ [oracle@es elasticsearch-6.1.1]$ ./bin/elasticsearch ...... [2018-01-04T01:25:18,416][INFO ][o.e.t.TransportService ] [A1SrvfU] publish_address {192.168.10.95:9300}, bound_addresses {192.168.10.95:9300} [2018-01-04T01:25:18,439][INFO ][o.e.b.BootstrapChecks ] [A1SrvfU] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks ERROR: [2] bootstrap checks failed [1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] [2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] [2018-01-04T01:25:18,507][INFO ][o.e.n.Node ] [A1SrvfU] stopping ... [2018-01-04T01:25:18,601][INFO ][o.e.n.Node ] [A1SrvfU] stopped [2018-01-04T01:25:18,601][INFO ][o.e.n.Node ] [A1SrvfU] closing ... [2018-01-04T01:25:18,653][INFO ][o.e.n.Node ] [A1SrvfU] closed [oracle@es elasticsearch-6.1.1]$ |
8)启动elasticsearch
- 用我们创建的oracle用户启动
- 日志打印在前台 ./bin/elasticsearch
- 日志打印在后台 ./bin/elasticsearch -p
1 2 3 4 5 6 |
[root@es ~]# su - oracle Last login: Thu Jan 4 01:32:33 CST 2018 on pts/0 [oracle@es ~]$ [oracle@es ~]$ cd /usr/local/elasticsearch-6.1.1/ [oracle@es elasticsearch-6.1.1]$ [oracle@es elasticsearch-6.1.1]$ ./bin/elasticsearch |
9)此时用浏览器输入地址及端口,则可以有如下显示,http://192.168.10.95:9200/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
{ "name" : "A1SrvfU", "cluster_name" : "elasticsearch", "cluster_uuid" : "t7KsRvrkQpORNnXLJBOKbg", "version" : { "number" : "6.1.1", "build_hash" : "bd92e7f", "build_date" : "2017-12-17T20:23:25.338Z", "build_snapshot" : false, "lucene_version" : "7.1.0", "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" : "You Know, for Search" } |
当然,不同的浏览器显示的情况可能不同,本人测试用的是Google Chrome,千万别用360极速浏览器,用360会提示你下载个文件,不知道它在干啥。