{"id":40750,"date":"2023-05-22T12:51:54","date_gmt":"2023-10-17T23:16:57","guid":{"rendered":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/"},"modified":"2024-04-30T05:23:19","modified_gmt":"2024-04-29T21:23:19","slug":"9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/","title":{"rendered":"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch"},"content":{"rendered":"<p>\u8fd9\u662f\u6211\u4ee5\u524d\u5728Hatena\u535a\u5ba2\u4e0a\u6295\u7a3f\u7684\u6587\u7ae0\u3002<\/p>\n<h1>\u9996\u5148\/\u9996\u8981<\/h1>\n<p>\u56e0\u4e3a\u4e0a\u4e00\u6b21\u5df2\u7ecf\u5b8c\u6210\u4e86\u57fa\u672c\u8bbe\u7f6e\uff0c\u4e3a\u4e86\u7b80\u5316\u8fd0\u8425\uff0c\u6211\u4eec\u5c06\u8003\u8651\u81ea\u52a8\u5316\u7684\u65b9\u6848\u3002<\/p>\n<h1>\u5b66\u4e60Elastic\u516c\u53f8\u7684\u516c\u5f0f\u65b9\u6cd5.<\/h1>\n<h2>\u505c\u6b62\u7684\u65b9\u5f0f<\/h2>\n<pre class=\"post-pre\"><code>$ .\/bin\/elasticsearch -p \/tmp\/elasticsearch-pid -d\r\n$ cat \/tmp\/elasticsearch-pid &amp;&amp; echo\r\n15516\r\n$ kill -SIGTERM 15516\r\n<\/code><\/pre>\n<p>\u5c31\u50cf\u4e0a\u9762\u6240\u8bf4\u7684\u90a3\u6837\uff0c\u53ea\u662f\u901a\u8fc7\u7ec8\u6b62\u8fdb\u7a0b\u6765\u505c\u6b62\u5b83\u3002\uff08\u771f\u662f\u5927\u80c6\u554a\uff09<\/p>\n<h2>\u8bf7\u5c1d\u8bd5\u67e5\u770b\u5728RPM\u5b89\u88c5\u4e2d\u8bbe\u7f6e\u7684\u811a\u672c\u3002<\/h2>\n<p>\u56e0\u4e3a\u4ec5\u4ec5\u505c\u6b62\u65b9\u6cd5\u662f\u65e0\u6cd5\u521b\u5efa\u4e00\u4e2a\u6b63\u5e38\u7684\u89e3\u51b3\u65b9\u6848\u7684\uff0c\u6240\u4ee5\u6211\u60f3\u8981\u67e5\u770b\u4f7f\u7528\u6807\u51c6\u7684systemctl\u6267\u884c\u7684\u811a\u672c\u3002<\/p>\n<p>\u5982\u679c\u60a8\u542f\u7528\u4e86\u4ee5\u4e0b\u670d\u52a1\uff0c\u60a8\u5c06\u80fd\u591f\u8bbf\u95ee\u94fe\u63a5\u5e76\u67e5\u770b\u8be5\u6587\u4ef6\u3002<\/p>\n<pre class=\"post-pre\"><code># systemctl enable elasticsearch.service\r\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/elasticsearch.service to \/usr\/lib\/systemd\/system\/elasticsearch.service.\r\n<\/code><\/pre>\n<p>\u4ee5\u4e0b\u662f\u6807\u51c6\u7684\u81ea\u52a8\u542f\u52a8\u811a\u672c\u5185\u5bb9\u3002<\/p>\n<pre class=\"post-pre\"><code>[Unit]\r\nDescription=Elasticsearch   # \u30e1\u30e2\uff1aUnit\u306e\u8aac\u660e\u6587\r\nDocumentation=http:\/\/www.elastic.co # \u30e1\u30e2\uff1a\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306eURL\r\nWants=network-online.target # \u30e1\u30e2\uff1a\u3053\u306eUnit\u304c\u5fc5\u8981\u3068\u3059\u308b\u524d\u63d0Unit\u21d2\u81ea\u524dsystemctl\u3067\u6d3b\u7528\u3059\u308b\r\nAfter=network-online.target # \u30e1\u30e2\uff1a\u3053\u306eUnit\u3088\u308a\u5148\u306b\u8d77\u52d5\u3059\u308b\u3079\u304dUnit\u21d2\u81ea\u524dsystemctl\u3067\u6d3b\u7528\u3059\u308b\r\n\r\n[Service]\r\nRuntimeDirectory=elasticsearch\r\nEnvironment=ES_HOME=\/usr\/share\/elasticsearch\r\nEnvironment=ES_PATH_CONF=\/etc\/elasticsearch\r\nEnvironment=PID_DIR=\/var\/run\/elasticsearch\r\nEnvironmentFile=-\/etc\/sysconfig\/elasticsearch\r\n\r\nWorkingDirectory=\/usr\/share\/elasticsearch\r\n\r\nUser=elasticsearch\r\nGroup=elasticsearch\r\n\r\nExecStart=\/usr\/share\/elasticsearch\/bin\/elasticsearch -p ${PID_DIR}\/elasticsearch.pid --quiet\r\n\r\n# StandardOutput is configured to redirect to journalctl since &lt;===== \u3053\u3053\u304b\u3089\u4e0b\u3082\u6d41\u7528\u3057\u307e\u3059\u3002\r\n# some error messages may be logged in standard output before\r\n# elasticsearch logging system is initialized. Elasticsearch\r\n# stores its logs in \/var\/log\/elasticsearch and does not use\r\n# journalctl by default. If you also want to enable journalctl\r\n# logging, you can simply remove the \"quiet\" option from ExecStart.\r\nStandardOutput=journal\r\nStandardError=inherit\r\n\r\n# Specifies the maximum file descriptor number that can be opened by this process\r\nLimitNOFILE=65536\r\n\r\n# Specifies the maximum number of processes\r\nLimitNPROC=4096\r\n\r\n# Specifies the maximum size of virtual memory\r\nLimitAS=infinity\r\n\r\n# Specifies the maximum file size\r\nLimitFSIZE=infinity\r\n\r\n# Disable timeout logic and wait until process is stopped\r\nTimeoutStopSec=0\r\n\r\n# SIGTERM signal is used to stop the Java process\r\nKillSignal=SIGTERM\r\n\r\n# Send the signal only to the JVM rather than its control group\r\nKillMode=process\r\n\r\n# Java process is never killed\r\nSendSIGKILL=no\r\n\r\n# When a JVM receives a SIGTERM signal it exits with code 143\r\nSuccessExitStatus=143\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n\r\n# Built for distribution-6.2.2 (distribution)\r\n<\/code><\/pre>\n<h1>\u81ea\u52a8\u542f\u52a8\u7684\u8bbe\u7f6e<\/h1>\n<p>\u5b66\u4e60Elastic\u516c\u53f8\u7684\u65b9\u5f0f\uff0c\u5e76\u5236\u4f5c\u81ea\u52a8\u542f\u52a8\u7a0b\u5e8f\u3002<\/p>\n<h2>\u521b\u5efa\u4e00\u4e2a\u7528\u4e8e\u5b58\u50a8PID\u7684\u6587\u4ef6\u5939\u3002<\/h2>\n<p>\u65e0\u8bba\u662f\u4f7f\u7528\u505c\u6b62\u6307\u4ee4\u8fd8\u662f\u81ea\u52a8\u811a\u672c\uff0c\u90fd\u662f\u6839\u636e\u8fdb\u7a0b\u7684PID\u6765\u505c\u6b62\u8fdb\u7a0b\u3002<\/p>\n<p>\u5728\u542f\u52a8\u65f6\u5c06\u6b64PID\u5199\u5165\u6587\u4ef6\uff0c\u4f46\u9700\u8981\u4fdd\u5b58\u8be5\u6587\u4ef6\u7684\u6587\u4ef6\u5939\u3002<br \/>\n\u6211\u662f\u5728\/usr\/lib\u76ee\u5f55\u4e0b\u521b\u5efa\u6587\u4ef6\u5939\uff0c\u4f46\u5728RHEL7\u53ca\u66f4\u9ad8\u7248\u672c\u4e2d\uff0c\u5982\u679c\u4e0d\u6309\u7167\u6b63\u786e\u7684\u6b65\u9aa4\u64cd\u4f5c\uff0c\u91cd\u542f\u65f6\u4f1a\u88ab\u5220\u9664\u3002<\/p>\n<p>(1) \u5728 \/usr\/lib\/tmpfiles.d \u4e0b\u521b\u5efa\u5b9a\u4e49\u6587\u4ef6\u7684\u4f4d\u7f6e\u3002<\/p>\n<pre class=\"post-pre\"><code># vi \/usr\/lib\/tmpfiles.d\/my_auto_elasticsearch.conf\r\n<\/code><\/pre>\n<p>\u6211\u5c06\u6309\u7167\u4ee5\u4e0b\u7684\u63cf\u8ff0\u8fdb\u884c\u9648\u8ff0\u3002<\/p>\n<pre class=\"post-pre\"><code>d \/var\/run\/my_auto_elasticsearch 0755 elasticsearch elasticsearch\r\n<\/code><\/pre>\n<p>(2) \u6211\u4eec\u5c06\u91cd\u65b0\u542f\u52a8\u64cd\u4f5c\u7cfb\u7edf\u3002<\/p>\n<p>\u8bf7\u786e\u8ba4\u6587\u4ef6\u5939\u662f\u5426\u5df2\u7ecf\u88ab\u521b\u5efa\u3002\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u5e94\u8be5\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3a\u300cmy_auto_elasticsearch\u300d\u7684\u6587\u4ef6\u5939\u3002<\/p>\n<pre class=\"post-pre\"><code># ls \/var\/run\r\n<\/code><\/pre>\n<h2>\u521b\u5efa\u4e00\u4e2a\u80fd\u591f\u901a\u8fc7systemctl\u8fdb\u884c\u63a7\u5236\u7684\u811a\u672c<\/h2>\n<p>\u6211\u5c06\u521b\u5efa\u4e00\u4e2a\u811a\u672c\uff0c\u4f7f\u5176\u88ab\u8bc6\u522b\u4e3asystemctl\u63a7\u5236\u7684\u670d\u52a1\u3002<\/p>\n<p>\u8bf7\u5728\/etc\/systemd\/system\u76ee\u5f55\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a&#8221;\u670d\u52a1\u540d.service&#8221;\u7684\u6587\u4ef6\u3002<br \/>\n\u8981\u6ce8\u610f\uff0c\u5982\u679c\u6ca1\u6709\u5305\u542b&#8221;.service&#8221;\u90e8\u5206\uff0csystemctl\u5c06\u65e0\u6cd5\u8bc6\u522b\u5b83\u4f5c\u4e3a\u4e00\u4e2a\u670d\u52a1\u3002<\/p>\n<p>\u521b\u5efa\u542f\u52a8\/\u505c\u6b62\u4e3b\u8282\u70b9\u811a\u672c<br \/>\n\u4e3a\u6bcf\u4e2a\u8282\u70b9\u521b\u5efa\u5355\u72ec\u7684\u542f\u52a8\u811a\u672c\u3002<\/p>\n<p>\u30fb\u4e3b\u8282\u70b9<\/p>\n<pre class=\"post-pre\"><code># vi \/etc\/systemd\/system\/master_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u6570\u636e\u8282\u70b9<\/p>\n<pre class=\"post-pre\"><code># vi \/etc\/systemd\/system\/data_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u5ba2\u6237\u8282\u70b9<\/p>\n<pre class=\"post-pre\"><code># vi \/etc\/systemd\/system\/client_node.service\r\n<\/code><\/pre>\n<p>\u8bf7\u5c06\u4ee5\u4e0b\u811a\u672c\u4e2d\u7684XXX\u90e8\u5206\u4fee\u6539\u4e3amaster\/data\/client\u3002<\/p>\n<pre class=\"post-pre\"><code>[Unit]\r\nDescription=Elasticsearch XXX Node Service  \r\nWants=network-online.target\r\nAfter=network-online.target\r\n\r\n[Service]\r\n#\u30e1\u30e2\uff1a\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u547c\u3076\u5834\u5408\u306fforking\u306b\u3059\u308b\r\nType=forking\r\n\r\n# \u30e1\u30e2\uff1a\u5916\u90e8\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u547c\u3076\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002\u5f15\u6570\u3067\u5bfe\u8c61\u30ce\u30fc\u30c9\u3068\u52d5\u4f5c\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002\r\n# XXX\u306bmaster\/node\/client\u306e\u3044\u305a\u308c\u304b\u3092\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\r\nExecStart=\/usr\/local\/bin\/elasticsearch_control.sh XXX start\r\n\r\n# StandardOutput is configured to redirect to journalctl since\r\n# some error messages may be logged in standard output before\r\n# elasticsearch logging system is initialized. Elasticsearch\r\n# stores its logs in \/var\/log\/elasticsearch and does not use\r\n# journalctl by default. If you also want to enable journalctl\r\n# logging, you can simply remove the \"quiet\" option from ExecStart.\r\nStandardOutput=journal\r\nStandardError=inherit\r\n\r\n# \u30d7\u30ed\u30bb\u30b9\u306e\u6700\u5927\u30d5\u30a1\u30a4\u30eb\u30c7\u30a3\u30b9\u30af\u30ea\u30d7\u30bf\u6570(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Specifies the maximum file descriptor number that can be opened by this process\r\nLimitNOFILE=65536\r\n\r\n# \u30d7\u30ed\u30bb\u30b9\u306e\u6700\u5927\u6570(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Specifies the maximum number of processes\r\nLimitNPROC=4096\r\n\r\n# \u4eee\u60f3\u30e1\u30e2\u30ea\u306e\u6700\u5927\u30b5\u30a4\u30ba(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Specifies the maximum size of virtual memory\r\nLimitAS=infinity\r\n\r\n# \u6700\u5927\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Specifies the maximum file size\r\nLimitFSIZE=infinity\r\n\r\n# \u30bf\u30a4\u30e0\u30a2\u30a6\u30c8\u3092\u7121\u52b9\u5316\u3057\u3001\u30d7\u30ed\u30bb\u30b9\u306e\u505c\u6b62\u307e\u3067\u5f85\u3064(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Disable timeout logic and wait until process is stopped\r\nTimeoutStopSec=0\r\n\r\n# Elasticsearch\u306e\u30d7\u30ed\u30bb\u30b9(Java\u30d7\u30ed\u30bb\u30b9)\u306eKill\u30b7\u30b0\u30ca\u30eb\u306e\u6307\u5b9a(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# SIGTERM signal is used to stop the Java process\r\nKillSignal=SIGTERM\r\n\r\n# Elasticsearch\u306e\u30d7\u30ed\u30bb\u30b9(Java\u30d7\u30ed\u30bb\u30b9)\u306e\u64cd\u4f5c\u30b0\u30eb\u30fc\u30d7(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Send the signal only to the JVM rather than its control group\r\nKillMode=process\r\n\r\n# Java\u30d7\u30ed\u30bb\u30b9\u3092\u505c\u6b62\u3057\u306a\u3044\u8a2d\u5b9a(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# Java process is never killed\r\nSendSIGKILL=no\r\n\r\n# JVM\u304cSIGTERM\u30b7\u30b0\u30ca\u30eb\u3092\u53d7\u4fe1\u3057\u305f\u969b\u306e\u7d42\u4e86\u30b3\u30fc\u30c9(Elasticsearch\u306e\u8d77\u52d5\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3092\u8a2d\u5b9a)\r\n# When a JVM receives a SIGTERM signal it exits with code 143\r\nSuccessExitStatus=143\r\n\r\n# \u3010\u8ffd\u52a0\u3011swap off\u6642\u306b\u5fc5\u9808\u3068\u306a\u308b\u30d1\u30e9\u30e1\u30fc\u30bf\r\n# \u53c2\u8003\uff1ahttps:\/\/support.elastic.co\/customers\/s\/article\/How-do-I-enable-mlockall-on-Linux\r\n# Memory Limit\r\nLimitMEMLOCK=infinity\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/code><\/pre>\n<p>\uff082\uff09\u786e\u8ba4\u670d\u52a1<br \/>\n\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff0c\u786e\u8ba4\u5df2\u5c06\uff081\uff09\u521b\u5efa\u7684\u811a\u672c\u8bc6\u522b\u4e3a\u670d\u52a1\u3002<\/p>\n<pre class=\"post-pre\"><code>systemctl list-unit-files --type=service | grep node\r\n<\/code><\/pre>\n<p>\uff083\uff09\u521b\u5efa\u4e00\u4e2a\u53ef\u542f\u52a8\u8282\u70b9\u7684shell\u811a\u672c<br \/>\n\u6211\u4eec\u8981\u521b\u5efa\u4e00\u4e2a\u8c03\u7528\u4ece\u6ce8\u518c\u5230systemctl\u7684\u542f\u52a8\u811a\u672c\u7684shell\u811a\u672c\u3002<\/p>\n<pre class=\"post-pre\"><code># vi \/usr\/local\/bin\/elasticsearch_control.sh\r\n<\/code><\/pre>\n<pre class=\"post-pre\"><code>#!\/bin\/bash\r\n\r\n#### \u5909\u6570\u5b9a\u7fa9 ####\r\n## Common\r\n# Elasticsearch\u306e\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30d1\u30b9\r\nES_HOME=\/usr\/share\/elasticsearch\r\n\r\n# Elasticsearch\u306e\u30b3\u30f3\u30d5\u30a3\u30b0\u304c\u683c\u7d0d\u3055\u308c\u3066\u3044\u308b\u30d1\u30b9 \r\nES_PATH_CONF=\/etc\/elasticsearch\r\n\r\n# \u30d7\u30ed\u30bb\u30b9ID\u3092\u683c\u7d0d\u3059\u308b\u30d1\u30b9\r\nPID_DIR=\/var\/run\/my_auto_elasticsearch\r\n\r\n#ulimit\u306fOS\u5074\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u5ff5\u306e\u305f\u3081\u8a18\u8ff0\u3057\u307e\u3059\u3002\r\nulimit -n 65536\r\n\r\n# \u5f15\u6570\u3068\u3057\u3066\u6e21\u3055\u308c\u305f\u30ce\u30fc\u30c9\u306e\u7a2e\u985e\u306b\u3088\u3063\u3066\u51e6\u7406\u3092\u30d1\u30e9\u30e1\u30bf\u3092\u5909\u3048\u307e\u3059\u3002\r\ncase \"$1\" in\r\n  client)\r\n    echo \"client\"\r\n    JVM=\"-Xms8g -Xmx8g\" # JVM\r\n    FLG_MASTER=false    # Master Node Flag\r\n    FLG_DATA=false  # Data Node Flag\r\n    HTTP_PORT=9200  # REST API PORT\r\n    TCP_PORT=9300   # INTERNAL PORT\r\n    PID_FILE=client.pid # PID FILE NAME\r\n    OPTIONAL_PARM=\"\"    # OPTIONAL PARAMETER\r\n    NODE_NAME=${HOSTNAME}_CLIENT    # NODE_NAME\r\n    ;;\r\n  master)\r\n    echo \"master\"\r\n    JVM=\"-Xms8g -Xmx8g\" # JVM\r\n    FLG_MASTER=true # Master Node Flag\r\n    FLG_DATA=false  # Data Node Flag\r\n    HTTP_PORT=9290  # REST API PORT\r\n    TCP_PORT=9390   # INTERNAL PORT\r\n    PID_FILE=master.pid # PID FILE NAME\r\n    OPTIONAL_PARM=\"\"    # OPTIONAL PARAMETER\r\n    NODE_NAME=${HOSTNAME}_MASTER    # NODE_NAME\r\n    ;;\r\n  data)\r\n    echo \"data\"\r\n    JVM=\"-Xms30g -Xmx30g\"   # JVM\r\n    FLG_MASTER=false    # Master Node Flag\r\n    FLG_DATA=true   # Data Node Flag\r\n    HTTP_PORT=9210  # REST API PORT\r\n    TCP_PORT=9310   # INTERNAL PORT\r\n    PID_FILE=hot1.pid   # PID FILE NAME\r\n\r\n    # OPTIONAL PARAMETER\r\n    #  hot\/warm\u306e\u8a2d\u5b9a\u3092\u3057\u305f\u3044\u6642\u306f\u4ee5\u4e0b\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u4ed8\u4e0e\u3057\u307e\u3059\u3002 \r\n    #OPTIONAL_PARM=\"-Enode.attr.box_type=hot\"  # Hot Node\r\n    #OPTIONAL_PARM=\"-Enode.attr.box_type=warm\"  # Warm Node\r\n\r\n    NODE_NAME=${HOSTNAME}_DATA  # NODE_NAME\r\n    ;;\r\n  *)\r\n    echo $\"Usage: NODE {master|data|client}\"\r\n    exit\r\nesac\r\n\r\n#### Action ####\r\n\r\ncase \"$2\" in\r\n  start)\r\n    echo \"Start\"\r\n    sudo -u elasticsearch ES_JAVA_OPTS=\"${JVM}\" ${ES_HOME}\/bin\/elasticsearch -p ${PID_DIR}\/${PID_FILE} -d -Ehttp.port=${HTTP_PORT} -Etransport.tcp.port=${TCP_PORT} -Enode.master=${FLG_MASTER} -Enode.data=${FLG_DATA} -Enode.name=${NODE_NAME} ${OPTIONAL_PARM}\r\n\r\n    ;;\r\n\r\n  stop)\r\n    echo \"Stop\"\r\n    kill -SIGTERM `cat ${PID_DIR}\/${PID_FILE}`\r\n    ;;\r\n\r\n  *)\r\n    echo $\"Usage: ACTION {start|stop|restart}\"\r\n\r\nesac\r\n<\/code><\/pre>\n<p>\uff084\uff09\u8fdb\u884cShell\u64cd\u4f5c\u9a8c\u8bc1<\/p>\n<p>\u4f7f\u7528\u5df2\u521b\u5efa\u7684\u811a\u672c\uff0c\u4f20\u9012\u8282\u70b9\u7c7b\u578b\u548c\u63a7\u5236\u6765\u6267\u884c\u3002<br \/>\n\u786e\u4fdd\u53ef\u4ee5\u542f\u52a8\/\u505c\u6b62\u5355\u4e2a\u8282\u70b9\u548c\u5728\u6bcf\u4e2a\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\u60f3\u8981\u7684\u591a\u4e2a\u8282\u70b9\u3002<\/p>\n<pre class=\"post-pre\"><code>\/usr\/local\/bin\/elasticsearch_control.sh master start\r\n\/usr\/local\/bin\/elasticsearch_control.sh master stop\r\n<\/code><\/pre>\n<p>\uff085\uff09\u9a8c\u8bc1systemctl\u63a7\u5236\u662f\u5426\u6709\u6548\u3002<br \/>\n\u5c06\u786e\u8ba4\u662f\u5426\u80fd\u591f\u5b9e\u9645\u8fdb\u884c\u670d\u52a1\u63a7\u5236\u3002<\/p>\n<p>\u30fb\u4e3b\u8282\u70b9<\/p>\n<pre class=\"post-pre\"><code># systemctl start master_node.service\r\n# systemctl stop master_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u6570\u636e\u8282\u70b9<\/p>\n<pre class=\"post-pre\"><code># systemctl start data_node.service\r\n# systemctl stop data_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u5ba2\u6237\u8282\u70b9<\/p>\n<pre class=\"post-pre\"><code># systemctl start client_node.service\r\n# systemctl stop client_node.service\r\n<\/code><\/pre>\n<h2>\u6240\u6709\u670d\u52a1\u5668\u7684\u542f\u52a8\/\u505c\u6b62\u5217\u8868<\/h2>\n<p>\u5982\u679c\u6267\u884c\u5230\u6b64\u6b65\u9aa4\uff0c\u5e0c\u671b\u901a\u8fc7systemctl enable\u542f\u7528\u81ea\u52a8\u542f\u52a8\/\u505c\u6b62\uff0c\u4f46\u5728Elasticsearch\u591a\u8282\u70b9\u914d\u7f6e\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u679c\u4e0d\u6309\u7167\u6307\u5b9a\u7684\u6b65\u9aa4\u6267\u884c\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6570\u636e\u635f\u574f\u3002<br \/>\n\u203b\u6709\u5173\u591a\u8282\u70b9\u7684\u6307\u5b9a\u542f\u52a8\/\u505c\u6b62\u65b9\u6cd5\u5c06\u7a0d\u540e\u8be6\u8ff0\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u5efa\u8bae\u5c06\u542f\u52a8\/\u505c\u6b62\u547d\u4ee4\u8bb0\u5f55\u5728\u6587\u672c\u4e2d\u5e76\u6267\u884c\u3002<br \/>\n* \u8fc4\u4eca\u4e3a\u6b62\uff0c\u6211\u4eec\u521b\u5efa\u7684\u673a\u5236\u65e8\u5728\u901a\u8fc7\u7b80\u77ed\u7684\u547d\u4ee4\u8f7b\u677e\u5b9e\u73b0\u542f\u52a8\/\u505c\u6b62\u3002<br \/>\n* \u76ee\u524d\u4ec5\u5b58\u5728\u7ba1\u7406\u6570\u636e\uff0c\u51e0\u4e4e\u4e0d\u4f1a\u51fa\u73b0\u635f\u574f\u7684\u60c5\u51b5\u3002<\/p>\n<p>\u30fb\u7ea2\u5e3d\u4f01\u4e1aLinux #1<\/p>\n<pre class=\"post-pre\"><code># systemctl start\/stop master_node.service\r\n# systemctl start\/stop data_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u7ea2\u5e3d\u4f01\u4e1a\u7248Linux#2<\/p>\n<pre class=\"post-pre\"><code># systemctl start\/stop master_node.service\r\n# systemctl start\/stop data_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u7ea2\u5e3d\u4f01\u4e1aLinux3<\/p>\n<pre class=\"post-pre\"><code># systemctl start\/stop master_node.service\r\n# systemctl start\/stop data_node.service\r\n# systemctl start\/stop client_node.service\r\n<\/code><\/pre>\n<p>\u30fb\u7ea2\u5e3d\u4f01\u4e1a Linux \u7248\u672c4<\/p>\n<pre class=\"post-pre\"><code># systemctl start\/stop data_node.service\r\n# systemctl start\/stop client_node.service\r\n<\/code><\/pre>\n<p>\u7ea2\u5e3d\u4f01\u4e1a\u7248Linux 5<\/p>\n<pre class=\"post-pre\"><code># systemctl start\/stop data_node.service\r\n# systemctl start\/stop client_node.service\r\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u662f\u6211\u4ee5\u524d\u5728Hatena\u535a\u5ba2\u4e0a\u6295\u7a3f\u7684\u6587\u7ae0\u3002 \u9996\u5148\/\u9996\u8981 \u56e0\u4e3a\u4e0a\u4e00\u6b21\u5df2\u7ecf\u5b8c\u6210\u4e86\u57fa\u672c\u8bbe\u7f6e\uff0c\u4e3a\u4e86\u7b80\u5316\u8fd0\u8425\uff0c\u6211\u4eec\u5c06\u8003\u8651 [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-40750","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/zh\/blog\/9-\u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8-elasticsearch\u3002\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch\" \/>\n<meta property=\"og:description\" content=\"\u8fd9\u662f\u6211\u4ee5\u524d\u5728Hatena\u535a\u5ba2\u4e0a\u6295\u7a3f\u7684\u6587\u7ae0\u3002 \u9996\u5148\/\u9996\u8981 \u56e0\u4e3a\u4e0a\u4e00\u6b21\u5df2\u7ecf\u5b8c\u6210\u4e86\u57fa\u672c\u8bbe\u7f6e\uff0c\u4e3a\u4e86\u7b80\u5316\u8fd0\u8425\uff0c\u6211\u4eec\u5c06\u8003\u8651 [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/zh\/blog\/9-\u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8-elasticsearch\u3002\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2023-10-17T23:16:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-29T21:23:19+00:00\" \/>\n<meta name=\"author\" content=\"\u79d1, \u96c5\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u79d1, \u96c5\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/\",\"name\":\"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\"},\"datePublished\":\"2023-10-17T23:16:57+00:00\",\"dateModified\":\"2024-04-29T21:23:19+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/zh\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a\",\"name\":\"\u79d1, \u96c5\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g\",\"caption\":\"\u79d1, \u96c5\"},\"url\":\"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/zh\/blog\/9-\u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8-elasticsearch\u3002\/","og_locale":"zh_CN","og_type":"article","og_title":"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch","og_description":"\u8fd9\u662f\u6211\u4ee5\u524d\u5728Hatena\u535a\u5ba2\u4e0a\u6295\u7a3f\u7684\u6587\u7ae0\u3002 \u9996\u5148\/\u9996\u8981 \u56e0\u4e3a\u4e0a\u4e00\u6b21\u5df2\u7ecf\u5b8c\u6210\u4e86\u57fa\u672c\u8bbe\u7f6e\uff0c\u4e3a\u4e86\u7b80\u5316\u8fd0\u8425\uff0c\u6211\u4eec\u5c06\u8003\u8651 [&hellip;]","og_url":"https:\/\/www.silicloud.com\/zh\/blog\/9-\u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8-elasticsearch\u3002\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2023-10-17T23:16:57+00:00","article_modified_time":"2024-04-29T21:23:19+00:00","author":"\u79d1, \u96c5","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u79d1, \u96c5","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/","url":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/","name":"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website"},"datePublished":"2023-10-17T23:16:57+00:00","dateModified":"2024-04-29T21:23:19+00:00","author":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/zh\/blog\/"},{"@type":"ListItem","position":2,"name":"9- \u8003\u8651\u5b89\u88c5\u548c\u8bbe\u7f6e\u81ea\u52a8\u542f\u52a8 ElasticSearch"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#website","url":"https:\/\/www.silicloud.com\/zh\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/41e222757cdd2a3365361328bd79970a","name":"\u79d1, \u96c5","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1b2d3e00a7df03689797ebd4af8c5827ba5af936849a71050ec331f4cf902c5d?s=96&d=mm&r=g","caption":"\u79d1, \u96c5"},"url":"https:\/\/www.silicloud.com\/zh\/blog\/author\/keya\/"},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.silicloud.com\/zh\/blog\/9-%e8%80%83%e8%99%91%e5%ae%89%e8%a3%85%e5%92%8c%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e5%90%af%e5%8a%a8-elasticsearch%e3%80%82\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40750","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/comments?post=40750"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40750\/revisions"}],"predecessor-version":[{"id":89947,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/posts\/40750\/revisions\/89947"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/media?parent=40750"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/categories?post=40750"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/zh\/blog\/wp-json\/wp\/v2\/tags?post=40750"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}