Skip to content

Commit 7242b9a

Browse files
committed
2017-05-29 完善 ELK
1 parent 52d8fec commit 7242b9a

File tree

2 files changed

+67
-69
lines changed

2 files changed

+67
-69
lines changed

CentOS6-and-CentOS7.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@
5151
- `systemctl stop firewalld.service` #停止firewall
5252
- `systemctl disable firewalld.service` #禁止firewall开机启动
5353
- 安装 iptables
54-
- yum install -y iptables-services
54+
- `yum install -y iptables-services`
5555
- 启动 iptables
56-
- systemctl restart iptables.service #最后重启防火墙使配置生效
57-
- systemctl enable iptables.service #设置防火墙开机启动
56+
- `systemctl restart iptables.service` #最后重启防火墙使配置生效
57+
- `systemctl enable iptables.service` #设置防火墙开机启动
5858
- 其他使用照旧
5959

6060
## ifconfig 没有了

ELK-Install-And-Settings.md

Lines changed: 64 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ discovery.zen.ping.unicast.hosts: ["192.168.1.127", "192.168.1.126"] #这个为
7777
# allow user 'elasticsearch' mlockall
7878
elasticsearch soft memlock unlimited
7979
elasticsearch hard memlock unlimited
80-
* soft nofile 65536
81-
* hard nofile 65536
80+
* soft nofile 262144
81+
* hard nofile 262144
8282
```
8383

8484
- 关闭 firewall
@@ -342,85 +342,83 @@ kibana.index: ".kibana" #在elastic中添加.kibana
342342
- kibana 的高级用法请看我单独的一篇文章:[kibana 相关知识](Kibana-Base.md)
343343

344344

345-
//==================================================================================================================================================================
346345

347-
## 5.2 安装(未完成)
346+
## Elasticsearch 5.2.0 安装
348347

349-
### RPM 安装
348+
### 环境
350349

351-
- 官网总的安装文档:<https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html>
350+
- 机子 IP:192.168.1.127
351+
- CentOS 7.3
352+
- JDK 版本:1.8(最低要求),主推:JDK 1.8.0_121
353+
- Elasticsearch 版本:5.2.0
354+
- 关闭 firewall
355+
- `systemctl stop firewalld.service` #停止firewall
356+
- `systemctl disable firewalld.service` #禁止firewall开机启动
352357

353-
### 安装 Elasticsearch
354358

355-
- 确保安装有 JDK
356-
- 官网文档:<https://www.elastic.co/guide/en/elasticsearch/reference/5.2/install-elasticsearch.html>
357-
- 创建 repo 文件:`vim /etc/yum.repos.d/elasticsearch.repo`,文件内容如下:
359+
### zip 解压安装
358360

359-
``` ini
360-
[elasticsearch-5.x]
361-
name=Elasticsearch repository for 5.x packages
362-
baseurl=https://artifacts.elastic.co/packages/5.x/yum
363-
gpgcheck=1
364-
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
365-
enabled=1
366-
autorefresh=1
367-
type=rpm-md
361+
- 官网总的安装文档:<https://www.elastic.co/guide/en/elasticsearch/reference/5.x/zip-targz.html>
362+
- 我的解压目录:`/usr/program`,解压包名:`elasticsearch-5.2.0.zip`
363+
- 解压:`cd /usr/program ; unzip elasticsearch-5.2.0.zip`
364+
- 删除掉压缩包:`rm -rf elasticsearch-5.2.0.zip`
365+
- 添加组和用户
366+
- 该版本不能使用 root 用户进行使用
367+
- `useradd elasticsearch -p 123456`,添加一个名为 elasticsearch 的用户,还有一个同名的组
368+
- 添加数据目录:`mkdir -p /opt/elasticsearch/data /opt/elasticsearch/log`
369+
- 赋权限:
370+
- `chown -R elasticsearch:elasticsearch /usr/program/elasticsearch-5.2.0 /opt/elasticsearch`
371+
- 编辑配置文件:`vim /usr/program/elasticsearch-5.2.0/config/elasticsearch.yml`,打开下面注释,并修改
372+
373+
``` nginx
374+
cluster.name: youmeek-cluster
375+
node.name: youmeek-node-1
376+
path.data: /opt/elasticsearch/data
377+
path.logs: /opt/elasticsearch/log
378+
bootstrap.memory_lock: true
379+
network.host: 0.0.0.0 # 也可以是本机 IP
380+
http.port: 9200
381+
discovery.zen.ping.unicast.hosts: ["192.168.1.127"] #这个为两台机子的 IP 地址
368382
```
369383

