Set the Elasticsearch server address

Hello,

I installed an SSL certificate after the installation and now I get the following message:

{"error": "Unable to process GET request to elasticsearch URL 'http: // localhost: 9200 / zammad_production_ticket / _doc / _search'. Elasticsearch is not reachable, probably because it's not running or even

I’ve already tried connecting to my live domain:
zammad run rails r "Setting.set ('es_url', 'https: //my.sub.domain:12312')"

My zammad.conf looks like this:
# Added - Automatically redirect HTTP to HTTPS Nginx
server {
listen 12311;
server_name my.sub.domain;
return 301 https://$host:12312$request_uri;
}

# Added - HTTPS configuration for Zammad
server {
    listen 12312 http2 ssl;

    # replace 'localhost' with your fqdn if you want to use zammad from remote
    server_name my.sub.domain;

    # security - prevent information disclosure about server version
    server_tokens off;

    root /opt/zammad/public;

    ssl_certificate /etc/letsencrypt/live/my.sub.domain/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/my.sub.domain/privkey.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;
    ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
    ssl_ecdh_curve secp384r1;
    ssl_session_cache shared:SSL:10m;
    ssl_session_tickets off;
    ssl_stapling on;
    ssl_stapling_verify on;
    resolver 8.8.8.8 8.8.4.4 valid=300s;
    resolver_timeout 5s;
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
    add_header X-Frame-Options DENY;
    add_header X-Content-Type-Options nosniff;

What do I have to do?

Hi @Phillip,

it seems like you are connecting Elasticsearch to the port where your nginx runs… but it should point to:

zammad run rails r “Setting.set(‘es_url’, ‘http://my.sub.domain:9200’)”

instead… unless you have also modified the port for Elasticsearch…

HTH,
Martin

Unable to process GET request to elasticsearch URL 'https://my.sub.domain:9200'. Elasticsearch is not reachable, probably because it's not running or even installed.

I haven’t set anything with Elasticsearch or nynsx.
Do I need port forwarding in the router?

Can you check your elasticsearch.yml for the option http.port?

I set nothing there
#http.port: 9200

But, it worked with the settings before I installed SSL and made the zammad.conf settings.

this seems to be the default value, so it should be OK.

Please run the command I posted before, this should connect Zammad with Elasticsearch

Alternatively, you can install everything from scratch and use my installer script which would take care of everything for you :wink:

Provided that you stick to the officially supported Linux distributions there.

HTH
Martin

Geez you’re really advertising your installation script agressively.
The issue seems to be that @Phillip updates the elasticsearch URL alongside his FQDN for Zammad.

If your Elasticsearch installation is a local one and you didn’t change anything in that regard (let’s ignore the change from http to https for your Zammad installation), the correct Elasticsearch URL will be:
http://localhost:9200

You’ll need to reindex your searchindex as you proberbly have lost too much time for Zammad to rerun those failing indexes.

Does not sound good :frowning:
Here is the complete output if I set according to instructions

root@zammad:/etc/elasticsearch# zammad run rails r "Setting.set('es_url', 'http://localhost:9200')"
root@zammad:/etc/elasticsearch# zammad run rake searchindex:rebuild
rake aborted!
Unable to process GET request to elasticsearch URL 'http://localhost:9200'. Elasticsearch is not reachable, probably because it's not running or even installed.

Response:
#<UserAgent::Result:0x000055a97bfe4690 @success=false, @body=nil, @data=nil, @code=0, @content_type=nil, @error="#<Errno::ECONNREFUSED: Failed to open TCP connection to localhost:9200 (Connection refused - connect(2) for \"localhost\" port 9200)>">

Payload:
null

Payload size: 0M
/opt/zammad/lib/search_index_backend.rb:32:in `info'
/opt/zammad/lib/tasks/search_index_es.rake:333:in `es_version'
/opt/zammad/lib/tasks/search_index_es.rake:343:in `es_version_supported?'
/opt/zammad/lib/tasks/search_index_es.rake:182:in `block (2 levels) in <main>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/rake-12.3.3/exe/rake:27:in `<top (required)>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `load'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli/exec.rb:28:in `run'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:463:in `exec'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:27:in `dispatch'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/cli.rb:18:in `start'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:30:in `block in <top (required)>'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/opt/zammad/vendor/bundle/ruby/2.6.0/gems/bundler-1.17.3/exe/bundle:22:in `<top (required)>'
bin/bundle:3:in `load'
bin/bundle:3:in `<main>'
Tasks: TOP => searchindex:rebuild => searchindex:version_supported
(See full trace by running task with --trace)

Your Elasticsearch is local AND running?

ss -tulpen| grep "9200" should provide at least two lines, one for your elasticsearch.

The documentation states to start and enable elasticsearch after installation:

systemctl restart elasticsearch
systemctl enable elasticsearch

Ensure ES is running and that you fullfilled all required steps.
If you updated Elasticsearch without Zammad, ensure to install the new ingest-plugin.
This step is required with every ES update.

If all that does not help, provide your elasticsearch logfiles.

hmm…

Please run:

rpm -qa | grep elasticsearch

if it is installed, you should start it:

systemctl enable --now elasticsearch <-- this will start the service even after server reboots

Everything runs locally, unless you are using an external server for Elasticsearch, so nothing needs to be modified in the router.

@MrGeneration it’s not advertising, but rather an advice.
I offered the script to the Zammad Community in order to assist fellow SysAdmins of all levels.
If suggesting people a tool that could make their life a bit easier is not encouraged here, fear not. I will not “advertise” anything else :slight_smile:

Peace out.

Timeout:

root@zammad:/etc/elasticsearch# rpm -qa | grep elasticsearch

root@zammad:/etc/elasticsearch# systemctl enable --now elasticsearch
Synchronizing state of elasticsearch.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable elasticsearch
Job for elasticsearch.service failed because a timeout was exceeded.
See "systemctl status elasticsearch.service" and "journalctl -xe" for details.

root@zammad:/etc/elasticsearch# systemctl status elasticsearch.service
● elasticsearch.service - Elasticsearch
     Loaded: loaded (/lib/systemd/system/elasticsearch.service; enabled; vendor preset: enabled)
     Active: failed (Result: timeout) since Thu 2020-11-19 13:18:41 UTC; 15min ago
       Docs: https://www.elastic.co
   Main PID: 8483 (code=exited, status=143)

Elasticsearch is no running:
Here is my solution: https://blog.sleeplessbeastie.eu/2020/02/29/how-to-prevent-systemd-service-start-operation-from-timing-out/

@rsysadmin it’s okay, I just noticed that you also tell about these scripts if the system is already installed. That’s all :wink:

@Phillip to me your solution sounds like a workaround for other issues.
I don’t know anything about the specs of your system, but if your elasticsearch already takes ages to startup, you’ll likely run into performance issues sooner or later.

Another question.
I restarted the Ubuntu server. Now the index has been updated more.

Elasticsearch was active, but I had to run the command first to get everything working again.
zammad run rake searchindex:rebuild

Is that normal and can it be automated?

WTH?? the command above shows that you do not have ES installed…

Which OS are you using? Maybe the package is called something else there…