elasticsearch 6.5源码单机安装
1.创建用户elastic
adduser elastic
passwd elastic
密码规则:chen123456.
2.给用户elastic赋权限,文件路径为es解压路径
chown -R elastic:elastic /usr/local/elasticsearch/elasticsearch-6.5.0/
chmod -R elastic:elastic elasticsearch.keystore
3.修改服务器进程数
在root用户下进行以下操作,不加会报错
vim /etc/security/limits.conf 添加用户级别句柄和进程
内容如下,复制进去即可:
* soft nofile 65536
* hard nofile 131072
* soft nproc 4096
* hard nproc 4096
保存重启,查看设置是否成功
ulimit -Hu
ulimit -Su
ulimit -Hn
ulimit -Sn
说明:
说明:
* 代表针对所有用户
noproc 是代表最大进程数
nofile 是代表最大文件打开数
4.在 /etc/sysctl.conf文件最后添加一行
vm.max_map_count=262144
重启 reboot
即可永久修改
5.安装es
tar -xvf elasticsearch-5.0.2.tar # 解压
cd /home/tongdun/local/ elasticsearch-5.0.2 # 进入解压后的目录
mkdir data
mkdir logs
6.配置vim elasticsearch.yml
1)进入/opt/elasticsearch-6.5.0/config目录,使用vi编辑器:vi elasticsearch.yml(注:冒 号前面不能有空格,后面必须有一个空格)
2)取消如下注释,并修改为当前主机地址:
cluster.name: my-application
node.name: node-1
path.data: /usr/local/elasticsearch/elasticsearch-6.5.0/data
path.logs: /usr/local/elasticsearch/elasticsearch-6.5.0/logs
bootstrap.memory_lock: false
network.host: 0.0.0.0 #开通外网访问
http.port: 9200
discovery.zen.ping.unicast.hosts: ["10.100.2.235"]
discovery.zen.minimum_master_nodes: 1 #注意,因为本人目前是单节点,这里必须为1
3)新增如下配置:
transport.tcp.port: 9300
transport.tcp.compress: true
bootstrap.system_call_filter: false
4)使用vi编辑器,修改/etc/sysctl.conf文件,添加如下代码(若无将会出现下面常见问题2):
vm.max_map_count=262144
5)退出保存后执行如下命令:
sysctl -p
7.启动Elasticsearch
1)切换用户
su elastic
2)查看当前用户
who am i
3)启动服务
elasticsearch-6.5.0/bin/elasticsearch
4)后台启动
elasticsearch-6.5.0/bin/elasticsearch -d
5)测试是否启动成功
curl -XGET 'http://10.206.0.14:9200/'
查看es进程
ps -ef|grep elastic
8.异常
常见异常地址: https://www.cnblogs.com/zhi-leaf/p/8484337.html
max number of threads [3818] for user [es] is too low, increase to at least [4096]
最大线程个数太低。修改配置文件/etc/security/limits.conf,增加配置
* soft nproc 4096
* hard nproc 4096
执行命令sysctl -p生效