1. boyaa 接入ES搜索服务方案
    2. 1、申请服务器权限
    3. http://it.oa.com/needs_apply/index?typeId=2&type=opm&yw=0&rand=834325577
    4. 测试环境: 192.168.202.100
    5. 线上环境: 视实际IP
    6. 2、先部署好后面的服务再来更新文件
    7. cmslib/inc.php
    8. cmslib/lib/es.class.php
    9. cmslib/bylib/fun.class.php
    10. cmslib/app/logses/index.html
    11. cmslib/app/logses/logses.php
    12. cmslib/app/logses/logses.js
    13. cms/crontab/doudp.php
    14. cms/crontab/es.sh.php
    15. cms/crontab/crontab.sh.php
    16. 3、安装JDK
    17. 说明:
    18. ElasticSearchLogstash依赖于JDK,所以需要安装JDK
    19. 对于JDK 版本一定要大于等于1.7.0
    20. # yum -y install java-1.7.0-openjdk*
    21. # java -version
    22. 4 安装ElasticSearch
    23. 说明:ElasticSearch默认的对外服务的HTTP端口是9200,节点间交互的TCP端口是9300
    24. 4.1下载ElasticSearch
    25. # mkdir -p /opt/software && cd /opt/software
    26. # sudo wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/tar/elasticsearch/2.3.4/elasticsearch-2.3.4.tar.gz
    27. 或者上传 #rz 回车 或 #rz -bye 命令选择文件不要鼠标选择文件
    28. # sudo tar -zxvf elasticsearch-2.3.4.tar.gz -C /usr/local/
    29. # ln -s /usr/local/elasticsearch-2.3.4 /usr/local/elasticsearch
    30. 软连
    31. 4.2 设置elasticsearch 配置文件
    32. #vim /usr/local/elasticsearch/config/elasticsearch.yml
    33. 需要修改如下:
    34. ...
    35. # cluster.name: my-application
    36. cluster.name: cms-cluster
    37. ...
    38. # node.name: node-1
    39. node.name: cms_node1
    40. ...
    41. # network.host: 192.168.0.1
    42. network.host: 192.168.202.100,127.0.0.1
    43. #注意 192.168.202.100 是测试环境IP 线上则修改成对应IP
    44. ...
    45. # http.port: 9200
    46. http.port: 9200
    47. ...
    48. #path.data: /path/to/data
    49. path.data: /data/wwwroot/cms/data/es/data
    50. ...
    51. #path.logs: /path/to/logs
    52. path.logs: /data/wwwroot/cms/data/es/logs
    53. ...
    54. #以下配置 等安装elasticfence 插件后才配置
    55. #elasticfence 是 elasticsearch http auth 认证
    56. #行首要空格 ,否则会报错
    57. elasticfence.disabled: false
    58. elasticfence.root.password: boyaaPWD
    59. elasticfence.whitelist: ["127.0.0.1", "192.168.202.100"]
    60. #elasticfence.blacklist: ["127.0.0.2", "10.0.0.99"]
    61. 4.3启动服务用于测试
    62. # cd elasticsearch
    63. # bin/elasticsearch
    64. 如果root 启动,则用
    65. bin/elasticsearch -Des.insecure.allow.root=true
    66. 4.4测试ElasticSearch服务是否正常,预期返回200的状态码:
    67. # curl -X GET http://localhost:9200
    68. 返回一个例子
    69. {
    70. "name" : "cms_node1",
    71. "cluster_name" : "cms-cluster",
    72. "version" : {
    73. "number" : "2.3.4",
    74. "build_hash" : "e455fd0c13dceca8dbbdbb1665d068ae55dabe3f",
    75. "build_timestamp" : "2016-06-30T11:24:31Z",
    76. "build_snapshot" : false,
    77. "lucene_version" : "5.5.0"
    78. },
    79. "tagline" : "You Know, for Search"
    80. }
    81. 5.ElasticSearch-HeadElasticSearch-Kopf 插件安装
    82.   a.命令安装
    83.     a.1 cd /usr/local/elasticsearch
    84.     a.2 执行命令 ./bin/plugin install mobz/elasticsearch-head 即可。
    85.     a.3 详细信息请看:https://github.com/mobz/elasticsearch-head下面的README.md文件。
    86. a.4测试是否成功 open http://localhost:9200/_plugin/head
    87. b.ElasticSearch-Kopf
    88. 说明:Kopf是一个ElasticSearch的管理工具,它也提供了对ES集群操作的API
    89. b.1安装
    90. ./elasticsearch/bin/plugin install lmenezes/elasticsearch-kopf/
    91. b.2 测试是否成功 open http://localhost:9200/_plugin/kopf
    92. 6Elasticfence 插件安装
    93. 说明:Elasticsearch HTTP Basic User Auth plugin
    94. Elasticsearch user authentication plugin with http basic auth and IP ACL
    95. This plugin provides user authentication APIs and a User management web console.
    96. 6.1 安装
    97. #cd /usr/local/elasticsearch
    98. #bin/plugin install https://raw.githubusercontent.com/elasticfence/elasticsearch-http-user-auth/2.3.x/jar/elasticfence-2.3.4-SNAPSHOT.zip
    99. 6.2 修改配置文件 elasticsearch.yml 在后面添加如下内容:
    100. ...
    101. #elasticfence 是 elasticsearch http auth 认证
    102. #行首要空格 ,否则会报错
    103. elasticfence.disabled: false
    104. elasticfence.root.password: boyaaPWD
    105. elasticfence.whitelist: ["127.0.0.1", "192.168.202.100"]
    106. #elasticfence.blacklist: ["127.0.0.2", "10.0.0.99"]
    107. ...
    108. 注意:
    109. 行首要空格 ,否则会报错
    110. http auth
    111. 用户名是 root 密码是 boyaaPWD (注意,代码中也使用了此密码)
    112. 6.3 重启 elasticsearch
    113. 启动服务用于测试
    114. # cd elasticsearch
    115. # bin/elasticsearch
    116. 如果root 启动,则用
    117. bin/elasticsearch -Des.insecure.allow.root=true
    118. 6.4 测试验证是否生效
    119. http://your.elasticsearch.hostname:9200/_plugin/elasticfence/index.html
    120. eg:测试环境IP
    121. http://192.168.202.100:9200/_plugin/elasticfence/index.html
    122. 7、设置 crontab.sh.php 与添加 es.sh.php
    123. 7.1 cms/crontab/crontab.sh.php 后添加
    124. #es server 日志搜索服务
    125. source ${path}es.sh.php
    126. 7.2、在cms/crontab/ 目录下 添加 es.sh.php 文件
    127. #!/bin/sh
    128. #<?php die()?>
    129. #此处 es server 不设置开机启动,是因crontab.sh.php 会每分钟都在检查,然而下面会启动es 服务
    130. ps -fe|grep elasticsearch |grep -v grep
    131. if [ $? -ne 0 ];then
    132. /usr/local/elasticsearch/bin/elasticsearch -Des.insecure.allow.root=true &
    133. fi
    134. 7.3 重启 crontab.sh.php
    135. 8、重启 udp
    136. /data/wwwroot/cms/data
    137. # rm -f doudpdemo.run
    138. # /usr/local/php/bin/php -f /data/wwwroot/cms/crontab/doudp.php > /data/wwwroot/cms/doudp.log 2>&1 &
    139. # /usr/local/php/bin/php -f /data/wwwroot/cms/crontab/udp.php 45541 > /dev/null 2>&1 &
    140. ------全文完-----