ElasticSearch is installed on linux
ES installation version: 6.3.0
Linux system: centos7
ik analysis plug-in: 6.3.0
kibana version: 6.3.0
virtual machine JDK1.8
Create a new user leyou (you can start any name)
Reason: For security reasons, elasticsearch is not allowed to run as root by default.
Create user:
useradd leyou
set password:
passwd leyou
Switch user:
su - leyou
Upload the installation package and unzip
We upload the installation package to: /home/leyou directory
Unzip:
tar -zxvf elasticsearch-6.2.4.tar.gz
We rename the directory:
mv elasticsearch-6.3.0/ elasticsearch
Enter and view the directory structure:
Change setting
We enter the config directory: cd config
there are two configuration files that need to be modified:
- jvm.options
Elasticsearch is based on Lucene, and the bottom layer of Lucene is implemented in Java, so we need to configure the jvm parameters.
Edit jvm.options:
vim jvm.options
The default configuration is as follows:
-Xms1g
-Xmx1g
The memory takes up too much, let's reduce it:
-Xms512m
-Xmx512m
- elasticsearch.yml
vim elasticsearch.yml
- Modify the data and log directory:
path.data: /home/leyou/elasticsearch/data # 数据目录位置
path.logs: /home/leyou/elasticsearch/logs # 日志目录位置
We modified the data and logs directories to point to the elasticsearch installation directory. But these two directories do not exist, so we need to create them.
Enter the root directory of elasticsearch, the logs directory already exists, so just create the data directory, and then create:
mkdir data
mkdir logs
Modify the bound ip:
vim elasticsearch.yml
network.host: 0.0.0.0 # Bind to 0.0.0.0, allowing any ip to access
At present, we are doing a stand-alone installation. If you want to do a cluster, you only need to add other node information in this configuration file.
Other configurable information of elasticsearch.yml:
Attribute name | Description |
---|---|
cluster.name | Configure the cluster name of elasticsearch. The default is elasticsearch. It is recommended to modify it to a meaningful name. |
node.name | Node name, es will randomly assign a name by default, it is recommended to assign a meaningful name to facilitate management |
path.conf | Set the storage path of the configuration file. The tar or zip package is installed in the config folder under the es root directory by default, and the rpm installation is in /etc/elasticsearch by default. |
path.data | Set the storage path of index data. The default is the data folder under the es root directory. Multiple storage paths can be set, separated by commas. |
path.logs | Set the storage path of the log file, the default is the logs folder under the es root directory |
path.plugins | Set the storage path of the plugin, the default is the plugins folder under the es root directory |
bootstrap.memory_lock | Set to true to lock the memory used by ES and avoid memory swap |
network.host | Set bind_host and publish_host, set to 0.0.0.0 to allow external network access |
http.port | Set the http port for external services, the default is 9200. |
transport.tcp.port | Communication port between cluster nodes |
discovery.zen.ping.timeout | Set the time for ES to automatically discover the node connection timeout, the default is 3 seconds, if the network delay is high, it can be set larger |
discovery.zen.minimum_master_nodes | The minimum value of the number of master nodes, the formula for this value is: (master_eligible_nodes / 2) + 1, for example: if there are 3 master nodes that meet the requirements, then it should be set to 2 here |
run
Enter the elasticsearch/bin directory, you can see the following executable file:
Then enter the command:
./elasticsearch
Error 1: The core is too low
The centos6 used has a linux kernel version of 2.6. The Elasticsearch plugin requires at least version 3.5. But it doesn't matter, we can disable this plugin.
Modify the elasticsearch.yml file and add the following configuration at the bottom:
bootstrap.system_call_filter: false
Then restart
Error 2: Insufficient file permissions
Started again, another error occurred:
[1]: max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
We use the leyou user instead of root, so the file permissions are insufficient.
First log in as root user.
Then modify the configuration file:
vim /etc/security/limits.conf
Add the following content:
- soft nofile 65536
- hard nofile 131072
- soft nproc 4096
- hard nproc 4096
Mistake 3: Not enough threads
In the error report, there is another line:
[1]: max number of threads [1024] for user [leyou] is too low, increase to at least [4096]
This is not enough threads.
Continue to modify the configuration:
vim /etc/security/limits.d/90-nproc.conf
Modify the following content:
- soft nproc 1024
To:
- soft nproc 4096
Error 4: Process virtual memory
[3]: max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]
vm.max_map_count: Limit the number of VMA (virtual memory area) a process can have, continue to modify the configuration file,:
vim /etc/sysctl.conf
Add the following content:
vm.max_map_count=655360
Then execute the command:
sysctl -p
My mistake is as follows:
Then modify it according to the above scheme. Note: Only the root user can modify those files
Restart the terminal window
After all errors are corrected, you must restart your Xshell terminal, otherwise the configuration will be invalid.
start up
Start ES as the leyou user at startup
Visit the ES of the virtual machine in the browser in the window, turn off the firewall, and the Es is installed
Kibana
Because Kibana depends on node, our virtual machine does not have node installed, but it was installed in the window. So we choose to use kibana under the window.
The latest version is consistent with elasticsearch, also 6.3.0, unzip to a specific directory to
configure and run
Enter the config directory under the installation directory and modify the kibana.yml file:
modify the address of the elasticsearch server:
elasticsearch.url: “http://192.168.1.181:9200”
Enter the bin directory under the installation directory:
double-click to run:
It is found that the listening port of kibana is 5601.
We visit: http://localhost:5601
Select the DevTools menu on the left to enter the console page:
on the right side of the page, we can enter a request and access Elasticsearch.
Install ik tokenizer
installation
Upload the elasticsearch-analysis-ik-6.3.0.zip package and unzip it to the plugins directory of the Elasticsearch directory:
use the unzip command to unzip:
unzip elasticsearch-analysis-ik-6.3.0.zip -d i-analyzer
Then restart elasticsearch:
test
Enter the following request in the kibana console:
POST _analyze
{
"analyzer": "ik_max_word",
"text": "我是中国人"
}