Modify the Host Name of centos (Do not spray), and change the Host Name of centos

Source: Internet
Author: User

Modify the Host Name of centos (Do not spray), and change the Host Name of centos
1. Temporarily modify the Host Name

Show Host Name:
Spark @ master :~ $ Hostname
Master

Modify host name:
Spark @ master :~ $ Sudo hostname hadoop
Spark @ master :~ $ Hostname
Hadoop

PS: the above changes are only temporary changes, and the changes are restored after the restart.

2. Change the host name permanently.

Permanent modification on redhat/centos

[Root @ localhost ~] # Cat/etc/sysconfig/network
NETWORKING = yes
HOSTNAME = localhost. localdomain
GATEWAY = 192.168.10.1

Modify the HOSTNAME of the network. The host name is located at the beginning and the domain name is located at the end. The host name is ignored.

[Root @ localhost ~] # Vi/etc/sysconfig/network

NETWORKING = yes
NETWORKING_IPV6 = no
HOSTNAME = master

This is a permanent modification and takes effect after restart. I do not know how to take effect immediately.

To take effect immediately, you can use the first method at the same time.

Another change is:

/Etc/hosts

127.0.0.1 localhost. localdomain

The part after 127.0.0.1.

Modify on deb/ubuntu:

Hostname
Localhost. localdomain

Sudo vi/etc/hostname

Enter hostname as master in/etc/hostname

Spark @ localhost :~ $ Cat/etc/hostname
Localhost

After the restart, the prompt is changed.

Spark @ master :~ $

If you do not want to restart, use the hostname command.


3. Other modification methods


Use sysctl to modify kernel. hostname

View:

Spark @ master :~ $ Sysctl kernel. hostname
Kernel. hostname = master

Modify:

Spark @ master :~ $ Sudo sysctl kernel. hostname = hadoop
Kernel. hostname = hadoop

Re-open the shell and change it to the following hostname: hadoop

Spark @ master :~ $


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.