系统优化
步骤 1)设置环境变量。
vim /etc/profile
增加
ulimit -n 65535
用以设定同一时间打开的文件数的最大值为 65535。
source /etc/profile
步骤 2)修改 limits.conf 配置文件。
vi /etc/security/limits.conf
增加
* soft nofile 65536
* hard nofile 65536
用来限制打开文件数 65535
步骤 3)修改 sysctl.conf 配置文件。
vi /etc/sysctl.conf
修改
vm.max_map_count=262144
运行 sysctl -p
重启电脑 reboot
elasticsearch 安装
yum -y install wget net-tools java-1.8.0-openjdk java-1.8.0-openjdk-devel
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.2.tar.gz
tar xvzf elasticsearch-6.4.2.tar.gz
mv elasticsearch-6.4.2 /usr/local/
useradd -m elk
#修改密码
passwd elk
chmod 777 -R /usr/local/elasticsearch-6.4.2
配置master
(修改 文件 elasticsearch.yml)
cluster.name: "elk-cluster"
node.name: "master"
network.publish_host: IP # 公网IP
network.bind_host: 0.0.0.0
node.master: true
node.data: false
http.cors.enabled: true
http.cors.allow-origin: "*"
#修改数据存储目录.可以多个目录 eg: /drive/elk/data1 /drive/elk/data2 这里的目录需要增加权限 chmod 777 -R /drive/elk/data1
path.data: /drive/elk/data
transport.tcp.port: 9300
http.port: 9200
data.ymal
cluster.name: "elk-cluster"
node.name: "data1"
network.publish_host: IP # 公网IP
network.bind_host: 0.0.0.0
node.master: false
node.data: true
http.cors.enabled: true
http.cors.allow-origin: "*"
transport.tcp.port: 9300
http.port: 9200
discovery.zen.ping.unicast.hosts: ["master1", "master2", "master3"]
#path.data: /path/to/data1,/path/to/data2
#修改数据存储目录.可以多个目录 eg: /drive/elk/data1 /drive/elk/data2 这里的目录需要增加权限 chmod 777 -R /drive/elk/data1
修改jvm.options
# 这个值设为内存的一半,必须设置为一样
-Xms4g
-Xmx4g
其他
启动 start.sh
#/bin/bash
./bin/elasticsearch -p /tmp/elasticsearch-pid -d
重启 restart.sh
#!/bin/bash
if [ -f /tmp/elasticsearch-pid ];then
pid=$(cat /tmp/elasticsearch-pid)
echo $pid
if [ ! -z "$pid" ];then
kill $pid
fi
fi
./bin/elasticsearch -p /tmp/elasticsearch-pid -d
停止 stop.sh
#!/bin/bash
if [ -f /tmp/elasticsearch-pid ];then
pid=$(cat /tmp/elasticsearch-pid)
echo $pid
if [ ! -z "$pid" ];then
kill $pid
fi
fi
logstash
安装Java环境
yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel -y
安装logstash
wget https://artifacts.elastic.co/downloads/logstash/logstash-6.4.2.tar.gz
配置
input {
nsq {
nsqlookupd => ["192.168.0.125:4161"]
topic => "kline"
channel => "test"
max_in_flight => 200
codec => plain
}
}
output {
stdout {
codec => rubydebug
}
}
nsq插件安装
./logstash-plugin install logstash-input-nsq