centos/kylin(yum)安装elasticsearch6.3.1
安装包下载 (包含ik分词器)
- 链接: https://pan.baidu.com/s/16hZCo46eHkuqW1_HMTj3Dw
- 提取码: ekkr
安装路径
- elasticsearch :
/opt/elasticsearch-6.3.1
- ip地址:
192.168.56.101
解压,建目录,创建用户,修改权限
1 | ###解压到/opt |
安装ik分词器
1 | ###解压到插件目录 |
改elasticsearch配置
- 配置文件: /opt/elasticsearch-6.3.1/config/elasticsearch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21###修改集群名称tjzx-els
sed -i "s/#cluster.name: my-application/cluster.name: tjzx-els/g" elasticsearch.yml
###修改节点名称(不能重复)
sed -i "s/#node.name: node-1/node.name: node-1/g" elasticsearch.yml
###修改数据文件路径
sed -i "s/#path.data: \/path\/to\/data/path.data: \/opt\/elasticsearch-6.3.1\/data/g" elasticsearch.yml
###修改log路径
sed -i "s/#path.logs: \/path\/to\/logs/path.logs: \/opt\/elasticsearch-6.3.1\/logs/g" elasticsearch.yml
###启用内存锁定
sed -i "s/#bootstrap.memory_lock: true/bootstrap.memory_lock: true/g" elasticsearch.yml
###启用系统调用过滤器提高安全性
sed -i '$a\bootstrap.system_call_filter:\ true' elasticsearch.yml
###禁用机器学习,在linux-aarch64下不能用,其他版本再开启
#X-Pack is not supported and Machine Learning is not available for [linux-aarch64]
sed -i '$a\xpack.ml.enabled:\ false' elasticsearch.yml
###修改当前主机ip
sed -i "s/#network.host: 192.168.0.1/network.host: 192.168.56.101/g" elasticsearch.yml
###修改监听端口
sed -i "s/#http.port: 9200/http.port: 9200/g" elasticsearch.yml
###配置集群master可以多个,这里自己和自己组成集群
sed -i "s/#discovery.zen.ping.unicast.hosts: \[\"host1\", \"host2\"\]/discovery.zen.ping.unicast.hosts: \[\"192.168.56.101\"\]/g" elasticsearch.yml修改系统配置文件
- 配置文件: /etc/security/limits.conf 增加配置
1
2
3
4
5
6elastic soft nofile 65536
elastic hard nofile 65536
elastic hard nproc 4096
elastic soft nproc 4096
elastic soft memlock unlimited
elastic hard memlock unlimited - 配置文件: /etc/sysctl.conf 增加配置执行
1
vm.max_map_count=655360
sysctl -p
并且重新登陆
使其生效启动elasticsearch
因为不能使用root启动,这里su到elastic用户启动服务1
2su -s /bin/bash elastic
/opt/elasticsearch-6.3.1/bin/elasticsearch -d解压kibana,测试
1
2
3
4
5
6### 解压
tar xf kibana-6.3.1-linux-x86_64.tar.gz
###配置els地址
sed -i "s/#elasticsearch.url: \"http:\/\/localhost:9200\"/elasticsearch.url: \"http:\/\/192.168.56.101:9200\"/g" kibana.yml
### 切换到bin目录, ./kibana启动
### 访问 http://192.168.56.101:5601 进入相关端口
端口 说明 9200 elasticseach服务端口, rest接口 9300 elasticsearch集群通信端口 5601 kibana管理界面监听端口
附加开启端口命令
- iptables -I INPUT -p tcp –dport 9200 -j ACCEPT
- iptables -I INPUT -p tcp –dport 9300 -j ACCEPT
- iptables -I INPUT -p tcp –dport 5601 -j ACCEPT
iptables持久化可以搜索下看看,如果没有,说明还没写
systemctl 服务化
这是service文件,复制到相应系统目录
1 | [Unit] |
系统配置
新建用户
1
useradd -M -s /bin/nologin elastic
修改打开文件和进程数内存锁定大小等 /etc/security/limits.conf
1
2
3
4
5
6
7
8
9
10
11#执行 ulimit -Sn 查看打开文件数 太小 增加配置如下
elastic soft nofile 65536
#执行 ulimit -Hn 查看打开文件数 太小 增加唉配置如下
elastic hard nofile 65536
#执行 ulimit -Hu 查看同时打开进程数 太小 增加唉配置如下
elastic hard nproc 4096
#执行 ulimit -Su 查看同时打开进程数 太小 增加唉配置如下
elastic soft nproc 4096
#执行 ulimit -Sl 查看最大锁定内存数 这是kb, 按照相应机器内存设置,这里设置为不限制
elastic soft memlock unlimited
elastic hard memlock unlimited修改申请的内存权限大小 /etc/sysctl.conf增加配置
1
vm.max_map_count=655360
新建配置/etc/sysconfig/elasticsearch
1
2ES_JAVA_OPTS="-Xms4g -Xmx4g"
MAX_LOCKED_MEMORY=unlimitedsystemctl start elasticsearch
启动即可