Elastic search系统学习之三:设置elasticsearch
来源:互联网 发布:java单选框值的获取 编辑:程序博客网 时间:2024/05/22 15:02
系统: ubutnu
一、安装elastic search
1、下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.4.zipsha1sum elasticsearch-5.6.4.zip unzip elasticsearch-5.6.4.zipcd elasticsearch-5.6.4、
2、运行
./bin/elasticsearch
3、状态检验
http://localhost:9200/
curl -XGET 'localhost:9200/?pretty'
或
kibana中: GET /
4、作为守护进程运行
./bin/elasticsearch -d -p pid
-d: 守护进程
-p: 指定存储进程id的文件pid
日志: $ES_HOME/logs/
终止进程:
kill `cat pid`
5、配置
home
Elasticsearch home directory or $ES_HOME
Directory created by unpacking the archive
bin
Binary scripts including elasticsearch
to start a node and elasticsearch-plugin
to install plugins
$ES_HOME/bin
conf
Configuration files including elasticsearch.yml
$ES_HOME/config
path.conf
data
The location of the data files of each index / shard allocated on the node. Can hold multiple locations.
$ES_HOME/data
path.data
logs
Log files location.
$ES_HOME/logs
path.logs
plugins
Plugin files location. Each plugin will be contained in a subdirectory.
$ES_HOME/plugins
repo
Shared file system repository locations. Can hold multiple locations. A file system repository can be placed in to any subdirectory of any directory specified here.
Not configured
path.repo
script
Location of script files.
$ES_HOME/scripts
path.scripts
步骤一:下载
https://www.elastic.co/cn/downloads/kibana
步骤二:解压
步骤三:修改配置
config/kibana.yml
elasticsearch.url 指向es的实例,默认是9200端口
步骤四:运行
bin\kibana.bat
二、配置elasticsearch
1、config 文件位置
config包含文件: elasticsearch.yml配置elasticsearh
log4j2.properties配置日志
默认: $ES_HOME/config
./bin/elasticsearch -Epath.conf=/path/to/my/config/
2、config文件格式
path: data: /var/lib/elasticsearch logs: /var/log/elasticsearch
或
path.data: /var/lib/elasticsearchpath.logs: /var/log/elasticsearch
3、环境变量替换
node.name: ${HOSTNAME}network.host: ${ES_NETWORK_HOST}
如果配置的环境变量,config/elasticsearch.yml中的配置会被替换
4、快速配置
config/elasticsearch.yml中配置
node: name: ${prompt.text}
启动es会让输入:
Enter value for [node.name]:
5、日志配置
1> 路径配置
path.logs
: 在elasticsearch.yml配置,默认为$ES_HOME/logs
config/log4j2.properties
${sys:es.logs.base_path}: ${path.logs}
${sys:es.logs.cluster_name}: 集群名称
${sys:es.logs.node_name}: 节点名称
2> 日志级别
通过命令行配置: -E -E <name of logging hierarchy>=<level>
(e.g., -E logger.org.elasticsearch.transport=trace
).
elasticsearch.yml配置: <name of logging hierarchy>: <level>
(e.g., logger.org.elasticsearch.transport: trace
).
通过集群配置:
PUT /_cluster/settings{ "transient": { "<name of logging hierarchy>": "<level>" }}
例如:
PUT /_cluster/settings{ "transient": { "logger.org.elasticsearch.transport": "trace" }}或curl -XPUT 'localhost:9200/_cluster/settings?pretty' -H 'Content-Type: application/json' -d'{ "transient": { "logger.org.elasticsearch.transport": "trace" }}'
通过log4j2.properties配置
logger.<unique_identifier>.name = <name of logging hierarchy>logger.<unique_identifier>.level = <level>
例如
logger.transport.name = org.elasticsearch.transportlogger.transport.level = trace
3> 禁止日志级别
logger.deprecation.level = warn
在elasticsearch.yml中配置
6、重要配置 elasticsearch.yml
path.data 和 path.logs:
默认是$ES_HOME的子目录
path.data可以设置为多个目录
path: data: - /mnt/elasticsearch_1 - /mnt/elasticsearch_2 - /mnt/elasticsearch_3
cluster.name:
bootstrap.memory_lock: 禁止jvm与磁盘交换,这样会严重影响es的性能
network.host: 单节点不需要配置,多节点需要配置
discovery.zen.ping.unicast.hosts: 有其他机器上的节点时候,需要配置其他节点所在机器ip或者域名
discovery.zen.ping.unicast.hosts: - 192.168.1.10:9300 - 192.168.1.11 - seeds.mydomain.com
discovery.zen.minimum_master_nodes:
防止脑裂,集群中有多少个master节点才能成为一个集群
7、安全配置
创建存储key的文件
bin/elasticsearch-keystore create
列出key文件的所有配置
bin/elasticsearch-keystore list
添加配置
方法一: bin/elasticsearch-keystore add the.setting.name.to.set方法二:cat /file/containing/setting/value | bin/elasticsearch-keystore add / --stdin the.setting.name.to.set
删除配置
bin/elasticsearch-keystore remove the.setting.name.to.set
8、启动程序检测
目的:避免一些重要配置没有配置,开发模式提示warning,生产环境提示error
path.data
andpath.logs
cluster.name
node.name
bootstrap.memory_lock
network.host
discovery.zen.ping.unicast.hosts
discovery.zen.minimum_master_nodes
- JVM heap dump path
es默认绑定localhost(http and transport)
生产模式
如果绑定外部接口,默认是开发模式,该模式下会进行启动检测
单例模式: discovery.type: single-node
transport可以绑定外部接口
可以正常启动,不会进行启动程序检测
强制启动检查: es.enforce.bootstrap.checks=true
设置系统变量
-Des.enforce.bootstrap.checks=true
例如:
export ES_JAVA_OPTS="$ES_JAVA_OPTS -Des.enforce.bootstrap.checks=true"./bin/elasticsearch
1> 堆大小检测
默认情况下,es最大最小内存都是1g,生产环境需要配置
例如:
ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch
或配置到config/jvm.options
-Xms2g
-Xmx2g
原则:
xms=xmx
xmx不大于50%机器内存
2> 文件描述检测
macOS: -XX:MaxFDLimit
linux系统:
命令设置: $ulimit -n 65536
检测该值:
GET _nodes/stats/process?filter_path=**.max_file_descriptors
或
curl -XGET 'localhost:9200/_nodes/stats/process?filter_path=**.max_file_descriptors&pretty'
3> 内存锁检测[设置失败------后续再研究-]
原因: 大多系统都尽量使用内存缓存,并将不用的应用内存置换出去;内存置换影响性能、节点稳定和垃圾回收延长。
关闭页交换[linux]
方法一: 临时关闭sudo swapoff -a
方法二:/etc/fstab文件中包含swap的行全注释掉
方法三:配置虚拟运存控制
查看swappiness配置: # cat /proc/sys/vm/swappiness
修改swappiness: /etc/sysctl.conf 中配置vm.swappiness=1
sysctl vm.swappiness=1:
方法四:设置内存锁
config/elasticsearch.yml中设置:
bootstrap.memory_lock: true
验证配置是否成功:
GET _nodes?filter_path=**.mlockall
或
curl -XGET 'localhost:9200/_nodes?filter_path=**.mlockall&pretty'
mlockall=true表示设置成功
4> 不成功原因:
权限问题
/tmp目录拥有noexec选项去挂载的
文档描述符数设置的权限问题:
方法一:命令配置
启动elastic Search前,运行命令:
$ulimit -l unlimited
或
sudo su ulimit -n 65536 su elasticsearch
方法二:系统配置文件配置
/etc/security/limits.conf中加入:
elasticsearch - nofile 65536
ubuntu注意:
默认是init.d启动的进程不识别limits.conf,需要编辑/etc/pam.d/su,添加一行:
# session required pam_limits.so
方法三: 系统命令配置
用RPM或deban包安装
/usr/lib/systemd/system/elasticsearch.service 含有limit的配置
$sudo systemctl edit elasticsearch 自动打开配置文件
填入:
[Service]LimitMEMLOCK=infinity
$sudo systemctl daemon-reload
临时目录问题:
方法一:通过配置文件jvm.options
config/jvm.options //tar or zip安装
/etc/elasticsearch/jvm.options //rpm包或debian包安装
方法二:命令行
export ES_JAVA_OPTS="$ES_JAVA_OPTS -Djava.io.tmpdir=/path/to/temp/dir"./bin/elasticsearch
5> 最大线程数
配置文件:/etc/security/limits.conf
lxq - nproc 1024
root - nproc 1024
6> 最大虚拟内存
配置文件:/etc/security/limits.conf
lxq - as unlimited
root - as unlimited
7> 最大文件大小
配置文件:/etc/security/limits.conf
lxq - fsize unlimited
root - fsize unlimited
8> 最大映射数数得大于: 262144
设置:
echo 'vm.max_map_count=655360' >> /etc/sysctl.conf
查看
9> 客户jvm
jdk有两种: client JVM 和 server JVM.
Elasticsearch默认强制使用server JVM
现在系统和操作系统中,默认都是采用server JVM
10> 串行垃圾收集器
jvm不能使用串行垃圾收集器,会严重影响elastic search性能, es默认会启动不了。
jvm默认不采用串行收集器,除非采用-XX:+UseSerialGC启动elasticsearch
11> 系统调用过滤器
保证开启
12> 错误和内存溢出
OnError和OutOfMemoryError 关闭
seccomp
13> Early-access check 暂时不研究
14> G1GC check 暂时不研究
- Elastic search系统学习之三:设置elasticsearch
- Elastic search系统学习之二: 插件安装
- Elastic search 系统学习之四: 文档API
- Elastic Search系统学习之一: 入门
- Elastic Search 学习概要
- ELASTIC SEARCH学习笔记
- elastic search学习
- Elastic Search学习总结
- Elastic Search 设置默认analyzer
- elastic search
- Elastic Search初识之吐槽
- elasticsearch之Search API
- [ElasticSearch]Search之分页
- elastic search sql 按字段设置分词器
- 三、ElasticSearch常用设置
- [elastic search](2-1)深入搜索之结构化搜索
- elasticsearch---search in depth之struct search
- elasticsearch之query-----执行Search
- Error:This Gradle plugin requires Studio 3.0 minimum解决办法
- mac上查看android手机文件 --HandShaker
- Volley 请求返回数据中文出现乱码
- SpringMVC项目中使用 spring security时<async-supported>报错
- intellij idea svn报错:xxx is not a working copy directory
- Elastic search系统学习之三:设置elasticsearch
- js返回顶部
- 通过Redisson实现基于redis的分布式锁
- Python判断文件和文件夹是否存在的方法
- sklear_ELASTIC_regression
- C#使用NIDAQmx采集电压
- 2017.11.14笔记
- kotlin学习3遍历jsonArray以及页面跳转
- springboot多配置文件,多个application