ElasticSearch 安装
1.首先准备好Java环境:
CentOS7下安装JDK详细过程 :https://www.cnblogs.com/zsls-lang/p/11687510.html
[root@zsls ~]# java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)
2.复制地址进行下载
[root@zsls ~]# cd /usr/local/src/
[root@zsls src]# wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.8.13.tar.gz
[root@zsls src]# ls
elasticsearch-6.8.13.tar.gz
解压命令如何指定文件夹, -C 参数
[root@zsls src]# tar -zxvf elasticsearch-6.8.13.tar.gz -C /usr/local/
[root@zsls src]# ls /usr/local/elasticsearch-6.8.13/
bin config lib LICENSE.txt modules NOTICE.txt plugins README.textile
因为ElasticSearch不允许在root用户下运行,所以我们需要创建独立的用户来运行es,so我们来创建elsearch用户组elasticSerach 及elsearch用户 elasticUser
[root@zsls ~]# groupadd elsearch
[root@zsls ~]# useradd elsearch -g elsearch -p elasticsearch
#-g 用户组 -p 密码
可以更改密码
[root@zsls ~]# passwd elsearch # 这里我改成elsearch
更改elasticsearch安装目录及其内部文件的所属用户及组为elsearch:elsearch
[root@zsls local]# chown -R elsearch:elsearch elasticsearch-6.8.13/
[root@zsls local]# ll | grep elasticsearch-6.8.13
drwxr-xr-x. 7 elsearch elsearch 131 Jun 6 2018 elasticsearch-6.8.13
[root@zsls local]#
在CentOS7下,启动会有些问题导致启动报错,我们需要设置如下系统参数来解决这个问题
[root@zsls local]# vim /etc/security/limits.conf
elsearch soft memlock unlimited ###elsearch是当前设置启动es的用户
elsearch hard memlock unlimited
* hard nofile 65536
* soft nofile 65536
* hard nproc 4096
* soft nproc 4096
vim /etc/sysctl.conf :添加 vm.max_map_count = 262144
vm.max_map_count = 262144 [root@localhost ~]# sysctl -p vm.max_map_count = 262144
在启动es前先设置一下绑定的ip,设置为可被外部访问的ip,以及设置bootstrap相关的参数
[elsearch@zsls local]$ cd /usr/local/elasticsearch-6.8.13/
[elsearch@zsls elasticsearch-6.8.13]$ ls
bin config lib LICENSE.txt modules NOTICE.txt plugins README.textile
[elsearch@zsls elasticsearch-6.8.13]$ cd config/
[elsearch@zsls config]$ ls
elasticsearch.yml jvm.options log4j2.properties
[elsearch@zsls config]$ vim elasticsearch.yml
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
path.data: /data/elasticsearch-data ###数据存储位置
path.logs: /var/log/elasticsearch ### 日志位置
bootstrap.memory_lock: true ### 防止交换swap分区
network.host: 0.0.0.0 # 找到该项,设置为可被外部访问的ip
创建文件目录并授权
mkdir -p /var/log/elasticsearch/
mkdir -p /data/elasticsearch-data
chown -R elsearch:elsearch /var/log/elasticsearch/
chown -R elsearch:elsearch /data/elasticsearch-data
root用户切换到elsearch用户
[root@zsls local]# su elsearch
[elsearch@zsls local]$
3.启动ElasticSearch服务的命令
不能再root用户下启动 需要切换用户
[elsearch@zsls elasticsearch6.8.13]$ cd bin/
[elsearch@zsls bin]$ sh elasticsearch
一般我们都采用后台启动的方式 加上-d参数表示后台启动
[elsearch@zsls bin]$ sh elasticsearch -d
进程
[elsearch@zsls bin] ps aux |grep elasticsearch
ElasticSearch服务所监听的端口
netstat -lntp |grep java
[root@localhost elasticsearch]# netstat -lntp |grep java
tcp6 0 0 :::9200 :::* LISTEN 6958/java
tcp6 0 0 :::9300 :::* LISTEN 6958/java
[root@localhost elasticsearch]# netstat -ntap | grep 9200
tcp6 0 0 :::9200 :::* LISTEN 6958/java
4.设置防火墙规则,开放ElasticSearch服务所监听的端口
[root@zsls elasticsearch-6.8.13]# sudo firewall-cmd --zone=public --add-port=9200/tcp --permanent [root@zsls elasticsearch-6.8.13]# sudo firewall-cmd --zone=public --add-port=9300/tcp --permanent [root@zsls elasticsearch-6.8.13]# sudo firewall-cmd --reload
开放了相应的端口后,从浏览器中访问,服务器ip:端口 看看能否访问成功
http://192.168.217.150:9200/
elasticsearch没有直接的关闭或重启命令,关闭elasticsearch服务只能通过kill命令来杀掉服务的进程
[root@zsls elasticsearch-6.8.13]# ps aux | grep elasticsearch [root@zsls elasticsearch-6.8.13]#kill -9 pid
5.elasticsearch平台分析和可视化的开源平台
kibana https://www.cnblogs.com/zsls-lang/p/12522204.html
elasticsearch-head https://www.cnblogs.com/zsls-lang/p/10193409.html
本文来自博客园,作者:zsls-lang,转载请注明原文链接:https://www.cnblogs.com/zsls-lang/p/10171367.html
行也思卿,坐也思卿
日高三竿我犹眠,不管人间万里愁