默认情况安装好的elasticsearch可用内存为1G:
[root@server1 ~]# curl http://172.10.10.1:9200/_nodes/stats/breaker?pretty
{
"_nodes" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"cluster_name" : "xq4-test",
"nodes" : {
"276ff2iyRwGo6G7c-HbYwQ" : {
"timestamp" : 1690354264336,
"name" : "node-1",
"transport_address" : "172.20.40.1:9300",
"host" : "172.20.40.1",
"ip" : "172.20.40.1:9300",
"roles" : [
"master",
"ingest",
"data"
],
"attributes" : {
"ml.machine_memory" : "6068113408",
"xpack.installed" : "true",
"ml.max_open_jobs" : "20"
},
"breakers" : {
"request" : {
"limit_size_in_bytes" : 623326003,
"limit_size" : "594.4mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 1.0,
"tripped" : 0
},
"fielddata" : {
"limit_size_in_bytes" : 415550668,
"limit_size" : "396.2mb",
"estimated_size_in_bytes" : 567592,
"estimated_size" : "554.2kb",
"overhead" : 1.03,
"tripped" : 0
},
"in_flight_requests" : {
"limit_size_in_bytes" : 1038876672,
"limit_size" : "990.7mb",
"estimated_size_in_bytes" : 0,
"estimated_size" : "0b",
"overhead" : 2.0,
"tripped" : 0
},
"accounting" : {
"limit_size_in_bytes" : 1038876672,
"limit_size" : "990.7mb",
"estimated_size_in_bytes" : 3294803,
"estimated_size" : "3.1mb",
"overhead" : 1.0,
"tripped" : 0
},
"parent" : {
"limit_size_in_bytes" : 986932838,
"limit_size" : "941.2mb",
"estimated_size_in_bytes" : 527649784,
"estimated_size" : "503.2mb",
"overhead" : 1.0,
"tripped" : 0
}
}
}
}
}
[root@server1 ~]#
#可以看到这一项为内存大小
"limit_size" : "941.2mb",
如果操作系统内存足够的话可以修改大一些,修改方法如下:
[root@server1 ~]# cd /etc/elasticsearch/
[root@server1 elasticsearch]# ls
elasticsearch.keystore jvm.options log4j2.properties roles.yml users_roles
elasticsearch.yml jvm.options.d role_mapping.yml users
[root@server1 elasticsearch]#
修改jvm.options文件:
[root@server1 config]# pwd
/data/elasticsearch/config
[root@xq4-test-mysql config]# ls
elasticsearch.keystore jvm.options role_mapping.yml users
elasticsearch.yml log4j2.properties roles.yml users_roles
[root@xq4-test-mysql config]# cat jvm.options | grep "^\-Xm"
#修改这两个地方
-Xms2g
-Xmx2g
[root@server1 config]#
上面的是最小值,下面的是最大值,修改成一样的,不然服务起不来,这里我修改成2G,重启服务
这里已经变成1.8G了,默认这个可用内存是刚才设置的值的90%。