? Note: 1. Need to install jdk11 2. Elasticsearch cannot be started with root account
-
Install JDK11
-
Create users and groups for elasitcsearch: esuser/esuser
#Create group group add esuser #create user useradd -r -g esuser esuser #set password passwd esuser
-
Install
#Download wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.9-linux-x86_64.tar.gz # unzip tar -vxf elasticsearch-7.17.9-linux-x86_64.tar.gz #Authorization to esuser chown -R esuser:esuser elasticsearch-7.17.9 #Switch to esuser user su - esuser #start service cd /sino/elasticsearch-7.17.9/bin ./elasticsearch & # View service ps -ef|grep elasticsearch -bash-4.2$ ps -ef|grep elasticsearch esuser 38211 38117 45 14:09 pts/2 00:00:54 /usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.el7_9.x86_64/bin/java -Xshare:auto -Des. networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -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 -Dio.netty.allocator.numDirectArenas=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable. jmx=true -Dlog4j2.formatMsgNoLookups=true -Djava.locale.providers=SPI,COMPAT --add-opens=java.base/java.io=ALL-UNNAMED -XX: + UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX: + UseCMSInitiatingOccupancyOnly -Djava.io.tmpdir=/tmp/elasticsearch-17699362327497274207 -XX: + HeapDumpOnOutOfMemoryError -XX: + ExitOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_gc* -Xgclog,%p + age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount =32,filesize=64m -Xms1024m -Xmx1024m -XX:MaxDirectMemorySize=536870912 -Des.path.home=/sino/elasticsearch-7.17.9 -Des.path.conf=/sino/elasticsearch-7.17.9/config -Des .distribution.flavor=default -Des.distribution.type=tar -Des.bundled_jdk=true -cp /sino/elasticsearch-7.17.9/lib/* org.elasticsearch.bootstrap.Elasticsearch esuser 38384 38211 0 14:09 pts/2 00:00:00 /sino/elasticsearch-7.17.9/modules/x-pack-ml/platform/linux-x86_64/bin/controller esuser 38738 38117 0 14:11 pts/2 00:00:00 grep --color=auto elasticsearch #View port netstat -an|grep 9200 -bash-4.2$ netstat -an|grep 9200 tcp6 0 0 127.0.0.1:9200 :::* LISTEN tcp6 0 0 ::1:9200 :::* LISTEN #Use curl to open local port 9200 curl http://127.0.0.1:9200 -bash-4.2$ curl http://127.0.0.1:9200 { "name" : "localhost.localdomain", "cluster_name" : "elasticsearch", "cluster_uuid" : "YQ12G4DoTUKAaGkPwMe7Gw", "version" : { "number" : "7.17.9", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "ef48222227ee6b9e70e502f0f0daa52435ee634d", "build_date" : "2023-01-31T05:34:43.305517834Z", "build_snapshot" : false, "lucene_version" : "8.11.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" } #Browser cannot access port 9200 http://172.16.103.27:9200 #Modify configuration config/elasticsearch.yml cd /sino/elasticsearch-7.17.9/config vi elasticsearch.yml #find #network.host: 192.168.0.1, delete the front # ip changed to 0.0.0.0 #Restart ES: (pkill ES first, then start ES again, the same below) pkill -f elasticsearch cd /sino/elasticsearch-7.17.9/bin ./elasticsearch & #Prompt that the startup failed, the reason is that the system parameters are too small and need to be modified ERROR: [3] bootstrap checks failed. You must address the points described in the following [3] lines before starting Elasticsearch. bootstrap check failure [1] of [3]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535] bootstrap check failure [2] of [3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144] bootstrap check failure [3] of [3]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured ERROR: Elasticsearch did not exit normally - check the logs at /sino/elasticsearch-7.17.9/logs/elasticsearch.log [2023-03-23T14:18:41,574][INFO ][o.e.n.Node][localhost.localdomain]stopping... [2023-03-23T14:18:41,599][INFO ][o.e.n.Node][localhost.localdomain] stopped [2023-03-23T14:18:41,599][INFO ][o.e.n.Node] [localhost.localdomain] closing... [2023-03-23T14:18:41,624][INFO ][o.e.n.Node] [localhost.localdomain] closed #Switch to the root account sudo su root #Modify virtual memory vi /etc/sysctl.conf #Add at the end vm.max_map_count=262144 sysctl -p #Modify the maximum number of open files; after this file is modified, the user needs to log in again to take effect. vi /etc/security/limits.conf #Add the following content, pay attention not to remove the * number * soft nofile 65536 * hard nofile 131072 * soft nproc 2048 * hard nproc 4096 #Modify the limit on the number of threads started by ordinary users vi /etc/security/limits.d/20-nproc.conf * soft nproc 1024 #change into * soft nproc 4096 #Switch to esuser account sudo su esuser vi /sino/elasticsearch-7.17.9/config/elasticsearch.yml #add parameters #cluster name cluster.name: sino-es-cluster #node name node.name: node-1 #cluster discovery discovery.seed_hosts: ["127.0.0.1"] # master node cluster.initial_master_nodes: ["node-1"] #Close the map service, otherwise it will report an error when starting, but it will not affect the use ingest.geoip.downloader.enabled: false #start service cd /sino/elasticsearch-7.17.9/bin ./elasticsearch & #Browser access http://172.16.103.27:9200/ can be opened normally { "name" : "node-1", "cluster_name" : "sino-es-cluster", "cluster_uuid" : "YQ12G4DoTUKAaGkPwMe7Gw", "version" : { "number" : "7.17.9", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "ef48222227ee6b9e70e502f0f0daa52435ee634d", "build_date" : "2023-01-31T05:34:43.305517834Z", "build_snapshot" : false, "lucene_version" : "8.11.1", "minimum_wire_compatibility_version" : "6.8.0", "minimum_index_compatibility_version" : "6.0.0-beta1" }, "tagline" : "You Know, for Search" }
-
Install the IK word breaker plug-in (Chinese word breaker)
#github address https://github.com/medcl/elasticsearch-analysis-ik #download wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.6/elasticsearch-analysis-ik-7.17.6.zip #Copy it to the /plugin/ik directory, unzip and delete the zip file #Because there is no corresponding version 7.17.9, you need to modify the configuration in plugin-descriptor.properties before starting elasticsearch.version=7.17.6 changed to elasticsearch.version=7.17.9 #Finally restart the service, the log shows that the plugin has been loaded 2023-03-23T19:19:18,150][INFO ][o.e.p.PluginsService] [node-1] loaded module [x-pack-voting-only-node] [2023-03-23T19:19:18,150][INFO ][o.e.p.PluginsService] [node-1] loaded module [x-pack-watcher] [2023-03-23T19:19:18,151][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [analysis-ik] [2023-03-23T19:19:18,151][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [analysis-pinyin] [2023-03-23T19:19:18,152][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [ingest-attachment]
-
Install the pinyin plug-in (the pinyin plug-in of ES can enable ES to have the ability to search through Chinese characters, pinyin or Chinese pinyin mixed)
#github address https://github.com/medcl/elasticsearch-analysis-pinyin #download wget https://github.com/medcl/elasticsearch-analysis-pinyin/releases/download/v7.17.5/elasticsearch-analysis-pinyin-7.17.5.zip #Copy it to the /plugin/pinyin directory, decompress and delete the zip file #Because there is no corresponding version 7.17.9, you need to modify the configuration in plugin-descriptor.properties before starting elasticsearch.version=7.17.6 changed to elasticsearch.version=7.17.9 #Finally restart the service, the log shows that the plugin has been loaded 2023-03-23T19:19:18,150][INFO ][o.e.p.PluginsService] [node-1] loaded module [x-pack-voting-only-node] [2023-03-23T19:19:18,150][INFO ][o.e.p.PluginsService] [node-1] loaded module [x-pack-watcher] [2023-03-23T19:19:18,151][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [analysis-ik] [2023-03-23T19:19:18,151][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [analysis-pinyin] [2023-03-23T19:19:18,152][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [ingest-attachment]
-
Install ingest-attachment (processing documentation)
#Download wget https://artifacts.elastic.co/downloads/elasticsearch-plugins/ingest-attachment/ingest-attachment-7.17.9.zip #Copy it to the /plugin/ingest-attachment directory, unzip and delete the zip file #Finally restart the service, the log shows that the plugin has been loaded 2023-03-23T19:19:18,150][INFO ][o.e.p.PluginsService] [node-1] loaded module [x-pack-voting-only-node] [2023-03-23T19:19:18,150][INFO ][o.e.p.PluginsService] [node-1] loaded module [x-pack-watcher] [2023-03-23T19:19:18,151][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [analysis-ik] [2023-03-23T19:19:18,151][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [analysis-pinyin] [2023-03-23T19:19:18,152][INFO ][o.e.p.PluginsService] [node-1] loaded plugin [ingest-attachment]
-
Install kibana (a visual ES tool that can manage and operate ES well through kibana)
#Note that the kibana version needs to correspond to elasticsearch https://www.elastic.co/cn/support/matrix#matrix_compatibility #downloadkibana wget https://artifacts.elastic.co/downloads/kibana/kibana-7.17.9-linux-x86_64.tar.gz # unzip tar -zxvf kibana-7.17.9-linux-x86_64.tar.gz cd /sino/kibana-7.17.9-linux-x86_64/config vi kibana.yml #Modify as follows server.host: "172.16.103.27" elasticsearch.hosts: ["http://127.0.0.1:9200"] i18n.locale: "zh-CN" #Modify directory permissions chown -R esuser:esuser kibana-7.17.9-linux-x86_64 #Switch to the esuser user to start the kubana service sudo su esuser cd /sino/kibana-7.17.9-linux-x86_64/bin ./kibana & #Browser access http://172.16.103.27:5601/