一、elk架构简介
成都创新互联公司制作网站网页找三站合一网站制作公司,专注于网页设计,网站制作、成都网站建设,网站设计,企业网站搭建,网站开发,建网站业务,680元做网站,已为上1000+服务,成都创新互联公司网站建设将一如既往的为我们的客户提供最优质的网站建设、网络营销推广服务!
二、环境
三、系统参数优化
- # 最大用户打开进程数
- $ vim /etc/security/limits.d/20-nproc.conf
- * soft nproc 65535
- * hard nproc 65535
- # 优化内核,用于 docker 支持
- $ modprobe br_netfilter
- $ cat <
/etc/sysctl.d/k8s.conf - net.bridge.bridge-nf-call-ip6tables = 1
- net.bridge.bridge-nf-call-iptables = 1
- net.ipv4.ip_forward = 1
- EOF
- $ sysctl -p /etc/sysctl.d/k8s.conf
- # 优化内核,对 es 支持
- $ echo 'vm.max_map_count=262144' >> /etc/sysctl.conf
- # 生效配置
- $ sysctl -p
四、部署 docker 和 docker-compose
部署 docker
- # 安装必要的一些系统工具
- $ yum install -y yum-utils device-mapper-persistent-data lvm2
- # 添加软件源信息
- $ yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- # 更新并安装 Docker-CE
- $ yum makecache fast
- $ yum -y install docker-ce
- # 配置docker
- $ systemctl enable docker
- $ systemctl start docker
- $ vim /etc/docker/daemon.json
- {"data-root": "/var/lib/docker", "bip": "10.50.0.1/16", "default-address-pools": [{"base": "10.51.0.1/16", "size": 24}], "registry-mirrors": ["https://4xr1qpsp.mirror.aliyuncs.com"], "log-opts": {"max-size":"500m", "max-file":"3"}}
- $ sed -i '/ExecStart=/i ExecStartPost=\/sbin\/iptables -P FORWARD ACCEPT' /usr/lib/systemd/system/docker.service
- $ systemctl enable docker.service
- $ systemctl daemon-reload
- $ systemctl restart docker
部署 docker-compose
- # 安装 docker-compose
- $ sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
- $ chmod +x /usr/local/bin/docker-compose
五、部署 ES
es-master1 操作
- # 创建 es 目录
- $ mkdir /data/ELKStack
- $ mkdir elasticsearch elasticsearch-data elasticsearch-plugins
- # 容器es用户 uid 和 gid 都是 1000
- $ chown 1000.1000 elasticsearch-data elasticsearch-plugins
- # 临时启动一个es
- $ docker run --name es-test -it --rm docker.elastic.co/elasticsearch/elasticsearch:7.10.1 bash
- # 生成证书,证书有效期10年,证书输入的密码这里为空
- $ bin/elasticsearch-certutil ca --days 3660
- $ bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12 --days 3660
- # 打开新的窗口,拷贝生成的证书
- $ cd /data/ELKStack/elasticsearch
- $ mkdir es-p12
- $ docker cp es-test:/usr/share/elasticsearch/elastic-certificates.p12 ./es-p12
- $ docker cp es-test:/usr/share/elasticsearch/elastic-stack-ca.p12 ./es-p12
- $ chown -R 1000.1000 ./es-p12
- # 创建 docker-compose.yml
- $ vim docker-compose.yml
- version: '2.2'
- services:
- elasticsearch:
- image: docker.elastic.co/elasticsearch/elasticsearch:7.10.1
- container_name: es01
- environment:
- - cluster.name=es-docker-cluster
- - cluster.initial_master_nodes=es01,es02,es03
- - bootstrap.memory_lock=true
- - "ES_JAVA_OPTS=-Xms10000m -Xmx10000m"
- ulimits:
- memlock:
- soft: -1
- hard: -1
- nofile:
- soft: 65536
- hard: 65536
- mem_limit: 13000m
- cap_add:
- - IPC_LOCK
- restart: always
- # 设置 docker host 网络模式
- network_mode: "host"
- volumes:
- - /data/ELKStack/elasticsearch-data:/usr/share/elasticsearch/data
- - /data/ELKStack/elasticsearch-plugins:/usr/share/elasticsearch/plugins
- - /data/ELKStack/elasticsearch/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
- - /data/ELKStack/elasticsearch/es-p12:/usr/share/elasticsearch/config/es-p12
- # 创建 elasticsearch.yml 配置文件
- $ vim elasticsearch.yml
- cluster.name: "es-docker-cluster"
- node.name: "es01"
- network.host: 0.0.0.0
- node.master: true
- node.data: true
- discovery.zen.minimum_master_nodes: 2
- http.port: 9200
- transport.tcp.port: 9300
- # 如果是多节点es,通过ping来健康检查
- discovery.zen.ping.unicast.hosts: ["172.20.166.25:9300", "172.20.166.24:9300", "172.20.166.22:9300", "172.20.166.23:9300", "172.20.166.26:9300"]
- discovery.zen.fd.ping_timeout: 120s
- discovery.zen.fd.ping_retries: 6
- discovery.zen.fd.ping_interval: 10s
- cluster.info.update.interval: 1m
- indices.fielddata.cache.size: 20%
- indices.breaker.fielddata.limit: 40%
- indices.breaker.request.limit: 40%
- indices.breaker.total.limit: 70%
- indices.memory.index_buffer_size: 20%
- script.painless.regex.enabled: true
- # 磁盘分片分配
- cluster.routing.allocation.disk.watermark.low: 100gb
- cluster.routing.allocation.disk.watermark.high: 50gb
- cluster.routing.allocation.disk.watermark.flood_stage: 30gb
- # 本地数据分片恢复配置
- gateway.recover_after_nodes: 3
- gateway.recover_after_time: 5m
- gateway.expected_nodes: 3
- cluster.routing.allocation.node_initial_primaries_recoveries: 8
- cluster.routing.allocation.node_concurrent_recoveries: 2
- # 允许跨域请求
- http.cors.enabled: true
- http.cors.allow-origin: "*"
- http.cors.allow-headers: Authorization,X-Requested-With,Content-Length,Content-Type
- # 开启xpack
- xpack.security.enabled: true
- xpack.monitoring.collection.enabled: true
- # 开启集群中https传输
- xpack.security.transport.ssl.enabled: true
- xpack.security.transport.ssl.verification_mode: certificate
- xpack.security.transport.ssl.keystore.path: es-p12/elastic-certificates.p12
- xpack.security.transport.ssl.truststore.path: es-p12/elastic-certificates.p12
- # 把 es 配置使用 rsync 同步到其它 es 节点
- $ rsync -avp -e ssh /data/ELKStack 172.20.166.24:/data/
- $ rsync -avp -e ssh /data/ELKStack 172.20.166.22:/data/
- $ rsync -avp -e ssh /data/ELKStack 172.20.166.23:/data/
- $ rsync -avp -e ssh /data/ELKStack 172.20.166.26:/data/
- # 启动 es
- $ docker-compose up -d
- # 查看 es
- $ docker-compose ps
es-master2 操作
- $ cd /data/ELKStack/elasticsearch
- # 修改 docker-compose.yml elasticsearch.yml 两个配置
- $ sed -i 's/es01/es02/g' docker-compose.yml elasticsearch.yml
- # 启动 es
- $ docker-compose up -d
es-master3 操作
- $ cd /data/ELKStack/elasticsearch
- # 修改 docker-compose.yml elasticsearch.yml 两个配置
- $ sed -i 's/es01/es03/g' docker-compose.yml elasticsearch.yml
- # 启动 es
- $ docker-compose up -d
es-data1 操作
- $ cd /data/ELKStack/elasticsearch
- # 修改 docker-compose.yml elasticsearch.yml 两个配置
- $ sed -i 's/es01/es04/g' docker-compose.yml elasticsearch.yml
- # 不做为 es master 节点,只做数据节点
- $ sed -i 's/node.master: true/node.master: false/g' elasticsearch.yml
- # 启动 es
- $ docker-compose up -d
es-data2 操作
- $ cd /data/ELKStack/elasticsearch
- # 修改 docker-compose.yml elasticsearch.yml 两个配置
- $ sed -i 's/es01/es05/g' docker-compose.yml elasticsearch.yml
- # 不做为 es master 节点,只做数据节点
- $ sed -i 's/node.master: true/node.master: false/g' elasticsearch.yml
- # 启动 es
- $ docker-compose up -d
设置 es 访问账号
- # es-master1 操作
- $ docker exec -it es01 bash
- # 设置 elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user 等密码
- # 密码都设置为 elastic123,这里只是举例,具体根据需求设置
- $ ./bin/elasticsearch-setup-passwords interactive
六、部署 Kibana
logstash3 操作
- $ mkdir -p /data/ELKStack/kibana
- $ cd /data/ELKStack/kibana
- # 创建 kibana 相关目录,用于容器挂载
- $ mkdir config data plugins
- $ chown 1000.1000 config data plugins
- # 创建 docker-compose.yml
- $ vim docker-compose.yml
- version: '2'
- services:
- kibana:
- image: docker.elastic.co/kibana/kibana:7.10.1
- container_name: kibana
- restart: always
- network_mode: "bridge"
- mem_limit: 2000m
- environment:
- SERVER_NAME: kibana.example.com
- ports:
- - "5601:5601"
- volumes:
- - /data/ELKStack/kibana/config:/usr/share/kibana/config
- - /data/ELKStack/kibana/data:/usr/share/kibana/data
- - /data/ELKStack/kibana/plugins:/usr/share/kibana/plugins
- # 创建 kibana.yml
- $ vim config/kibana.yml
- server.name: kibana
- server.host: "0"
- elasticsearch.hosts: ["http://172.20.166.25:9200","http://172.20.166.24:9200","http://172.20.166.22:9200"]
- elasticsearch.username: "kibana"
- elasticsearch.password: "elastic123"
- monitoring.ui.container.elasticsearch.enabled: true
- xpack.security.enabled: true
- xpack.encryptedSavedObjects.encryptionKey: encryptedSavedObjects1234567890
网页名称:详解容器部署ELK7.10,适用于生产
转载源于:http://www.mswzjz.cn/qtweb/news7/230157.html攀枝花网站建设、攀枝花网站运维推广公司-贝锐智能,是专注品牌与效果的网络营销公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 贝锐智能