大家好,我是烤鸭:   

环境:

        linux Cent OS 7.3

        elasticsearch-6.2.4

1. 下载elasticsearch 

    https://www.elastic.co/downloads/elasticsearch

上面的网址直接下载的话,实在太慢了。官方还提供了另一种方式。

https://www.elastic.co/guide/en/elasticsearch/reference/current/zip-targz.html 

如图。


wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.tar.gz.sha512
shasum -a 512 -c elasticsearch-6.2.4.tar.gz.sha512 
tar -xzf elasticsearch-6.2.4.tar.gz
cd elasticsearch-6.2.4/ 
./bin/elasticsearch

2.  启动及常见问题

    异常1:org.elasticsearch.bootstrap.StartupException: java.lang.RuntimeException: can not run elasticsearch as root.    

       2.1  创建es用户和用户组es,指定密码es,赋予权限。(/opt/elasticsearch/为es安装目录)

groupadd es
useradd es -g es -p es
chown -R es.es /opt/elasticsearch/

        2.2  切换es用户访问成功

su - es
./elasticsearch-6.2.4/bin/elasticsearch

         上一张启动成功的图:

         

         2.3  常见异常:

 异常2 : bound or publishing to a non-loopback address, enforcing bootstrap checks
                ERROR: [2] bootstrap checks failed
[1]: max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]     

          2.4   修改   limits.conf

vim /etc/security/limits.conf

          最后一行加:

* soft nofile 65536
* hard nofile 131072

        此文件修改后需要重新登录用户,才会生效。

        2.5  编辑权限

vim /etc/security/limits.d/xx-nproc.conf

最下面加上两行:

*   soft    nproc     2048
*   soft    nproc     4096

       2.6  修改配置文件

vi /etc/sysctl.conf
sysctl -p

如图:

        

        2.7  切换es用户,重新启动

su - es
cd /opt/elasticsearch/elasticsearch-6.2.4/bin
./elasticsearch

        后台启动:

./elasticsearch -d

        成功如图:       

        

        2.8   测试访问

        阿里云的服务器需要在安全组配置,端口开放才可以访问。

       

        2.9  yml配置

        可以看出来,上面的启动端口不是8200和8300,分享一下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: yxd-es
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
node.name: node-1
#
# 设置充当master节点,默认为true
#
node.master: true  
#
# 设置不充当data节点,默认为true
#
node.data: true
#
# 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: ../data    #数据目录
#
# Path to log files:
#
path.logs: ../logs    #日志目录
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#设置为true来锁住内存。因为内存交换到磁盘对服务器性能来说是致命的,当jvm开始swapping时es的效率会降低,所以要保证它不swap
#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: 192.168.1.1    (服务器内网ip)
network.bind_host: 192.168.1.1     (服务器内网ip)
#
# Set a custom port for HTTP:
#
http.port: 9303    #设置对外服务的http端口,默认为9200
transport.tcp.port: 9393   # 设置节点间交互的tcp端口,默认是9300   

# transport.publish_host: 127.0.0.1     # 发布集群中要连接到的节点的主机地址。默认为transport.host(如果设置)或network.publish_host
      
# transport.bind_host: 127.0.0.1    #将传输服务绑定到的主机地址。默认为transport.host(如果设置)或network.bind_host

# transport.publish_port: 9300    # 与此节点通信时,群集中其他节点应使用的端口。当群集节点位于代理或防火墙之后并且transport.tcp.port不能从外部直接寻址时很有用。默认为通过分配的实际端口 transport.tcp.port

#
# 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]"]
#
#这提供了自动集群体验,而无需进行任何配置。数组设置或逗号分隔的设置。每个值的形式应该是host:port或host  
#(如果没有设置,port默认设置会transport.profiles.default.port 回落到transport.tcp.port)。  
#请注意,IPv6主机必须放在括号内。默认为127.0.0.1, [::1]  
discovery.zen.ping.unicast.hosts: ["内网ip:9393"]
#
# 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

    2.10  调整jvm内存

