(一)Elasticsearch
(一)平台所需的环境OS:CentOS 7.x minimal
elasticsearch :elasticsearch-5.4.0版本
jdk:1.8以上版本
创建普通用户:appuser
最新的下载路径地址为:https://www.elastic.co/downloads
(二)配置操作系统的环境并安装elasticsearch:
1.ifconifg查看网络的命令无法使用,最后的解决方案为:yum -y install net-tools
# ifconifig
bash: ifconifig: command not found
# ipaddr
bash: ipaddr: command not found
# ip addr
1: lo:mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0:mtu 1500 qdisc mq state UP qlen 1000
link/ether 00:15:5d:6e:28:1a brd ff:ff:ff:ff:ff:ff
inet 192.168.180.23/24 brd 192.168.180.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::215:5dff:fe6e:281a/64 scope link
valid_lft forever preferred_lft forever
# yum -y install net-tools #########使用yum安装net-tools工具
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package net-tools.x86_64 0:2.0-0.17.20131004git.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
net-tools x86_64 2.0-0.17.20131004git.el7 base 304 k
Transaction Summary
========================================================================================================================
Install1 Package
Total download size: 304 k
Installed size: 917 k
Downloading packages:
net-tools-2.0-0.17.20131004git.el7.x86_64.rpm | 304 kB00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : net-tools-2.0-0.17.20131004git.el7.x86_64 1/1
Verifying: net-tools-2.0-0.17.20131004git.el7.x86_64 1/1
Installed:
net-tools.x86_64 0:2.0-0.17.20131004git.el7
Complete!
# ifconif
bash: ifconif: command not found
# ifconfig
eth0: flags=4163mtu 1500
inet 192.168.180.23netmask 255.255.255.0broadcast 192.168.180.255
inet6 fe80::215:5dff:fe6e:281aprefixlen 64scopeid 0x20
ether 00:15:5d:6e:28:1atxqueuelen 1000(Ethernet)
RX packets 26463bytes 33446022 (31.8 MiB)
RX errors 0dropped 0overruns 0frame 0
TX packets 10534bytes 895992 (874.9 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0
lo: flags=73mtu 65536
inet 127.0.0.1netmask 255.0.0.0
inet6 ::1prefixlen 128scopeid 0x10
looptxqueuelen 0(Local Loopback)
RX packets 32bytes 2724 (2.6 KiB)
RX errors 0dropped 0overruns 0frame 0
TX packets 32bytes 2724 (2.6 KiB)
TX errors 0dropped 0 overruns 0carrier 0collisions 0 2.安装jdk1.8版本以上的版本,在官网上下好,直接上传。
# rpm -ivh jdk-8u131-linux-x64.rpm
Preparing... #################################
Updating / installing...
1:jdk1.8.0_131-2000:1.8.0_131-fcs#################################
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
# vim /etc/profile
#####install for JDK在最下边添加如下
export JAVA_HOME=/usr/java/jdk1.8.0_131/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=$JAVA_HOME/lib:.:$CLASSPATH
# source /etc/profile
# java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode) 3.创建appuser普通用户,并安装elasticsearch
# groupadd appuser
# useradd -g appuser.appuser
# password appuser
bash: password: command not found
# passwd appuser
Changing password for user appuser.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
$ wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.4.0.tar.gz
$ tar xf elasticsearch-5.4.0.tar.gz
$ mv elasticsearch-5.4.0 ../
$ cd ../elasticsearch-5.4.0/
$ mkdir -pv {data,logs}
mkdir: created directory ‘data’
mkdir: created directory ‘logs’
$ vim config/elasticsearch.yml
cluster.name: cluster-lqb
node.name: node-1
path.data: /home/appuser/elasticsearch-5.4.0/data
path.logs: /home/appuser/elasticsearch-5.4.0/logs
network.host: 192.168.180.23
http.port: 9200
http.cors.enabled:true
http.cors.allow-origin:"*" 4.修改系统参数,用root账号
# vim /etc/security/limits.conf
* soft nproc 65536
* hard nproc 65536
* soft nofile 65536
* hard nofile 65536
# vim /etc/sysctl.conf
vm.max_map_count= 262144
# sysctl -p
vm.max_map_count = 262144 5.启动服务
$ ./bin/elasticsearch &
2266
$ initializing ...
using data paths, mounts [], net usable_space , net total_space , spins? , types
heap size , compressed ordinary object pointers
node name , node ID
version, pid, build, OS, JVM
loaded module
loaded module
loaded module
loaded module
loaded module
loaded module
loaded module
loaded module
loaded module
loaded module
no plugins loaded
using discovery type
initialized
starting ...
publish_address {192.168.180.23:9300}, bound_addresses {192.168.180.23:9300}
bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
new_master {node-1}{fLZy_engTtOA3jBrR-K5Dg}{VLbtX7DdQzW51L_GF_nzfA}{192.168.180.23}{192.168.180.23:9300}, reason: zen-disco-elected-as-master ( nodes joined)
publish_address {192.168.180.23:9200}, bound_addresses {192.168.180.23:9200}
started
recovered indices into cluster_state
$ ps -ef|grep elasticsearch
root 231522130 04:54 pts/1 00:00:00 tail -f /home/appuser/elasticsearch-5.4.0/logs/cluster-lqb.log
appuser 24352250 99 04:58 pts/0 00:01:12 /usr/java/jdk1.8.0_131//bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/home/appuser/elasticsearch-5.4.0 -cp /home/appuser/elasticsearch-5.4.0/lib/* org.elasticsearch.bootstrap.Elasticsearch
appuser 252322500 04:59 pts/0 00:00:00 grep --color=auto elasticsearch
$netstat -lntp|grep 9200
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp6 0 0 192.168.180.23:9200 :::* LISTEN 2435/java 报错:max file descriptors for elasticsearch process is too low, increase to at least
解决方案:
cat /etc/security/limits.conf
* soft nproc 65536
* hard nproc 65536
* soft nofile 65536
* hard nofile 65536
并重启生效。 (三).安装head插件;由于head插件本质上还是一个nodejs的工程,因此需要安装node,使用npm来安装依赖的包。(npm可以理解为maven)
[*] 首先安装npm。下载地址(http://nodejs.org/)
# yum -y install xz
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package xz.x86_64 0:5.1.2-12alpha.el7 will be updated
Updated:
xz.x86_64 0:5.2.2-1.el7
Dependency Updated:
xz-libs.x86_64 0:5.2.2-1.el7
Complete!
# wget
# xz -d node-v6.10.3-linux-x64.tar.xz
# tar xf node-v6.10.3-linux-x64.tar.xz
#tar -xvf node-v6.10.3-linux-x64.tar
# cd node-v6.10.3-linux-x64
# pwd
/tmp/install/elk/node-v6.10.3-linux-x64
# vim /etc/profile
####SET NOD environment
export NODE_HOME=/tmp/install/elk/node-v6.10.3-linux-x64
export PATH=$NODE_HOME/bin:$PATH
# source /etc/profile
# npm -v
3.10.10
# node -v
v6.10.3
###node安装完成 2.安装下载插件包git
# yum install git -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0:1.8.3.1-6.el7_2.1 will be installed
--> Running transaction check
---> Package libgnome-keyring.x86_64 0:3.8.0-3.el7 will be installed
---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed
---> Package perl-Git.noarch 0:1.8.3.1-6.el7_2.1 will be installed
---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed
---> Package rsync.x86_64 0:3.0.9-17.el7 will be installed
--> Finished Dependency Resolution
Installed:
git.x86_64 0:1.8.3.1-6.el7_2.1
Dependency Installed:
libgnome-keyring.x86_64 0:3.8.0-3.el7 perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-6.el7_2.1
perl-TermReadKey.x86_64 0:2.30-20.el7 rsync.x86_64 0:3.0.9-17.el7
# git clone git://github.com/mobz/elasticsearch-head.git
Cloning into 'elasticsearch-head'...
remote: Counting objects: 4063, done.
remote: Total 4063 (delta 0), reused 0 (delta 0), pack-reused 4063
Receiving objects: 100% (4063/4063), 2.10 MiB | 1.02 MiB/s, done.
Resolving deltas: 100% (2222/2222), done.
Complete! 3.安装解压软件.tar.bz2
# yum install bzip2 phantomjs-2.1.1-linux-x86_64.tar.bz2
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.163.com
* updates: mirrors.163.com
No package phantomjs-2.1.1-linux-x86_64.tar.bz2 available.
Resolving Dependencies
--> Running transaction check
---> Package bzip2.x86_64 0:1.0.6-13.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
====================================================================================================================================
Package Arch Version Repository Size
====================================================================================================================================
Installing:
bzip2 x86_64 1.0.6-13.el7 base 52 k
Transaction Summary
====================================================================================================================================
Install1 Package
Total download size: 52 k
Installed size: 82 k
Is this ok : y
Downloading packages:
bzip2-1.0.6-13.el7.x86_64.rpm |52 kB00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : bzip2-1.0.6-13.el7.x86_64 1/1
Verifying: bzip2-1.0.6-13.el7.x86_64 1/1
Installed:
bzip2.x86_64 0:1.0.6-13.el7
Complete! 4.安装grunt。grunt是一个很方便的构建工具,可以进行打包压缩、测试、执行等等的工作,5.X里的head插件就是通过grunt启动的。
root@localhost elk]# cd elasticsearch-head
# npm install -g grunt --registry=https://registry.npm.taobao.org
/tmp/install/elk/node-v6.10.3-linux-x64/bin/grunt -> /tmp/install/elk/node-v6.10.3-linux-x64/lib/node_modules/grunt/bin/grunt
/tmp/install/elk/node-v6.10.3-linux-x64/lib
└── grunt@1.0.1
# /tmp/install/elk/elasticsearch-head/node_modules/grunt/bin/grunt -V
grunt-cli v1.2.0
grunt v1.0.1 5.安装Head
# npm install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN elasticsearch-head@0.0.0 license should be a valid SPDX license expression
#在elasticsearch-head目录下node_modules/grunt下如果没有grunt二进制程序,需要执行:
cd elasticsearch-head
npm install grunt --save由于head的代码还是2.6版本的,直接执行有很多限制,比如无法跨机器访问。因此需要我们需要修改两个文件:
a.修改服务器监听地址( /tmp/install/elk/elasticsearch-head/Gruntfile.js )。b.修改连接地址(/tmp/install/elk/elasticsearch-head/_site/app.js)
6.修改配置
a.修改监听地址Gruntfile.js 。增加hostname属性,设置为*
# vim /tmp/install/elk/elasticsearch-head/Gruntfile.js
tasks: ['default'],
options: {
spawn: false
}
},
"grunt": {
files: [ 'Gruntfile.js' ]
}
},
connect: {
server: {
options: {
hostname: '*',
port: 9100,
base: '.',
keepalive: true
}
}
}
});
b.修改连接地址:app.js .
# vim /tmp/install/elk/elasticsearch-head/_site/app.js
(function( app, i18n ) {
var ui = app.ns("ui");
var services = app.ns("services");
app.App = ui.AbstractWidget.extend({
defaults: {
base_uri: null
},
init: function(parent) {
this._super();
this.prefs = services.Preferences.instance();
this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.180.23:9200";
if( this.base_uri.charAt( this.base_uri.length - 1 ) !== "/" ) {
// XHR request fails if the URL is not ending with a "/"
this.base_uri += "/";
}
if( this.config.auth_user ) {
var credentials = window.btoa( this.config.auth_user + ":" + this.config.auth_password );
$.ajaxSetup({
headers: {
"Authorization": "Basic " + credentials
}
});
}
this.cluster = new services.Cluster({ base_uri: this.base_uri });
this._clusterState = new services.ClusterState({ 。大概在4329行把ocalhost修改成你es的服务器地址。his.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://localhost:9200";
====>this.base_uri = this.config.base_uri || this.prefs.get("app-base_uri") || "http://192.168.180.23:9200";
7.elasticsearch-head启动
$ cd /home/appuser/elasticsearch-5.4.0/plugins/elasticsearch-head/node_modules/grunt/bin/
$ ./grunt server &
3741
$ Running "connect:server" (connect) task
Waiting forever...
Started connect web server on http://localhost:9100 至此启动成功,可以在浏览器里查看了
https://s1.运维网.com/wyfs02/M02/97/71/wKioL1kucBSRX3mgAACtdJJA8Nw051.png
(四).安装bigdesk插件
appuser@localhost plugins]$ git clone https://github.com/hlstudio/bigdesk
Cloning into 'bigdesk'...
remote: Counting objects: 151, done.
remote: Total 151 (delta 0), reused 0 (delta 0), pack-reused 151
Receiving objects: 100% (151/151), 348.16 KiB | 91.00 KiB/s, done.
Resolving deltas: 100% (57/57), done.
$ cd bigdesk/_site/
$python -m SimpleHTTPServer
Serving HTTP on 0.0.0.0 port 8000 ...
192.168.181.231 - - "GET / HTTP/1.1" 200 -
192.168.181.231 - - "GET /css/reset.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /css/CssGrid_2/styles.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /css/CssGrid_2/1140.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /css/bigdesk.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/charts/common.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/charts/not-available/not-available-chart.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/charts/time-series/time-series-chart.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/charts/time-area/time-area-chart.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/charts/pack/pack.css HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/css3-mediaqueries/css3-mediaqueries.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/jquery/jquery-1.7.1.min.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/tinysort/jquery.tinysort.min.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/mustache/mustache.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/backbone/backbone-min.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/underscore/underscore-min.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/lib/D3-v2.8.1/d3.v2.min.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/util/bigdesk_extension.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/Hello.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/cluster/IndicesStatus.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/cluster/ClusterHealth.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/cluster/ClusterState.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/cluster/NodesState.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/cluster/NodesStats.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/models/cluster/NodeInfo.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/views/templates.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/views/ClusterHealthView.js HTTP/1.1" 200 -
192.168.181.231 - - "GET /js/views/ClusterNodesListView.js HTTP/1.1" 200 - 至此安装完成,见下图
https://s5.运维网.com/wyfs02/M02/97/71/wKiom1kud9SieZn1AAHAYW5YyY4816.png
页:
[1]