ELK从5.5.0升级到6.1.3升级方案

写在最前,ES6的重大变化

1. 安装6.1.3版本的软件

1.1 安装JAVA1.8(不用操作,沿用老的)

  • 卸载1.8以下的版本
# rpm -–nodeps –e java-*
  • 安装jdk1.8
# mkdir /usr/local/elk
# tar xf jdk-8u141-linux-x64.tar -C /usr/local/elk/
  • 设置JAVA环境变量
# vi /etc/profile
JAVA_HOME=/usr/local/elk/jdk1.8.0_144
JRE_HOME=/usr/local/elk/jdk1.8.0_144/jre
CLASSPATH=.:$JAVA_HOME/lib:/dt.jar:$JAVA_HOME/lib/tools.jar
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME
export JRE_HOME
  • JAVA环境变量生效
# source /etc/profile
  • JAVA安装验证
#java –version

1.2 安装ElasticSearch 6.1.3

  • 解压文件,并放置到对应的目录
# unzip elasticsearch-6.1.3.zip
# mv elasticsearch-6.1.3 /usr/local/elk/
  • 添加用户,设置目录权限
# useradd elk
# chown –R elk:elk /usr/local/elk/elasticsearch-6.1.3
  • 修改配置文件
# vi /usr/local/elk/elasticsearch-6.1.3/config/elasticsearch.yml
cluster.name: es-test
node.name: node-122
#注意此处设置为一个公共的位置,不放置到某一个版本里面
path.data: /usr/local/elk/elasticsearch/data
path.logs: /usr/local/elk/elasticsearch/logs
network.host: 192.168.237.122
http.port: 9200
#如果集群内有多台ES,否则按默认
discovery.zen.ping.unicast.hosts: ["192.168.237.119","192.168.237.109","192.168.237.122"]
discovery.zen.minimum_master_nodes: 2
#CentOS7.0版本以下需要做这个设置
bootstrap.system_call_filter: false
#X-PACK插件需要这个配置
xpack.security.transport.ssl.enabled: true

#如果配置cross-cluster
search:
    remote:
        es-test1:
            seeds: 192.168.237.109:9300
        es-test2:
            seeds: 192.168.237.119:9300
#集群节点(master/data)设置(安装x-pack后):
master:
node.master: true 
node.data: false 
node.ingest: false 
node.ml: false 
xpack.ml.enabled: true 

data:
node.master: false 
node.data: true 
node.ingest: false 
node.ml: false
  • 修改系统参数
# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
#注意这个值在新版本中必须设置为最少是4096
* soft nproc 4096
* hard nproc 8192
# vi /etc/sysctl.conf
vm.max_map_count=655360
# sysctl -p
# vi /etc/security/limits.d/90-nproc.conf
* soft nproc unlimited

1.3 为ElasticSearch安装X-PACK插件,并破解

  • 本地安装
# cd /usr/local/elk/elasticsearch-6.1.3/bin
# ./elasticsearch-plugin install file:///data/src/x-pack-6.1.3.zip
# chown -R elk:elk /usr/elk/local/elasticsearch-6.1.3/
  • 生成kibana、logstash_system、elastic用户的密码
$bin/x-pack/setup-passwords auto
Initiating the setup of passwords for reserved users elastic,kibana,logstash_system.
The passwords will be randomly generated and printed to the console.
Please confirm that you would like to continue [y/N]y

Changed password for user kibana
PASSWORD kibana = !2&ffs6&W&$WOEft9tcX

Changed password for user logstash_system
PASSWORD logstash_system = ev##5$n0H$4AYe75KJL8

Changed password for user elastic
PASSWORD elastic = BdcjL76vK*l%^Y5G#CZI
  • 验证
# curl –XGET –u user:passwd ‘http://192.168.237.122:9200/’
# mv /usr/elk/local/elasticsearch-6.1.3/plugins/x-pack/x-pack-6.1.3.jar /usr/elk/local/elasticsearch-6.1.3/plugins/x-pack/x-pack-6.1.3.jar.bak
# mv /root/src/License/x-pack-6.1.3.jar /usr/elk/local/elasticsearch-6.1.3/plugins/x-pack/
# curl -XPUT -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://127.0.0.1:9200/_xpack/license?acknowledge=true'   -H "Content-Type: application/json" -d @/data/src/License/license.json
# chown -R elk:elk /usr/elk/local/elasticsearch-6.1.3/

1.4 安装Logstash

  • 解压缩到对应的目录
#tar xzf logstash-6.1.3.tar.gz -C /usr/local/elk/
  • 性能调优
    修改jvm内存为物理机内存的一半
# vi /usr/local/elk/logstash-6.1.3/config/jvm.options
-Xms4g
-Xmx4g

pipeline.workers为cpu逻辑核数的1-1.5倍

