zoukankan      html  css  js  c++  java
  • Install elasticsearch-head: – for Elasticsearch 5.x

    Running as a plugin of Elasticsearch

      • Install elasticsearch-head:
        – for Elasticsearch 5.x:
        site plugins are not supported. Run elasticsearch-head as a standalone server

     

    Running with built in server

     https://github.com/mobz/elasticsearch-head#running-with-built-in-server

    1、windows下的NodeJS安装是比较方便的(v0.6.0版本之后,支持windows native),只需要登陆官网(http://nodejs.org/),便可以看到首页的“INSTALL”按钮,直接点击就会自动下载安装了。

    NodeJS安装步骤(windows版本) - 逍遥仔 - Jones HoBlog
     
    2、安装过程基本直接“NEXT”就可以了。(windows的安装msi文件在过程中会直接添加path的系统变量,变量值是你的安装路径,例如“C:Program Files odejs”)。
     
    3、安装完成后可以使用cmd(win+r然后输入cmd进入)测试下是否安装成功。方法:在cmd下输入node -v,出现下图版本提示就是完成了NodeJS的安装。
    NodeJS安装步骤(windows版本) - 逍遥仔 - Jones HoBlog
     4、npm的安装。由于新版的NodeJS已经集成了npm,所以之前npm也一并安装好了。同样可以使用cmd命令行输入"npm -v"来测试是否成功安装。如下图,出现版本提示便OK了。
     
    NodeJS安装步骤(windows版本) - 逍遥仔 - Jones HoBlog
     
    5、常规NodeJS的搭建到现在为止已经完成了,急不及待的话你可以在”cmd“输入”node“进入node开发模式下,输入你的NodeJS第一句:”hello world“ - 输入:console.log('hello world')。
    http://blog.csdn.net/html5_/article/details/40896091


    步骤3

     MINGW64 /e/elasticsearch-head (master)
    $ npm install
    npm WARN deprecated node-uuid@1.4.7: use uuid module instead

    > phantomjs-prebuilt@2.1.13 install E:workspace-demoelasticsearch-head ode_modulesphantomjs-prebuilt
    > node install.js

    PhantomJS not found on PATH
    Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-windows.zip
    Saving to C:UsersTANG~1.CHEAppDataLocalTempphantomjsphantomjs-2.1.1-windows.zip
    Receiving...

    Received 17767K total.
    Extracting zip contents
    Removing E:workspace-demoelasticsearch-head ode_modulesphantomjs-prebuiltlibphantom
    Copying extracted folder C:UsersTANG~1.CHEAppDataLocalTempphantomjsphantomjs-2.1.1-windows.zip-extract-1479521265399phantomjs-2.1.1-windows -> E:workspace-demoelasticsearch-head ode_modulesphantomjs-prebuiltlibphantom
    Writing location.js file
    Done. Phantomjs binary available at E:workspace-demoelasticsearch-head ode_modulesphantomjs-prebuiltlibphantominphantomjs.exe
    elasticsearch-head@0.0.0 E:workspace-demoelasticsearch-head
    `-- grunt-contrib-jasmine@1.0.3
    +-- grunt-lib-phantomjs@1.1.0
    | +-- phantomjs-prebuilt@2.1.13
    | | +-- es6-promise@4.0.5
    | | +-- extract-zip@1.5.0
    | | | +-- concat-stream@1.5.0
    | | | | `-- typedarray@0.0.6
    | | | +-- debug@0.7.4
    | | | +-- mkdirp@0.5.0
    | | | | `-- minimist@0.0.8
    | | | `-- yauzl@2.4.1
    | | | `-- fd-slicer@1.0.1
    | | | `-- pend@1.2.0
    | | +-- fs-extra@0.30.0
    | | | +-- jsonfile@2.4.0
    | | | `-- klaw@1.3.1
    | | +-- hasha@2.2.0
    | | | `-- is-stream@1.1.0
    | | +-- kew@0.7.0
    | | +-- progress@1.1.8
    | | +-- request@2.74.0
    | | | +-- aws-sign2@0.6.0
    | | | +-- aws4@1.5.0
    | | | +-- bl@1.1.2
    | | | +-- caseless@0.11.0
    | | | +-- combined-stream@1.0.5
    | | | | `-- delayed-stream@1.0.0
    | | | +-- forever-agent@0.6.1
    | | | +-- form-data@1.0.1
    | | | | `-- async@2.1.2
    | | | | `-- lodash@4.17.2
    | | | +-- har-validator@2.0.6
    | | | | +-- commander@2.9.0
    | | | | | `-- graceful-readlink@1.0.1
    | | | | `-- is-my-json-valid@2.15.0
    | | | | +-- generate-function@2.0.0
    | | | | +-- generate-object-property@1.2.0
    | | | | | `-- is-property@1.0.2
    | | | | +-- jsonpointer@4.0.0
    | | | | `-- xtend@4.0.1
    | | | +-- hawk@3.1.3
    | | | | +-- boom@2.10.1
    | | | | +-- cryptiles@2.0.5
    | | | | +-- hoek@2.16.3
    | | | | `-- sntp@1.0.9
    | | | +-- http-signature@1.1.1
    | | | | +-- assert-plus@0.2.0
    | | | | +-- jsprim@1.3.1
    | | | | | +-- extsprintf@1.0.2
    | | | | | +-- json-schema@0.2.3
    | | | | | `-- verror@1.3.6
    | | | | `-- sshpk@1.10.1
    | | | | +-- asn1@0.2.3
    | | | | +-- assert-plus@1.0.0
    | | | | +-- bcrypt-pbkdf@1.0.0
    | | | | +-- dashdash@1.14.0
    | | | | | `-- assert-plus@1.0.0
    | | | | +-- ecc-jsbn@0.1.1
    | | | | +-- getpass@0.1.6
    | | | | | `-- assert-plus@1.0.0
    | | | | +-- jodid25519@1.0.2
    | | | | +-- jsbn@0.1.0
    | | | | `-- tweetnacl@0.14.3
    | | | +-- is-typedarray@1.0.0
    | | | +-- isstream@0.1.2
    | | | +-- json-stringify-safe@5.0.1
    | | | +-- node-uuid@1.4.7
    | | | +-- oauth-sign@0.8.2
    | | | +-- qs@6.2.1
    | | | +-- stringstream@0.0.5
    | | | +-- tough-cookie@2.3.2
    | | | | `-- punycode@1.4.1
    | | | `-- tunnel-agent@0.4.3
    | | `-- request-progress@2.0.1
    | | `-- throttleit@1.0.0
    | `-- rimraf@2.5.4
    `-- lodash@2.4.2

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_moduleschokidar ode_modulesfsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.15: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
    npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression

    grunt

    是一套前端自动化工具,一个基于nodeJs的命令行工具,一般用于:
    ① 压缩文件
    ② 合并文件
    ③ 简单语法检查

    对于其他用法,我还不太清楚,我们这里简单介绍下grunt的压缩、合并文件,初学,有误请包涵

    准备阶段

    1、nodeJs环境

    因为grunt是基于nodeJs的,所以首先各位需要安装nodeJS环境,这块我们便不管了
    http://www.cnblogs.com/yexiaochai/p/3527418.html

    2、安装grunt

    有了nodeJs环境后,我们便可以开始搞grunt了,因为我们可能在任何目录下运行打包程序,所以我们需要安装CLI
    官方推荐在全局安装CLI(grunt的命令行接口)

    npm install -g grunt-cli

    这条命令将会把grunt命令植入系统路径,这样就能在任意目录运行他,原因是

    每次运行grunt时,它都会使用node的require查找本地是否安装grunt,如果找到CLI便加载这个本地grunt库
    然后应用我们项目中的GruntFile配置,并执行任务

    步骤4

    /e/elasticsearch-head (master)
    $ npm install -g grunt-cli
    C:UsersadminAppDataRoaming pmgrunt -> C:UsersadminAppDataRoaming pm ode_modulesgrunt-cliingrunt
    C:UsersadminAppDataRoaming pm
    `-- grunt-cli@1.2.0
    +-- findup-sync@0.3.0
    | `-- glob@5.0.15
    | +-- inflight@1.0.6
    | | `-- wrappy@1.0.2
    | +-- inherits@2.0.3
    | +-- minimatch@3.0.3
    | | `-- brace-expansion@1.1.6
    | | +-- balanced-match@0.4.2
    | | `-- concat-map@0.0.1
    | +-- once@1.4.0
    | `-- path-is-absolute@1.0.1
    +-- grunt-known-options@1.1.0
    +-- nopt@3.0.6
    | `-- abbrev@1.0.9
    `-- resolve@1.1.7

    ANTS-SH-0063 MINGW64 /e/elasticsearch-head (master)
    $ grunt server
    Running "connect:server" (connect) task
    Waiting forever...
    Started connect web server on http://localhost:9100

    IK Analysis for Elasticsearch

    The IK Analysis plugin integrates Lucene IK analyzer (http://code.google.com/p/ik-analyzer/) into elasticsearch, support customized dictionary.

    Analyzer: ik_smart , ik_max_word , Tokenizer: ik_smart , ik_max_word

    Versions

    IK versionES version
    master 5.x -> master
    5.0.1 5.0.1
    1.10.1 2.4.1
    1.9.5 2.3.5
    1.8.1 2.2.1
    1.7.0 2.1.1
    1.5.0 2.0.0
    1.2.6 1.0.0
    1.2.5 0.90.x
    1.1.3 0.20.x
    1.0.0 0.16.2 -> 0.19.0

    Install

    1.compile

    checkout ik version respective to your elasticsearch version

    git checkout tags/{version}

    mvn package

    copy and unzip target/releases/elasticsearch-analysis-ik-{version}.zip to your-es-root/plugins/ik

    2.restart elasticsearch

    Tips:

    ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合;

    ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。

    Quick Example

    1.create a index

    curl -XPUT http://localhost:9200/index

    2.create a mapping

    curl -XPOST http://localhost:9200/index/fulltext/_mapping -d'
    {
        "fulltext": {
                 "_all": {
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word",
                "term_vector": "no",
                "store": "false"
            },
            "properties": {
                "content": {
                    "type": "text",
                    "analyzer": "ik_max_word",
                    "search_analyzer": "ik_max_word",
                    "include_in_all": "true",
                    "boost": 8
                }
            }
        }
    }'

    3.index some docs

    curl -XPOST http://localhost:9200/index/fulltext/1 -d'
    {"content":"美国留给伊拉克的是个烂摊子吗"}
    '
    curl -XPOST http://localhost:9200/index/fulltext/2 -d'
    {"content":"公安部:各地校车将享最高路权"}
    '
    curl -XPOST http://localhost:9200/index/fulltext/3 -d'
    {"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
    '
    curl -XPOST http://localhost:9200/index/fulltext/4 -d'
    {"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
    '

    4.query with highlighting

    curl -XPOST http://localhost:9200/index/fulltext/_search  -d'
    {
        "query" : { "match" : { "content" : "中国" }},
        "highlight" : {
            "pre_tags" : ["<tag1>", "<tag2>"],
            "post_tags" : ["</tag1>", "</tag2>"],
            "fields" : {
                "content" : {}
            }
        }
    }
    '

    Result

    {
        "took": 14,
        "timed_out": false,
        "_shards": {
            "total": 5,
            "successful": 5,
            "failed": 0
        },
        "hits": {
            "total": 2,
            "max_score": 2,
            "hits": [
                {
                    "_index": "index",
                    "_type": "fulltext",
                    "_id": "4",
                    "_score": 2,
                    "_source": {
                        "content": "中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"
                    },
                    "highlight": {
                        "content": [
                            "<tag1>中国</tag1>驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首 "
                        ]
                    }
                },
                {
                    "_index": "index",
                    "_type": "fulltext",
                    "_id": "3",
                    "_score": 2,
                    "_source": {
                        "content": "中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"
                    },
                    "highlight": {
                        "content": [
                            "均每天扣1艘<tag1>中国</tag1>渔船 "
                        ]
                    }
                }
            ]
        }
    }

     https://github.com/medcl/elasticsearch-analysis-ik

    配置 JDBC 数据源
    1. 安装 openjdk(本人用的ubuntu)
    sudo apt-get install openjdk-7-jre

    2.下载安装 elasticsearch

    wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.deb
    sudo dpkg -i elasticsearch-1.4.4.deb
    /etc/init.d/elasticsearch start

    3.安装JDBC 插件
    1
    ./bin/plugin --install jdbc --url http://xbib.org/repository/org/xbib/elasticsearch/plugin/elasticsearch-river-jdbc/1.4.0.10/elasticsearch-river-jdbc-1.4.0.10.zip
    4.安装MySQL JDBC 驱动

    curl -o mysql-connector-java-5.1.33.zip -L 'http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.33.zip/from/http://cdn.mysql.com/'
    unzip mysql-connector-java-5.1.33.zip
    cp mysql-connector-java-5.1.33-bin.jar $ES_HOME/plugins/jdbc/
    chmod 644 $ES_HOME/plugins/jdbc/*
    /etc/init.d/elasticsearch restart

    http://localhost:9200/_nodes?settings=true&pretty=true 配置信息(安装路径、插件...)
    更多参数见:https://github.com/jprante/elasticsearch-river-jdbc

    5.测试mysql (用户root 密码passwd 库jdbctest 表名posts)

    curl -XPUT 'localhost:9200/_river/my_jdbc_river/_meta' -d '{
    "type" : "jdbc",
    "jdbc" : {
    "url" : "jdbc:mysql://localhost:3306/jdbctest",
    "user" : "root",
    "password" : "passwd",
    "sql" : "select * from posts"
    }
    }'
    curl 'localhost:9200/jdbc/_search'

    npm install pkg - 本地安装

    运行如下命令,就会在当前目录下安装grunt-cli(grunt命令行工具)

    npm install grunt-cli

    安装结束后,当前目录下回多出一个node_modules目录,grunt-cli就安装在里面。同时注意控制台输出的信息:

    grunt-cli@0.1.9 node_modules/grunt-cli
    ├── resolve@0.3.1
    ├── nopt@1.0.10 (abbrev@1.0.4)
    └── findup-sync@0.1.2 (lodash@1.0.1, glob@3.1.21)

    简单说明一下:

    • grunt-cli@0.1.9:当前安装的package为grunt-cli,版本为0.19
    • node_modules/grunt-cli:安装目录
    • resolve@0.3.1:依赖的包有resolve、nopt、findup-sync,它们各自的版本、依赖在后面的括号里列出来

    npm install -g pkg- 全局安装

    上面已经安装了grunt-cli,然后你跑到其他目录下面运行如下命令

    grunt

    果断提示你grunt命令不存在,为什么呢?因为上面只是进行了本地安装,grunt命令只能在对应安装目录下使用。

    -bash: grunt: command not found

    如果为了使用grunt命令,每到一个目录下都得重新安装一次,那不抓狂才怪。肿么办呢?

    很简单,采用全局安装就行了,很简单,加上参数-g就可以了

    npm install -g grunt-cli

    于是,在所有目录下都可以无压力使用grunt命令了。这个时候,你会注意到控制台输入的信息有点不同。主要的区别在于安装目录,现在变成了/usr/local/lib/node_modules/grunt-cli/usr/local/lib/node_modules/也就是之前所说的全局安装目录啦。

    grunt-cli@0.1.9 /usr/local/lib/node_modules/grunt-cli
    ├── resolve@0.3.1
    ├── nopt@1.0.10 (abbrev@1.0.4)
    └── findup-sync@0.1.2 (lodash@1.0.1, glob@3.1.21)

    npm包管理

    npm的包管理命令是使用频率最高的,所以也是我们需要牢牢记住并熟练使用的。其实无非也就是几个动作:安装、卸载、更新、查看、搜索、发布等。

    安装最新版本的grunt-cli

    npm install grunt-cli

    安装0.1.9版本的grunt-cli

    npm install grunt-cli@"0.1.9"

    通过package.json进行安装

    如果我们的项目依赖了很多package,一个一个地安装那将是个体力活。我们可以将项目依赖的包都在package.json这个文件里声明,然后一行命令搞定

    npm install

    其他package安装命令

    运行如下命令,列出所有npm install可能的参数形式

    npm install --help

    输出如下,有兴趣的童鞋可以了解下

    npm install <tarball file>
    npm install <tarball url>
    npm install <folder>
    npm install <pkg>
    npm install <pkg>@<tag>
    npm install <pkg>@<version>
    npm install <pkg>@<version range>

    卸载grunt-cli

    比如卸载grunt-cli

    npm uninstall grunt-cli

    卸载0.1.9版本的grunt-cli

    npm uninstall grunt-cli@"0.1.9"

    npm ls:查看安装了哪些包

    运行如下命令,就可以查看当前目录安装了哪些package

    npm ls

    输出如下

    /private/tmp/npm
    └─┬ grunt-cli@0.1.9
      ├─┬ findup-sync@0.1.2
      │ ├─┬ glob@3.1.21
      │ │ ├── graceful-fs@1.2.3
      │ │ ├── inherits@1.0.0
      │ │ └─┬ minimatch@0.2.12
      │ │   ├── lru-cache@2.3.0
      │ │   └── sigmund@1.0.0
      │ └── lodash@1.0.1
      ├─┬ nopt@1.0.10
      │ └── abbrev@1.0.4
      └── resolve@0.3.1

    输出如下,同样,如果是要查看package的全局安装信息,加上-g就可以

    npm ls pkg:查看特定package的信息

    运行如下命令,输出grunt-cli的信息

    npm ls grunt-cli

    输出的信息比较有限,只有安装目录、版本,如下:

    /private/tmp/npm
    └── grunt-cli@0.1.9 

    如果要查看更详细信息,可以通过npm info pkg,输出的信息非常详尽,包括作者、版本、依赖等。

    npm info grunt-cli

    npm update pkg:package更新

    npm update grunt-cli

    npm search pgk:搜索

    输入如下命令

    npm search grunt-cli

    返回结果如下

    npm http GET http://registry.npmjs.org/-/all/since?stale=update_after&startkey=1375519407838
    npm http 200 http://registry.npmjs.org/-/all/since?stale=update_after&startkey=1375519407838
    NAME                  DESCRIPTION                                        AUTHOR            DATE              KEYWORDS
    grunt-cli             The grunt command line interface.                  =cowboy =tkellen  2013-07-27 02:24
    grunt-cli-dev-exitprocess The grunt command line interface.              =dnevnik          2013-03-11 16:19
    grunt-client-compiler Grunt wrapper for client-compiler.                 =rubenv           2013-03-26 09:15  gruntplugin
    grunt-clientside      Generate clientside js code from CommonJS modules  =jga              2012-11-07 01:20  gruntplugin

    npm发布

    这个命令我自己也还没实际用过,不误导大家,语法如下,也可参考官方对于package发布的说明https://npmjs.org/doc/developers.html

    npm publish <tarball>
    npm publish <folder>

    NPM配置

    npm的配置工作主要是通过npm config命令,主要包含增、删、改、查几个步骤,下面就以最为常用的proxy配置为例。

    设置proxy

    内网使用npm很头痛的一个问题就是代理,假设我们的代理是 http://proxy.example.com:8080,那么命令如下:

    npm config set proxy http://proxy.example.com:8080

    由于npm config set命令比较常用,于是可以如下简写

    npm set proxy http://proxy.example.com:8080    

    查看proxy

    设置完,我们查看下当前代理设置

    npm config get proxy

    输出如下:

    同样可如下简写:

    npm get proxy

    删除proxy

    代理不需要用到了,那删了吧

    npm delete proxy

    查看所有配置

    npm config list

    直接修改配置文件

    有时候觉得一条配置一条配置地修改有些麻烦,就直接进配置文件修改了

    npm config edit

    关于package.json

    这货在官网似乎没有详细的描述,其实就是包的描述信息啦。假设当我们下载了node应用,这个node应用依赖于A、B、C三个包,如果没有package.json,我们需要人肉安装这个三个包(如果对版本有特定要求就更悲剧了):

    npm install A
    npm install B
    npm install C

    有了package.json,一行命令安装所有依赖。

    npm install

    package.json字段简介

    字段相当多,但最重要的的是下面几个

    1. name: package的名字(由于他会成为url的一部分,所以 non-url-safe 的字母不会通过,也不允许出现"."、"_"),最好先在http://registry.npmjs.org/上搜下你取的名字是否已经存在
    2. version: package的版本,当package发生变化时,version也应该跟着一起变化,同时,你声明的版本需要通过semver的校验(semver可自行谷歌)
    3. dependencies: package的应用依赖模块,即别人要使用这个package,至少需要安装哪些东东。应用依赖模块会安装到当前模块的node_modules目录下。
    4. devDependencies:package的开发依赖模块,即别人要在这个package上进行开发
    5. 其他:参见官网

    package版本

    在package.json里,你经常会在包名后看到类似"~0.1.0"这样的字符串,这就是包的版本啦。下面会列举最常见的版本声明形式,以及版本书写的要求:

    常见版本声明形式

    a、"~1.2.3" 是神马意思呢,看下面领悟

    "~1.2.3" = ">=1.2.3 <1.3.0"
    "~1.2" = ">=1.2.0 <1.3.0"
    "~1" = ">=1.0.0 <1.1.0"

    b、"1.x.x"是什么意思呢,继续自行领悟

    "1.2.x" = ">=1.2.0 <1.3.0"
    "1.x.x" = ">=1.0.0 <2.0.0"
    "1.2" = "1.2.x"
    "1.x" = "1.x.x"
    "1" = "1.x.x"

    版本书写要求

    1. 版本可以v开头,比如 v1.0.1(v只是可选)
    2. 1.0.1-7,这里的7是所谓的“构建版本号”,不理是神马,反正版本大于1.0.1
    3. 1.0.1beta,或者1.0.1-beta,如果1.0.1后面不是 “连字符加数字” 这种形式,那么它是pre release 版本,即版本小于 1.0.1
    4. 根据b、c,有:0.1.2-7 > 0.1.2-7-beta > 0.1.2-6 > 0.1.2 > 0.1.2beta

    写在后面

    内容只是简单地把最常见的命令,以及一些需要了解的内容列了出来。如要进一步了解,可参考官网说明。此外,npm help是我们最好的朋友,如果忘了有哪些命令,命令下有哪些参数,可通过help进行查看。

    最关键的:如果文章内容有误,请指出!!!

    http://www.cnblogs.com/chyingp/p/npm.html

  • 相关阅读:
    DelphiXE下的字符串变化
    FastMM配置文件详解
    [转] FastMM、FastCode、FastMove的使用
    FastMM 定位内存泄露的代码位置
    转 Delphi中使用FastMM4结合View CPU避免内存泄漏
    [转] FastMM使用详解
    salesforce 零基础开发入门学习(九)Approval Process 介绍
    salesforce 零基础开发入门学习(八)数据分页简单制作
    salesforce 零基础开发入门学习(七)PickList的value值获取
    salesforce 零基础开发入门学习(六)简单的数据增删改查页面的构建
  • 原文地址:https://www.cnblogs.com/softidea/p/6079980.html
Copyright © 2011-2022 走看看