ELK搭建社工库_社工裤搭建(1)

前置准备

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.7.0-x86_64.rpm
wget https://artifacts.elastic.co/downloads/kibana/kibana-7.7.0-x86_64.rpm
wget https://artifacts.elastic.co/downloads/logstash/logstash-7.7.0.rpm
wget https://repo.huaweicloud.com/java/jdk/8u201-b09/jdk-8u201-linux-x64.rpm

systemctl stop firewalld.service

开始安装

Elasticsearch

安装Elasticsearch
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
rpm --install elasticsearch-7.7.0-x86_64.rpm

设置开机自启
systemctl daemon-reload
systemctl enable elasticsearch

启动Elasticsearch
systemctl start elasticsearch

修改配置文件
vim /etc/elasticsearch/elasticsearch.yml

#集群名称
cluster.name: test-el
#节点名称
node.name: node-1
#监听IP
network.host: 0.0.0.0
#初始化设置
cluster.initial_master_nodes: ["node-1", "node-2"]

重启Elasticsearch
systemctl restart elasticsearch

image-20230810145604170

Kibana

安装Kibana
rpm -ivh kibana-7.7.0-x86_64.rpm

设置开机自启
systemctl daemon-reload
systemctl enable kibana

修改配置文件
vim /etc/kibana/kibana.yml

#服务端口
server.port: 5601
#监听地址
server.host: "0.0.0.0"
#elasticsearch 的地址+端口
elasticsearch.hosts: ["http://192.168.110.135:9200"]
#语言
i18n.locale: "zh-CN"

启动Kibana
systemctl start kibana

image-20230810150004102

Logstash

安装java
rpm -ivh jdk-8u201-linux-x64.rpm

安装Logstash
rpm -ivh logstash-7.7.0.rpm

设置开机自启
systemctl daemon-reload
systemctl enable logstash

启动Logstash
systemctl start logstash

导入社工库

创建配置文件
vim /usr/share/logstash/bin/1.conf

input {
  file {
    path => ["/root/data.csv"]
	# 设置多长时间检测文件是否修改(单位:秒)
	stat_interval => 1
	# 监听文件的起始位置,默认是end
	start_position => beginning
	# 监听文件读取信息记录的位置(名称随便填一个)
	sincedb_path => "/root/data_db.txt"
	# 设置多长时间会写入读取的位置信息(单位:秒)
	sincedb_write_interval => 5
    	codec => plain{
		charset=>"GBK"
		}
	}
}
filter {
	#去除每行记录中需要过滤的\N,替换为空字符串
	mutate{
		gsub => [ "message", "\\r", "" ]
	}
	csv {
		# 每行记录的字段之间以|分隔
		separator => ","
		columns => ["name","phone","sfz"]
		# 过滤掉默认加上的字段
		remove_field => ["host", "tags", "path", "message","@timestamp","@version"]
	}
}
output {
    elasticsearch {
        hosts => ["127.0.0.1:9200"]
        index => "social"
    }
#建议吧stdout这段删除,会影响到导入数据,这个是显示导入数据过程的
	stdout {
		codec => rubydebug
	}
}

生成数据
/usr/share/logstash/bin/logstash -f 1.conf

社工库部署

image-20230810155120797

image-20230810155212568

image-20230810155227100

image-20230810155257174

image-20230810155317224

image-20230810155334783

上线!

Tips

修改elasticsearch文件存储路径
停止需要迁移的节点,禁用分片(IP换成你自己的)
curl -XPUT 'http://127.0.0.1:9200/_cluster/settings?pretty' -H 'Content-Type:application/json' -d '{"transient":{"cluster.routing.allocation.enable": "none"}}'

查看分片是否禁用 (IP换成你自己的):
curl -XGET '127.0.0.1:9200/_cluster/settings?pretty'

停止实例
systemctl stop elasticsearch

创建数据目录(使用你自己的新的目录 磁盘空间大的)
mkdir -p /home/soft/elasticsearch/data
mkdir -p /home/soft/elasticsearch/logs

复制原数据到新目录
cp -r /var/lib/elasticsearch/nodes/ /home/soft/elasticsearch/data/

授权为es用户
chown -R elasticsearch:elasticsearch /home/soft/elasticsearch/data/
chown -R elasticsearch:elasticsearch /home/soft/elasticsearch/logs/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值