linux下ES的安装
官网https://www.elastic.co/cn/downloads/elasticsearch
外部访问端口 9200
节点间通信端口 9300
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.tar.gz
# 解压
tar zxvf elasticsearch-6.3.1.tar.gz
elasticsearch.yml配置文件的修改
# 打开配置文件
vim conf/elasticsearch.yml
# 修改集群名称
cluster.name: my-application
# 修改节点名称
node.name: node-1
# 修改网络请求host,0.0.0.0可以被所有外网访问到
network.host: 0.0.0.0
#配置当前集群的所有节点信息
discovery.zen.ping.unicast.hosts: ["0.0.0.0"]
# 允许跨域,跨端口访问,设置后elasticsearch_head插件才可以访问到
http.cors.enabled: true
http.cors.allow-origin: "*"
elasticsearch启动
cd /soft/elasticsearch-6.8.0/bin
前台启动:./elasticsearch
后台启动:./elasticsearch -d
查看是否启动:ps aux|grep elasticsearch
授权:chown es /soft/elasticsearch-6.8.0 -R
chown es /tmp -R
curl http://localhost:9200
es启动失败的问题处理
elaticsearch默认不能用root用户启动,所以会报java.lang.RuntimeException: can not run elasticsearch as root异常
adduser es #新建用户
passwd es #新建用户密码
#文件夹归属组
#chown -R [用户]:[所属组] 目录
chown -R es:es elasticsearch-6.3.1/
#修改文件夹权限
chmod 770 elasticsearch-6.3.1/
#切换到用户目录
su es
#重新执行成功
./elasticsearch -d
max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]
1、修改/etc/security/limits.conf
* hard nofile 65536
* soft nofile 65536
2、修改(如果没有文件,新建)
[root@master config]# cat /etc/pam.d/sshd
session required /lib64/security/pam_limits.so
[root@master config]# cat /etc/pam.d/common-session
session required /lib64/security/pam_limits.so
3、修改/etc/profile增加一条
ulimit -n 65536
4、重启sshd服务
/etc/init.d/sshd restart
5、重新登陆es用户,解决。
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
elasticsearch 启动报
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
在/etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
执行/sbin/sysctl -p 立即生效
之后再起启动就好了
ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked
elasticsearch官网建议生产环境需要设置bootstrap.memory_lock: true
官网的解释 是:发生系统swapping的时候ES节点的性能会非常差,也会影响节点的稳定性。所以要不惜一切代价来避免swapping。swapping会导致Java GC的周期延迟从毫秒级恶化到分钟,更严重的是会引起节点响应延迟甚至脱离集群。
所以最好限制住elasticsearch占用的内存情况,可选少用swap
错误内容:
开启bootstrap.memory_lock: true
后,在Elasticsearch集群启动的时候,会报如下错误
ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked
root权限编辑/etc/security/limits.conf
$ sudo vim /etc/security/limits.conf
添加如下内容,保存退出
Kabana安装与汉化
官网下载地址,版本号必须与对应的es版本匹配 https://www.elastic.co/downloads/past-releases
端口号5601
运行 nohup ./kibana &
守护进程运行 nohup ./kibana >/data1/apps/logs/kibana.log&
tail -f /data1/apps/logs/kibana.log
netstat -tunlp|grep 5601
查看当前端口被哪个进程占用 fuser -n tcp 5601
logstash运行
ps -ef | grep logstash
/soft/logstash-6.8.0/bin/logstash -f /soft/logstash-6.8.0/script/test.conf
nohup /data1/apps/logstash-6.8.0/bin/logstash -f /data1/apps/logstash-6.8.0/script/logstash_nyzt.conf >/data1/apps/logs/logstash.log&
tail -f /data1/apps/logs/logstash.log
/soft/logstash-6.8.0/bin/logstash -f /soft/logstash-6.8.0/script/c420000_002_021_100024_000009.conf