Cannot setup hostname and FQDN Centos 7

Solution 1:

The Red Hat documentation explicitly instructs you to use the fully qualified domain name as the machine's static hostname. Trying to name a server with a single unqualified name causes a variety of problems with various services, most notably email.

A host name can be a free-form string up to 64 characters in length. However, Red Hat recommends that both static and transient names match the fully-qualified domain name (FQDN) used for the machine in DNS, such as host.example.com.

You should be doing:

hostnamectl set-hostname server.example.com

You can also manually edit /etc/hostname for the same effect; again, it should contain the FQDN.

# cat /etc/hostname
server.example.com