Elasticsearch安装

下载,安装 Elasticsearch

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#集群名称
cluster.name: GEO-ES
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#es集群节点名称
node.name: node-0
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#es数据文件
path.data: /usr/elasticsearch-5.6.11/data
#
# Path to log files:
#es日志文件
path.logs: /usr/elasticsearch-5.6.11/log
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#该节点es的IP
#network.host: 192.168.0.1
network.host: 10.111.23.70 
#
# Set a custom port for HTTP:
#该节点es的PORT
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes: 3
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
#gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#开启跨域(跨ip访问)
http.cors.enabled: true  

#允许所有ip访问
http.cors.allow-origin: "*"

#add x-pack configuration
#自动创建index,如果因某种原因无法创建,手动创建
action.auto_create_index: .security,.security-6,.monitoring*,.watches,.triggered_watches,.watcher-history*,app-a-*,app-b-*,.ml*

  • 修改jvm设置:
vim /usr/elasticsearch-5.6.11/config/jvm.options 
## JVM configuration

################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
#===============修改elasticSearch内存(初始分配内存,最大分配内存)
-Xms2g
-Xmx2g

################################################################
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################

## GC configuration
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly

## optimizations

# pre-touch memory pages used by the JVM during initialization
-XX:+AlwaysPreTouch

## basic

# force the server VM (remove on 32-bit client JVMs)
-server

# explicitly set the stack size (reduce to 320k on 32-bit client JVMs)
-Xss1m

# set to headless, just in case
-Djava.awt.headless=true

# ensure UTF-8 encoding by default (e.g. filenames)
-Dfile.encoding=UTF-8

# use our provided JNA always versus the system one
-Djna.nosys=true

# use old-style file permissions on JDK9
-Djdk.io.permissionsUseCanonicalPath=true

# flags to configure Netty
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0

# log4j 2
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-Dlog4j.skipJansi=true

## heap dumps

# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX:+HeapDumpOnOutOfMemoryError

# specify an alternative path for heap dumps
# ensure the directory exists and has sufficient space
#-XX:HeapDumpPath=${heap.dump.path}

## GC logging

#-XX:+PrintGCDetails
#-XX:+PrintGCTimeStamps
#-XX:+PrintGCDateStamps
#-XX:+PrintClassHistogram
#-XX:+PrintTenuringDistribution
#-XX:+PrintGCApplicationStoppedTime

# log GC status to a file with time stamps
# ensure the directory exists
#-Xloggc:${loggc}

# By default, the GC log file will not rotate.
# By uncommenting the lines below, the GC log file
# will be rotated every 128MB at most 32 times.
#-XX:+UseGCLogFileRotation
#-XX:NumberOfGCLogFiles=32
#-XX:GCLogFileSize=128M

# Elasticsearch 5.0.0 will throw an exception on unquoted field names in JSON.
# If documents were already indexed with unquoted fields in a previous version
# of Elasticsearch, some operations may throw errors.
#
# WARNING: This option will be removed in Elasticsearch 6.0.0 and is provided
# only for migration purposes.
#-Delasticsearch.json.allow_unquoted_field_names=true

下载设置elasticSearch-head

  • 需要安装node.js,elasticSearch-head,并安装grunt-cli

    • 下载elasticSearch-head

git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
npm install
npm run start
```

  • 安装grunt-cli
/usr/node/bin/npm  install -g grunt-cli
  • 配置文件:
  • vim Gruntfile.js
module.exports = function(grunt) {

    var fileSets = require("./grunt_fileSets.js");

    // Project configuration.
    grunt.initConfig({
        clean: {
            _site: {
                src: ['_site']
            }
        },
        concat: {
            vendorjs: {
                src: fileSets.vendorJs,
                dest: '_site/vendor.js'
            },
            vendorcss: {
                src: fileSets.vendorCss,
                dest: '_site/vendor.css'
            },
            appjs: {
                src: fileSets.srcJs,
                dest: '_site/app.js'
            },
            appcss: {
                src: fileSets.srcCss,
                dest: '_site/app.css'
            }
        },

        copy: {
            site_index: {
                src: 'index.html',
                dest: '_site/index.html',
                options: {
                    process: function( src ) {
                        return src.replace(/_site\//g, "");
                    }
                }
            },
            base: {
                expand: true,
                cwd: 'src/app/base/',
                src: [ '*.gif', '*.png', '*.css' ],
                dest: '_site/base/'
            },
            iconFonts: {
                expand: true,
                cwd: 'src/vendor/font-awesome/fonts/',
                src: '**',
                dest: '_site/fonts'
            },
            i18n: {
                src: 'src/vendor/i18n/i18n.js',
                dest: '_site/i18n.js'
            },
            lang: {
                expand: true,
                cwd: 'src/app/lang/',
                src: '**',
                dest: '_site/lang/'
            }
        },

        jasmine: {
            task: {
                src: [ fileSets.vendorJs, 'src/vendor/i18n/i18n.js', 'src/app/lang/en_strings.js', fileSets.srcJs ],
                options: {
                    specs: 'src/app/**/*Spec.js',
                    helpers: 'test/spec/*Helper.js',
                    display: "short",
                    summary: true
                }
            }
        },

        watch: {
            "scripts": {
                files: ['src/**/*', 'test/spec/*' ],
                tasks: ['default'],
                options: {
                    spawn: false
                }
            },
            "grunt": {
                files: [ 'Gruntfile.js' ]
            }
        },
        //修改此处,es-head的ip:port
        connect: {
            server: {
                options: {
                    port: 9100,
                    hostname:"0.0.0.0",
                    base: '.',
                    keepalive: true
                }
            }
        }

    });

    grunt.loadNpmTasks('grunt-contrib-clean');
    grunt.loadNpmTasks('grunt-contrib-concat');
    grunt.loadNpmTasks('grunt-contrib-watch');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-jasmine');

    // Default task(s).
    grunt.registerTask('default', ['clean', 'concat', 'copy', 'jasmine']);
    grunt.registerTask('server', ['connect:server']);
    grunt.registerTask('dev', [ 'default', 'watch' ]);


};
  • 启动es-head
grunt server

修改elasticSearch index配置

  • 接触查询数据限制(达到10000条报错),增至1亿条
curl -XPUT http://10.111.32.205:9200/_settings -d '{ "index" : { "max_result_window" : 100000000}}' | python -m json.tool
  • 修改index的type存储字段限制
curl  -XPUT -H "Content-Type: application/json"  10.111.32.205:9200/_template/all -d '{"template":"*","settings":{"index.mapping.total_fields.limit":50000,"refresh_interval":"30s"}}'  | python -m json.tool
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值