Elastic官网:https://www.elastic.co/cn/
下载地址: elasticsearch
下载完成后解压
修改config下的elasticsearch.yml
效果如下:
# ======================== 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: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
#path.data: /path/to/data
#
# Path to log files:
#
#path.logs: /path/to/logs
#
# ----------------------------------- 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):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["127.0.0.1", "[::1]"]
#
# For more information, consult the discovery and cluster formation 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
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: true
node.data: true
进入 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
-Xms256m
-Xmx256m
################################################################
## 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
## G1GC Configuration
# NOTE: G1GC is only supported on JDK version 10 or later.
# To use G1GC uncomment the lines below.
# 10-:-XX:-UseConcMarkSweepGC
# 10-:-XX:-UseCMSInitiatingOccupancyOnly
# 10-:-XX:+UseG1GC
# 10-:-XX:G1ReservePercent=25
# 10-:-XX:InitiatingHeapOccupancyPercent=30
## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}
## 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=data
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log
## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
进入bin 目录 双击 elasticsearch.bat
访问 127.0.0.1:9200 效果如下:
下载
注意:你的Elasticsearch和IK分词器必须版本统一
下载地址
下载后解压至新建文件夹 IK 目录下
效果如下:
将文件夹转移至elasticsearch-7.5.1/plugins目录下
重启elasticsearch
进入postman进行测试 是否安装成功
效果如下
http://127.0.0.1:9200/_analyze
{"analyzer":"chinese","text":"我是程序员"}
下载地址
下载后效果:
修改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/'
},
chrome: {
src: 'src/chrome_ext/*.*',
dest: '_site/'
}
},
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' ]
}
},
connect: {
server: {
options: {
hostname: '*',
port: 9100,
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' ]);
};
注意:es5以上版本安装head需要安装node和grunt
从地址:https://nodejs.org/en/download/ 下载相应系统的msi,双击安装。
执行 npm install -g grunt-cli 安装grunt ,安装完成后执行grunt -version查看是否安装成功,会显示安装的版本号
cmd 进入 elasticsearch-head 目录 执行
npm install
grunt server 或者 npm run start
如果运行不成功建议重新安装grunt
打开浏览器访问:http://127.0.0.1:9100
效果如下:
至此Windows环境下搭建 Elasticsearch(7.5.1) 就全部完成了
如果出现问题请在下方评论区告知