如果您想了解centeros7安装elasticSeartch和centos8安装elasticsearch的知识,那么本篇文章将是您的不二之选。我们将深入剖析centeros7安装elasticSe
如果您想了解center os 7 安装 elasticSeartch和centos8安装elasticsearch的知识,那么本篇文章将是您的不二之选。我们将深入剖析center os 7 安装 elasticSeartch的各个方面,并为您解答centos8安装elasticsearch的疑在这篇文章中,我们将为您介绍center os 7 安装 elasticSeartch的相关知识,同时也会详细的解释centos8安装elasticsearch的运用方法,并给出实际的案例分析,希望能帮助到您!
本文目录一览:- center os 7 安装 elasticSeartch(centos8安装elasticsearch)
- CentOS 5.6 安装 Elasticsearch 5.0
- centos 6.5 elasticsearch 5.1 安装
- CentOS 6.7 安装ElasticSearch2.0.0
- Centos 6.7 安装ElasticSearch2.3.3
center os 7 安装 elasticSeartch(centos8安装elasticsearch)
Centos7下安装配置elasticsearch 6.3.1
1)下载
Elasticsearch 6.3.1 地址:https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.3.1.tar.gz
2)拷贝
拷贝到服务器上,解压:tar -xvzf elasticsearch-6.3.1.tar.gz 。解压后路径:/home/elasticsearch-6.3.1
3)创建用户
创建用户,创建esdata目录,并赋予权限
[root@bogon home]# adduser esuser
[root@bogon home]# cd /home
[root@bogon home]# mkdir -p esdata/data
[root@bogon home]# mkdir -p esdata/log
[root@bogon home]# chown -R esuser elasticsearch-6.3.1
[root@bogon home]# chown -R esuser esdata
4)配置es


[root@bogon esdata]# cat /home/elasticsearch-6.3.1/config/elasticsearch.yml
# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
# Before you set out to tweak and tune the configuration, make sure you
# understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
cluster.name: my-application
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# Add custom attributes to the node:
#
node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /home/esdata/data
#
# Path to log files:
#
path.logs: /home/esdata/log
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when new node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
discovery.zen.ping.unicast.hosts: ["host1", "host2"]
#
# Prevent the "split brain" by configuring the majority of nodes (total number of master-eligible nodes / 2 + 1):
#
#discovery.zen.minimum_master_nodes:
#
# For more information, consult the zen discovery module documentation.
#
# ---------------------------------- Gateway -----------------------------------
#
# Block initial recovery after a full cluster restart until N nodes are started:
#
gateway.recover_after_nodes: 3
#
# For more information, consult the gateway module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
action.destructive_requires_name: true

5)配置系统
[root@bogon bin]# vim /etc/security/limits.conf(在文件最后添加)
esuser hard nofile 65536
esuser soft nofile 65536
esuser soft memlock unlimited
esuser hard memlock unlimited
以上配置解决问题:
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
memory locking requested for elasticsearch process but memory is not locked
[root@bogon bin]# sysctl -w vm.max_map_count=262144
vm.max_map_count = 262144
[root@bogon bin]# more /proc/sys/vm/max_map_count
262144
以上配置解决问题:
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[root@bogon logs]# visudo
。。。。。。。。
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
esuser ALL=(ALL) ALL
。。。。。。。。
以上配置解决某些情况下无法读写的问题
6)启动

