配置文件位置:
程序配置文件:/etc/elasticsearch/elasticsearch.yml
jvm配置文件:/etc/elasticsearch/jvm.options
1. 确认基础环境
确认主机limit相关参数
bash
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软件包
bash
rpm -qa | grep elasticsearch >/dev/null && echo exists || echo yes#执行此命令输出为yes即可
2. 使用YUM源进行安装
bash
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
bash
sed -i "s@^#network.host.*@network.host: 192.168.1.200@g" /etc/elasticsearch/elasticsearch.yml
4.启动
bash
systemctl start elasticsearch
5. 安装IK分词
bash
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.重动服务
bash
systemctl restart elasticsearch
systemctl enable elasticsearch
7.检测
以下命令涉及ip换成自己es节点内网ip
bash
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上执行
bash
cat > elasticsearch_service.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
annotations:
field.cattle.io/ipAddresses: '["192.168.1.200"]'#改ip为自己环境es ip,切勿删除或新增内容
name: elasticsearch
namespace: server
spec:
clusterIP: None
ports:
- name: elasticsearch
port: 9200
protocol: TCP
targetPort: 9200
sessionAffinity: None
type: ClusterIP
EOF
kubectl apply -f elasticsearch_service.yaml