ELK搭建及配置
1、在兩臺機器上分別新添加磁盤,格式化,掛載,專門用于ELK
mkfs.xfs /dev/sdb
mkdir /data1
mount /dev/sdb /data1
blkid /dev/sdb #查詢磁盤的uuid,使用uuid掛載,以防止服務器重啟時磁盤名稱變化
vim /etc/fstab
dd86fef0-3873-4767-bc9a-dc673dcecb5a /data1 xfs defaults 0 0
2、下載安裝包
https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.rpm
http://download.oracle.com/otn/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-linux-x64.rpm?AuthParam=1527560278_371b883a1f5d9c8b5944edcb464b5780
安裝
yum install jdk-8u121-linux-x64.rpm
yum install elasticsearch-5.4.0.rpm
3、設置主機名、本地hosts文件
hostnamectl set-hostname elk01.example.com
hostnamectl set-hostname elk02.example.com
cat /etc/hosts
10.1.2.184 elk01.example.com
10.1.2.186 elk02.example.com
4、關閉防火墻和selinux、打開的文件數
systemctl disable firewalld
systemctl disable NetworkManager
sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config
echo " soft nofile 65536" >> /etc/security/limits.conf
echo " hard nofile 65536" >> /etc/security/limits.conf
5、設置yun源,安裝必要包
yum install -y net-tools vim lrzsz tree screen lsof tcpdump wget ntpdate
6、配置elasticseach配置文件
grep "^[a-z]" /etc/elasticsearch/elasticsearch.yml
cluster.name: elk-cluster
node.name: elk-node-1
path.data: /data1/elkdata
path.logs: /data1/logs
bootstrap.memory_lock: true
network.host: 10.1.2.184
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.1.2.184", "10.1.2.186"]
7、創建目錄、修改權限,啟動
mkdir /data1/{elkdata,logs}
chown -R elasticsearch.elasticsearch /data1/{elkdata,logs}
8、修改啟動腳本的內存參數,否則會啟動不了
vim /usr/lib/systemd/system/elasticsearch.service
取消注釋 LimitMEMLOCK=infinity
vim /etc/elasticsearch/jvm.options #也可以不改,如果能啟動
-Xms3g #這個內存使用建議不超過物理內存的50%,最高不超過32G
-Xmx3g
PS:出錯提示
Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; disabled; vendor preset: disabled)
檢查jdk版本,及系統上原來是否安裝了其他版本的jdk
9、安裝elasticsearch插件之head
yum install git-core
git clone git://github.com/mobz/elasticsearch-head.git
cd elasticsearch-head
yum install -y npm
npm install grunt -save
ll node_modules/grunt 確認生成文件
npm install
npm run start & 啟動
10.1.2.189:9100訪問
安裝完測試集群狀態
curl http://10.1.2.189:9200/_cluster/health?protty=true
"status" : "green",這一欄是gree是正常的
10、修改elasticsearch配置文件后才能連接
http.cors.enabled: true #注意要空格
http.cors.allow-origin: "*"
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。