elasticsearch-安装

官网:https://www.elastic.co/cn/

官网只能找到最新的

下载:wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz

安装过程也可以参考:参考:https://www.imooc.com/article/20336

环境
centos7.6 (vagrant + virtualbox)
elasticsearch-5.5.2
java > 1.8 (java -version)

操作

su root
raoxiaoya

cd /usr/local

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz

tar -xf elasticsearch-5.2.2.tar.gz

因为Elasticsearch5.0之后,不能使用root账户启动,我们先创建账户
adduser elasticsearch
passwd elasticsearch
输入两次密码
elasticsearch
将对应的文件夹权限赋给该用户
chown -R elasticsearch elasticsearch-5.2.2

su elasticsearch

cd elasticsearch-5.2.2

修改 config/elasticsearch.yml 文件
xpack.security.enabled: false
xpack.security.http.ssl:
	enabled: false
	keystore.path: certs/http.p12

启动
./bin/elasticsearch

直到看到 started 字眼才算启动成功
找到 输出信息中的ip和端口
127.0.0.1:9200
127.0.0.1:9300

新开一个窗口
netstat -lntp
curl http://127.0.0.1:9200

本机CMD连接虚拟机测试
telnet 192.168.10.20 9200
telnet 192.168.10.20 9300

9200 http协议的RESTful接口
9300 是tcp通讯端口,集群间和TCPClient都走的它
显然都无法从外部连接。

浏览器
http://192.168.10.20:9200/
无法访问

ctrl+c关闭服务

vi config/elasticsearch.yml
注意:冒号后面有个空格
network.host: 192.168.10.20 # 默认是localhost,外部机器无法访问
http.port: 9200
#允许跨域请求,允许head插件访问
http.cors.enabled: true
http.cors.allow-origin: "*"

./bin/elasticsearch

报错

ERROR: bootstrap checks failed
max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

以上是两个报错

解决
报错1:
	su root
	raoxiaoya

	vi /etc/security/limits.conf 
	添加
		* soft nofile 65536

		* hard nofile 131072

		* soft nproc 2048

		* hard nproc 4096

报错2
	su root
	raoxiaoya

	查看 vm.max_map_count
	sysctl -a|grep vm.max_map_count

	vi /etc/sysctl.conf 
	其内容如下:
		# sysctl settings are defined through files in
		# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
		#
		# Vendors settings live in /usr/lib/sysctl.d/.
		# To override a whole file, create a new file with the same in
		# /etc/sysctl.d/ and put new settings there. To override
		# only specific settings, add a file with a lexically later
		# name in /etc/sysctl.d/ and put new settings there.
		#
		# For more information, see sysctl.conf(5) and sysctl.d(5).
	
	在最后添加
		vm.max_map_count=262144

	并执行命令:sysctl -p
	查看
	sysctl -a|grep vm.max_map_count

其他可能的报错:
max number of threads [1024] for user [lishang] likely too low, increase to at least [2048]

解决:
	su root
	raoxiaoya
	vi /etc/security/limits.d/90-nproc.conf 

	修改如下内容:
	* soft nproc 2048

启动
su elasticsearch
cd /usr/local/elasticsearch-5.2.2
./bin/elasticsearch

浏览器
http://192.168.10.20:9200/
成功

其他命令:
./bin/elasticsearch --help
./bin/elasticsearch --version
./bin/elasticsearch -d 后台运行
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值