#vi /usr/local/elk/logstash-6.1.3/config/logstash.yml
node.name: test122
pipeline.workers: 12
pipeline.batch.size: 8192
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.url: ["http://192.168.237.109:9200","http://192.168.237.119:9200"]
xpack.monitoring.elasticsearch.username: "user"
xpack.monitoring.elasticsearch.password: "passwd"
  • 安装X-PACK
#cd /usr/local/elk/logstash-6.1.3/bin
#logstash-plugin install file:///root/src/x-pack-6.1.3.zip
  • 清空logstatch的template
curl -XDELETE 'http://localhost:9200/_template/logstash

1.5 安装Kibana安装

  • 解压到对应的位置
# tar xzf kibana-6.1.3-linux-x86_64.tar.gz –C /usr/local/elk/
  • 配置文件修改
# vi /usr/local/elk/kibana-6.1.3-linux-x86_64/config/kibana.yml
server.port: 5601
elasticsearch.url: http://192.168.237.122:9200
#此处注意使用自动生成的kibana用户
elasticsearch.username: "user"
elasticsearch.password: "passwd"
#如果多台kibana连接到同一ES,需要设置不同的kibana.index
kibana.index: ".kibana"
#如果一台机器开启多个kibana应用,需要设置不同的pid
pid.file: /var/run/kibana.pid
  • 安装X-PACK
#cd /usr/local/elk/kibana-6.1.3-linux-x86_64/bin
#lkibana-plugin install file:///root/src/x-pack-6.1.3.zip

2. 升级(full cluster restart upgrade 方式升级)

2.1 关闭Logstash,停止继续采集日志

2.2 停止旧版本elasticsearch服务并拷贝data目录

  • 关闭shard Allocation:避免不必要的I/O
curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "cluster.routing.allocation.enable": "none"
  }
}
'
  • 停止索引,并且进行一次同步的flush
curl -XPOST 'localhost:9200/_flush/synced?pretty'
  • 关闭elasticsearch-5.5.0
  • 将旧版本的data目录和log目录拷贝到一个公共的目录,例如:/usr/local/elasticsearch/data
  • 配置新的elasticsearch-6.1.3中的data目录和log目录指向这个/usr/local/elasticsearch/data和/usr/local/elasticsearch/log
  • 开启elasticsearch-6.1.3
  • X-PACK重置密码
bin/x-pack/setup-passwords auto
  • 检查需要升级的索引(注意用新新生成的密码)
curl -XGET -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://192.168.237.119:9200/_xpack/migration/assistance?pretty'
  • 升级这些要升级的索引
curl -XPOST -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://192.168.237.119:9200/_xpack/migration/upgrade/要升级索引的名字?pretty'
  • 此时连接kibana会报错,需要升级和kibana6的对接
