ElasticSearch third: install and configure elasticsearch, kibana in Linux environment, super detailed! !

Note: The last two articles talked about the use under windows. Today we will install and configure a set of linux environment. After all, after integrating springboot, it still needs to run on linux. If you want to use it, you must first configure it.

One, the installation and configuration of Elasticsearch

1. Download the tar package from the official website, elasticsearch-7.6.1-linux-x86_64.tar.gz used by the blogger

2. Upload to /home/devops/ElasticSearch, operation is ignored, path is customized

3. Switch directory and unzip

cd /home/devops/ElasticSearch
tar -zxvf elasticsearch-7.6.1-linux-x86_64.tar.gz

4. Switch directories and modify the configuration file

cd /home/devops/ElasticSearch/elasticsearch-7.6.1
vim config/elasticsearch.yml

#取消下列项注释并修改:
cluster.name: elasticsearch #集群名称
node.name: node-1 #节点名称
#数据和日志的存储目录
path.data: /home/elasticsearch/data
path.logs: /home/elasticsearch/logs
#设置绑定的ip,设置为0.0.0.0以后就可以让任何计算机节点访问到了
network.host: 0.0.0.0
http.port: 9200 #端口
#设置在集群中的所有节点名称,这个节点名称就是之前所修改的,当然你也可以采用默认的也行,目前是单机,放入一个节点即可
cluster.initial_master_nodes: ["node-1"]

跨域配置:
http.cors.enabled: true
http.cors.allow-origin: "*"

5. After saving, switch to the bin directory to start es: ./elasticsearch -d
If there is no permission when executing at this time . / elasticsearch: Permission denied 
requires authorization to execute the command: chmod +x bin/ 
elasticsearch execute again./elasticsearch -d You can start 
using ps aux|grep elasticsearch to see if it is started

6. An error is reported during startup:

java.lang.RuntimeException: can not run elasticsearch as root

The reason is that the root user cannot be used to start, the solution:

Execute the following commands:

#创建elsearch用户组及elsearch用户,并修改密码:
groupadd elsearch
useradd elsearch -g elsearch
passwd elsearch

#更改elasticsearch安装目录文件夹及内部文件的所属用户及组为elsearch:elsearch,如果日志和数据目录外放,也需要更改。
chown -R elsearch:elsearch  /home/devops/ElasticSearch/elasticsearch-7.6.1/
chown -R elsearch:elsearch  /home/elasticsearch/data
chown -R elsearch:elsearch  /home/elasticsearch/logs

#切换用户并启动es
su elsearch 
cd /home/devops/ElasticSearch/elasticsearch-7.6.1/bin
./elasticsearch -d

7. It still reports an error after switching users:

Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c5330000, 986513408, 0) failed; error='Cannot allocate memory' (errno=12)

It means that the memory is insufficient, es occupies 1g of memory when it starts by default. Switch back to the root user and modify the jvm.options configuration file. I changed it to 256m:

vim /home/devops/ElasticSearch/elasticsearch-7.6.1/config/jvm.options
修改以下内容:
-Xms256m
-Xmx256m

8. After saving, switch back to the elsearch user, start es again, and the user switch command su elsearch.

The error of this report:

[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max number of threads [3802] for user [elsearch] is too low, increase to at least [4096]
解决方案:
# 切换到root用户修改
        su root
        vim /etc/security/limits.conf
       # 在最后面追加下面内容
        *               soft    nofile          65536
        *               hard    nofile          65536
        *               soft    nproc           4096
        *               hard    nproc           4096

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
解决方案:
# 切换到root用户修改
        su root
        vim /etc/sysctl.conf
		#末行加入
        vm.max_map_count=655360
       #执行以下命令生效,或者重启虚拟机:
        sysctl -p

9. Finally switch to the elsearch user and restart es again, and then access 192.168.141.128:9200, as shown below:

This shows that es in the linux environment has been installed and configured.

Two, Kibana installation and configuration

Compared to es, Kibana is much simpler, remember to configure the nodejs environment first.

1. Download the tar package address from the official website: https://www.elastic.co/cn/kibana  blogger kibana-7.6.1-linux-x86_64.tar.gz, the version should be consistent with es

2. Upload to the specified directory /home/devops/ElasticSearch

3. Unzip:

tar –zxvf kibana-7.6.1-linux-x86_64.tar.gz

4. Modify the configuration file

cd /home/devops/ElasticSearch/kibana-7.6.1-linux-x86_64
vim config/kibana.yml

# 放开注释,将默认配置改成如下:

server.port: 5601
server.host: "192.168.141.128"
elasticsearch.url: "http://192.168.202.128:9200"
kibana.index: ".kibana"
elasticsearch.requestTimeout: 50000
i18n.locale: "zh-CN"

5. After saving, switch to the bin directory and start kibana. The root user is not recommended to start. If you use the root user to start, you need to add --allow-root after the startup command, as follows:

cd /home/devops/ElasticSearch/kibana-7.6.1-linux-x86_64/bin
nohup ./kibana --allow-root &

6. Visit http://192.168.141.128:5601

It's over! ! ! Installation and configuration under windows and linux environment! Follow up with es' curd, y and integrate springboot to use this distributed full-text search engine!

Guess you like

Origin blog.csdn.net/weixin_46792649/article/details/106360871