单机多实例elasticsearch部署
2020-01-15 08:06
323 查看
单机多实例的源由
一般es的对内存的最大支持最高32G,原因是jvm在内存小于32G的时候会采用一个内存对象指针压缩技术,如果大于32G的话,不仅仅是浪费内存,还会使CPU的性能降低。但是我们的服务器不可能只有这么一点内存的,这时候我们可以部署单机多实例的es集群,充分利用剩余的内存。
部署前的准备
1.安装java和设置Java变量环境 (java安装包:jdk-8u144-linux-x64.tar.gz) 添加全局变量:/etc/profile export JAVA_HOME=/usr/local/jdk1.8.0_144 export JRE_HOME=$JAVA_HOME/jre export CLASSPATH=.:$CLASSPATH:$JAVA_HOME/lib:$JRE_HOME/lib export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin 2,调整用户最大创建文件数 /etc/sysctl.conf 默认:65530 永久设置:vm.max_map_count = 655360/262144 临时设置:sudo sysctl -w vm.max_map_count=262144/655360 sysctl -p使设置生效 3.添加以下内容到 /etc/security/limits.conf * soft nofile 65536 * hard nofile 65536 * soft nproc 4096 * hard nproc 4096 备注:* 代表Linux所有用户名称(比如 hadoop),后面设置的nproc实际上设置多线程,以防止再报用户最大可创建线程数太小的故障。 4.调整jvm内存参数 另外根据需要,可修改文件ElasticSearch目录下 config/jvm.options文件,调整jvm内存参数。 # Xms represents the initial size of total heap space # Xmx represents the maximum size of total heap space -Xms1g -Xmx1g 默认1g,可根据情况修改成-Xms2g之类。
本次部署需要的软件包
elasticsearch-6.3.1.tar.gz kibana-6.3.1-linux-x86_64.tar.gz logstash-6.3.1.zip 下载地址为: https://www.elastic.co/cn/downloads/past-releases/elasticsearch-6-3-1 https://www.elastic.co/cn/downloads/past-releases/kibana-6-3-1 https://www.elastic.co/cn/downloads/past-releases/logstash-6-3-1
es配置:
-
创建普通用户,并将压缩包权限更改为普通用户权限
-
/config/elasticsearch.yml配置文件更改,其余的实例配置相似
这些参数需要调整: cluster.name: 集群名 node.name: 节点名(不可相同) path.data: 数据存放目录 path.logs: 日志存放目录 network.host: 监听的主机地址 http.port: web端监听端口 transport.tcp.port: 内部通信监听端口 node.max_local_storage_nodes: 这个配置限制了单节点上可以开启的ES存储实例的个数,我们需要开多个实例,因此需要把这个配置写到配置文件中,并为这个配置赋值为2或者更高 discovery.zen.ping.unicast.hosts: 候选主节点地址 附加:elastic-head http.enabled: true #使用http协议对外提供服务 http.cors.enabled: true #允许head插件访问es http.cors.allow-origin: "*"
3.
启动实例:
后台运行elasticsearch还可以切换到es用户之后,在elasticsearch/bin目录下执行: nohup ./elasticsearch >> /home/es/elasticsearch-6.1.3/output.log 2>&1 & 输出日志倒是可有可无,因为elasticsearch本就有log记录。也可以直接: nohup ./elasticsearch & 或者: 通过后台启动并且指定pid文件 $ ./bin/elasticsearch -p /home/es/pid1/elasticsearch1-pid -d 找到pid号通过kill命令停止 $ cat /home/es/pid1/elasticsearch1-pid && echo 15516 $ kill -SIGTERM 15516 或 kill -9 15516
4.
查看节点信息:
http://IP_ADDRESS:9200/_cat/nodes?v
5.
查看启动成功与否:
http://IP_ADDRESS:9200
kibana的配置:
1.
kibana.yml配置文件更改
vim /home/es/kibana/config/kibana.yml server.port: 5601 server.host: "~~192.166.79.156~~ " elasticsearch.url: "http://~~192.166.79.156~~ :9202"
2.
kibana后台启动:
nohup /home/es/kibana/bin/kibana & 或者 /home/es/kibana/bin/kibana & 等待一会后,加载出status信息,接着输入“exit”回车,shell界面关闭
logstash配置:
cd /home/es/logstash-6.3.1/config vim logstash.conf
提示:官网提供的模板:
input { stdin { } } output { stdout { codec=> rubydebug } }
自行更改后:
input { file { type => "loges01" path => "/home/es/es1/logs/*.log" start_position => "beginning" } } input { file { type => "loges02" path => "/home/es/es2/logs/*.log" start_position => "beginning" } } input { file { type => "loges03" path => "/home/es/es3/logs/*.log" start_position => "beginning" } } input { file { type => "loges04" path => "/home/es/es4/logs/*.log" } ##-------------------------------------------------### output { stdout { codec => rubydebug { } } if[type]=='loges01'{ elasticsearch { hosts => "172.19.79.156" index => "loges01-%{+YYYY.MM.dd}" } } if[type]=='loges02'{ elasticsearch { hosts => "172.19.79.156" index => "loges02-%{+YYYY.MM.dd}" } } if[type]=='loges03'{ elasticsearch { hosts => "172.19.79.156" index => "loges03-%{+YYYY.MM.dd}" } } if[type]=='loges04'{ elasticsearch { hosts => "172.19.79.156" index => "loges04-%{+YYYY.MM.dd}" } } } }
注释:
上面是input(输入),下面是output(输出)。
logstash启动:
nohup ./logstash -f ../config/logstash.conf 停止的话,和上面基本一样
启动成功界面
kibana图形化添加index
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- ElasticSearch 单机部署多实例环境
- ElasticSearch单机多实例环境部署
- MySQL 使用mysqld multi部署单机多实例详细过程
- mysql使用mysqld_multi部署单机多实例的方法教程
- MYSQL的单机多实例部署
- MySQL 使用mysqld_multi部署单机多实例详细过程
- MySQL 使用mysqld_multi部署单机多实例详细过程
- Mysql 数据库单机多实例部署手记
- MySQL单机多实例部署详解之------利用mysqld_multi配置实现
- MySQL单机多实例部署详解之------多实例分别定义不同的配置文件
- zookeeper单机多实例和分布式部署
- ElasticSearch, Kibana, and Fluentd 的简单部署实例
- Elasticsearch单机下多实例配置
- elasticsearch 单机部署,脱离集群
- MySQL 使用mysqld_multi部署单机多实例详细过程 (转)
- Mysql 数据库单机多实例部署手记
- Postgres-XC集群部署实例(单机调试)
- nutch2.1+mysql+elasticsearch整合linux单机部署
- ElasticSearch 单机多实例启动卡死
- ElasticSearch单机双实例的配置方法