RHCE(一)--- at、crontab、网卡绑定

目录

一、atd和crond两个任务管理程序的区别

二、指定在2022/08/26 09:00将时间写入testmail.txt文件中

1、创建test.txt文件

2、在test.txt中写入命令 date >> testmail.txt

3、这里2022/8/26 09:00已经过去了,就会拒绝创建,我将时间改为2022/8/28 16:00

三、指定在每天凌晨4:00将该时间点之前的系统日志信息备份到根目录下(/var/log/messages ),备份后日志文件名显示格式logfileYY-MM-DD HH-MM

四、在当前主机添加两块网卡,将两块网卡绑定实现网卡冗余操作

1、添加两块虚拟网卡

2、连接会话

3、创建 team0 设备和 team0 会话

4、向team0中添加从设备(ens224、256)

5、先激活 team0-port1、team0-port2 从设备,再激活 team0 主设备

6、查看 team0 的工作状态

7、当从设备 team0-port1 (ens224)断开时,会切换到 ens256


一、atd和crond两个任务管理程序的区别

at -> atd:单一执行的例行性工作---仅处理执行一次就结束了
crond:循环执行的例行性工作---每隔一定的周期就需要执行一次


二、指定在2022/08/26 09:00将时间写入testmail.txt文件中

1、创建test.txt文件

2、在test.txt中写入命令 date >> testmail.txt

3、这里2022/8/26 09:00已经过去了,就会拒绝创建,我将时间改为2022/8/28 16:00

[root@xixi ~]# touch test.txt
[root@xixi ~]# vim test.txt

date >> testmail.txt
[root@xixi ~]# at 09:00 2022-8-26 -f test.txt
at: refusing to create job destined in the past
[root@xixi ~]# at 16:00 2022-8-28 -f test.txt
warning: commands will be executed using /bin/sh
job 6 at Sun Aug 28 16:00:00 2022

列出目前系统上面的所有该用户的 at 调度
[root@xixi ~]# at -l
6	Sun Aug 28 16:00:00 2022 a root


三、指定在每天凌晨4:00将该时间点之前的系统日志信息备份到根目录下(/var/log/messages ),备份后日志文件名显示格式logfileYY-MM-DD HH-MM

[root@xixi /]# crontab -e

0 4 * * * cp /var/log/messages /logfile`date +%F#%R` ; echo > /var/log/messages

:wq  


四、在当前主机添加两块网卡,将两块网卡绑定实现网卡冗余操作

1、添加两块虚拟网卡

2、连接会话

[root@xixi ~]# nmcli device connect ens224
Device 'ens224' successfully activated with '39bef2c8-fc11-4059-84b9-679bfb13719a'.
[root@xixi ~]# nmcli device connect ens256
Device 'ens256' successfully activated with 'b27b5e56-6c3c-4dc8-9f95-5c0a924fa971'.
[root@xixi ~]# nmcli device status 
DEVICE      TYPE      STATE      CONNECTION 
ens160      ethernet  connected  ens160     
ens224      ethernet  connected  ens224     
ens256      ethernet  connected  ens256     
virbr0      bridge    connected  virbr0     
lo          loopback  unmanaged  --         
virbr0-nic  tun       unmanaged  --        
5: ens256: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:07 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.131/24 brd 192.168.225.255 scope global dynamic noprefixroute ens256
       valid_lft 1764sec preferred_lft 1764sec
    inet6 fe80::2b84:62ab:7ee7:12f2/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
6: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.130/24 brd 192.168.225.255 scope global dynamic noprefixroute ens224
       valid_lft 1758sec preferred_lft 1758sec
    inet6 fe80::81f0:cc46:b792:268a/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

3、创建 team0 设备和 team0 会话

