CentOS7安装elasticsearch
作者QQ:67065435 QQ群:821635552
本站内容全部为作者原创,转载请注明出处!
安装elasticsearch
cd /root wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.2.tar.gz tar -zxvf elasticsearch-5.6.2.tar.gz mv /root/elasticsearch-5.6.2 /usr/local/elasticsearch
创建数据目录
mkdir /data mkdir /data/search useradd elasticsearch chown -R elasticsearch:elasticsearch /data/search chown -R elasticsearch:elasticsearch /usr/local/elasticsearch
修改配置文件
vim /usr/local/elasticsearch/config/elasticsearch.yml node.name: node-1 node.attr.rack: r1 path.data: /data/search network.host: 127.0.0.1 http.port: 9200 ESC :wq
系统配置
su root vim /etc/sysctl.conf # 分配512M内存(1G内存的服务器) vm.max_map_count=524288 ESC :wq # 重载sysctl.conf配置 sysctl -p vim /usr/local/elasticsearch/config/jvm.options # 分配512M内存(1G内存的服务器) -Xms512M # 分配512M内存(1G内存的服务器) -Xmx512M -XX:-AssumeMP ESC :wq # 编辑limits.conf vim /etc/security/limits.conf * soft nproc 1024000 * hard nproc 1024000 * soft nofile 1024000 * hard nofile 1024000 ESC :wq
启动elasticsearch
su elasticsearch /usr/local/elasticsearch/bin/elasticsearch -d
防火墙配置
su root systemctl enable firewalld systemctl start firewalld firewall-cmd --zone=public --add-port=9200/tcp --permanent firewall-cmd --zone=public --add-port=9300/tcp --permanent firewall-cmd --reload
检查是否成功运行
curl http://127.0.0.1:9200
进程管理
cd /etc/systemd/system vim search.service [Unit] Description=Start elasticsearch on boot. After=default.target network.target [Service] User=elasticsearch Group=elasticsearch Type=forking ExecStart=/usr/local/elasticsearch/bin/elasticsearch -d PrivateTmp=false Restart=always [Install] WantedBy=multi-user.target ESC :wq systemctl daemon-reload systemctl enable search systemctl start search
CURL管理所有索引
创建一个索引
curl -XPUT 'http://127.0.0.1:9200/test_key1?pretty'
查看所有索引
curl 'http://127.0.0.1:9200/_cat/indices'
删除指定索引
curl -XDELETE 'http://127.0.0.1:9200/test_key1?pretty'