二.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"