370-
- 引入 key:`rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch`
371-
- 开始安装:`yum install -y elasticsearch`
372-
- 如果网络慢下载不了,那可以手动安装:
373-
- 下载:`wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.rpm`
374-
- 安装:`rpm --install elasticsearch-5.2.2.rpm`
375-
- 添加自启动:`systemctl enable elasticsearch.service`
376-
- 因为我的 JDK 是解压版本,不是 yum 安装的,所以这里要配置 JDK 路径:`vim /etc/sysconfig/elasticsearch`
377-
- 找到 JAVA_HOME,打开注释,写上你的 JDK 路径即可
378-
- 修改配置:
379-
- 创建数据目录:`mkdir -p /opt/elasticsearch/data`
380-
- 给 ELK 系统用户授权:`chown -R elasticsearch:elasticsearch /opt/elasticsearch/data`
381-
- 修改配置:`vim /etc/elasticsearch/elasticsearch.yml`,打开下面这些内容的注释,并修改:
382-
383-
``` nginx
384-
cluster.name: gitnavi-cluster
385-
node.name: gitnavi-node-1
386-
path.data: /opt/elasticsearch/data
387-
path.logs: /var/log/elasticsearch
388-
bootstrap.memory_lock: true
389-
network.host: 本机 IP 地址
390-
http.port: 9200
391-
discovery.zen.ping.multicast.enabled: false
392-
discovery.zen.ping.unicast.hosts: ["192.168.1.127", "192.168.1.126"] #这个为两台机子的 IP 地址,ES 从2.0版本开始,默认的自动发现方式改为了单播(unicast)方式
393-
```
384+
- 修改这个配置文件,不然无法锁内存:`vim /etc/security/limits.conf`
385+
- 在文件最尾部增加下面内容:
394386

395-
- 修改这个配置文件,不然无法锁内存:`vim /etc/security/limits.conf`
396-
- 增加下面内容:
397-
398-
``` nginx
399-
# allow user 'elasticsearch' mlockall
400-
elasticsearch soft memlock unlimited
401-
elasticsearch hard memlock unlimited
402-
* soft nofile 65536
403-
* hard nofile 65536
404-
```
387+
``` nginx
388+
# allow user 'elasticsearch' mlockall
389+
elasticsearch soft memlock unlimited
390+
elasticsearch hard memlock unlimited
391+
* soft nofile 262144
392+
* hard nofile 262144
393+
```
405394

406395
- 修改:`vim /etc/sysctl.conf`,添加下面配置
407396

408397
``` ini
409-
vm.max_map_count=655360
398+
vm.max_map_count=262144
410399
```
411400

412-
- 启动(比较慢,耐心点):`systemctl start elasticsearch.service`
413-
- 查看启动日志:`tail -500f /var/log/elasticsearch/节点名.log`
414-
- 停止:`systemctl stop elasticsearch.service`
415-
- rpm 安装后一些路径说明:
416-
- home:`/usr/share/elasticsearch`
417-
- bin:`/usr/share/elasticsearch/bin`
418-
- 配置文件:`/etc/elasticsearch/elasticsearch.yml`
419-
- 变量配置文件:`/etc/sysconfig/elasticsearch`
420-
- log:`/var/log/elasticsearch/集群名称.log`
421-
- plugins:`/usr/share/elasticsearch/plugins`
422-
- data:`/var/lib/elasticsearch`,只是我在上面改到 /opt 目录下了
423-
- script:`/etc/elasticsearch/scripts`
401+
- 重启机子:`reboot`
402+
- 切换用户:`su elasticsearch`
403+
- 控制台运行(启动比较慢):`cd /usr/program/elasticsearch-5.2.0 ; ./bin/elasticsearch`
404+
- 后台运行:`cd /usr/program/elasticsearch-5.2.0 ; ./bin/elasticsearch -d -p 自定义pid值`
405+
- 在本机终端输入该命令:`curl -XGET 'http://192.168.1.127:9200'`,(也可以用浏览器访问:<http://192.168.1.127:9200/>)如果能得到如下结果,则表示启动成功:
406+
407+
``` json
408+
{
409+
"name" : "xrfsiZM",
410+
"cluster_name" : "elasticsearch",
411+
"cluster_uuid" : "8AtVCJYWTweSK7PZubAaYQ",
412+
"version" : {
413+
"number" : "5.2.0",
414+
"build_hash" : "24e05b9",
415+
"build_date" : "2017-01-24T19:52:35.800Z",
416+
"build_snapshot" : false,
417+
"lucene_version" : "6.4.0"
418+
},
419+
"tagline" : "You Know, for Search"
420+
}
421+
```
424422

425423
### 安装 X-Pack 或是其他插件
426424

0 commit comments

Comments
 (0)