Can't enable read only mode

Hello there

I got stuck after updating Enterprise Search from version 7.14 to 7.17. Based on app-server.log there needs to be migrations performed which is clear. The option 'skip_read_only_check' is on FALSE as per default and I don't dare to enable it.
Now there are 2 possible options how to enable Read Only. First over API - this can't be done, since I can't start Enterprise, therefore API isn't running. and the second is over parameter on start:

/usr/share/enterprise-search/bin/enterprise-search --enable-read-only-mode

I'm on CentOS, installed through RPM "Elasticsearch repository for 7.x packages" (in the middle of migration off it, since CentOS has been EOL)
And this is also not working for me, this is optput when I start Enterprise with that parameter

Java version detected: 11.0.14 (major version: 11)
Enterprise Search is starting...

ERROR: Encoding must be UTF-8!
Please set `JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8'`

In the guide at:

stands that it's possible to change JAVA_OPTS which are read by elastic on start, which seems to be true, because when I put there something invalid, I got error on it. So i chnged the line with JAVA_OPTS as follows:

export JAVA_OPTS=${JAVA_OPTS:-"-Xms2g -Xmx2g -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8"}

Also tried this

export JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8'

Still getting the same error. Now I'm out of ideas. Any suggestions?

Hi @Libor_Chaloupek, just to clarify.

  1. When you're running this:
    export JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8'
    and then this:
    /usr/share/enterprise-search/bin/enterprise-search --enable-read-only-mode
    Are you doing it in the same terminal?

  2. What happens if you run it like this?
    JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8' /usr/share/enterprise-search/bin/enterprise-search --enable-read-only-mode

  3. Can you configure these values in config/env.sh as the doc proposes?

Hi @maryna.cherniavska. Thank you for your quick response.

Yes I teried both 1 & 2 in the same terminal. I verified also whether that export worked. Here is output:

[root@stage15:~]# export JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8'
[root@stage15:~]# echo $JAVA_OPTS
-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8
[root@stage15:~]# /usr/share/enterprise-search/bin/enterprise-search --enable-read-only-mode
Found java executable in PATH
Java version detected: 11.0.14 (major version: 11)
Enterprise Search is starting...

ERROR: Encoding must be UTF-8!
Please set `JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8'`

[root@stage15:~]# JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8' /usr/share/enterprise-search/bin/enterprise-search --enable-read-only-mode
Found java executable in PATH
Java version detected: 11.0.14 (major version: 11)
Enterprise Search is starting...

ERROR: Encoding must be UTF-8!
Please set `JAVA_OPTS='-Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8'`

This is under root as you can see, just to be sure, no permissions will stop it. I've also tried my own account and also over chroot as enterprise-search user like the service does. Always exporting variables in that terminal and then launch.

And regarding 3rd point - yes, I've modified the file

/usr/share/enterprise-search/config/env.sh

With the 2 export lines mentioned in my first post. As I mentioned, I also tried to supply there some invalid values to verify whether the file is truly being read on start. And that really generated error. So the file is read.

Hello, Libor,

Sorry you'e having problems trying to run Enterprise Search.

If you're using some kind of minimal CentOS environment, there may be an issue with the fact that nowadays Java tries to be smart about picking the right locale and, when locales are missing on the underlying OS, it falls back to some defaults that do not work with Enterprise Search. We have seen this in our Docker containers for example. Here is a Github issue discussing that behavior: Default locale is set to en_US.UTF-8 but it's missing · Issue #71 · CentOS/sig-cloud-instance-images · GitHub and the Redhat bug for the underlying problem: 1677927 – Unable to invoke localedef to UTF-8: cannot read character map directory `/usr/share/i18n/charmaps'.

Anyways, what you can try to fix is is to install (or reinstall) the english locale. Depending on the CentOS version:

For 7.x:

yum -y reinstall glibc-common
localedef -i en_US -f UTF-8 en_US.UTF-8

For 8.x:

yum -y install glibc-langpack-en

I hope this helps.

1 Like

HI @oleksiy-elastic. Problem resolved, thank you very much.

Reinstalling language packs doesn't reloved that problem. But with that you pointed me in right direction.

Story:
I've already installed latest version of glibc-common, like all other packages i'm running. Because I updated alle of them using yum update just yesterday after longer time and unpdated all of them. So The problem truly relies somewhere on newer behaviour of Java 11 which has been updated too.

While executing yum, i've noticed I got this warning:

Failed to set locale, defaulting to C

by checking locales like this, i've got also some issues:

[root@stage15:~]# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=c.UTF-8
LC_CTYPE="c.UTF-8"
LC_NUMERIC="c.UTF-8"
LC_TIME="c.UTF-8"
LC_COLLATE="c.UTF-8"
LC_MONETARY="c.UTF-8"
LC_MESSAGES="c.UTF-8"
LC_PAPER="c.UTF-8"
LC_NAME="c.UTF-8"
LC_ADDRESS="c.UTF-8"
LC_TELEPHONE="c.UTF-8"
LC_MEASUREMENT="c.UTF-8"
LC_IDENTIFICATION="c.UTF-8"
LC_ALL=

So I corrected that by suppliying golobal configuration in

/etc/profile.d/custom.lang.sh

export LANG=en_US.UTF-8
export LANGUAGE=en_US.UTF-8
export LC_COLLATE=C
export LC_CTYPE=en_US.UTF-8

...executed that file to avoid restarting terminal and viola. The --enable-read-only-mode worked!

Thank you very much :slight_smile:

1 Like