1、修改/etc/hostname

vi /etc/hostname

打开之后的内容是:

localhost.localdomain

把它修改成想要的名字就可以,比如:master

保存退出

2、修改/etc/hosts文件

vi /etc/hosts

打开之后的内容是:

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

然后在最后面加一行:

192.168.80.10   master

保存退出,然后重启机器,这时候就可以通过hostname来访问这台机器的服务了

3、映射互访问(如master和slave1)

在/etc/hosts里面再加一行:

192.168.80.10    master

192.168.80.11    slave1

4、查看主机名:

uname -n //单独主机名

uname -a  //详细信息

hostname //单独主机名

查看主机IP:

hostname -i //主机IP

centos7修改hostname和hosts的更多相关文章

  1. CentOS7设置hostname、hosts、静态IP地址、关闭防火墙

    针对新安装或者克隆后的虚拟机配置 1. 设置hostname 方法1: centos7 里面修改hostname的方式有所改变,修改/etc/hosts和/etc/sysconfig/network两 ...

  2. centos7修改hostname

    [root@centos7 ~]$ hostnamectl set-hostname prd_web1 # 使用这个命令会立即生效且重启也生效 [root@centos7 ~]$ hostname # ...

  3. centOS7 修改hostname

    hostnamectl set-hostname 你要修改到的hostname   localectl set-locale LANG=要修改的语言     介绍个Centos 7很不错的教程网站:h ...

  4. centos 修改hostname

    centos修改主机名的正确方法 1 centos6下修改hostname [root@centos6 ~]$ hostname # 查看当前的hostnmae centos6.magedu.com ...

  5. Liunx centos 系统 修改hostname

    1 centos6下修改hostname [root@centos6 ~]$ hostname # 查看当前的hostnmae centos6.magedu.com [root@centos6 ~]$ ...

  6. Centos7中修改Hostname的方法

    一.Centos7中修改的方法: hostnamectl set-hostname <new hostname> 说明:centOS 7 里面修改hostname的方式有所改变,修改/et ...

  7. CentOS 7 修改hostname

    centOS 7 里面修改hostname的方式有所改变,修改/etc/hosts和/etc/sysconfig/network两个文件已经不能生效.使用的新命令是 : hostnamectl set ...

  8. Linux修改hostname与免密码登录

    修改hostname [root@centos7 ~]$ hostnamectl set-hostname hadoop001 # 使用这个命令会立即生效且重启也生效 [root@centos7 ~] ...

  9. Centos 7修改hostname浅析

    之前写过一篇博客"深入理解Linux修改hostname",里面总结了RHEL 5.7下面如何修改hostname,当然这篇博客的内容其实也适用于CentOS 6,但是自CentO ...

随机推荐

  1. dp之完全背包poj3181(高精度背包)

    这个题目要用到大数的加法,其他的,我没有感觉到有什么难想的......比较水的背包题,掠过..... #include<iostream> #include<stdio.h> ...

  2. Xml解析之PULL解析 例2

    <?xml version="1.0" encoding="UTF-8"?> <books> <book id="100 ...

  3. Unix domain socket IPC

    UNIX Domain socket 虽然网络socket也可用于同一台主机的进程间通讯(通过lo地址127.0.0.1),但是unix domain socket用于IPC更有效率:不需要经过网络协 ...

  4. springboot日志管理+集成log4j

    sprongboot使用的默认日志框架是Logback. 可以在application.properties配置简单日志属性,也可以单独配置logback.xml格式,还可以使用log4j来管理. 下 ...

  5. 在执行一行代码之前CLR做的68件事[The 68 things the CLR does before executing a single line of your code]

    待翻译,原文地址:http://mattwarren.org/2017/02/07/The-68-things-the-CLR-does-before-executing-a-single-line- ...

  6. oracle和SQLserver数据库中select into 的区别

    在Oracle中是这样的 在SQLserver中是这样的

  7. 判断ActiveX控件是Desgin Mode还是Runtime Mode

    对于MFC COleControl::AmbientUserMode Determines if the Container is in design mode or user mode. BOOL ...

  8. linux使用常见问题

    出现RTNETLINK answers: File exists 同时出现connect:network is unreachable 和 Determining IP information for ...

  9. iOS开发之--从URL加载图片

    + (UIImage *) imageFromURLString: (NSString *) urlstring { // This call is synchronous and blocking ...

  10. 获取jqGrid中选择的行的数据以及 jqGrid获得所有行数据的方法

    获取jqGrid中选择的行的数据: 获取选择一行的id,如果你选择多行,那下面的id是最后选择的行的id:   1 var id=$('#gridTable').jqGrid('getGridPara ...