강의에서는 Opensearch, Open Dashboard - 2.4.0 버전을 사용한다.
이 강의에서는 기본적인 설치만 다룬다. 더 자세한 설치와 설정 방법은 매뉴얼을 참고.
기본설치는 다음 특징을 갖는다.
설정을 Open Dashboard에서 편하게 할 수 있으므로, 5.1 Open Dashboard
설치하기도 함께 진행한다.
설치하기 전에는 항상 아래 내용이 설치되었는지 확인한다.
sudo apt update
sudo apt install build-essential -y
다운로드 링크 에서 자신의 환경에 맞는 파일을 다운로드 받는다.
# x64
wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.4.0/opensearch-2.4.0-linux-x64.tar.gz
# ARM64
wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.4.0/opensearch-2.4.0-linux-arm64.tar.gz
# x64
tar -xvf opensearch-2.4.0-linux-x64.tar.gz
# ARM64
tar -xvf opensearch-2.4.0-linux-arm64.tar.gz
cd opensearch-2.4.0
export OPENSEARCH_HOME=$(pwd)
주요 디렉토리
bin
: 실행파일들의 위치config
: 설정 파일의 위치. 부팅하기 전에 설정을 완료해야한다.data
: opensearch 가 데이터를 저장하는 위치jdk
: 내장 JDK. Host 에 JDK가 설치되어있지 않으면 사용한다.logs
: log 디렉토리plugins
: plugin 의 위치DB종류들은 system 세팅이 필요하다.
아래 내용은 실습을 위한 간단한 세팅이므로, 고성능이 필요하다면 따로 검토해야한다.
sudo swapoff -a
# Edit the sysctl config file
sudo vi /etc/sysctl.conf
# Add a line to define the desired value
# or change the value if the key exists,
# and then save your changes.
vm.max_map_count=262144
# Reload the kernel parameters using sysctl
sudo sysctl -p
# Verify that the change was applied by checking the value
cat /proc/sys/vm/max_map_count
Port number | OpenSearch component |
---|---|
443 | OpenSearch Dashboards in AWS OpenSearch Service with encryption in transit (TLS) |
5601 | OpenSearch Dashboards |
9200 | OpenSearch REST API |
9250 | Cross-cluster search |
9300 | Node communication and transport |
9600 | Performance Analyzer |
opensearch.yml
vi $OPENSEARCH_HOME/config/opensearch.yml
# Bind OpenSearch to the correct network interface. Use 0.0.0.0
# to include all available interfaces or specify an IP address
# assigned to a specific interface.
network.host: 0.0.0.0
# Unless you have already configured a cluster, you should set
# discovery.type to single-node, or the bootstrap checks will
# fail when you try to start the service.
discovery.type: single-node
# If you previously disabled the security plugin in opensearch.yml,
# be sure to re-enable it. Otherwise you can skip this setting.
# plugins.security.disabled: true
jvm.options
.vi $OPENSEARCH_HOME/config/jvm.options
-Xms128m
-Xmx128m
export OPENSEARCH_JAVA_HOME=$OPENSEARCH_HOME/jdk
Opensearch의 다양한 기능들은 plugin 방식으로 개발되어있다. Opensearch 기본은 데이터 저장과 인덱싱 방법을 제공하는 것이고, 그것을 활용하는 로직은 plugin 에 구현되어 있다.
플러그인 매뉴얼 ( + 지원가능한 플러그인 리스트)
다음 명령어들을 활용한다. sudo 권한이 있어야 한다. 내부적으로 maven 을 이용해서 설치한다.
bin/opensearch-plugin list
bin/opensearch-plugin install $plugin-name
bin/opensearch-plugin remove $plugin-name
설치한 플러그인은 $OPENSEARCH_HOME/plugins
디렉토리에 설치된다.
원활한 실습을 위해서 security 관련 플러그인을 제거한다.
bin/opensearch-plugin remove opensearch-security
bin/opensearch-plugin remove opensearch-security-analytics
$OPENSEARCH_HOME 에서
./bin/opensearch
로 실행한다.
확인
curl -X GET http://$IP:9200
결과
{
"name" : $YOUR_HOSTNAME,
"cluster_name" : "opensearch",
"cluster_uuid" : "pS8BqBFcTiyQBr62148MxA",
"version" : {
"distribution" : "opensearch",
"number" : "2.4.0",
"build_type" : "tar",
"build_hash" : "744ca260b892d119be8164f48d92b8810bd7801c",
"build_date" : "2022-11-15T04:42:29.671309257Z",
"build_snapshot" : false,
"lucene_version" : "9.4.1",
"minimum_wire_compatibility_version" : "7.10.0",
"minimum_index_compatibility_version" : "7.0.0"
},
"tagline" : "The OpenSearch Project: https://opensearch.org/"
}
설정파일
sudo vi /etc/systemd/system/opensearch.service
내용
[Unit]
Description=OpenSearch
Wants=network-online.target
After=network-online.target
[Service]
Type=forking
RuntimeDirectory=data
WorkingDirectory=$YOUR_OPENSEARCH_HOME
ExecStart=$YOUR_OPENSEARCH_HOME/bin/opensearch -d
User=$YOUR_USER
Group=$YOUR_USER
StandardOutput=journal
StandardError=inherit
LimitNOFILE=65535
LimitNPROC=4096
LimitAS=infinity
LimitFSIZE=infinity
TimeoutStopSec=0
KillSignal=SIGTERM
KillMode=process
SendSIGKILL=no
SuccessExitStatus=143
TimeoutStartSec=75
[Install]
WantedBy=multi-user.target
$YOUR_OPENSEARCH_HOME
을 자신의 경로에 맞게 수정한다.$YOUR_USER
도 자신이 사용할 유저에 맞게 수정한다. $YOUR_OPENSEARCH_HOME
에 대한 소유권한 ( chown )이$YOUR_USER
에게 있어야 한다.등록
sudo systemctl daemon-reload
sudo systemctl enable opensearch.service
systemctl로 opensearch 시작
sudo systemctl start opensearch.service
ps -ef | grep opensearch
로그 확인
tail -f $OPENSEARCH_HOME/logs/opensearch.log