二.Elasticsearch 配置信息
node
2.1 由於 Elasticsearch 能夠執行腳本文件,爲了安全性,默認不容許經過 root 用戶啓動服務。
咱們須要新建立用戶名和用戶組啓動服務linux
2.2 默認狀況下,Elasticsearch 只容許本機訪問,若是須要遠程訪問,須要修改其配置文件git
vim config/elasticsearch.yml # 去掉 network.host 前邊的註釋,將它的值改爲0.0.0.0 network.host: 0.0.0.0
2.3 經常使用命令 github
curl -i XGET "http://192.168.141.3:9200/_count?" #統計當前的信息npm
2.4 爲了方便實用 安裝Elasticsearch head 模塊vim
elasticsearch-head 安裝安全
訪問 http://x.x.x.x:9200 查看內容顯示效果不友好,所以,咱們須要安裝一個名爲 elasticsearch-head 的插件,讓內容顯示效果比較溫馨。bash
登錄 GitHub 網站,搜索 mobz/elasticsearch-head ,將其下載到本地服務器
wget https://github.com/mobz/elasticsearch-head/archive/master.zip unzip master.zip cd elasticsearch-head-master npm install npm run start
提示沒有npm 命令 ,安裝 npmcors
獲取nodejs 資源 # 4.x curl --silent --location https://rpm.nodesource.com/setup_4.x | bash - # 5.x curl --silent --location https://rpm.nodesource.com/setup_5.x | bash - # 0.10 curl --silent --location https://rpm.nodesource.com/setup | bash - 我這裏安裝的是 v4.x 安裝 yum install -y nodejs 測試是否安裝成功 node -v # v4.4.0 npm -v # 2.14.20
npm install 時報錯報錯:
npm ERR! phantomjs-prebuilt@2.1.16 install: `node install.js`
npm ERR! Exit status 1
解決:
安裝 phantomjs
一、獲取安裝包 wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2
或者
wget https://bbuseruploads.s3.amazonaws.com/fd96ed93-2b32-46a7-9d2b-ecbc0988516a/downloads/396e7977-71fd-4592-8723-495ca4cfa7cc/phantomjs-2.1.1-linux-x86_64.tar.bz2?Signature=yWIrMK09KI8r24QSHFdkuSIlR3A%3D&Expires=1523867378&AWSAccessKeyId=AKIAIQWXW6WLXMB5QZAQ&versionId=null&response-content-disposition=attachment%3B%20filename%3D%22phantomjs-2.1.1-linux-x86_64.tar.bz2%22
二、將bz2格式裝換成tar格式 bzip2 -d phantomjs-2.1.1-linux-x86_64.tar.bz2 三、解壓縮到/usr/local目錄下 tar xvf phantomjs-2.1.1-linux-x86_64.tar -C /usr/local/ 四、安裝依賴 yum -y install wget fontconfig 五、重命名 mv /usr/local/phantomjs-2.1.1-linux-x86_64/ /usr/local/phantomjs 六、進入目錄中,爲PhantomJS添加可執行權限 cd /usr/local/phantomjs/bin chmod 777 phantomjs 七、創建軟連接 ln -s /usr/local/phantomjs/bin/phantomjs /bin/phantomjs
八、測試是否可執行 [root@iz2zea6jqvyc0mokqu9jyaz bin]# phantomjs
phantomjs>
2.5
注意:在請求URL中要用127.0.0.1 或者 綁定的具體IP地址,用localhost不起做用(如下問題緣由在此)
圖中咱們發現 elasticsearch-head 插件和 Elasticsearch 服務並無創建鏈接,因此咱們還須要修改 Elasticsearch 的配置文件:
cd /etc/elasticsearch-5.6.1 vi elasticsearch.yml # 在文件末尾添加 2 段配置 http.cors.enabled: true http.cors.allow-origin: "*"
2.6修改服務器監聽地址(並不必定須要)
仍是顯示未鏈接,修改服務器監聽地址
[root@linux-node1 elasticsearch-head]# pwd
/usr/local/elasticsearch-head/
[root@linux-node1 elasticsearch-head]# vim Gruntfile.js #添加上下面的內容
connect: {
server: {
options: {
port: 9100,
hostname: '*',
base: '.',
keepalive: true
}
}
}
增長hostname屬性,設置爲*
2.7 以上兩個方法都試了,仍是鏈接不上
考慮下多是 ip地址的問題,由於 elasticsearch-head 和elasticsearch 在一臺機器上,
只不過elasticsearch 運行在容器內,elasticsearch-head在系統上運行
將localhost 換位內網ip地址
3.Kibana 配置信息
/opt/kibana/config/kibana.yml server.port: 5601 (默認) server.host: "localhost" server.host: "0.0.0.0" elasticsearch.url: "http://elk1:9200"