服务管理、安装服务、网络管理

技术 · 2020-01-07 · 33 人浏览
虚拟机密码 indionce

虚拟机IP地址
system1 虚拟机IP地址:172.25.6.11/24
              网关:172.25.6.254
              DNS:172.25.6.254

system2虚拟机IP地址:172.25.6.10/24
              网关:172.25.6.254
              DNS:172.25.6.254
  • 设置源

    • vim /etc/yum.repos.d/ll.repo
    • [ll]    # 标志名
      name = ll # 名
      enable = 1 # 
      gpgcheck = 0 # 校验 1 进行校验 0 不进行校验
      baseurl = http://server.region6.example.com/rhel #源地址
      
  • 验证

    • yum repolist
    • 1576639961502.png
  • 远程复制样目源

    • scp /etc/yum.repos.d/ll.repo [email protected]:/etc/yum.repos.d/ll.repo
    • 这是图片

      • 将1主机的文件复制到2主机上
  • 更改主机名

    • hostnamectl set-hostname system1.region6.com

服务的管理

  • 一个服务包含多个进程
  • 一个服务至少包含一个或多个守护进程

进程:

  • 是一个能量体,是一个可执行应用程序的运行中实例

系统架构与父进程

操作系统系统架构父进程管理方式启动方式
rhel6sysvinitservice串联方式
rhel7systemdsystemdsystemctl并联方式

系统运行级别:

数字运行级别含义sysvsystemd
0关机init 0poweroff.target
1单用户模式(修复模式)init 1rescue.target
2多用户模式init 2multi-user.target
3标准服务器模式init 3multi-user.target
4预留init 4multi-user.target
5标准图形化模式init 5graphical.target
6重启init 6reboot.target

切换运行级别:

  • rhel6

    • init 5
  • rhel7

    • systemctl set-default graphical.target

      • 永久性修改
    • systemctl isolate graphical.target

      • 立即生效,重启失效
    • systemctl get-default·

      • 获取当前系统的优先级

安装服务

  • yum install httpd -y

对服务器

开启关闭重启查看状态重新加载
systemctl start httpdsystemctl stop httpdsystemctl restart httpdsystemctl status httpdsystemctl reload httpd

下次开机自启动和取消

  • systemctl enable httpd
  • systemctl disable httpd

查看服务是否下次开机自启动

  • system is-enableed httpd

查看服务是否开启

  • systemctl is-active httpd

设置服务是否提前在内存中

  • systemctl mask httpd
  • systemctl unmask httpd

网络的管理:

network: 底层的网络服务 -- 配置文件的

NetworkManage: rhel7中默认使用的网络服务--图形化工具, nmcli 命令

  • gnome-control-center
  • nmtui
  • nm-connection-editor

将所有的网络配置,都保存成一个个方案,我们称之为连接多个连接可以应用到一个device

但是同一时间只能有一个连接生效

nmcli命令行:

  • nmcli connection show 列出所有链接
  • nmcli connection add autoconnect yes type ethernet ifname eth0 con-name port-eth0 ip4 11.111.11.11/24 gw4 11.111.11.11

    • 添加连接,是否自动连接,使用的真实设备是,连接的名字是
  • nmcli connection up|down port-eth0

    • 启动|关闭创建的连接
  • nmcli connection delete port-eth0

    • 删除连接
  • nmcli connection modify port-eth0 ipv4.addresses 12.12.12.12/24

    • 更改IP地址
  • nmcli device show

    • 查看系统当中的网卡设备
  • nmcli connection show --active

    • 查看系统当中活跃的网络连接

练习

  1. 创建新连接con-home,ip自动通过dhcp获取
  2. 创建新的连接connection1,指定静态获取,不自动连接,ip为10.10.10.10/24,网关为10.10.10.25
  3. nmcli connection add autoconnect yes type ethernet ifname eth0 con-name con-home
  4. nmcli connection add autoconnect yes type ethernet ifname eth0 con-name connection1 ip4 10.10.10.10/24 gw4 10.10.10.25
  • type:连接类型
  • ifname:指定网络设备
  • con-name:真实的连接名
  • autoconnect:该链接是否是自动连接
  • ip4:指定改连接IP地址,子网掩码写在地址后面
  • gw4:指定该连接的网关
  • add:添加
  • delete:删除

Theme Jasmine by Kent Liao