vim /opt/elasticsearch/elasticsearch-6.2.4/config/jvm.options

    #默认是1g官方建议对jvm进行一些修改,不然很容易出现OOM,参考官网改参数配置最好不要超过内存的50%    

-Xms1g  
-Xmx1g

      2.11  更多关于多节点配置yml

        请参考:    https://blog.csdn.net/qq_34021712/article/details/79342668

         配置文件中给出了三种配置高性能集群拓扑结构的模式,如下: 
            # 1. 如果你想让节点从不选举为主节点,只用来存储数据,可作为数据节点 
            # node.master: true 
            # node.data: false
            # node.ingest: true

            # 2. 如果想让节点成为主节点,且不存储任何数据,并保有空闲资源,可作为协调器 
            # node.master:true 
            # node.data:false 
            # node.ingest:false 

            # 3. 如果想让节点既不称为主节点,又不成为数据节点,那么可将他作为摄取节点,从节点中获取数据,生成搜索结果等 
            # node.master: false 
            # node.data: false 
            # node.ingest: true

            # 4. 仅作为协调器 
            # node.master: false 
            # node.data: false

            # node.ingest: false

3.    x-pack安装

      官方安装网址:   

        https://www.elastic.co/cn/downloads/x-pack

        就按照官方的来就行。

bin/elasticsearch-plugin install x-pack

        

        3.1  启动访问,会提示输入用户名密码就成功了。

./bin/elasticsearch

        

        3.2    初始化x-pack用户名,密码

bin/x-pack/setup-passwords auto

        用户名   和  密码 如图:

        

4.    kibana和x-pack安装

        官方安装网址:      https://www.elastic.co/cn/downloads/kibana

        4.1    wget方式安装

wget https://artifacts.elastic.co/downloads/kibana/kibana-6.2.4-linux-x86_64.tar.gz
shasum -a 512 kibana-6.2.4-linux-x86_64.tar.gz 
tar -xzf kibana-6.2.4-linux-x86_64.tar.gz
cd kibana-6.2.4-linux-x86_64/ 

         4.2    修改配置文件/config/kibana.xml

 elasticsearch.url: "http://xxxxx:9303"        #es的ip
 elasticsearch.username: "elastic"
 elasticsearch.password: "changme"
 server.host: "127.0.0.1"  #kibana的启动ip  
 server.port: 9399    #kibana的启动端口

        4.3   启动(9399端口)

./bin/kibana

       


        4.4   访问,用户名,密码就是刚才elastic的用户名和密码


        首页:


        4.5  kibana的x-pack安装

cd /opt/elasticsearch/kibana/kibana-6.2.4-linux-x86_64
bin/kibana-plugin install x-pack

        4.3   带x-pack启动

        

        可以看到比刚才多了monitoring选项,可以检测es的节点等情况。

        过期时间是一个月以后。快要过期的话,就再去注册x-pack,每次注册可以使用一年。

        注册网址:    https://register.elastic.co/xpack_register


ps:

1.    关于集群多节点配置x-pack。每个节点都需要安装x-pack。但是kibana只需要安装一次。

2.    x-pack的密码修改。(需要指定content-type)

curl -H "Content-Type: application/json" -XPUT -u elastic -p '内网ip:9303/_xpack/security/user/elastic/_password' -d '{ "password" : "密码"}'


    如果忘记elastic用户的密码,可以再创建一个用户超级角色的用户(用户admin,密码admin1)

bin/x-pack/users useradd admin -p admin1 -r superuser 

    上面的请求改一下:

curl -H "Content-Type: application/json" -XPUT -u admin -p '内网ip:9303/_xpack/security/user/elastic/_password' -d '{ "password" : "密码"}'

会弹出让你输入密码:输入admin1就可以完成密码修改了。








更多关于elasticsearch 6.x内容:

    1.   elasticsearch 6.x 部署 windows入门(一) spingboot连接


        

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