hadoop作业一
一:网络相关的命令
1、查看网络设备(ip link)
[root@master /]# ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0c:29:31:63:b3 brd ff:ff:ff:ff:ff:ff 3: ens34: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000 link/ether 00:0c:29:31:63:bd brd ff:ff:ff:ff:ff:ff
2、管理网络设备(ip link set )
关闭网络设备(禁用该网卡)
[root@server ~]# ip link set ens224 down [root@server ~]# ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 3: ens224: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DEFAULT group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 #ifconfig也看不到,查看的是开启的网卡的信息 [root@server ~]# ifconfig ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.20.10 netmask 255.255.255.0 broadcast 192.168.20.255 inet6 fe80::20c:29ff:fe6c:7db6 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6c:7d:b6 txqueuelen 1000 (Ethernet) RX packets 1712 bytes 154391 (150.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1152 bytes 143819 (140.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 26 bytes 2660 (2.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26 bytes 2660 (2.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@server ~]# #使用ifconfig -a可以查看到所有的网卡信息 [root@server ~]# ifconfig -a ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.20.10 netmask 255.255.255.0 broadcast 192.168.20.255 inet6 fe80::20c:29ff:fe6c:7db6 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6c:7d:b6 txqueuelen 1000 (Ethernet) RX packets 1737 bytes 156527 (152.8 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1175 bytes 146929 (143.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens224: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 00:0c:29:6c:7d:c0 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 26 bytes 2660 (2.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26 bytes 2660 (2.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
3、开启网卡的设备(ip link set up)
[root@server ~]# ip link set up ens224 [root@server ~]# ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 #ens224显示的就是up [root@server ~]# ifconfig ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.20.10 netmask 255.255.255.0 broadcast 192.168.20.255 inet6 fe80::20c:29ff:fe6c:7db6 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6c:7d:b6 txqueuelen 1000 (Ethernet) RX packets 1964 bytes 176467 (172.3 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1306 bytes 163087 (159.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 00:0c:29:6c:7d:c0 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 26 bytes 2660 (2.5 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 26 bytes 2660 (2.5 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
4、查看网络是否开启了(nmcli networking)
[root@server ~]# nmcli networking enabled #如果是disabled的话,网卡的信息就如下 [root@server ~]# nmcli networking off [root@server ~]# nmcli n disabled [root@server ~]# ifconfig lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 42 bytes 3844 (3.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 42 bytes 3844 (3.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 #但是此时的你的网络服务的进程还是是开启的,所以禁用网络服务不等于进程也停止 [root@server ~]# systemctl is-active NetworkManager active #只需要将网络服务启用即可 [root@server ~]# nmcli n on [root@server ~]# nmcli n enabled [root@server ~]# ifconfig ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.20.10 netmask 255.255.255.0 broadcast 192.168.20.255 inet6 fe80::20c:29ff:fe6c:7db6 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6c:7d:b6 txqueuelen 1000 (Ethernet) RX packets 5 bytes 497 (497.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 23 bytes 2724 (2.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet6 fe80::3aa:9ae1:3bfb:a78a prefixlen 64 scopeid 0x20<link> ether 00:0c:29:6c:7d:c0 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 10 bytes 1480 (1.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6 ::1 prefixlen 128 scopeid 0x10<host> loop txqueuelen 1000 (Local Loopback) RX packets 42 bytes 3844 (3.7 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 42 bytes 3844 (3.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
5、总结
1)使用ifconfig也能实现上面的禁用网络设备等操作
2)禁用网络设备不等于网络设备和网络连接的配置文件断开(注意)
二:临时配置ip
使用ip命令
1、 临时添加
格式:
ip address add ip地址\掩码 dev 设备名
案例:
[root@server ~]# ip address add 192.168.10.10/24 dev ens224 [root@server ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.20.10/24 brd 192.168.20.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe6c:7db6/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 inet 192.168.10.10/24 scope global ens224 valid_lft forever preferred_lft forever
2、配置多个ip地址
[root@server ~]# ip addr add 192.168.10.20/24 dev ens224 #ifconfig只能查看一个ip地址,使用ip a可以查看多个ip地址 [root@server ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.20.10/24 brd 192.168.20.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe6c:7db6/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 inet 192.168.10.10/24 scope global ens224 valid_lft forever preferred_lft forever inet 192.168.10.20/24 scope global secondary ens224 valid_lft forever preferred_lft forever #网络通信也能通 [root@server ~]# ping 192.168.10.10 PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data. 64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.064 ms ^C --- 192.168.10.10 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.064/0.064/0.064/0.000 ms [root@server ~]# ping 192.168.10.20 PING 192.168.10.20 (192.168.10.20) 56(84) bytes of data. 64 bytes from 192.168.10.20: icmp_seq=1 ttl=64 time=0.050 ms ^C --- 192.168.10.20 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.050/0.050/0.050/0.000 ms
3、删除临时ip地址
使用ip addr del 来进行删除
[root@server ~]# ip addr del 192.168.10.20/24 dev ens224 [root@server ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.20.10/24 brd 192.168.20.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe6c:7db6/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 inet 192.168.10.10/24 scope global ens224 valid_lft forever preferred_lft forever
4、总结
就是临时配置ip的话,下次重启服务或者开机的时候,就失效了
三:永久配置ip
nmcli命令
配置多个ip的
nmcli device disconnect 设备 这个就是断开配置文件和设备的关联和nmcli connection down 一样
1、nmcli connection 相关的操作
1、配置ip地址
#仅主机的话只用配置手动获取和ip的配置,nat模式需要加上网关和dns [root@server ~]# nmcli connection modify ens224 ipv4.method manual ipv4.addresses 192.168.10.10/24 #加载配置文件,如果是手动更改配置的话,需要reload,没有的话,就直接up [root@server ~]# nmcli connection reload #激活ens224,(相当于重启) [root@server ~]# nmcli connection up ens224 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12) [root@server ~]# nmcli connection show NAME UUID TYPE DEVICE ens160 36089308-d7e2-3902-b3e9-eddfc2a57d2e ethernet ens160 ens224 4f030eac-ba68-4160-96c6-1dd9f4deba2e ethernet ens224 [root@server ~]# ping 192.168.10.10 PING 192.168.10.10 (192.168.10.10) 56(84) bytes of data. 64 bytes from 192.168.10.10: icmp_seq=1 ttl=64 time=0.040 ms ^C --- 192.168.10.10 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 0.040/0.040/0.040/0.000 ms
2、配置多个ip地址
#使用+就能实现配置ip地址,并且是永久生效的 [root@server ~]# nmcli connection modify ens224 +ipv4.addresses 192.168.10.20/24 [root@server ~]# nmcli connection up ens224 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/13) [root@server ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.20.10/24 brd 192.168.20.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe6c:7db6/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 inet 192.168.10.10/24 brd 192.168.10.255 scope global noprefixroute ens224 valid_lft forever preferred_lft forever inet 192.168.10.20/24 brd 192.168.10.255 scope global secondary noprefixroute ens224 valid_lft forever preferred_lft forever inet6 fe80::3aa:9ae1:3bfb:a78a/64 scope link noprefixroute valid_lft forever preferred_lft forever #使用-就能删除ip地址 [root@server ~]# nmcli connection modify ens224 -ipv4.addresses 192.168.10.20/24 [root@server ~]# nmcli connection up ens224 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14) [root@server ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:b6 brd ff:ff:ff:ff:ff:ff altname enp3s0 inet 192.168.20.10/24 brd 192.168.20.255 scope global noprefixroute ens160 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fe6c:7db6/64 scope link noprefixroute valid_lft forever preferred_lft forever 3: ens224: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:6c:7d:c0 brd ff:ff:ff:ff:ff:ff altname enp19s0 inet 192.168.10.10/24 brd 192.168.10.255 scope global noprefixroute ens224 valid_lft forever preferred_lft forever inet6 fe80::3aa:9ae1:3bfb:a78a/64 scope link noprefixroute valid_lft forever preferred_lft forever
2、nmcli device 相关的操作
#查看网络设备的连接状态 [root@server ~]# nmcli device status DEVICE TYPE STATE CONNECTION ens160 ethernet connected ens160 ens224 ethernet connected ens224 lo loopback unmanaged -- #禁用连接,与nmcli n down ens224一样的效果 [root@server ~]# nmcli device down ens224 Device 'ens224' successfully disconnected. [root@server ~]# nmcli device status DEVICE TYPE STATE CONNECTION ens160 ethernet connected ens160 ens224 ethernet disconnected -- lo loopback unmanaged -- [root@server ~]# nmcli connection show NAME UUID TYPE DEVICE ens160 36089308-d7e2-3902-b3e9-eddfc2a57d2e ethernet ens160 ens224 4f030eac-ba68-4160-96c6-1dd9f4deba2e ethernet -- #注意,仅仅是配置文件与网络设备断开了,网络设备还在up中
四:搭建一个本地的仓库
步骤
挂载镜像,编写yum仓库,安装软件
#挂载 [root@server ~]# mount /dev/cdrom /media/ mount: /media: WARNING: source write-protected, mounted read-only. [root@server ~]# df -hT Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 1.9G 0 1.9G 0% /dev tmpfs tmpfs 1.9G 0 1.9G 0% /dev/shm tmpfs tmpfs 778M 9.7M 769M 2% /run /dev/mapper/rhel-root xfs 36G 4.2G 32G 12% / /dev/mapper/vg0-lv0 xfs 2.4G 760K 2.4G 1% /data /dev/nvme0n1p1 xfs 495M 220M 275M 45% /boot tmpfs tmpfs 1.0M 0 1.0M 0% /run/stratisd/keyfiles /dev/mapper/stratis-1-9e4965f6774b4015ae23ae03fd46d64e-thin-fs-5cae49e5305e4a2e915dfe200b4e9192 xfs 1.0T 7.2G 1017G 1% /mnt/nvme tmpfs tmpfs 389M 96K 389M 1% /run/user/0 /dev/sr0 iso9660 8.0G 8.0G 0 100% /media #编写yum仓库 [root@server yum.repos.d]# pwd /etc/yum.repos.d [root@server yum.repos.d]# cat local.repo [AppStream] name=AppStream baseurl=file:///media/AppStream gpgcheck=0 enable=1 [BaseOS] name=BaseOS baseurl=file:///media/BaseOS gpgcheck=0 enable=1 #清理缓存和建立缓存 [root@server yum.repos.d]# yum clean all && yum makecache Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. 12 files removed Updating Subscription Management repositories. Unable to read consumer identity This system is not registered with an entitlement server. You can use subscription-manager to register. AppStream 189 MB/s | 5.8 MB 00:00 BaseOS 115 MB/s | 1.7 MB 00:00 Metadata cache created. #安装httpd [root@server yum.repos.d]# dnf -y install httpd [root@server yum.repos.d]# httpd -v Server version: Apache/2.4.51 (Red Hat Enterprise Linux) Server built: Mar 21 2022 00:00:00