Centos7 搭建Skywalking 6.0系列第一篇-Elasticsearch6.6集群搭建

发布时间:2019-06-26 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了Centos7 搭建Skywalking 6.0系列第一篇-Elasticsearch6.6集群搭建脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

随着Skywalking 6.0 GA版本的发布,Skywalking终于支持ElasticseArch 6.x版本,本文作为搭建Skywalking 6.0集群系列文章的第一篇介绍下Elasticsearch 6.6集群的搭建。

1. 准备

1.1 节点规划

IP cluster.name node.name
10.130.10.11 es_LOG es_1
10.130.10.12 es_log es_2
10.130.10.13 es_log es_3

1.2 安装Java运行环境JRE

wget -c -P /tmp https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u202-b08/OpenJDK8U-jre_x64_linux_hotspot_8u202b08.tar.gz

mkdir /usr/java;
tar xf /tmp/OpenJDK8U-jre_x64_linux_hotspot_8u202b08.tar.gz -C /usr/java;
rm -rf /usr/java/default;
ln -s /usr/java/jdk8u202-b08-jre /usr/java/default;
tee -a /etc/profile << 'EOF'
export JAVA_HOME=/usr/java/default
export PATH=$JAVA_HOME/bin:$PATH
EOF

2. 安装

2.1 导入Elasticserach软件

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch;
tee /etc/yum.repos.d/elasticsearch.repo << 'EOF'
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

2.2 安装软件

yum install elasticsearch -y

2.3 配置Limit

  • LimitMEMLOCK
    开启内存锁定
  • LimitNPROC
    最大进程数,系统支持的最大进程数:32768
    查看系统最大支持进程数:cat /proc/Sys/kernel/pid_max
  • LimitNOFILE
    打开文件数,系统默认最大文件描述符:791020
    查看系统最大文件描述符:cat /proc/sys/fs/file-max
mkdir /etc/systemd/system/elasticsearch.service.d;
cat > /etc/systemd/system/elasticsearch.service.d/override.conf << 'EOF'
[Service]
environment=JAVA_HOME=/usr/java/default 
LimitMEMLOCK=infinity
LimitNOFILE=204800
LimitNPROC=4096
EOF

2.4 配置JVM(可选)

  • 默认是2G
  • 不要超过可用 RAM 的 50%

    Lucene 能很好利用文件系统的缓存,它是通过系统内核管理的。如果没有足够的文件系统缓存空间,性能会受到影响。 此外,专用于堆的内存越多意味着其他所有使用 doc values 的字段内存越少
  • 不要超过 32 GB

    如果堆大小小于 32 GB,JVM 可以利用指针压缩,这可以大大降低内存的使用:每个指针 4 字节而不是 8 字节
sed -i '/-XMs2g/c-Xms3g' /etc/elasticsearch/jvm.options;
sed -i '/-Xmx2g/c-Xmx3g' /etc/elasticsearch/jvm.options

2.5 配置elasticsearch.yml

  • cluster.name

    集群名称,默认是elasticsearch,建议修改为明确的名称,比如es_log

  • node.name

    节点名,默认随机指定一个name列表中名字,建议修改为明确的名称,比如es_1,es_2,es_3

  • network.host

    主机IP

  • path.data

    数据目录

  • path.logs

    日志目录

  • discovery.zen.ping.unicast.hosts

    节点发现

2.5.1 所有节点执行相同的命令

mkdir -p /home/elasticsearch/data /home/elasticsearch/logs;
chown -R elasticsearch. /home/elasticsearch;
sed -i '/cluster.name/ccluster.name: es_log' /etc/elasticsearch/elasticsearch.yml;
sed -i '/network.host/cnetwork.host: 0.0.0.0' /etc/elasticsearch/elasticsearch.yml;
sed -i '/path.data/cpath.data: /home/elasticsearch/data' /etc/elasticsearch/elasticsearch.yml;
sed -i '/path.logs/cpath.logs: /home/elasticsearch/logs' /etc/elasticsearch/elasticsearch.yml;
sed -i '/discovery.zen.ping.unicast.hosts/cdiscovery.zen.ping.unicast.hosts: ["10.130.10.11","10.130.10.12","10.130.10.13"]' /etc/elasticsearch/elasticsearch.yml

2.5.2 各个节点执行对应的命令

#节点-1
sed -i '/node.name/cnode.name: es_1' /etc/elasticsearch/elasticsearch.yml

#节点-2
sed -i '/node.name/cnode.name: es_2' /etc/elasticsearch/elasticsearch.yml

#节点-3
sed -i '/node.name/cnode.name: es_3' /etc/elasticsearch/elasticsearch.yml

2.6 启动

systemctl enable elasticsearch;
systemctl daemon-reload;
systemctl start elasticsearch;
systemctl status elasticsearch

2.7 配置火墙

firewall-cmd --add-port=9200/tcp --permanent;
firewall-cmd --add-port=9300/tcp --permanent;
firewall-cmd --reload

3. 安装中文分词插件(可选)

#查看已安装插件
/usr/share/elasticsearch/bin/elasticsearch-plugin list

#安装IK
/usr/share/elasticsearch/bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.6.0/elasticsearch-analysis-ik-6.6.0.zip

4. 查询

#查看节点信息
curl -X GET http://localhost:9200/_nodes

#打开文件数信息
curl -X GET http://localhost:9200/_nodes/stats/process?filter_path=**.max_file_descriptors

#集群健康状态
curl -X GET http://localhost:9200/_cat/health?v

#查看集群索引数
curl -X GET http://localhost:9200/_cat/indices?v

#查看磁盘分配情况
curl -X GET http://localhost:9200/_cat/allocation?v

#查看集群节点
curl -X GET http://localhost:9200/_cat/nodes?v

#查看集群其他信息
curl -X GET http://localhost:9200/_cat

脚本宝典总结

以上是脚本宝典为你收集整理的Centos7 搭建Skywalking 6.0系列第一篇-Elasticsearch6.6集群搭建全部内容,希望文章能够帮你解决Centos7 搭建Skywalking 6.0系列第一篇-Elasticsearch6.6集群搭建所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。