CentOS 7 : Elasticsearch ¼³Ä¡ ¹æ¹ý, ¿¹Á¦, ¸í·É¾î
Elastic °Ë»öÀº ¿ÀÇ ¼Ò½º ºÐ»ê Àüü ÅؽºÆ® °Ë»ö ¹× ºÐ¼® ¿£ÁøÀÔ´Ï´Ù. RESTful ÀÛ¾÷À» Áö¿øÇÏ¸ç ´ë¿ë·® µ¥ÀÌÅ͸¦ ½Ç½Ã°£À¸·Î ÀúÀå, °Ë»ö ¹× ºÐ¼®ÇÒ ¼ö ÀÖ½À´Ï´Ù. ź·ÂÀû °Ë»öÀº ´ëÇü ÀüÀÚ»ó°Å·¡ ½ºÅä¾î ¹× ºÐ¼® ÀÀ¿ëÇÁ·Î±×·¥°ú °°Àº º¹ÀâÇÑ °Ë»ö ¿ä±¸»çÇ×À» °¡Áø ÀÀ¿ëÇÁ·Î±×·¥À» ±¸µ¿ÇÏ´Â °¡Àå Àαâ ÀÖ´Â °Ë»ö ¿£Áø Áß ÇϳªÀÔ´Ï´Ù.
CentOS 7¿¡ Elastic searchÀ» ¼³Ä¡ÇÏ´Â ¹æ¹ý¿¡ ´ëÇØ ¼³¸íÇÕ´Ï´Ù.
ÀüÁ¦Á¶°Ç
·Î±×ÀÎÇÑ »ç¿ëÀÚ¿¡°Ô sudo ±ÇÇÑÀÌ ÀÖ½À´Ï´Ù¾ß ÆÐÅ°Áö¸¦ ¼³Ä¡ÇÒ ¼ö ÀÖ½À´Ï´Ù.
Elastic search ¼³Ä¡
Cent OS7¿¡ Elastic searchÀ» ¼³Ä¡ÇÏ´Â ±ÇÀå ¹æ¹ýÀº °ø½Ä Elastic search ÀúÀå¼Ò¿¡¼ rpm ÆÐÅ°Áö¸¦ ¼³Ä¡ÇÏ´Â °ÍÀÔ´Ï´Ù.
Elastic °Ë»öÀÇ ÃֽŠ¹öÀüÀº 6.7À̸ç Java 8 ÀÌ»óÀÌ ÇÊ¿äÇÕ´Ï´Ù.
CentOS ½Ã½ºÅÛ À¯Çü¿¡ OpenJDK 8À» ¼³Ä¡ÇÏ·Á¸é ´ÙÀ½°ú °°ÀÌ ÇϽʽÿÀ.
sudo yum install java-1.8.0-openjdk-devel
Java ¹öÀüÀ» ÀμâÇÏ¿© Java ¼³Ä¡¸¦ È®ÀÎÇÕ´Ï´Ù.
java -version
# openjdk version "1.8.0_201"
# OpenJDK Runtime Environment (build 1.8.0_201-b09)
# OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode)
ÀÌÁ¦ Java°¡ ¼³Ä¡µÇ¾úÀ¸¹Ç·Î ´ÙÀ½ ´Ü°è´Â Elastic °Ë»ö ÀúÀå¼Ò¸¦ Ãß°¡ÇÏ´Â °ÍÀÔ´Ï´Ù.
´ÙÀ½ ¸í·ÉÀ» »ç¿ëÇÏ¿© ¸®Æ÷ÁöÅ丮ÀÇ GPG Å°¸¦ °¡Á®¿É´Ï´Ù.
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
ÅؽºÆ® ÆíÁý±â¸¦ ¿°í ´ÙÀ½ repo ÆÄÀÏÀ» ¸¸µì´Ï´Ù.
´ÙÀ½ ³»¿ëÀ» ÆÄÀÏ¿¡ ºÙ¿©³Ö½À´Ï´Ù.
# /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-6.x]
name=Elasticsearch repository for 6.x packages
baseurl=https://artifacts.elastic.co/packages/6.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
ÆÄÀÏÀ» ÀúÀåÇÏ°í ÅؽºÆ® ÆíÁý±â¸¦ ´Ý½À´Ï´Ù.
ÀÌÀü ¹öÀüÀÇ Elastic searchÀ» ¼³Ä¡ÇÏ·Á¸é À§ÀÇ ¸í·É¿¡¼ ÇÊ¿äÇÑ ¹öÀüÀ¸·Î 6.x¸¦ º¯°æÇϽʽÿÀ.
ÀÌÁ¦ ´ÙÀ½À» ÀÔ·ÂÇÏ¿© Elastic search ÆÐÅ°Áö¸¦ ¼³Ä¡ÇÒ ¼ö ÀÖ½À´Ï´Ù.
¼³Ä¡ ÇÁ·Î¼¼½º°¡ ¿Ï·áµÇ¸é ´ÙÀ½À» ½ÇÇàÇÏ¿© ¼ºñ½º¸¦ ½ÃÀÛÇÏ°í È°¼ºÈÇÕ´Ï´Ù.
sudo yum install elasticsearch sudo systemctl enable elasticsearch.service sudo systemctl start elasticsearch.service
´ÙÀ½ curl ¸í·ÉÀ» »ç¿ëÇÏ¿© ·ÎÄà ȣ½ºÆ®ÀÇ Æ÷Æ® 9200¿¡ HTTP ¿äûÀ» Àü¼ÛÇÏ¿© Elastic °Ë»öÀÌ ½ÇÇà ÁßÀÎÁö È®ÀÎÇÒ ¼ö ÀÖ½À´Ï´Ù.
curl -X GET "localhost:9200/"
{
"name" : "9KagRGb",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "mwwmjfApSFSeAFCEb4EktA",
"version" : {
"number" : "6.8.23",
"build_flavor" : "default",
"build_type" : "rpm",
"build_hash" : "4f67856",
"build_date" : "2022-01-06T21:30:50.087716Z",
"build_snapshot" : false,
"lucene_version" : "7.7.3",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}
¼ºñ½º¸¦ ½ÃÀÛÇÏ´Â µ¥ 5-10ÃÊ°¡ °É¸± ¼ö ÀÖ½À´Ï´Ù. ÄÃÀÌ Ç¥½ÃµÇ¸é (7) ·ÎÄà ȣ½ºÆ® Æ÷Æ® 9200¿¡ ¿¬°áÇÏÁö ¸øÇß½À´Ï´Ù. ¿¬°áÀÌ °ÅºÎµÇ¾ú½À´Ï´Ù. ¸î ÃÊ°£ ±â´Ù¸° ÈÄ ´Ù½Ã ½ÃµµÇϽʽÿÀ.
Elastic °Ë»ö ¼ºñ½º¿¡¼ ±â·ÏÇÑ ¸Þ½ÃÁö¸¦ º¸·Á¸é ¾Æ·¡ ¸í·ÉÀ» »ç¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù.
sudo journalctl -u elasticsearch
ÀÌ ½ÃÁ¡¿¡¼ CentOS ¼¹ö¿¡ Elastic searchÀÌ ¼³Ä¡µÇ¾î ÀÖ½À´Ï´Ù.
Elasticsearch ±¸¼º
Elasticsearch µ¥ÀÌÅÍ´Â /var/lib/elastic °Ë»ö µð·ºÅ丮¿¡ ÀúÀåµÇ°í ±¸¼º ÆÄÀÏÀº /etc/elastic °Ë»ö¿¡ ÀÖ½À´Ï´Ù.
±âº»ÀûÀ¸·Î Elastic searchÀº ·ÎÄà ȣ½ºÆ®¿¡¼¸¸ ¼ö½ÅÇϵµ·Ï ±¸¼ºµË´Ï´Ù. µ¥ÀÌÅͺ£À̽º¿¡ ¿¬°áÇϴ Ŭ¶óÀ̾ðÆ®µµ µ¿ÀÏÇÑ È£½ºÆ®¿¡¼ ½ÇÇà ÁßÀÌ°í ´ÜÀÏ ³ëµå Ŭ·¯½ºÅ͸¦ ¼³Á¤ÇÏ´Â °æ¿ì¿¡´Â ±âº» ±¸¼º ÆÄÀÏÀ» º¯°æÇÒ ÇÊ¿ä°¡ ¾ø½À´Ï´Ù.
¿ø°Ý ¾×¼¼½º
±âº»ÀûÀ¸·Î Elastic searchÀº HTTP API¿¡ ¾×¼¼½ºÇÒ ¼ö ÀÖ´Â »ç¿ëÀÚ°¡ ¾×¼¼½ºÇÒ ¼ö ÀÖµµ·Ï ÀÎÁõÀ» ±¸ÇöÇÏÁö ¾Ê½À´Ï´Ù. Elastic °Ë»ö ¼¹ö¿¡ ´ëÇÑ ¿ø°Ý ¾×¼¼½º¸¦ Çã¿ëÇÏ·Á¸é ¹æȺ®À» ±¸¼ºÇÏ°í ½Å·ÚÇÒ ¼ö Àִ Ŭ¶óÀ̾ðÆ®¿¡¼¸¸ Elastic °Ë»ö Æ÷Æ® 9200¿¡ ´ëÇÑ ¾×¼¼½º¸¦ Çã¿ëÇØ¾ß ÇÕ´Ï´Ù.
Cent OS 7, FirewallD´Â iptables¸¦ ±âº» ¹æȺ® °ü¸® µµ±¸·Î ´ëüÇÕ´Ï´Ù.
Æ÷Æ® 9200ÀÇ ¿ø°Ý ½Å·Ú IP ÁÖ¼Ò¿¡¼ Æò°¡¸¦ Çã¿ëÇÏ·Á¸é ´ÙÀ½ ¸í·ÉÀ» ½ÇÇàÇÕ´Ï´Ù.
sudo firewall-cmd --new-zone=elasticsearch --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --zone=elasticsearch --add-source=192.168.121.80/32 --permanent
sudo firewall-cmd --zone=elasticsearch --add-port=9200/tcp --permanent
sudo firewall-cmd --reload
¿ø°Ý IP ÁÖ¼Ò·Î 192.168.121.80À» º¯°æÇÏ´Â °ÍÀ» ÀØÁö ¸¶½Ê½Ã¿À.
³ªÁß¿¡ ´Ù¸¥ IP ÁÖ¼ÒÀÇ ¾×¼¼½º¸¦ Çã¿ëÇÏ·Á¸é ´ÙÀ½À» »ç¿ëÇÕ´Ï´Ù.
sudo firewall-cmd --zone=elasticsearch --add-source=<IP_ADDRESS> --permanent
sudo firewall-cmd --reload
¹æȺ®ÀÌ ±¸¼ºµÇ¸é ´ÙÀ½ ´Ü°è´Â Elastic search ±¸¼ºÀ» ÆíÁýÇÏ°í Elastic searchÀÌ ¿ÜºÎ ¿¬°áÀ» ¼ö½ÅÇϵµ·Ï ÇÏ´Â °ÍÀÔ´Ï´Ù.
ÀÌ·¸°Ô ÇÏ·Á¸é elastic search.yml ±¸¼º ÆÄÀÏÀ» ¿©½Ê½Ã¿À.
³×Æ®¿öÅ©°¡ Æ÷ÇÔµÈ ÁÙÀ» °Ë»öÇÕ´Ï´Ù.È£½ºÆ®, ÁÖ¼® ´ÞÁö ¾Ê°í °ªÀ» 0.0.0.0À¸·Î º¯°æÇÕ´Ï´Ù.
# /etc/elasticsearch/elasticsearch.yml
network.host: 0.0.0.0
½Ã½ºÅÛ¿¡ ³×Æ®¿öÅ© ÀÎÅÍÆäÀ̽º°¡ ¿©·¯ °³ ÀÖ´Â °æ¿ì ÀÎÅÍÆäÀ̽º IP ÁÖ¼Ò¸¦ ÁöÁ¤ÇÒ ¼ö ÀÖÀ¸¸ç, ÀÌ·Î ÀÎÇØ Elastic searchÀº ÁöÁ¤µÈ ÀÎÅÍÆäÀ̽º¿¡¼¸¸ ¼ö½Å ´ë±âÇÏ°Ô µË´Ï´Ù.
Elastic search ¼ºñ½º¸¦ ´Ù½Ã ½ÃÀÛÇÏ¿© º¯°æ ³»¿ëÀ» Àû¿ëÇÕ´Ï´Ù.
sudo systemctl restart elasticsearch
ÀÌÁ¦ ¿ø°Ý À§Ä¡¿¡¼ Elastic search ¼¹ö¿¡ ¿¬°áÇÒ ¼ö ÀÖ½À´Ï´Ù.