• 第九天作业


    作业一:完成作业未做完的集群架构

    集群架构已完成。

    作业二:临时配置网络(ip,网关,dns)+永久配置

    [root@bogon ~]# ifconfig ens33 192.168.16.99 netmask  255.255.255.0 up 临时配置ip和子网掩码

    [root@bogon ~]# route add default gw 192.168.16.1临时配置网关

    [root@bogon ~]# echo "nameserver 8.8.8.8">> /etc/resolv.conf 临时配置dns

    永久配置ip,网关,dns如下图

    [root@bogon ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

    [root@bogon ~]# systemctl restart network

    作业三:为集群内的机器设定主机名,利用/etc/hosts文件来解析自己的集群中所有的主机名,相应的,集群的配置应该改成使用主机名的方式

    反向代理服务器:192.168.16.32 bogon

    web主机1:192.168.16.195 python-web1
    web主机2:192.168.16.171 python-web2
    web主机3:192.168.16.116 python-web3

    实现反向代理主机和三台web主机都能互相ping通

    [root@bogon ~]# vi /etc/nginx/nginx.conf  更改Nginx反向代理的集群配置,把三台web服务器的IP换成主机名

     

    [root@bogon ~]# /usr/sbin/nginx -s reload 重新加载Nginx配置文件

    然后再测试

     

    作业四:ssh登录,scp上传、下载,ssh秘钥登录,修改ssh server端的端口为8888然后进行登录和scp测试

    1、ssh登录python-web1(192.168.16.195)

    2、scp上传

    3、scp下载

    [root@python-web1 ~]# ls
    192.168.16.32 anaconda-ks.cfg b.txt gentalman hello.py test

     

    4、ssh秘钥登录

    生成公钥和私钥

     

    把python-web1的公钥和私钥传给反向代理服务器

     

    实现ssh免密登录!

    5、修改ssh server端的端口为8888然后进行登录和scp测试

    xshell连接符修改端口为8888连接成功!

    scp上传成功!

    作业五:整理bash命令类型,验证寻找一个命令的优先级

    bash命令类型分为:别名,内部命令,外部命令,如下图所示

    别名:alias

    内置命令查看:man builtin

    外部命令查看,Linux系统下的/bin,/sbin,/usr/bin , /usr/sbin目录等等

    命令优先级

    1、别名
    2、关键字
    3、函数
    4、内置命令  
    5、脚本或可执行程序($PATH)

    验证一个命令的优先级

    作业六:通配符实验

    #1、~ 家目录
    [root@proxy-nfs ~]# cd /tmp/ [root@proxy-nfs tmp]# cd ~ [root@proxy-nfs ~]# pwd /root #2、``命令的替换 取命令的执行结果 [root@proxy-nfs ~]# ret=`free -m` [root@proxy-nfs ~]# echo $ret total used free shared buff/cache available Mem: 322 115 12 8 194 161 Swap: 2047 0 2047 [root@proxy-nfs test]# echo `ls` 1.txt 2.txt 3.txt 4.txt a.sh sshd_config [root@proxy-nfs test]# a=`echo `ls`` [root@proxy-nfs test]# echo $a ls [root@proxy-nfs test]# b=$(echo $(ls)) [root@proxy-nfs test]# echo $b 1.txt 2.txt 3.txt 4.txt a.sh sshd_config #尽量使用括号 #3、!取非 [root@proxy-nfs test]# ls [!a-z].txt 1.txt 2.txt 3.txt 4.txt #4、@ 无特殊含义 #5、# 注释 [root@proxy-nfs test]# cat /etc/resolv.conf # Generated by NetworkManager #6、 $变量取值 [root@proxy-nfs test]# echo $ret total used free shared buff/cache available Mem: 322 115 12 8 194 161 Swap: 2047 0 2047 $()同`` [root@proxy-nfs test]# ret=$(ls) [root@proxy-nfs test]# echo $ret 1.txt 2.txt 3.txt 4.txt ${}变量名的范围 [root@proxy-nfs test]# aa=old [root@proxy-nfs test]# echo ${aa}girl oldgirl $[]整数计算echo $[2+3]-*/%浮点数用echo "sclae=3;10/3"|bc -l [root@proxy-nfs test]# echo $[1 + 1] 2 #7、杀后台进程jobs号;取莫 杀后台进程jobs号 kill -9 %1 #取模 [root@proxy-nfs test]# echo $[10%3] 1 #8、^取非和!雷同 [root@proxy-nfs test]# ls [^01].txt 2.txt 3.txt 4.txt #9、& 后台进程 [root@proxy-nfs test]# ./test.sh & 逻辑与 [root@proxy-nfs test]# ls && pwd 1.txt 2.txt 3.txt 4.txt /test #10、*通配符;任意字符 [root@proxy-nfs test]# ls * 1.txt 2.txt 3.txt 4.txt [root@proxy-nfs test]# ls *.txt 1.txt 2.txt 3.txt 4.txt #11、()在子进程中执行 [root@proxy-nfs test]# a=1 [root@proxy-nfs test]# (a=2;echo $a) 2 [root@proxy-nfs test]# echo $a 1 #12、-减号;区间;cd-; 减号 echo $[5 - 1] 区间 ls [a-z].txt 返回上一次工作的目录 cd - #13、|管道;||逻辑或 管道 [root@proxy-nfs test]# netstat -tunapl|grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 9440/nginx: master tcp6 0 0 :::80 :::* LISTEN 9440/nginx: master 逻辑或 [root@proxy-nfs test]# ls || pwd 1.txt 2.txt 3.txt 4.txt #14、{}命令列表#括号内的开头和结尾必须是空格 [root@proxy-nfs test]# { ls;cd /; } 1.txt 2.txt 3.txt 4.txt [root@proxy-nfs /]# #15、转义 [root@proxy-nfs ~]# rm -f [1].txt #16、:空命令 真值 [root@proxy-nfs ~]# : [root@proxy-nfs ~]# echo $? 0 #17、;可以接多个命令,无论对错,会一直执行到最后一条命令 [root@proxy-nfs ~]# pwd;who /root root tty1 2017-03-21 09:35 root pts/1 2017-03-21 14:53 (192.168.152.1) #18、“” 软引 ‘’硬引 [root@proxy-nfs ~]# aa=oldboy [root@proxy-nfs ~]# echo $aa oldboy [root@proxy-nfs ~]# echo "$aa" #软引用 oldboy [root@proxy-nfs ~]# echo '$aa' #硬引用 $aa [root@proxy-nfs ~]# #19、,枚举分隔符 [root@proxy-nfs ~]# echo {a,b,c,d} a b c d #20、<输入重定向 #21、>输出重定向 echo aa > aa.txt #22、追加 echo bb > aa.txt #23、. source 当前目录 [root@proxy-nfs test]# ./a.sh 1.txt 2.txt 3.txt 4.txt a.sh [root@proxy-nfs test]# source a.sh 1.txt 2.txt 3.txt 4.txt a.sh #24、/ 目录分隔符 [root@proxy-nfs test]# pwd /test/ #25、?通配符:任一字符 [root@proxy-nfs test]# echo ???? a.sh

      

  • 相关阅读:
    Iterator与 Enumeration
    多态性理解
    django---路由层
    django常用模块汇总
    django初识
    python常见模块
    python PEP8规范
    logging模块
    mysql一些了解的名词
    python 链接 mysql数据库
  • 原文地址:https://www.cnblogs.com/bingabcd/p/6594730.html
Copyright © 2020-2023  润新知