🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 基础环境部署 #### 阿里YUM源配置(略) #### 全局JDK 1.8部署 ```shell yum install java-1.8.131 ``` #### 配置系统参数 ##### 配置内存锁 ```shell #追加 /etc/security/limits.conf echo " " >> /etc/security/limits.conf echo "#elasticsearch memlock dinghe add 20170828 " >> /etc/security/limits.conf echo "elasticsearch soft memlock unlimited" >> /etc/security/limits.conf echo "elasticsearch hard memlock unlimited" >> /etc/security/limits.conf ``` ##### 配置文件描述符 ```shell echo " " >> /etc/security/limits.conf echo "#limit dinghe add 20170828 " >> /etc/security/limits.conf echo "* soft nofile 65536" >> /etc/security/limits.conf echo "* hard nofile 65536" >> /etc/security/limits.conf ``` ##### 配置map_counter ```shell echo "#elasticsearch inti dinghe add 20170828" >> /etc/sysctl.conf echo "vm.max_map_count = 262144" >> /etc/sysctl.conf ``` ##### 重启服务器 ### ELK安装(RPM安装、强烈推荐) ```shell rpm -ivh elasticsearch-5.5.0.rpm #修改用户shell usermod elasticsearch -s /bin/bash #5.5版本的rpm安装会出现变量找到到(oracle java找不到)和memlock配置不生效的情况,修改用户shell后或使用openjdk解决 ``` ### 配置Elasticsearch #### 创建用户和基础目录 ```shell mkdir /data/es-data #多磁盘方式mkdir /data/es01,/data/es02 chown -R elasticsearch. /data/es-data ``` 修改相关配置 vim /etc/elasticsearch/elasticsearch.yml ```shell cluster.name: es-cluster node.name: master-1 path.data: /data/es_data/ network.host: 192.168.0.232 http.port: 9200 discovery.zen.ping.unicast.hosts: ["192.168.0.232", "192.168.0.231"] ``` 配置注释 ```shell #集群名称 cluster.name: es-cluster #本节点名称 node.name: master-1 #数据文件位置 path.data: /data/es_data/ #日志位置 path.logs: /app/logs/es #配置绑定IP network.host: 192.168.0.232 #配置服务端口(9300为集群选举使用的端口) http.port: 9200 #使用单播的方式发现集群节点,避免网络波动和云服务器网络限制造成的节点发现失败问题 discovery.zen.ping.unicast.hosts: ["192.168.0.232", "192.168.0.231"] ``` #### 启动ES服务 ```shell #源码包启动 /app/es/bin/elasticsearch systemctl restart elasticsearch ``` ### 安装elasticsearch-head插件 #### Chrome插件方式(推荐) Chrome插件中搜索 elasticsearch head http://pan.baidu.com/s/1slSDvv3 #### 服务模式 ```shell cd /opt git clone git://github.com/mobz/elasticsearch-head.git cd elasticsearch-head/ npm install grunt-cli --registry=https://registry.npm.taobao.org #备注:grunt是Javascrip的构建工具 npm install --registry=https://registry.npm.taobao.org #安装过程中会下载phantomjs-2.1.1-linux-x86_64.tar.bz2,取消下载即可 npm run start ``` 访问elasticsearch-head插件 ```shell open (http://localhost:9100/) ``` #### 错误处理 ##### 错误1(RPM包处理方式):elasticsearch 5.x which: no java in - 安装的jdk 1.8.121,不成功,安装openjava-jdk1.8.131成功 - 或修改elasticsearch用户 usermod elasticsearch -s /bin/bash ##### 错误2:bootstrap.memory_lock: true导致Elasticsearch启动失败问题(RPM安装未解决) ```shell ...略 # allow user 'elasticsearch' mlockall elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited ...略 ERROR: bootstrap checks failed memory locking requested for elasticsearch process but memory is not locked ...略 ``` 解决: ```shell #追加 /etc/security/limits.conf elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited ``` ##### 错误3:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] ```shell echo "vm.max_map_count = 262144" >> /etc/sysctl.conf ``` ##### 错误4:Centos 6.x 安装elasticsearch5.2无法启动bug 报错: ```shell ERROR: bootstrap checks failed system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk ``` 原因: ```shell 这是在因为Centos6不支持SecComp,而ES5.2.0默认bootstrap.system_call_filter为true进行检测,所以导致检测失败,失败后直接导致ES不能启动。 ``` 解决: ```shell 在elasticsearch.yml中配置bootstrap.system_call_filter为false,注意要在Memory下面: bootstrap.memory_lock: false bootstrap.system_call_filter: false ``` 可以查看issues https://github.com/elastic/elasticsearch/issues/22 ##### 错误5:文件描述符设置太小 报错 ```shell max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536] max number of threads [1024] for user [[elasticsearch] is too low, increase to at least [2048] ``` 解决 编辑limits.conf 文件 ```shell #vim /etc/security/limits.conf * soft nofile 65536 * hard nofile 65536 #Centos6.x修改vim /etc/security/limits.d/90-nproc.conf soft nproc 1024 修改为 soft nproc 2048 sysctl -p ```