Elastic agent fails to install on Centos 7

Hi,

I am getting the following error message when attempting to install Fleet agent:

Installed as a system package, installation will not be altered.
Error: failed to execute enroll command: fork/exec /usr/bin/elastic-agent: no such file or directory

The machine previously had an older version 7.15.2 and we tried to update via the Kibana, but it failed to update.

I tried manually attempt to update and that didn't work. So I removed the old installation and purged all remnants of the previous install, but still get the above error.

Any suggestions on how I get pass this error?

Regards,
Simon

Hi @sblack Welcome to the Community!

Where / How did you install the Elastic Stack: Self Managed or Elastic Cloud?

Are you trying to do Fleet Managed Agent or Standalone Agent?

How did you install the old elastic agent?

How did you remove the old agent?

And exactly how did you try to install the new elastic agent?

Hi @stephenb,

Apologies, I should have added more specific detail.

The installation is self-managed (version 8.5.3). It is a small instance in our QA environment. Elastic/Kibana/Fleet agent server is installed on a Linux machine (Centos 7) and the agent was installed on separate Linux machine (also Centos 7). There are other agents installed on other machines (also Centos) and these installed without error. Only on the machine which previously had an older version of Fleet agent (7.15.2) is there a problem.

Older agent was installed as a Fleet Managed Agent. This was when we were running Elastic-Kibana version 7.15.2. This would have been installed as follows:

 curl -L -O https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-7.15.2-linux-x86_64.tar.gz
  tar xzvf elastic-agent-7.15.2-linux-x86_64.tar.gz
  cd elastic-agent-7.15.2-linux-x86_64
  sudo ./elastic-agent install -f --url=http://<agent hostname>:8220 --enrollment-token=<token>== --insecure

We then upgraded the stack to 8.5.3. After the upgrade, we attempted to update the agent via Kibana and as I mentioned above that didn't work.

To uninstall agent, ran the following:

sudo ./elastic-agent uninstall

Downloaded the new agent tar ball, extracted, added new agent via Kibana and ran the following:

 sudo ./elastic-agent install --url=http://<agent hostname>:8220 --enrollment-token=<token>== --insecure

This threw the error:

Installed as a system package, installation will not be altered.
Error: failed to execute enroll command: fork/exec /usr/bin/elastic-agent: no such file or directory

Searching the file system, I noticed there were still remnants of previous installation, so I removed all that:

sudo rm -rf  /usr/share/elastic-agent/
sudo rm /usr/bin/elastic-agent*
sudo rm /usr/lib/systemd/system/elastic-agent.service
sudo rm /etc/rc.d/init.d/elastic-agent
sudo rm -r /etc/elastic-agent
sudo rm -r /var/lib/elastic-agent

Maybe the uninstall wasn't successful. But I would have thought that removing the above would clear the installation.

Regards,
Simon

Yup that was your first error... :slight_smile:

Per the docs, running from the local directory does not uninstall correctly / everything.

sudo /opt/Elastic/Agent/elastic-agent uninstall

Try this above command after the installation fails and see what happens.

Then try to re-install

Thanks @stephenb

/opt/Elastic/Agent/ is not present anymore. Probably got removed with the (incorrect) uninstall? :anguished:

Is there any way back in this case?

Did you try to install...

Let it fail...

Then try the uninstall command

Did you clean /opt/Elastic ohh I see it's gone..

I can't recall removing the /opt/Elastic/Agent directory. I think the first uninstall did that.

I wasn't able to install the 8.5.3 agent to get back the /opt/Elastic/Agent directory.

But I was able to successfully install the 7.15.2 agent (and then have it fail - I passed some bogus token). This created the /opt/Elastic/Agent directory`. Then successfully uninstall it.

Then tried installing 8.5.3 and get the same error message.

I am going to try installing the 7.15.2 agent again and try updating to 8.5.3.

Okay, you're making progress. I went through this before but I can't remember all my step.

That was the right thing to do to reinstall the 7.15 and then remove it properly... I thought that worked for me.

Somewhere along the line try this command

sudo /bin/systemctl daemon-reload

That worked.

I installed 7.15.2 and had it enrol. Then via Kibana, upgraded the agent.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.