Replace ElasticSearch with OpenSearch in packages (#175)

* Copy hidden files and directories

* Replace elasticsearch with opensearch in packages

* Explicitly copy .next directory .rpm packages

* Repair opensearch configuration

* Fix opensearch conf
This commit is contained in:
Elbakyan Shirak 2024-03-25 15:27:30 +04:00 committed by GitHub
parent 4bd9be04f9
commit d9edb7bcda
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 38 additions and 46 deletions

View File

@ -79,7 +79,7 @@ elif [ "$UPDATE" = "true" ] && [ "$PRODUCT_INSTALLED" = "true" ]; then
CURRENT_VERSION=$(dpkg-query -W -f='${Version}' ${product} 2>/dev/null) CURRENT_VERSION=$(dpkg-query -W -f='${Version}' ${product} 2>/dev/null)
AVAILABLE_VERSIONS=$(apt show ${product} 2>/dev/null | grep -E '^Version:' | awk '{print $2}') AVAILABLE_VERSIONS=$(apt show ${product} 2>/dev/null | grep -E '^Version:' | awk '{print $2}')
if [[ "$AVAILABLE_VERSIONS" != *"$CURRENT_VERSION"* ]]; then if [[ "$AVAILABLE_VERSIONS" != *"$CURRENT_VERSION"* ]]; then
apt-get install -o DPkg::options::="--force-confnew" -y --only-upgrade ${product} elasticsearch=${ELASTIC_VERSION} apt-get install -o DPkg::options::="--force-confnew" -y --only-upgrade ${product} opensearch=${ELASTIC_VERSION}
elif [ "${RECONFIGURE_PRODUCT}" = "true" ]; then elif [ "${RECONFIGURE_PRODUCT}" = "true" ]; then
DEBIAN_FRONTEND=noninteractive dpkg-reconfigure ${product} DEBIAN_FRONTEND=noninteractive dpkg-reconfigure ${product}
fi fi

View File

@ -31,12 +31,10 @@ fi
locale-gen en_US.UTF-8 locale-gen en_US.UTF-8
# add elasticsearch repo # add opensearch repo
ELASTIC_VERSION="7.16.3" curl -o- https://artifacts.opensearch.org/publickeys/opensearch.pgp | gpg --dearmor --batch --yes -o /usr/share/keyrings/opensearch-keyring
ELASTIC_DIST=$(echo $ELASTIC_VERSION | awk '{ print int($1) }') echo "deb [signed-by=/usr/share/keyrings/opensearch-keyring] https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/apt stable main" >> /etc/apt/sources.list.d/opensearch-2.x.list
curl -fsSL https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/elastic-${ELASTIC_DIST}.x.gpg --import ELASTIC_VERSION="2.11.1"
echo "deb [signed-by=/usr/share/keyrings/elastic-${ELASTIC_DIST}.x.gpg] https://artifacts.elastic.co/packages/${ELASTIC_DIST}.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-${ELASTIC_DIST}.x.list
chmod 644 /usr/share/keyrings/elastic-${ELASTIC_DIST}.x.gpg
# add nodejs repo # add nodejs repo
NODE_VERSION="18" NODE_VERSION="18"
@ -114,8 +112,8 @@ apt-get install -o DPkg::options::="--force-confnew" -yq \
rabbitmq-server \ rabbitmq-server \
ffmpeg ffmpeg
if ! dpkg -l | grep -q "elasticsearch"; then if ! dpkg -l | grep -q "opensearch"; then
apt-get install -yq elasticsearch=${ELASTIC_VERSION} apt-get install -yq opensearch=${ELASTIC_VERSION}
fi fi
# disable apparmor for mysql # disable apparmor for mysql

View File

@ -61,20 +61,9 @@ if ! rpm -q mysql-community-server; then
MYSQL_FIRST_TIME_INSTALL="true"; MYSQL_FIRST_TIME_INSTALL="true";
fi fi
#add elasticsearch repo #add opensearch repo
ELASTIC_VERSION="7.16.3" curl -SL https://artifacts.opensearch.org/releases/bundle/opensearch/2.x/opensearch-2.x.repo -o /etc/yum.repos.d/opensearch-2.x.repo
ELASTIC_DIST=$(echo $ELASTIC_VERSION | awk '{ print int($1) }') ELASTIC_VERSION="2.11.1"
rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
cat > /etc/yum.repos.d/elasticsearch.repo <<END
[elasticsearch]
name=Elasticsearch repository for ${ELASTIC_DIST}.x packages
baseurl=https://artifacts.elastic.co/packages/${ELASTIC_DIST}.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md
END
# add nginx repo, Fedora doesn't need it # add nginx repo, Fedora doesn't need it
if [ "$DIST" != "fedora" ]; then if [ "$DIST" != "fedora" ]; then
@ -98,7 +87,7 @@ ${package_manager} -y install $([ $DIST != "fedora" ] && echo "epel-release") \
python3 \ python3 \
nodejs ${NODEJS_OPTION} \ nodejs ${NODEJS_OPTION} \
dotnet-sdk-8.0 \ dotnet-sdk-8.0 \
elasticsearch-${ELASTIC_VERSION} --enablerepo=elasticsearch \ opensearch-${ELASTIC_VERSION} --enablerepo=opensearch-2.x \
mysql-community-server \ mysql-community-server \
postgresql \ postgresql \
postgresql-server \ postgresql-server \

View File

@ -608,15 +608,26 @@ setup_enterprise() {
change_elasticsearch_config(){ change_elasticsearch_config(){
systemctl stop elasticsearch systemctl stop opensearch
systemctl is-active --quiet elasticsearch && systemctl stop elasticsearch
local ELASTIC_SEARCH_CONF_PATH="/etc/elasticsearch/elasticsearch.yml" ELASTIC_VERSION=$(awk '/build:/{f=1} f&&/version:/{gsub(/"/,"",$2);print $2; exit}' /usr/share/opensearch/manifest.yml 2>/dev/null || echo "2.11.1")
local ELASTIC_SEARCH_JAVA_CONF_PATH="/etc/elasticsearch/jvm.options"; [[ -f "$APP_DIR/.private/opensearch-version" && $(cat $APP_DIR/.private/opensearch-version) != *$ELASTIC_VERSION* ]] && $MYSQL "$DB_NAME" -e "TRUNCATE webstudio_index";
if /usr/share/elasticsearch/bin/elasticsearch-plugin list | grep -q "ingest-attachment"; then echo "$ELASTIC_VERSION" > $APP_DIR/.private/opensearch-version
/usr/share/elasticsearch/bin/elasticsearch-plugin remove -s ingest-attachment chmod o-rwx $APP_DIR/.private/opensearch-version
sed -i '/^plugins\.security/d' /etc/opensearch/opensearch.yml
sed -i '/CN=kirk,OU=client,O=client,L=test, C=de/d' /etc/opensearch/opensearch.yml
/usr/share/opensearch/bin/opensearch-plugin remove opensearch-security
local ELASTIC_SEARCH_CONF_PATH="/etc/opensearch/opensearch.yml"
local ELASTIC_SEARCH_JAVA_CONF_PATH="/etc/opensearch/jvm.options";
if /usr/share/opensearch/bin/opensearch-plugin list | grep -q "ingest-attachment"; then
/usr/share/opensearch/bin/opensearch-plugin remove -s ingest-attachment
fi fi
/usr/share/elasticsearch/bin/elasticsearch-plugin install -s -b ingest-attachment /usr/share/opensearch/bin/opensearch-plugin install -s -b ingest-attachment
if [ -f ${ELASTIC_SEARCH_CONF_PATH}.rpmnew ]; then if [ -f ${ELASTIC_SEARCH_CONF_PATH}.rpmnew ]; then
cp -rf ${ELASTIC_SEARCH_CONF_PATH}.rpmnew ${ELASTIC_SEARCH_CONF_PATH}; cp -rf ${ELASTIC_SEARCH_CONF_PATH}.rpmnew ${ELASTIC_SEARCH_CONF_PATH};
@ -648,12 +659,6 @@ change_elasticsearch_config(){
sed -i "s/Dlog4j2.formatMsgNoLookups.*/Dlog4j2.formatMsgNoLookups=true/" ${ELASTIC_SEARCH_JAVA_CONF_PATH} sed -i "s/Dlog4j2.formatMsgNoLookups.*/Dlog4j2.formatMsgNoLookups=true/" ${ELASTIC_SEARCH_JAVA_CONF_PATH}
fi fi
if ! grep -q "ingest.geoip.downloader.enabled" ${ELASTIC_SEARCH_CONF_PATH}; then
echo "ingest.geoip.downloader.enabled: false" >> ${ELASTIC_SEARCH_CONF_PATH}
else
sed -i "s/ingest.geoip.downloader.enabled.*/ingest.geoip.downloader.enabled: false/" ${ELASTIC_SEARCH_CONF_PATH}
fi
local TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1); local TOTAL_MEMORY=$(free --mega | grep -oP '\d+' | head -n 1);
local MEMORY_REQUIREMENTS=12000; #RAM ~12Gb local MEMORY_REQUIREMENTS=12000; #RAM ~12Gb
@ -675,13 +680,13 @@ change_elasticsearch_config(){
echo "-Xmx${ELASTICSEATCH_MEMORY}" >> "${ELASTIC_SEARCH_JAVA_CONF_PATH}" echo "-Xmx${ELASTICSEATCH_MEMORY}" >> "${ELASTIC_SEARCH_JAVA_CONF_PATH}"
fi fi
if [ -d /etc/elasticsearch/ ]; then if [ -d /etc/opensearch/ ]; then
chmod g+ws /etc/elasticsearch/ chmod g+ws /etc/opensearch/
fi fi
} }
setup_elasticsearch() { setup_elasticsearch() {
echo -n "Configuring elasticsearch... " echo -n "Configuring opensearch... "
#Save elasticsearch parameters in .json #Save elasticsearch parameters in .json
[[ $1 == "EXTERNAL_ELASTIC_SERVER" ]] && local EXTERNAL_ELASTIC_FLAG="rewrite" [[ $1 == "EXTERNAL_ELASTIC_SERVER" ]] && local EXTERNAL_ELASTIC_FLAG="rewrite"
@ -693,8 +698,8 @@ setup_elasticsearch() {
if [ $1 == "LOCAL_ELASTIC_SERVER" ]; then if [ $1 == "LOCAL_ELASTIC_SERVER" ]; then
change_elasticsearch_config change_elasticsearch_config
systemctl enable elasticsearch >/dev/null 2>&1 systemctl enable opensearch >/dev/null 2>&1
systemctl restart elasticsearch systemctl restart opensearch
fi fi
echo "OK" echo "OK"
} }
@ -811,7 +816,7 @@ fi
if [[ ! -z $EXTERNAL_ELK_FLAG ]]; then if [[ ! -z $EXTERNAL_ELK_FLAG ]]; then
check_connection_external_services "$ELK_HOST" "$ELK_PORT" "Elasticsearch" check_connection_external_services "$ELK_HOST" "$ELK_PORT" "Elasticsearch"
setup_elasticsearch "EXTERNAL_ELASTIC_SERVER" setup_elasticsearch "EXTERNAL_ELASTIC_SERVER"
elif $PACKAGE_MANAGER elasticsearch >/dev/null 2>&1; then elif $PACKAGE_MANAGER opensearch >/dev/null 2>&1; then
setup_elasticsearch "LOCAL_ELASTIC_SERVER" setup_elasticsearch "LOCAL_ELASTIC_SERVER"
fi fi

View File

@ -120,7 +120,7 @@ reassign_values (){
WORK_DIR="${BASE_DIR}/products/ASC.Files/service/" WORK_DIR="${BASE_DIR}/products/ASC.Files/service/"
EXEC_FILE="ASC.Files.Service.dll" EXEC_FILE="ASC.Files.Service.dll"
CORE_EVENT_BUS=" --core:eventBus:subscriptionClientName=asc_event_bus_files_service_queue" CORE_EVENT_BUS=" --core:eventBus:subscriptionClientName=asc_event_bus_files_service_queue"
DEPENDENCY_LIST="${DEPENDENCY_LIST} elasticsearch.service" DEPENDENCY_LIST="${DEPENDENCY_LIST} opensearch.service"
;; ;;
studio ) studio )
SERVICE_PORT="5003" SERVICE_PORT="5003"

View File

@ -56,7 +56,7 @@ Package: {{product}}-files
Architecture: all Architecture: all
Multi-Arch: foreign Multi-Arch: foreign
Depends: {{product}}-common (= {{package_header_tag_version}}), dotnet-sdk-8.0, ${misc:Depends}, ${shlibs:Depends} Depends: {{product}}-common (= {{package_header_tag_version}}), dotnet-sdk-8.0, ${misc:Depends}, ${shlibs:Depends}
Recommends: elasticsearch (= 7.16.3) Recommends: opensearch (= 2.11.1)
Description: {{product}}-files Description: {{product}}-files
The service which handles API requests related to The service which handles API requests related to
documents and launches the OFormService service documents and launches the OFormService service
@ -65,7 +65,7 @@ Package: {{product}}-files-services
Architecture: all Architecture: all
Multi-Arch: foreign Multi-Arch: foreign
Depends: {{product}}-common (= {{package_header_tag_version}}), dotnet-sdk-8.0, ${misc:Depends}, ${shlibs:Depends} Depends: {{product}}-common (= {{package_header_tag_version}}), dotnet-sdk-8.0, ${misc:Depends}, ${shlibs:Depends}
Recommends: ffmpeg, elasticsearch (= 7.16.3) Recommends: ffmpeg, opensearch (= 2.11.1)
Description: {{product}}-files-services Description: {{product}}-files-services
The service which launches additional services related to file management: The service which launches additional services related to file management:
- ElasticSearchIndexService - indexes documents using elasticsearch; - ElasticSearchIndexService - indexes documents using elasticsearch;
@ -79,7 +79,7 @@ Package: {{product}}-notify
Architecture: all Architecture: all
Multi-Arch: foreign Multi-Arch: foreign
Depends: {{product}}-common (= {{package_header_tag_version}}), dotnet-sdk-8.0, ${misc:Depends}, ${shlibs:Depends} Depends: {{product}}-common (= {{package_header_tag_version}}), dotnet-sdk-8.0, ${misc:Depends}, ${shlibs:Depends}
Recommends: ffmpeg, elasticsearch (= 7.16.3) Recommends: ffmpeg, opensearch (= 2.11.1)
Description: {{product}}-notify Description: {{product}}-notify
The service which launches additional services The service which launches additional services
related to notifications about DocSpace events: related to notifications about DocSpace events: