配置文件位置:
程序配置文件:/etc/elasticsearch/elasticsearch.ymljvm配置文件:/etc/elasticsearch/jvm.options
1. 确认基础环境
确认主机limit相关参数
grep vm.max_map_count /etc/sysctl.conf && sed -i "s@vm.max_map_count.*@vm.max_map_count=655360@g" /etc/sysctl.conf || echo 'vm.max_map_count=655360' >>/etc/sysctl.conf
sysctl -p
确认主机无其他ElasticSearch软件包
rpm -qa | grep elasticsearch >/dev/null && echo exists || echo yes#执行此命令输出为yes即可
2. 使用YUM源进行安装
yum install jdk1.8.0_131 wget -y
wget http://foreman.lilinlin.science:8080/x86_64/elk/elasticsearch-6.8.7.rpm
yum localinstall elasticsearch-6.8.7.rpm -y
rm -f elasticsearch-6.8.7.rpm
3. 修改配置
以下命令修改ip地址为安装es主机的内网ip
sed -i "s@^#network.host.*@network.host: 192.168.1.200@g" /etc/elasticsearch/elasticsearch.yml
4.启动
systemctl start elasticsearch
5. 安装IK分词
cd /tmp/wget https://web.chinamcloud.com/k8s/ik/elasticsearch-analysis-ik-6.8.7.zip/usr/share/elasticsearch/bin/elasticsearch-plugin install file:///tmp/elasticsearch-analysis-ik-6.8.7.zip
6.重动服务
systemctl restart elasticsearchsystemctl enable elasticsearch
7.检测
以下命令涉及ip换成自己es节点内网ip
curl http://192.168.1.200:9200/_cat/plugins | grep "analysis-ik 6.8.7" &>/dev/null && echo 'success' || echo 'fail'
上面命令输出success则为成功,输出fail则失败,需要检查日志
8.暴露服务
在master上执行
cat > elasticsearch_service.yaml <<EOFapiVersion: v1kind: Servicemetadata:annotations:field.cattle.io/ipAddresses: '["192.168.1.200"]'#改ip为自己环境es ip,切勿删除或新增内容name: elasticsearchnamespace: serverspec:clusterIP: Noneports:- name: elasticsearchport: 9200protocol: TCPtargetPort: 9200sessionAffinity: Nonetype: ClusterIPEOFkubectl apply -f elasticsearch_service.yaml