Linux 安装ElasticSearch

 

网上也有很多资料,但是比较乱,自己整理了下,希望对大家有帮助

1.下载elasticsearch安装包 链接:https://www.elastic.co/downloads/elasticsearch (注意:linux安装内存建议1g内存以上)

2.上传elasticsearch安装包,并解压elasticsearch

tar -zxvf elasticsearch-7.0.1.tar.gz

3.修改配置

vim /usr/local/elasticsearch-7.0.1/config/elasticsearch.yml

cluster.name: my-application  //这行取消注释 并且改为自己的应用名称
node.name: node-1 //这行也一样 也可以改为自己的节点名称
network.host: 192.168.0.1 //取消注释 改为自己的ip或者0.0.0.0
http.port: 9200 //取消注释就行 可以自行修改端口号
cluster.initial_master_nodes: ["node-1"] //取消注释就行,改成这样

切记 取消注释后 首字母前面不能有空格 不然启动会报错 

vi /etc/sysctl.conf

vm.max_map_count=655360 //加上这句
sysctl –p //保存后执行命令
vi /etc/security/limits.conf
//加上这些内容
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

4.新建一个账户:并赋权限

adduser admin
passwd admin  //然后输入两次密码
chown -R admin /usr/local/elasticsearch-7.0.1  //赋权

访问elasticsearch,需要关闭防火墙

systemctl stop firewalld

在创建的账户(admin)下,启动es:

su - admin
cd /usr/local/elasticsearch-7.0.1/bin
./elasticsearch  或者加上 -d, 以守护线程方式启动,

查看进程是否启动: ps -ef|grep elasticsearch

关闭es和关闭他的线程方式一样: kill -9 '进程号

最后访问:http://192.168.248.128:9200/

看到这里,那就没问题了:

{
  "name" : "node-1",
  "cluster_name" : "myElasticSearch",
  "cluster_uuid" : "R-8UCW9PQp6Eb3_oA5MTEQ",
  "version" : {
    "number" : "7.0.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "e4efcb5",
    "build_date" : "2019-04-29T12:56:03.145736Z",
    "build_snapshot" : false,
    "lucene_version" : "8.0.0",
    "minimum_wire_compatibility_version" : "6.7.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

 5.常见错误分析

can not run elasticsearch as root  //因为安全问题elasticsearch不让用root用户直接运行,所以要创建新用户
    
第一步:liunx创建新用户  adduser XXX    然后给创建的用户加密码 passwd XXX    输入两次密码。
第二步:切换刚才创建的用户 su XXX  然后执行elasticsearch  会显示Permission denied 权限不足。
第三步:给新建的XXX赋权限,chmod 777 *  这个不行,因为这个用户本身就没有权限,肯定自己不能给自己付权限。所以要用root用户登录付权限。
第四步:root给XXX赋权限,chown -R XXX /你的elasticsearch安装目录,然后执行。

继续报错:

bootstrap checks failed max virtual memory areas vm.max_map_count [65530] is

继续修改配置:

vi /etc/sysctl.conf
vm.max_map_count=655360 //加上这句
sysctl –p //保存后执行命令

 继续报错:

max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]

继续修改配置:

vi /etc/security/limits.conf

 加入这几行:

* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

继续报错:

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

报这个错误,是忘记修改配置了:

#cluster.initial_master_nodes: ["node-1", "node-2"]
cluster.initial_master_nodes: ["node-1"] 这个的话,这里的node-1是上面一个默认的记得打开就可以了

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值