curl -XPUT -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://192.168.237.119:9200/.kibana/_settings?pretty' -H 'Content-Type: application/json' -d'
{
  "index.blocks.write": true
}
curl -XPUT -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://192.168.237.119:9200/.kibana-6?pretty' -H 'Content-Type: application/json' -d'
{
  "settings" : {
    "number_of_shards" : 1,
    "index.mapper.dynamic": false
  },
  "mappings" : {
    "doc": {
      "properties": {
        "type": {
          "type": "keyword"
        },
        "updated_at": {
          "type": "date"
        },
        "config": {
          "properties": {
            "buildNum": {
              "type": "keyword"
            }
          }
        },
        "index-pattern": {
          "properties": {
            "fieldFormatMap": {
              "type": "text"
            },
            "fields": {
              "type": "text"
            },
            "intervalName": {
              "type": "keyword"
            },
            "notExpandable": {
              "type": "boolean"
            },
            "sourceFilters": {
              "type": "text"
            },
            "timeFieldName": {
              "type": "keyword"
            },
            "title": {
              "type": "text"
            }
          }
        },
        "visualization": {
          "properties": {
            "description": {
              "type": "text"
            },
            "kibanaSavedObjectMeta": {
              "properties": {
                "searchSourceJSON": {
                  "type": "text"
                }
              }
            },
            "savedSearchId": {
              "type": "keyword"
            },
            "title": {
              "type": "text"
            },
            "uiStateJSON": {
              "type": "text"
            },
            "version": {
              "type": "integer"
            },
            "visState": {
              "type": "text"
            }
          }
        },
        "search": {
          "properties": {
            "columns": {
              "type": "keyword"
            },
            "description": {
              "type": "text"
            },
            "hits": {
              "type": "integer"
            },
            "kibanaSavedObjectMeta": {
              "properties": {
                "searchSourceJSON": {
                  "type": "text"
                }
              }
            },
            "sort": {
              "type": "keyword"
            },
            "title": {
              "type": "text"
            },
            "version": {
              "type": "integer"
            }
          }
        },
        "dashboard": {
          "properties": {
            "description": {
              "type": "text"
            },
            "hits": {
              "type": "integer"
            },
            "kibanaSavedObjectMeta": {
              "properties": {
                "searchSourceJSON": {
                  "type": "text"
                }
              }
            },
            "optionsJSON": {
              "type": "text"
            },
            "panelsJSON": {
              "type": "text"
            },
            "refreshInterval": {
              "properties": {
                "display": {
                  "type": "keyword"
                },
                "pause": {
                  "type": "boolean"
                },
                "section": {
                  "type": "integer"
                },
                "value": {
                  "type": "integer"
                }
              }
            },
            "timeFrom": {
              "type": "keyword"
            },
            "timeRestore": {
              "type": "boolean"
            },
            "timeTo": {
              "type": "keyword"
            },
            "title": {
              "type": "text"
            },
            "uiStateJSON": {
              "type": "text"
            },
            "version": {
              "type": "integer"
            }
          }
        },
        "url": {
          "properties": {
            "accessCount": {
              "type": "long"
            },
            "accessDate": {
              "type": "date"
            },
            "createDate": {
              "type": "date"
            },
            "url": {
              "type": "text",
              "fields": {
                "keyword": {
                  "type": "keyword",
                  "ignore_above": 2048
                }
              }
            }
          }
        },
        "server": {
          "properties": {
            "uuid": {
              "type": "keyword"
            }
          }
        },
        "timelion-sheet": {
          "properties": {
            "description": {
              "type": "text"
            },
            "hits": {
              "type": "integer"
            },
            "kibanaSavedObjectMeta": {
              "properties": {
                "searchSourceJSON": {
                  "type": "text"
                }
              }
            },
            "timelion_chart_height": {
              "type": "integer"
            },
            "timelion_columns": {
              "type": "integer"
            },
            "timelion_interval": {
              "type": "keyword"
            },
            "timelion_other_interval": {
              "type": "keyword"
            },
            "timelion_rows": {
              "type": "integer"
            },
            "timelion_sheet": {
              "type": "text"
            },
            "title": {
              "type": "text"
            },
            "version": {
              "type": "integer"
            }
          }
        },
        "graph-workspace": {
          "properties": {
            "description": {
              "type": "text"
            },
            "kibanaSavedObjectMeta": {
              "properties": {
                "searchSourceJSON": {
                  "type": "text"
                }
              }
            },
            "numLinks": {
              "type": "integer"
            },
            "numVertices": {
              "type": "integer"
            },
            "title": {
              "type": "text"
            },
            "version": {
              "type": "integer"
            },
            "wsState": {
              "type": "text"
            }
          }
        }
      }
    }
  }
}
'
curl -XPOST -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://192.168.237.119:9200/_reindex?pretty' -H 'Content-Type: application/json' -d'
{
  "source": {
    "index": ".kibana"
  },
  "dest": {
    "index": ".kibana-6"
  },
  "script": {
    "inline": "ctx._source = [ ctx._type : ctx._source ]; ctx._source.type = ctx._type; ctx._id = ctx._type + \":\" + ctx._id; ctx._type = \"doc\"; ",
    "lang": "painless"
  }
}
'
curl -XPOST -uelastic:BdcjL76vK*l%^Y5G#CZI 'http://192.168.237.119:9200/_aliases?pretty' -H 'Content-Type: application/json' -d'
{
  "actions" : [
    { "add":  { "index": ".kibana-6", "alias": ".kibana" } },
    { "remove_index": { "index": ".kibana" } }
  ]
}
'
  • 重新开启allocation
curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'
{
 "transient": {
   "cluster.routing.allocation.enable": "all"
 }
}
'
  • 检查ES的状态
curl -XGET 'localhost:9200/_cat/health?pretty'
curl -XGET 'localhost:9200/_cat/recovery?pretty'

3. 配置集群间的TLS

不加密在集群间传输所有的数据将不允许安装一个带X-PACK安全组件的license。

2.1 为每一个es节点生成一个私钥和X.509证书。

  • 为整个cluster生成一个CA。
bin/x-pack/certutil ca
  • 将这个CA拷贝到cluster的每台服务器上,并且生成证书和私钥(证书和私钥都在同一个文件),可以不配置密码。
bin/x-pack/certutil cert --ca elastic-stack-ca.p12
  • 如果配置密码的话还要设置keystore
bin/elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password
bin/elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password
  • 将这个证书

2.2 将证书配置到es节点的配置文件上

xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: certs/elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: certs/elastic-certificates.p12

2.3

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,029评论 6 493
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,238评论 3 388
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 159,576评论 0 349
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,214评论 1 287
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,324评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,392评论 1 292
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,416评论 3 412
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,196评论 0 269
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,631评论 1 306
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 36,919评论 2 328
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,090评论 1 342
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,767评论 4 337
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,410评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,090评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,328评论 1 267
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 46,952评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 43,979评论 2 351

推荐阅读更多精彩内容