Failed to create fleet server elastic agent in Ubuntu

i have download the .tar.gz elastic agent version 9.1

after extract it, i got error when running the installation

sudo ./elastic-agent install \
  --fleet-server-es=https://redacted \
  --fleet-server-service-token=redacted \
  --fleet-server-policy=fleet-server-policy \
  --fleet-server-es-ca-trusted-fingerprint=redacted \
  --fleet-server-port=8220 \
  --install-servers

Installed as a system package, installation will not be altered.
[    ] Failed to Enroll  [0s] Error uninstalling. Printing logs
Error: failed to execute enroll command: fork/exec /usr/bin/elastic-agent: no such file or directory
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

i have delete all existing elastic-agent in

/opt/Elastic/*
/usr/share/elastic-agent/*

i redownloaded the .tar.zip from https://artifacts.elastic.co/downloads/beats/elastic-agent/elastic-agent-9.1.0-linux-x86_64.tar.gz, and check the sha512 but still got error like that, im so frustated with this issue. what should i do?

edited

i forgot to give another info, i miss download and install the arm64 linux one instead of x86_64

when i install it, the log shows like this

./elastic-agent: 1: ELF�@8: not found
./elastic-agent: 2: @%$@@@0pppL0LMNN
                                    �
                                     0�0�0�0P�dLMLLMLLML� not found
./elastic-agent: 2: � not found
./elastic-agent: 2: Q�dMNR�dMNN� not found
./elastic-agent: 3: � not found
./elastic-agent: 4: /lib/ld-linux-aarch64.so.1GNUSGoHpK7IeWlq96IQeXsoVj3/i3ea7Cb9xdzmNLjFQhKz/pxjP8ciBVSxEwhYjCIds/YpyI2LPTNrPr8-9zAnxZGNUAkDe[� not found
./elastic-agent: 1: Syntax error: Unterminated quoted string

is there any correlation about this?

Hello @Adib_Aulia_Rahmansya

Welcome to the community!!

Could you please share the latest issue & logs :

  1. You tried installing the elastic-agent arm64 linux.
  2. It gave error & you deleted the below folders :
/opt/Elastic/*
/usr/share/elastic-agent/*
  1. You downloaded the elastic-agent x86_64 & are now trying to install it again which throws same error or new error?

Maybe try to uninstall it first and then follow the steps related to installation & see what is the error?

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

Reference URL for troubleshooting :

Thanks!!

1 Like

Hello!

My VM is Ubuntu with x86_64 architecture
I wrongly install the arm64 one, then i download the x86_64 and do the install fleet server. The logs shows like this

Installed as a system package, installation will not be altered.
[    ] Failed to Enroll  [0s] Error uninstalling. Printing logs
Error: failed to execute enroll command: fork/exec /usr/bin/elastic-agent: no such file or directory
For help, please see our troubleshooting guide at https://www.elastic.co/guide/en/fleet/9.1/fleet-troubleshooting.html

I can't do sudo /opt/Elastic/Agent/elastic-agent uninstall because the /opt/Elastic/Agent is empty

Hi @Adib_Aulia_Rahmansya

Yeah you got yourself in a bad position here...

I would try to install the correct package... Again

Then whether it installs correctly or not. I would then try to uninstall it using the correct command...

Let us know if that works or not. I might have a couple other hack suggestions at this point, but trying to install the wrong architecture is bad and we should probably warn you about that but at this point we need to get you fixed.

I suspect you have a package installed with the architecture wrong and trying to uninstall it with the different architecture isn't working but we need to give it a try.

I have been do that, install and uninstall again and got frustated because nothing works with .tar.gz installation. So i decided to use the deb package installation to make it work but i know i can't easily upgrade version when available via fleet.

What are hack suggestions you want to suggest?

Hi @Adib_Aulia_Rahmansya

I appreciate the frustration...

However, The tar.gz on Ubuntu x86 works fine... it has been installed 1000s of times, I have installed it many times myself.

The problem is that the initial installation was installed with the wrong architecture, which unpacked the files but would not install / uninstall because the binaries were unexecutable... == bad state.

Then the installation directories were manually removed.... == bad state

Just recapping...

So your system is in a broken/inconsistent state... Badly

So what I would probably do is the following... as an extreme / hack / workaround

  1. Go to another Uhbutu x86 and install the agent as a standalone, it probably does not really matter if it fully connects etc, just that the install uppacks etc.
  2. Then I would tar up the /opt/Elastic/Agent directory...
  3. Copy that to your broken machine
  4. Untar It into /opt/Elasti/Agent
  5. Make sure the permissions and executables are correct
  6. Make sure the directory and files look the same as on the other / correct machine
  7. Also, copy the /usr/bin/elastic-agent over to the broken system NOTE this is a script do not just copy the one from the /opt directory they are different
  8. Then run the

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

Command

See what happens

Then try to reinstall correctly

Then I would probably uninstall one more time to make sure everything is programmatically cleaned up.

Then I would think you should be in a clean state ...

Then install again...

NO this is not expected but, the system is in a really bad state...

1 Like

Okey, i will do it

but for now, i successfully install the deb version and use it smoothly. I should remove it first via apt then would it have any issue like this again?

Yes first uninstall the deb package using the appropriate apt command if you want to clean up the other.

To be clear I am not sure my steps will work because I have never had a system in the same state as yours... But its worth a try... I have used similar to clean up other errors I have made.

Update, I have succesfully install the elastic agent using your method. Thankyou so much! Now my elastic agent much cleanerr and smooth!

1 Like

@Adib_Aulia_Rahmansya YAY!! Nicely done... glad we could help.

You are not the first nor the last to get an installation mucked up... we have all done it... glad we could undo it!

1 Like