文章目录
- 一、安装Error汇总
- 1. 由于Elasticsearch可以输入且执行脚本,为了系统安全,不允许使用root启动
- 2. 外部无法访问
- 3. 解决 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
- 4. sysctl: setting key "vm.max_map_count": Read-only file system
- 5. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
- 二、kibana使用案例
一、安装Error汇总
1. 由于Elasticsearch可以输入且执行脚本,为了系统安全,不允许使用root启动
useradd -m work
su work
2. 外部无法访问
vim elasticsearch.yml
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
#network.host: 192.168.0.1
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
3. 解决 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
// 修改下面的文件 里面是一些内核参数
vi /etc/sysctl.conf
//添加以下配置
vm.max_map_count=655360
保存,然后:
sysctl -p
//-p 从指定的文件加载系统参数,如不指定即从/etc/sysctl.conf中加载
会提示错误:
4. sysctl: setting key “vm.max_map_count”: Read-only file system
这是因为Docker的base image做的很精简,甚至都没有init进程,原本在OS启动时执行生效系统变量的过程(sysctl -p)也给省略了,导致这些系统变量依旧保留着kernel默认值,这时候需要我们在容器启动时加入 –privileged 来获取修改系统参数的权限
这里我选择的是修改宿主机本身的配置文件,然后重新启动镜像,也能解决问题,退出容器,返回到宿主机
修改vm.max_map_count 可以通过命令行修改,但是在机器重启时会失效,所以通过修改配置文件来解决问题
命令行修改办法:
sudo sysctl -w vm.max_map_count=655360
5. the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
elasticsearch.yml文件
node.name: node-1 前面的#打开
cluster.initial_master_nodes: ["node-1"] 这里一定要这样设置,我就是这里没有这样设置出问题的,弄了好久
二、kibana使用案例
1. 数据集
- William Shakespeare的全部作品,适当地解析成字段,下载
shakespeare.json
数据结构:
{
"line_id": INT,
"play_name": "String",
"speech_number": INT,
"line_number": "String",
"speaker": "String",
"text_entry": "String",
}
2. 设置映射
在Kibana Dev Tools > Console,为Shakespeare数据集设置映射:
PUT /shakespeare
{
"mappings": {
"properties": {
"doc": {
"properties": {
"speaker": {
"type": "keyword"
},
"play_name": {
"type": "keyword"
},
"line_id": {
"type": "integer"
},
"speech_number": {
"type": "integer"
}
}
}
}
}
}
3. 加载数据集
curl -H 'Content-Type: application/x-ndjson' -XPOST '49.52.10.203:9200/shakespeare/doc/_bulk?pretty' --data-binary @shakespeare_6.0.json
验证加载成功:
GET /_cat/indices?v
4. 定义索引模式
Error: FAILED TO PARSE MAPPING [_DOC]: ROOT MAPPING DEFINITION HAS UNSUPPORTED PARAMETERS
With Elastic search 7.0 , types were removed and when creating a mapping it no longer accepts types which is a breaking change
PUT /shakespeare
{
"mappings": {
"properties": {
"doc": {
"properties": {
"speaker": {
"type": "keyword"
},
"play_name": {
"type": "keyword"
},
"line_id": {
"type": "integer"
},
"speech_number": {
"type": "integer"
}
}
}
}
}
}