[root@xixi ~]# nmcli connection add type team ifname team0 con-name team0 config '{"runner":{"name": "activebackup"}}'
[root@xixi doc]# cd /usr/share/doc/teamd/example_configs/
[root@xixi example_configs]# ll
total 64
-rw-r--r--. 1 root root 305 Jul 26  2020 activebackup_arp_ping_1.conf
-rw-r--r--. 1 root root 465 Jul 26  2020 activebackup_arp_ping_2.conf
-rw-r--r--. 1 root root 194 Jul 26  2020 activebackup_ethtool_1.conf
-rw-r--r--. 1 root root 212 Jul 26  2020 activebackup_ethtool_2.conf
-rw-r--r--. 1 root root 241 Jul 26  2020 activebackup_ethtool_3.conf
-rw-r--r--. 1 root root 447 Jul 26  2020 activebackup_multi_lw_1.conf
-rw-r--r--. 1 root root 285 Jul 26  2020 activebackup_nsna_ping_1.conf
-rw-r--r--. 1 root root 318 Jul 26  2020 activebackup_tipc.conf
-rw-r--r--. 1 root root  96 Jul 26  2020 broadcast.conf
-rw-r--r--. 1 root root 209 Jul 26  2020 lacp_1.conf
-rw-r--r--. 1 root root  98 Jul 26  2020 loadbalance_1.conf
-rw-r--r--. 1 root root 140 Jul 26  2020 loadbalance_2.conf
-rw-r--r--. 1 root root 183 Jul 26  2020 loadbalance_3.conf
-rw-r--r--. 1 root root  93 Jul 26  2020 random.conf
-rw-r--r--. 1 root root 244 Jul 26  2020 roundrobin_2.conf
-rw-r--r--. 1 root root  97 Jul 26  2020 roundrobin.conf
[root@xixi example_configs]# more activebackup_arp_ping_2.conf 
{
	"device":	"team0",
	"runner":	{"name": "activebackup"},
	"link_watch":	{
		"name": "arp_ping",
		"interval": 100,
		"missed_max": 30,
		"source_host": "192.168.23.2",
		"target_host": "192.168.23.1"
	},
	"ports":	{
		"eth1": {
			"prio": -10,
			"sticky": true
		},

4、向team0中添加从设备(ens224、256)

[root@xixi ~]# nmcli connection add type team-slave ifname ens224 con-name team0-port1 master team0
Connection 'team0-port1' (3c198f30-556c-407d-8a58-1c7e123b4791) successfully added.
[root@xixi ~]# nmcli connection add type team-slave ifname ens256 con-name team0-port2 master team0
Connection 'team0-port2' (cd8f75d6-e16a-402e-a651-a8d964683282) successfully added.

如果没有 team-slave 就输出 ethernet

ip a 查看到 team0 是未开启状态

7: team0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 6e:c2:f8:66:cf:70 brd ff:ff:ff:ff:ff:ff

5、先激活 team0-port1、team0-port2 从设备,再激活 team0 主设备

[root@xixi ~]# nmcli connection up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)

[root@xixi ~]# nmcli connection up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12)

[root@xixi ~]# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13)
[root@xixi ~]# nmcli connection show 
NAME         UUID                                  TYPE      DEVICE 
ens160       f667da4f-915c-4c68-ba16-2211ac796d6a  ethernet  ens160 
team0        597c5007-56ea-402b-9768-48ea445f47c4  team      team0  
virbr0       82441c83-895c-46c2-add3-a9b378921af6  bridge    virbr0 
team0-port1  3c198f30-556c-407d-8a58-1c7e123b4791  ethernet  ens224 
team0-port2  cd8f75d6-e16a-402e-a651-a8d964683282  ethernet  ens256 
ens224       39bef2c8-fc11-4059-84b9-679bfb13719a  ethernet  --     
ens256       b27b5e56-6c3c-4dc8-9f95-5c0a924fa971  ethernet  --     

6、查看 team0 的工作状态

[root@xixi ~]# teamdctl team0 stat
setup:
  runner: activebackup
ports:
  ens224
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  ens256
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: ens224
7: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.130/24 brd 192.168.225.255 scope global dynamic noprefixroute team0

7、当从设备 team0-port1 (ens224)断开时,会切换到 ens256

[root@xixi ~]# nmcli connection down team0-port1
Connection 'team0-port1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)

[root@xixi ~]# teamdctl team0 stat
setup:
  runner: activebackup
ports:
  ens256
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: ens256
7: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:0c:29:79:d6:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.225.130/24 brd 192.168.225.255 scope global dynamic noprefixroute team0

team0 ip地址不变

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值