EKL安装
-
es安装–打开
-
es-head安装–打开
-
kibana安装–打开
es安装
- 解压:tar -zxf elasticsearch-6.2.2.tar.gz
- mv elasticsearch-6.2.2 es
- 增加用户:useradd es
- passwd es
- 把es目录及其内容修改为es用户和所属的组:chown es:es -R es
- cd es
- 修改:vi config/elasticsearch.yml
- 最后添加
http.cors.enabled: true
http.cors.allow-origin: “*”
cluster.name: elk
node.name: boss
node.master: true
network.host: 192.168.236.9
discovery.zen.ping.unicast.hosts: [“hadoop9”] - 修改:vi /etc/sysctl.conf
- 最后添加vm.max_map_count=655360
- sysctl -p使它生效
- 修改:vi /etc/security/limits.conf进入后最后添加
- soft nofile 65536
- hard nofile 65536
- soft nproc 4096
- hard nproc 4096
su es
启动es:bin/elasticsearch(es目录下)
后台启动:bin/elasticsearch -d(es目录下)
(注意:jdk必须放在非root里,否则需要给root加权限555)
- 浏览器输入:http://192.168.236.9:9200/ 看结果:
head-master安装配置
- 解压head和node,改名字为head和node
- mv掉两个压缩包
- 配置node环境变量:vi /etc/profile
export NODE_HOME=/opt/software/node8
export PATH= P A T H : PATH: PATH:NODE_HOME/bin - source /etc/profile
- 在head-master安装目录下修改Gruntfile.js里的port: 9100下面添加hostname: ‘*’,
- 修改_site/app.js,第4360行把localhost改成ip:192.163.236.9
- 执行npm install -g grunt-cli 安装grunt
- 执行npm config set registry https://registry.npm.taobao.org
- 执行npm get registry
- 执行npm install初始化配置
- npm install phantomjs-prebuilt@2.1.4 --ignore-scripts
- npm run start启动head-master
- nohup npm run start & 后台启动
kibana的安装
- 直接安装:tar -zxf kibana-6.2.2-linux-x86_64.tar.gz
- 改名字:mv kibana-6.2.2-linux-x86_64 kibana
-
修改:vi kibana/config/kibana.yml
在最下面添加:
server.host: “192.168.236.11”
elasticsearch.url: “http://192.168.236.11:9200”
启动:kibana/bin/kibana
后台启动:nohup kibana/bin/kibana &
进程查看与关闭
jps查看
ps -aux | grep xxx:查看
ps -ef | grep xxx:查看
关闭进程:kill +进程的PID(上面两个ps可以查看PID)
非关系型数据???
5. linux添加数据:(好处-批量处理数据(取决于json文件的大小))
curl -H “Content-type: application/json” -X PUT http://192.168.236.9:9200/usr/student/2 -d ‘{“id”:2,“name”:“wangwu”,“age”:21,“classname”:“da”,“gender”:“nan”}’
25. head-master(处理数据)
- kibana(处理数据)
linux命令操作(KIBANA)
curl:利用URL语法在命令行方式下工作的开源文件传输工具,使用curl可以简单实现常见的get、post请求。在centOS的默认库里有curl工具,如果没有请yum安装即可;
-x:指定http的请求方法,有HEAD GET PUT POST DELETE
-d:指定要传输的数据(插入的数据)
-H:指定http请求头信息
创建:curl -XPUT http://192.168.236.11:9200/student/?pretty(不用加?pretty,表示格式化)
增:
curl -H “Content-Type: application/json” -X PUT http://192.168.236.11:9200/usr/stu/9 -d’{“name”:“lcs”,“age”:29}’
删:
删除索引:curl -XDELETE http://192.168.236.11:9200/student
删除一行数据:curl -XDELETE http://192.168.236.11:9200/sur/stu/1
改:
curl -H “Content-Type: application/json” -X PUT http://192.168.236.11:9200/usr/stu/1 -d ‘{“name”:“zhaoqian”,“age”:20,“gender”:“femal”}’
查:(查找_id=1的原始数据:包括_index,_type,_id等等数据)
例1:curl -XGET http://192.168.236.11:9200/usr/stu/1
结果:{"_index":“usr”,"_type":“stu”,"_id":“5”,"_version":1,“found”:true,"_source":{“name”:“James”,“age”:35}}
例2:curl -XGET http://192.168.236.11:9200/usr/stu/_search(表示遍历输出)
例3:curl -XGET http://192.168.236.11:9200/usr/stu/_search?q=name:zhao(按字段内容查找)
注意:{}两侧有单引号
查询结果说明:
{
"took": 2,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 0.47000363,
"hits": [
{
"_index": "usr",
"_type": "stu",
"_id": "2",
"_score": 0.47000363,
"_source": {
"name": "zhao",
"age": 13
}
},
{
"_index": "usr",
"_type": "stu",
"_id": "4",
"_score": 0.47000363,
"_source": {
"name": "zhao"
}
},
{
"_index": "usr",
"_type": "stu",
"_id": "3",
"_score": 0.2876821,
"_source": {
"name": "zhao",
"age": 12,
"gender": "man"
}
}
]
说明:
took:耗时几毫秒
time_out:是否超时
shards里的total:查询的分片数
shards里的successful:成功的数目
hits里的total:查询到的数目
hits里的max_score:最高评分
批量插入:
curl -H “Content-Type: application/json” -X PUT http://192.168.236.11:9200/_bulk --data-binary @/opt/software/request.json
增:put /索引/类型/id
{
“列名”:值,
“列名2”:值2
}
删:delete /索引 或者/索引/类型/id
改:post(不用put)/索引/类型/id
{
“doc”:{
“列名”:值
}
}
查
GET /索引 查出结果是原始数据
GET /索引/类型/id 查询结果是id对应的数据
GET /索引/类型/_search 遍历所有id对应的数据
GET /索引/类型/_search?q=name:“aaa”
批量
PUT /_bulk --data-binary @文件路径
curl -H “Content-type: application/json” -X PUT http://192.168.236.9:9200/-bulk --data-binary @/opt/software/request.json