[root@bogon ~]# cd /home/elasticsearch-6.3.1/bin/
[root@bogon bin]# su esuser
[esuser@bogon bin]$ ./elasticsearch
[2018-07-17T10:17:30,139][INFO ][o.e.n.Node ] [node-1] initializing ...
[2018-07-17T10:17:30,234][INFO ][o.e.e.NodeEnvironment ] [node-1] using [1] data paths, mounts [[/ (rootfs)]], net usable_space [22.1gb], net total_space [27.6gb], types [rootfs]
[2018-07-17T10:17:30,234][INFO ][o.e.e.NodeEnvironment ] [node-1] heap size [1007.3mb], compressed ordinary object pointers [true]
[2018-07-17T10:17:30,236][INFO ][o.e.n.Node ] [node-1] node name [node-1], node ID [cb69e4JjSBKeHJ9y-q-hNA]
[2018-07-17T10:17:30,236][INFO ][o.e.n.Node ] [node-1] version[6.3.1], pid[26327], build[default/tar/eb782d0/2018-06-29T21:59:26.107521Z], OS[Linux/3.10.0-514.6.1.el7.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_92/25.92-b14]
[2018-07-17T10:17:30,236][INFO ][o.e.n.Node ] [node-1] JVM arguments [-Xms1g, -Xmx1g, -XX:+UseConcMarkSweepGC, -XX:CMSInitiatingOccupancyFraction=75, -XX:+UseCMSInitiatingOccupancyOnly, -XX:+AlwaysPreTouch, -Xss1m, -Djava.awt.headless=true, -Dfile.encoding=UTF-8, -Djna.nosys=true, -XX:-OmitStackTraceInFastThrow, -Dio.netty.noUnsafe=true, -Dio.netty.noKeySetOptimization=true, -Dio.netty.recycler.maxCapacityPerThread=0, -Dlog4j.shutdownHookEnabled=false, -Dlog4j2.disable.jmx=true, -Djava.io.tmpdir=/tmp/elasticsearch.F1Jh0AOB, -XX:+HeapDumpOnOutOfMemoryError, -XX:HeapDumpPath=data, -XX:ErrorFile=logs/hs_err_pid%p.log, -XX:+PrintGCDetails, -XX:+PrintGCDateStamps, -XX:+PrintTenuringDistribution, -XX:+PrintGCApplicationStoppedTime, -Xloggc:logs/gc.log, -XX:+UseGCLogFileRotation, -XX:NumberOfGCLogFiles=32, -XX:GCLogFileSize=64m, -Des.path.home=/home/elasticsearch-6.3.1, -Des.path.conf=/home/elasticsearch-6.3.1/config, -Des.distribution.flavor=default, -Des.distribution.type=tar]
[2018-07-17T10:17:33,136][INFO ][o.e.p.PluginsService ] [node-1] loaded module [aggs-matrix-stats]
[2018-07-17T10:17:33,136][INFO ][o.e.p.PluginsService ] [node-1] loaded module [analysis-common]
[2018-07-17T10:17:33,137][INFO ][o.e.p.PluginsService ] [node-1] loaded module [ingest-common]
。。。。。。

7)验证
浏览器访问:http://192.168.20.115:9200/ (192.168.20.115是es服务器的IP,另外请确保9200端口能够被外部访问),返回:

{
"name" : "node-1",
"cluster_name" : "my-application",
"cluster_uuid" : "_na_",
"version" : {
"number" : "6.3.1",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "eb782d0",
"build_date" : "2018-06-29T21:59:26.107521Z",
"build_snapshot" : false,
"lucene_version" : "7.3.1",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

当然最方便的安装方法还是下载docker镜像,官方安装手册:https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html 步骤:
1)下载镜像:docker pull docker.elastic.co/elasticsearch/elasticsearch:6.3.1
2)运行容器:docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:6.3.1
ElasticSearch Head安装
官方的模拟工具是控制台的curl,不是很直观,可以在chrome浏览器中安装head插件来作为请求的工具:head插件的地址:https://chrome.google.com/webstore/detail/elasticsearch-head/ffmkiejjmecolpfloofpjologoblkegm/


