注意点:es不允许root用户启动,所以要新建另外一个用户启动es。Es默认启动内存为2G。
编辑config下的jvm.options文件 -Xmx512m
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
还是不行的话就关闭防火墙吧!
systemctl stop firewalld.service
外网还无法访问的话就需要改下配置文件了
config/elasticsearch.yml
7.1vim /etc/security/limits.conf
esyonghu soft nofile 65536
esyonghu hard nofile 68836
esyonghu soft nproc 4096
esyonghu hard nproc 4096
7.2vim /etc/sysctl.conf
vm.max_map_count=655360
使其生效sysctl -p
./bin/elasticsearch-plugin install https://github.com/NLPchina/elasticsearch-sql/releases/download/6.4.2.0/elasticsearch-sql-6.4.2.0.zip
Api查询方式
http://192.168.163.165:9200/_sql?sql=select * from index1
查询进程ps -ef | grep Elasticsearch
关闭进程kill -9 PID
wget https://artifacts.elastic.co/downloads/kibana/kibana-6.4.2-linux-x86_64.tar.gz
tar -zxvf kibana-6.4.2-linux-x86_64.tar.gz
mv kibana-6.4.2-linux-x86_64 kibana-6.4.2
vim kibana-6.4.2/config/kibana.yml
启动命令 进入kibana-6.4.2目录下面
nohup bin/kibana >/dev/null 2>&1 &
安装x-pack
注意:安装x-pack需要先安装kibana
x-pack安装:讲的比较详细,这里推荐一下 http://www.51niux.com/?id=210
x-pack是elasticsearch的一个扩展包,将安全,警告,监视,图形和报告功能捆绑在一个易于安装的软件包中
具体按住步骤官网上有详细说明:https://www.elastic.co/downloads/x-pack
cd /usr/local/elasticsearch-6.1.1
# 安装过程中输入y即可
./bin/elasticsearch-plugin install x-pack
# 启动es
./bin/elasticsearch
# 在另一个窗口执行
cd /usr/local/elasticsearch-6.1.1
# 设置过程中提示,输入y即可
./bin/x-pack/setup-passwords auto
# 返回结果
Changed password for user kibana
PASSWORD kibana = wZ54LdeFa+1N5C##IAuF
Changed password for user logstash_system
PASSWORD logstash_system = E6&gqoW5TP-?JJMLsHjs
Changed password for user elastic
PASSWORD elastic = @Dc?$qz3w6eZf%jUwKD+
cd /usr/local/kibana-6.1.1
# 安装过程比较慢
./bin/kibana-plugin install x-pack
# 在kibana.yml中配置用户名和密码
elasticsearch.username: "kibana"
# 密码是上面步骤自动生成的
elasticsearch.password: "wZ54LdeFa+1N5C##IAuF"
安装完成后访问http://localhost:5601/并使用用户名: elastic 密码:@Dc?$qz3w6eZf%jUwKD+ 登录
1.首先进入到 ElasticSearch 的路径下面,然后执行下面的命令,其中的 6.4.2 替换成你的 ElasticSearch 版本
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.2/elasticsearch-analysis-ik-6.4.2.zip
操作说明
GET /_cat/indices?v 列出所有索引
PUT /customer?pretty 创建一个索引 customer 索引名称 pretty 返回JSON格式化数据
PUT /customer/external/1?pretty
{
"name": "John Doe"
}
创建索引文档 customer索引名称 external类型名称 ID为1
查看集群健康状态
http://127.0.0.1:9200/_cat/health?v
查看集群索引数
http://127.0.0.1:9200/_cat/indices?v
查看集群所在磁盘的分配状况
http://127.0.0.1:9200/_cat/allocation?v
查看集群的节点
http://127.0.0.1:9200/_cat/nodes?v
#增加重新分配的最大负载
PUT /_cluster/settings
{
"persistent" : {
"indices.recovery.max_bytes_per_sec" : "600mb"
}
}
#允许在节点上发生多少并发传出分片恢复
PUT /_cluster/settings
{
"persistent" : {
"cluster": {
"routing": {
"allocation.cluster_concurrent_rebalance": 500
}
}
}
}
PUT _cluster/settings
{
"transient": {
"cluster.routing.allocation.node_concurrent_outgoing_recoveries": 500
}
}
PUT _cluster/settings
{
"transient": {
"cluster": {
"routing": {
"allocation.node_initial_primaries_recoveries": 18
}
}
}
}