Loading... #### 一、下载 #### 二、解压 #### 三、创建用户 ```shell useradd es passwd es chown -R es:es ~/es ``` #### 四、修改文件句柄数配置 - 修改/etc/security/limits.conf ``` #文件末尾添加 #修改打开文件最大数量 es soft nofile 65536 es hard nofile 65536 ``` - 修改/etc/sysctl.conf ```shell #文件末尾添加 #进程可以拥有的虚拟内存数量 vm.max_map_count=655360 ``` 重新加载:`sysctl -p` #### 五、修改elasticsearch.yml ```shell #======================== 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: es-cluster #集群内同时启动的数据任务个数,默认是2个 cluster.routing.allocation.cluster_concurrent_rebalance: 16 #添加或删除节点及负载均衡时并发恢复的线程个数,默认是4个 cluster.routing.allocation.node_concurrent_recoveries: 16 #初始化数据恢复是,并发恢复线程的个数,默认是4个 cluster.routing.allocation.node_initial_primaries_recoveries: 16 # # ------------------------------------ Node ------------------------------------ # # Use a descriptive name for the node: # node.name: es-node-1 # # Add custom attributes to the node: # #node.attr.rack: r1 #是不是有资格主节点 node.master: true node.data: true # # ----------------------------------- Paths ------------------------------------ # # Path to directory where to store the data (separate multiple locations by comma): # path.data: /app/es/data/path/to/data # # Path to log files: # path.logs: /app/es/data/path/to/logs # ----------------------------------- 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): #如果需要外网访问,设置成0.0.0.0 network.host: 192.168.101.104 # # Set a custom port for HTTP: # http.port: 9200 #head插件需要打开这两个配置 http.cors.allow-origin: "*" http.cors.enabled: true http.max_content_length: 200mb network.tcp.keep_alive: true network.tcp.no_delay: true transport.tcp.compress: true # # For more information, consult the network module documentation. # # --------------------------------- Discovery ---------------------------------- # # Pass an initial list of hosts to perform discovery when this node is started: # The default list of hosts is ["127.0.0.1", "[::1]"] # discovery.seed_hosts: ["192.168.101.104:9300", "192.168.101.105:9300","192.168.101.106:9300"] # # Bootstrap the cluster using an initial set of master-eligible nodes: # cluster.initial_master_nodes: ["es-node-1"] # # For more information, consult the discovery and cluster formation 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 # # ``` #### 六、修改elasticsearch-env 高版本的es,使用的java版本最好使用es自带的。不然会出现java相关的错误。修改elasticsearch-env中now set the path to java部分 ```shell # now set the path to java if [ ! -z "$ES_HOME" ]; then JAVA="$ES_HOME/jdk/bin/java" JAVA_TYPE="bundled jdk" else if [ "$(uname -s)" = "Darwin" ]; then # macOS has a different structure JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java" else JAVA="$ES_HOME/jdk/bin/java" fi JAVA_TYPE="bundled jdk" fi if [ ! -x "$JAVA" ]; then echo "could not find java in $JAVA_TYPE at $JAVA" >&2 exit 1 fi ``` #### 七、安装插件 以安装ik分词器为例 - 下载ik分词器的插件 - 上传到服务器 - 解压到es的plugin文件夹下 - 将analysi-ik的config目录放到es的config目录下 #### 八、启动ES集群 创建启动脚本 vim startup.sh ```shell #!/bin/bash bin/elasticsearch -d ``` 启动。 © Allow specification reprint Support Appreciate the author AliPayWeChat Like 0 If you think my article is useful to you, please feel free to appreciate