CentOS 5.6 安装 Elasticsearch 5.0
0. 操作系统:CentOS release 5.6 i686 athlon i386 GNU/Linux
1. 安装 java jdk1.8 (参考:Centos 6.5 安装java及设置默认jdk版本)
2. 下载安装包:elasticsearch-5.0.0.tar.zip
注:此为虚拟机测试,以下系统资源配置会较低。
解压文件
# tar zxvf elasticsearch-5.0.0.tar.gz # mv elasticsearch-5.0.0 /usr/local/elasticsearch # mkdir -p /usr/local/elasticsearch/{data,logs}
配置 es 参数文件 (Important Elasticsearch configuration)
# vi /usr/local/elasticsearch/config/elasticsearch.yml # 注意冒号后有空格 http.port: 9200 node.name: node-1 cluster.name: es_cluster network.host: 192.168.1.222 bootstrap.memory_lock: false path.data: /usr/local/elasticsearch/data path.logs: /usr/local/elasticsearch/logs
配置足够内存 (Set JVM heap size via jvm.options)
# vi /usr/local/elasticsearch/config/jvm.options -xms512M -Xmx512M
配置环境变量
# vi /etc/profile export ES_HOME=/usr/local/elasticsearch # source /etc/profile
添加独立用户,并启动服务
# groupadd elsearch # useradd elsearch -g elsearch # chown -R elsearch:elsearch /usr/local/elasticsearch # su elsearch # cd /usr/local/elasticsearch/bin # ./elasticsearch
可能错误(一)
ERROR: bootstrap checks Failed max file descriptors [4096] for elasticsearch process likely too low,increase to at least [65536] max number of threads [1024] for user [elsearch] likely too low,increase to at least [2048] max virtual memory areas vm.max_map_count [65530] likely too low,increase to at least [262144] 解决:修改配置 # https://www.elastic.co/guide/en/elasticsearch/reference/master/setting-system-settings.html # vi /etc/security/limits.conf #永久设置 elsearch soft nofile 65536 elsearch hard nofile 65536 elsearch soft nproc 2048 elsearch hard nproc 2048 # ulimit -n 65536 #临时设置,重启无效 # ulimit -u 2048 # ulimit -a # vi /etc/sysctl.conf #永久设置 vm.max_map_count=262144 # sysctl -w vm.max_map_count=262144 #临时设置,重启无效 # sysctl -a | grep "vm.max_map_count"
可能错误(二)
Java HotSpot(TM) Server VM warning: INFO: os::commit_memory(0xcc000000,469762048,0) Failed; error='Cannot allocate memory' (errno=12) # # There is insufficient memory for the Java Runtime Environment to continue. # Native memory allocation (mmap) Failed to map 469762048 bytes for committing reserved memory. # An error report file with more information is saved as: # /usr/local/elasticsearch/bin/hs_err_pid7598.log 解决:修改足够的内存 # vi /usr/local/elasticsearch/config/jvm.options -xms512M -Xmx512M # vi /usr/local/elasticsearch/bin/elasticsearch # ES_JAVA_OPTS="-xms512m -Xmx512m" $ES_HOME/bin/elasticsearch
正常启动服务状态
[2017-01-07T12:18:21,508][INFO ][o.e.n.Node ] [node-1] initializing ... [2017-01-07T12:18:21,814][INFO ][o.e.e.nodeenvironment ] [node-1] using [1] data paths,mounts [[/ (/dev/sda2)]],net usable_space [11gb],net total_space [17.7gb],spins? [possibly],types [ext3] [2017-01-07T12:18:21,816][INFO ][o.e.e.nodeenvironment ] [node-1] heap size [505.6mb],compressed ordinary object pointers [unkNown] [2017-01-07T12:18:21,849][INFO ][o.e.n.Node ] [node-1] version[5.0.0],pid[16529],build[253032b/2016-10-26T04:37:51.531Z],OS[Linux/2.6.18-238.el5/i386],JVM[Oracle Corporation/Java HotSpot(TM) Server VM/1.8.0_111/25.111-b14] [2017-01-07T12:18:30,971][INFO ][o.e.p.PluginsService ] [node-1] loaded module [aggs-matrix-stats] [2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [ingest-common] [2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-expression] [2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-groovy] [2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-mustache] [2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-painless] [2017-01-07T12:18:30,972][INFO ][o.e.p.PluginsService ] [node-1] loaded module [percolator] [2017-01-07T12:18:30,974][INFO ][o.e.p.PluginsService ] [node-1] loaded module [reindex] [2017-01-07T12:18:30,974][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty3] [2017-01-07T12:18:30,975][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty4] [2017-01-07T12:18:30,976][INFO ][o.e.p.PluginsService ] [node-1] no plugins loaded [2017-01-07T12:18:55,728][INFO ][o.e.n.Node ] [node-1] initialized [2017-01-07T12:18:55,728][INFO ][o.e.n.Node ] [node-1] starting ... [2017-01-07T12:18:59,185][INFO ][o.e.t.TransportService ] [node-1] publish_address {192.168.1.222:9300},bound_addresses {192.168.1.222:9300} [2017-01-07T12:18:59,277][INFO ][o.e.b.BootstrapCheck ] [node-1] bound or publishing to a non-loopback or non-link-local address,enforcing bootstrap checks [2017-01-07T12:19:03,447][INFO ][o.e.c.s.ClusterService ] [node-1] new_master {node-1}{8x-utN34QFqJmeeIhrTGjA}{euJKK9YNSSueCM__ko6O8Q}{192.168.1.222}{192.168.1.222:9300},reason: zen-disco-elected-as-master ([0] nodes joined) [2017-01-07T12:19:03,636][INFO ][o.e.h.HttpServer ] [node-1] publish_address {192.168.1.222:9200},bound_addresses {192.168.1.222:9200} [2017-01-07T12:19:03,636][INFO ][o.e.n.Node ] [node-1] started [2017-01-07T12:19:03,637][INFO ][o.e.g.GatewayService ] [node-1] recovered [0] indices into cluster_state [2017-01-07T12:23:04,309][INFO ][o.e.m.j.JvmGcMonitorService] [node-1] [gc][young][248][9] duration [723ms],collections [1]/[1s],total [723ms]/[1.7s],memory [72.1mb]->[37mb]/[505.6mb],all_pools {[young] [51.2mb]->[172.8kb]/[51.2mb]}{[survivor] [6.3mb]->[4.7mb]/[6.3mb]}{[old] [14.4mb]->[32.3mb]/[448mb]} [2017-01-07T12:23:04,310][WARN ][o.e.m.j.JvmGcMonitorService] [node-1] [gc][248] overhead,spent [723ms] collecting in the last [1s]
浏览器打开网址:http://192.168.1.222:9200/ (出现当前集群节点信息)
{ "name" : "node-1","cluster_name" : "es_cluster","cluster_uuid" : "3DUO7WigT9m0pqMz-QlR4g","version" : { "number" : "5.0.0","build_hash" : "253032b","build_date" : "2016-10-26T04:37:51.531Z","build_snapshot" : false,"lucene_version" : "6.2.0" },"tagline" : "You KNow,for Search" }
参考:Installing Elasticsearch
Elasticsearch 权威指南(中文版)
centos 6.5 elasticsearch 5.1 安装
添加普通用户
useradd tommy
passwd tommy
[root@localhost home]# useradd tommy
[root@localhost home]# passwd tommy
Changing password for user tommy.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully.
赋予root权限
vi /etc/sudoers
添加 tommy ALL=(ALL) ALL
[root@localhost home]# chmod -w /etc/sudoers
[root@localhost home]# vi /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
tommy ALL=(ALL) ALL
安装jdk
安装elasticsearch
unzip elasticsearch-5.1.1.zip
[tommy@localhost ~]$ unzip elasticsearch-5.1.1.zip
配置
$ vi config/elasticsearch.yml
[tommy@localhost elasticsearch-5.1.1]$ vi config/elasticsearch.yml
打开network.host设置为当前ip
# ---------------------------------- Network -----------------------------------
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
network.host: 192.168.1.107
#
# Set a custom port for HTTP:
#
http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html>
#
启动
cd elasticsearch-5.1.1/bin/
./elasticsearch
[tommy@localhost ~]$ cd elasticsearch-5.1.1/bin/
[tommy@localhost bin]$ ./elasticsearch
遇到如下错误
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-mustache]
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService ] [node-1] loaded module [lang-painless]
[2016-12-31T10:04:16,012][INFO ][o.e.p.PluginsService ] [node-1] loaded module [percolator]
[2016-12-31T10:04:16,049][INFO ][o.e.p.PluginsService ] [node-1] loaded module [reindex]
[2016-12-31T10:04:16,050][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty3]
[2016-12-31T10:04:16,051][INFO ][o.e.p.PluginsService ] [node-1] loaded module [transport-netty4]
[2016-12-31T10:04:16,063][INFO ][o.e.p.PluginsService ] [node-1] no plugins loaded
[2016-12-31T10:04:31,693][INFO ][o.e.n.Node ] [node-1] initialized
[2016-12-31T10:04:31,696][INFO ][o.e.n.Node ] [node-1] starting ...
[2016-12-31T10:04:33,025][INFO ][o.e.t.TransportService ] [node-1] publish_address {192.168.1.107:9300}, bound_addresses {192.168.1.107:9300}
[2016-12-31T10:04:33,054][INFO ][o.e.b.BootstrapCheck ] [node-1] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks
ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max number of threads [1024] for user [tommy] is too low, increase to at least [2048]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2016-12-31T10:04:33,157][INFO ][o.e.n.Node ] [node-1] stopping ...
[2016-12-31T10:04:33,340][INFO ][o.e.n.Node ] [node-1] stopped
[2016-12-31T10:04:33,340][INFO ][o.e.n.Node ] [node-1] closing ...
[2016-12-31T10:04:33,454][INFO ][o.e.n.Node ] [node-1] closed
设置 max file descriptors (linux能够打开的最大文件句柄数)
在 /etc/security/limits.conf 文件最后添加
* hard nofile 65536
* soft nofile 65536
[root@localhost home]# echo ''* hard nofile 65536'' >> /etc/security/limits.conf
[root@localhost home]# echo ''* soft nofile 65536'' >> /etc/security/limits.conf
注意是 >> 千万不要少打一个 >
设置 max number of threads (linux允许每个用户的最大线程数)
修改 vi /etc/security/limits.d/90-nproc.conf
# Default limit for number of user''s processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 2048
root soft nproc unlimited
设置 vm.max_map_count (限制一个进程可以拥有的VMA(虚拟内存区域)的数量)
echo 262144 > /proc/sys/vm/max_map_count
sysctl -p
[root@localhost home]# echo 262144 > /proc/sys/vm/max_map_count
退出再次ssh到服务器启动elasticsearch
遇到如下错误
[tommy@localhost bin]$ ./elasticsearch
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x000000008a660000, 1973026816, 0) failed; error=''Cannot allocate memory'' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 1973026816 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /home/tommy/elasticsearch-5.1.1/bin/hs_err_pid24402.log
设置elasticsearch jvm配置
vi config/jvm.options (调整jvm参数)
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms1g
-Xmx1g
Caused by: java.lang.IllegalStateException: failed to obtain node locks, tried [[/home/tommy/elasticsearch-5.1.1/data/my-application]] with lock id [0]; maybe these locations are not writable or multiple nodes were started without increasing [node.max_local_storage_nodes] (was [1])?
在 elasticsearch-5.1.1/data/nodes/0 目录下有一个 node.lock
rm -rf node.lock 即可
以守护模式启动
$ bin/elasticsearch -d
./bin/elasticsearch -d -p pid
查看日志
tail -100f logs/xxx.log (节点名)
[tommy@localhost elasticsearch-5.1.1]$ tail -100f logs/elasticsearch.log
杀死进程
kill `cat pid`
测试连接
[tommy@localhost ~]$ curl -XGET ''192.168.1.107:9200''
{
"name" : "node-1",
"cluster_name" : "my-application",
"cluster_uuid" : "KMX4Y_skRByI3wYxvYCp5Q",
"version" : {
"number" : "5.1.1",
"build_hash" : "5395e21",
"build_date" : "2016-12-06T12:36:15.409Z",
"build_snapshot" : false,
"lucene_version" : "6.3.0"
},
"tagline" : "You Know, for Search"
}
CentOS 6.7 安装ElasticSearch2.0.0
“是不是所有的麻雀,都会在冬天里死去;是不是所有的人们都在金钱里丧失着良知;是不是只有穷苦的孩子才能唱出最美的歌;是不是只有漂泊的人们才懂得生活的苦涩。”——《涩》
1. jdk的安装配置
首先是要安装jdk的,
最初采用命令yum install java
安装的java并没有javac,其实我也并不清楚具体是哪些包,所以开启任性模式——反正我不管,就把1.7.0版本相关的全都装上吧……
yum list java* yun install java-1.7.0-openjdk*
然后需要设置一下JAVA_HOME环境变量,那么问题来了,刚才安装的jdk路径在哪?
rpm -qa | grep java
看一眼,然后发现有个包叫java-1.7.0-openjdk-1.7.0.91-2.6.2.2.el6_7.x86_64
rpm -ql java-1.7.0-openjdk-1.7.0.91-2.6.2.2.el6_7.x86_64
于是列出了一大串路径,在其中找到了/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64/jre/bin
,cd到这个目录下发现嗯,javac啊,java都有,就是它了。下面配置JAVA_HOME环境变量
vim /etc/profile
在尾部加上
export JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.91.x86_64 export CLAsspATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
:wq
退出vim编辑器,然后source /etc/profile
就行了。
2. ElasticSearch的安装配置
这里使用yum方式来安装 ES的官方网站上有说明: https://www.elastic.co/guide/en/elasticsearch/reference/current/setup.html 首先下载并安装公钥
rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch
配置一下yum源
vim /etc/yum.repos.d/elasticsearch.repo
elasticsearch.repo
内容:
[elasticsearch-2.x] name=Elasticsearch repository for 2.x packages baseurl=http://packages.elastic.co/elasticsearch/2.x/centos gpgcheck=1 gpgkey=http://packages.elastic.co/GPG-KEY-elasticsearch enabled=1
然后yum makecache
更新一下缓存,
yum install elasticsearch
安装elasticsearch完毕。
之后我们需要将ElasticSearch作为一个服务来运行,具体参考这里 https://www.elastic.co/guide/en/elasticsearch/reference/current/setup-service.html
sudo /sbin/chkconfig --add elasticsearch sudo service elasticsearch start
至此为止,elasticsearch服务就启动了,访问一下9200端口
curl -X GET localhost:9200
{ "name" : "Hindsight Lad","cluster_name" : "elasticsearch","version" : { "number" : "2.0.0","build_hash" : "de54438d6af8f9340d50c5c786151783ce7d6be5","build_timestamp" : "2015-10-22T08:09:48Z","build_snapshot" : false,"lucene_version" : "5.2.1" },"tagline" : "You KNow,for Search" }
Centos 6.7 安装ElasticSearch2.3.3
闲来无事,就来学习下被称为新全文的ElasticSearch。新手第一次装新全文,问题还是挺多的。
1.关于ElasticSearch
ElasticSearch是一个基于Lucene的搜索工具,它使用Java开发并且使用Lucene作为核心来实现索引和搜索的功能。但是它的目的是通过简单的Restful API来隐藏Lucene的复杂性,从而让全文搜索变得简单。
但是,Elasticsearch不仅仅是Lucene和全文搜索,我们还能这样去描述它:
1)分布式的实时文件存储,每个字段都被索引并可被搜索
2)分布式的实时分析搜索引擎
3)可以扩展到上百台服务器,处理PB级结构化或非结构化数据
而且,所有的这些功能被集成到一个服务里面,你的应用可以通过简单的RestfulAPI、各种语言的客户端甚至命令行与之交互。
2. 下载最新版的ElasticSearch的安装包,该版本可直接部署到Linux系统上
安装之前,请确认已安装好最新版的JDK版本,安装步骤请参照其他网友文章。最好把安装的工具包放在/opt目录,本人安装在centos 6.7下的/home目录下使用,wget命令得到该zip安装包。
Elasticsearch 2.3.3 ZIP https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/zip/elasticsearch/2.3.3/elasticsearch-2.3.3.zip</span> Woo hoo! Your download is almost complete! It's clear you're about to do great things with data. Whether this is your first,tenth,or umpteenth download of an open source Elastic project,there's always something new to learn. So,before you dive into the documentation,have a gander at the goodness below. Try something new,expand to a new use case,think up something totally novel,and,above all,stay curIoUs.
3. 正式安装ElasticSearch
在root用户,/home目录下解压zip包,创建软连接In -s elasticsearch2.3.3 elasticsearch,cd /elasticsearch后,执行 ./bin/elasticsearch,会出现如下的错误:
[root@xxxx bin]# ./elasticsearch Exception in thread "main" java.lang.RuntimeException: don't run elasticsearch as root.</span> at org.elasticsearch.bootstrap.Bootstrap.initializeNatives(Bootstrap.java:93) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:144) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Refer to the log for complete error details.
这是ElasticSearch出于系统安全考虑设置的条件。由于ElasticSearch可以接收用户输入的脚本并且执行,为了系统安全考虑,因此可以创建一个单独的用户用来运行ElasticSearch。
1) 创建单独的用户组和elsearch用户:
groupadd elsearch useradd elsearch -g elsearch -p elasticsearch
2) 更改/home/elasticsearch用户及组:
<span> </span></span>cd /home <span> </span></span>chown -R elsearch:elsearch elasticsearch
3) 使用elsearch用户执行安装命令
<span> </span></span>su elsearch <span> </span></span>cd elasticsearch/bin 执行 ./elasticsearch
4. 关于安装plugins(插件管理)
Exception in thread "main" java.lang.IllegalStateException: Unable to access 'path.plugins' (/home/hye/elasticsearch/plugins) Likely root cause: java.nio.file.AccessDeniedException: /home/hye/elasticsearch/plugins at sun.nio.fs.UnixException.translatetoIOException(UnixException.java:84) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102) at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107) at sun.nio.fs.UnixFileSystemProvider.createDirectory(UnixFileSystemProvider.java:384) at java.nio.file.Files.createDirectory(Files.java:674) at java.nio.file.Files.createAndCheckIsDirectory(Files.java:781) at java.nio.file.Files.createDirectories(Files.java:767) at org.elasticsearch.bootstrap.Security.ensureDirectoryExists(Security.java:337) at org.elasticsearch.bootstrap.Security.addpath(Security.java:314) at org.elasticsearch.bootstrap.Security.addFilePermissions(Security.java:246) at org.elasticsearch.bootstrap.Security.createPermissions(Security.java:212) at org.elasticsearch.bootstrap.Security.configure(Security.java:118) at org.elasticsearch.bootstrap.Bootstrap.setupSecurity(Bootstrap.java:196) at org.elasticsearch.bootstrap.Bootstrap.setup(Bootstrap.java:167) at org.elasticsearch.bootstrap.Bootstrap.init(Bootstrap.java:270) at org.elasticsearch.bootstrap.Elasticsearch.main(Elasticsearch.java:35) Refer to the log for complete error details.
请按照官网的plguins Managerment的介绍和安装方法进行安装:
4.1安装前的准备
Running as root If Elasticsearch was installed using the deb or rpm package then run bin/plugin as root so it can write to the appropriate files on disk. Otherwise run bin/plugin as the user that owns all of the Elasticsearch files.
4.2 正式安装plugins插件
本人安装的是Core Elasticsearch plugins,按照图中的安装步骤,完成安装。
Plugin Management Core Elasticsearch pluginsedit Core Elasticsearch plugins can be installed as follows: sudo bin/plugin install [plugin_name] For instance,to install the core ICU plugin,just run the following command: sudo bin/plugin install analysis-icu This command will install the version of the plugin that matches your Elasticsearch version. Community and non-core pluginsedit Non-core plugins provided by Elasticsearch,or plugins provided by the community,can be installed from download.elastic.co,from Maven (Central and Sonatype),or from GitHub. In this case,the command is as follows: sudo bin/plugin install [org]/[user|component]/[version]</span><span>
5. 启动ElasticSearch
使用非root用户进行安装:
<span> </span>su elsearch <span> </span>cd elasticsearch/bin <span> </span>./elasticsearch
如果想要ElasticSearch在后端运行: <span> </span>./elasticsearch -d
控制台显示:(启动ElasticSearch成功)
[elsearch@xhyu-100 elasticsearch]$ ./bin/elasticsearch [2016-06-19 00:27:24,188][WARN ][bootstrap ] unable to install syscall filter: seccomp unavailable: CONfig_SECCOMP not compiled into kernel,CONfig_SECCOMP and CONfig_SECCOMP_FILTER are needed [2016-06-19 00:27:24,417][INFO ][node ] [Mad-Dog] version[2.3.3],pid[4260],build[218bdf1/2016-05-17T15:40:04Z] [2016-06-19 00:27:24,417][INFO ][node ] [Mad-Dog] initializing ... [2016-06-19 00:27:25,040][INFO ][plugins ] [Mad-Dog] modules [reindex,lang-expression,lang-groovy],plugins [analysis-icu],sites [] [2016-06-19 00:27:25,066][INFO ][env ] [Mad-Dog] using [1] data paths,mounts [[/ (/dev/sda3)]],net usable_space [33.4gb],net total_space [45.6gb],spins? [possibly],types [ext4] [2016-06-19 00:27:25,066][INFO ][env ] [Mad-Dog] heap size [1015.6mb],compressed ordinary object pointers [true] [2016-06-19 00:27:25,066][WARN ][env ] [Mad-Dog] max file descriptors [4096] for elasticsearch process likely too low,consider increasing to at least [65536] [2016-06-19 00:27:27,264][INFO ][node ] [Mad-Dog] initialized [2016-06-19 00:27:27,264][INFO ][node ] [Mad-Dog] starting ... [2016-06-19 00:27:27,330][INFO ][transport ] [Mad-Dog] publish_address {192.168.31.200:9300},bound_addresses {192.168.31.200:9300} [2016-06-19 00:27:27,333][INFO ][discovery ] [Mad-Dog] elasticsearch/-H0Z_q6irsuYDXd1b1jCAg [2016-06-19 00:27:30,390][INFO ][cluster.service ] [Mad-Dog] new_master {Mad-Dog}{-H0Z_q6irsuYDXd1b1jCAg}{192.168.31.200}{192.168.31.200:9300},reason: zen-disco-join(elected_as_master,[0] joins received) [2016-06-19 00:27:30,420][INFO ][http ] [Mad-Dog] publish_address {192.168.31.200:9200},bound_addresses {192.168.31.200:9200} [2016-06-19 00:27:30,420][INFO ][node ] [Mad-Dog] started [2016-06-19 00:27:30,441][INFO ][gateway ] [Mad-Dog] recovered [0] indices into cluster_state
6. ElasticSearch界面验证失败,修改ElasticSearch配置文件
未修改配置文件前,使用非root用户进行elasticsearch安装。
[root@xxxx elasticsearch]# curl -X GET http://机器ip:9200/ curl: (7) Couldn't connect to host
按照网上的文章和官网安装说明,并没有修改默认配置文件的说法。
/home/hye/elasticsearch/config
修改完后,开启验证界面,最好找个好点浏览器,QQ浏览器就别用了。可以用Chrome浏览器。
在界面输入:http://安装机器ip:9200/,页面回馈信息如下:
{ "name" : "Mad-Dog","cluster_name" : "elasticsearch","version" : { "number" : "2.3.3","build_hash" : "218bdf10790eef486ff2c41a3df5cfa32dadcfde","build_timestamp" : "2016-05-17T15:40:04Z","build_snapshot" : false,"lucene_version" : "5.5.0" },"tagline" : "You KNow,for Search" }
至此,安装结束。。。(今天博客上传图片有问题,只能用文字描述了,抱歉)
我们今天的关于center os 7 安装 elasticSeartch和centos8安装elasticsearch的分享就到这里,谢谢您的阅读,如果想了解更多关于CentOS 5.6 安装 Elasticsearch 5.0、centos 6.5 elasticsearch 5.1 安装、CentOS 6.7 安装ElasticSearch2.0.0、Centos 6.7 安装ElasticSearch2.3.3的相关信息,可以在本站进行搜索。
本文标签: