boyaa 接入ES搜索服务方案1、申请服务器权限http://it.oa.com/needs_apply/index?typeId=2&type=opm&yw=0&rand=834325577测试环境: 192.168.202.100线上环境: 视实际IP2、先部署好后面的服务再来更新文件cmslib/inc.php cmslib/lib/es.class.php cmslib/bylib/fun.class.php cmslib/app/logses/index.html cmslib/app/logses/logses.php cmslib/app/logses/logses.js cms/crontab/doudp.phpcms/crontab/es.sh.php cms/crontab/crontab.sh.php 3、安装JDK说明:ElasticSearch和Logstash依赖于JDK,所以需要安装JDK对于JDK 版本一定要大于等于1.7.0# yum -y install java-1.7.0-openjdk* # java -version 4 安装ElasticSearch说明:ElasticSearch默认的对外服务的HTTP端口是9200,节点间交互的TCP端口是9300。4.1下载ElasticSearch:# mkdir -p /opt/software && cd /opt/software # sudo wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.4/elasticsearch-2.3.4.tar.gz或者上传 #rz 回车 或 #rz -bye 命令选择文件不要鼠标选择文件# sudo tar -zxvf elasticsearch-2.3.4.tar.gz -C /usr/local/ # ln -s /usr/local/elasticsearch-2.3.4 /usr/local/elasticsearch 软连4.2 设置elasticsearch 配置文件#vim /usr/local/elasticsearch/config/elasticsearch.yml需要修改如下:...# cluster.name: my-applicationcluster.name: cms-cluster...# node.name: node-1node.name: cms_node1...# network.host: 192.168.0.1network.host: 192.168.202.100,127.0.0.1 #注意 192.168.202.100 是测试环境IP 线上则修改成对应IP...# http.port: 9200http.port: 9200...#path.data: /path/to/datapath.data: /data/wwwroot/cms/data/es/data...#path.logs: /path/to/logspath.logs: /data/wwwroot/cms/data/es/logs...#以下配置 等安装elasticfence 插件后才配置#elasticfence 是 elasticsearch http auth 认证#行首要空格 ,否则会报错elasticfence.disabled: falseelasticfence.root.password: boyaaPWDelasticfence.whitelist: ["127.0.0.1", "192.168.202.100"]#elasticfence.blacklist: ["127.0.0.2", "10.0.0.99"]4.3启动服务用于测试# cd elasticsearch# bin/elasticsearch如果root 启动,则用bin/elasticsearch -Des.insecure.allow.root=true4.4测试ElasticSearch服务是否正常,预期返回200的状态码:# curl -X GET http://localhost:9200 返回一个例子{ "name" : "cms_node1", "cluster_name" : "cms-cluster", "version" : { "number" : "2.3.4", "build_hash" : "e455fd0c13dceca8dbbdbb1665d068ae55dabe3f", "build_timestamp" : "2016-06-30T11:24:31Z", "build_snapshot" : false, "lucene_version" : "5.5.0" }, "tagline" : "You Know, for Search"}5.ElasticSearch-Head,ElasticSearch-Kopf 插件安装 a.命令安装 a.1 cd /usr/local/elasticsearch a.2 执行命令 ./bin/plugin install mobz/elasticsearch-head 即可。 a.3 详细信息请看:https://github.com/mobz/elasticsearch-head下面的README.md文件。 a.4测试是否成功 open http://localhost:9200/_plugin/headb.ElasticSearch-Kopf说明:Kopf是一个ElasticSearch的管理工具,它也提供了对ES集群操作的API。b.1安装./elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf/b.2 测试是否成功 open http://localhost:9200/_plugin/kopf6、Elasticfence 插件安装说明:Elasticsearch HTTP Basic User Auth pluginElasticsearch user authentication plugin with http basic auth and IP ACLThis plugin provides user authentication APIs and a User management web console.6.1 安装#cd /usr/local/elasticsearch#bin/plugin install https://raw.githubusercontent.com/elasticfence/elasticsearch-http-user-auth/2.3.x/jar/elasticfence-2.3.4-SNAPSHOT.zip6.2 修改配置文件 elasticsearch.yml 在后面添加如下内容:...#elasticfence 是 elasticsearch http auth 认证#行首要空格 ,否则会报错elasticfence.disabled: falseelasticfence.root.password: boyaaPWDelasticfence.whitelist: ["127.0.0.1", "192.168.202.100"]#elasticfence.blacklist: ["127.0.0.2", "10.0.0.99"]...注意:行首要空格 ,否则会报错http auth用户名是 root 密码是 boyaaPWD (注意,代码中也使用了此密码)6.3 重启 elasticsearch启动服务用于测试# cd elasticsearch# bin/elasticsearch如果root 启动,则用bin/elasticsearch -Des.insecure.allow.root=true6.4 测试验证是否生效http://your.elasticsearch.hostname:9200/_plugin/elasticfence/index.htmleg:测试环境IPhttp://192.168.202.100:9200/_plugin/elasticfence/index.html7、设置 crontab.sh.php 与添加 es.sh.php7.1 、 在 cms/crontab/crontab.sh.php 后添加#es server 日志搜索服务source ${path}es.sh.php7.2、在cms/crontab/ 目录下 添加 es.sh.php 文件#!/bin/sh#<?php die()?>#此处 es server 不设置开机启动,是因crontab.sh.php 会每分钟都在检查,然而下面会启动es 服务ps -fe|grep elasticsearch |grep -v grepif [ $? -ne 0 ];then /usr/local/elasticsearch/bin/elasticsearch -Des.insecure.allow.root=true &fi7.3、 重启 crontab.sh.php8、重启 udp/data/wwwroot/cms/data# rm -f doudpdemo.run# /usr/local/php/bin/php -f /data/wwwroot/cms/crontab/doudp.php > /data/wwwroot/cms/doudp.log 2>&1 &# /usr/local/php/bin/php -f /data/wwwroot/cms/crontab/udp.php 45541 > /dev/null 2>&1 &------全文完-----