首页 > 其他分享 >week4-homework

week4-homework

时间:2022-12-13 23:22:14浏览次数:74  
标签:12 make 6.0 linux root week4 homework rocky9

1. 自定义写出10个定时任务的示例:

比如每周三凌晨三点执行data命令
要求尽量的覆盖各种场景

#我这里之列出了4个我目前能想到的场景
30 1 * * * /bin/sh  /backupscripts #每天晚上一点半备份数据
* 8 * * 1-5 /bin/sh  /tobo_before_working #每个工作日早上八点执行特定脚本,执行结果发送邮箱
0 * * * * /bin/sh  /tobo_per_hour #每个小时要执行的任务
*/10 8-24 * 11-12 *  /bin/sh  /tobo_scripts #大促月份11月12月从8点到24点每隔10分钟刷新一下数据确保数据状态正常

2. 图文并茂说明Linux进程和内存概念

这篇文章我觉得总结的很到位,我这里直接引用了:https://blog.csdn.net/m0_57018588/article/details/123589243

进程与内存的关系
课本上说:加载到内存的程序,叫做进程。
内核的观点是:担当分配系统资源(cpu时间、内存)的实体

3. 图文并茂说明Linux启动流程

centos6启动流程

CentOS 7之后版本引导顺序
1.UEFi或BIOS初始化,运行POST开机自检
2.选择启动设备
3.引导装载程序, centos7是grub2,加载装载程序的配置文件:
  /etc/grub.d/
  /etc/default/grub
  /boot/grub2/grub.cfg
4.加载initramfs驱动模块
5.加载内核选项
6.内核初始化,centos7使用systemd代替init
7.执行initrd.target所有单元,包括挂载/etc/fstab
8.从initramfs根文件系统切换到磁盘根目录
9.systemd执行默认target配置,配置文件/etc/systemd/system/default.target
10.systemd执行sysinit.target初始化系统及basic.target准备操作系统
11.systemd启动multi-user.target下的本机与服务器服务
12.systemd执行multi-user.target下的/etc/rc.d/rc.local
13.Systemd执行multi-user.target下的getty.target及登录服务
14.systemd执行graphical需要的服务

5. 写Linux内核编译安装博客

下载并解压缩linux内核源码

[root@rocky9-1 ~]# cd /usr/local/src/
[root@rocky9-1 src]# wget https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.0.12.tar.xz
[root@rocky9-1 src]# tar xvf linux-6.0.12.tar.xz

安装相关依赖包

[root@rocky9-1 linux-6.0.12]# yum install -y gcc make ncurses-devel flex bison openssl openssl-devel elfutils-libelf-devel binutils binutils-devel

配置需要编译的模块,生成相应的配置文件.config,注意这个文件不要给重命名

[root@rocky9-1 linux-6.0.12]# make menuconfig
.config:431:warning: symbol value 'm' invalid for I8K
.config:7576:warning: symbol value 'm' invalid for CRYPTO_BLAKE2S_X86
.config:7667:warning: symbol value 'm' invalid for CRYPTO_ARCH_HAVE_LIB_BLAKE2S
.config:7668:warning: symbol value 'm' invalid for CRYPTO_LIB_BLAKE2S_GENERIC


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.




开始编译内核,-j之后的数字是指定一次可以同时执行多少个任务,根据各自编译机的CPU性能自行指定

[root@rocky9-1 linux-6.0.12]# time(make -j16)

real	0m12.377s
user	0m41.270s
sys	0m31.690s

安装相关模块,出现报错

[root@rocky9-1 linux-6.0.12]# make modules_install
sed: can't read modules.order: No such file or directory
make: *** [Makefile:1483: __modinst_pre] Error 2

执行make -j16 modules命令,排查模块相关错误

[root@rocky9-1 linux-6.0.12]# make -j16 modules
  DESCEND objtool
  DESCEND bpf/resolve_btfids
  CALL    scripts/atomic/check-atomics.sh
/bin/sh: line 1: bc: command not found
  UPD     include/generated/bounds.h
make[1]: *** [Kbuild:24: include/generated/timeconst.h] Error 127
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1205: prepare0] Error 2
make: *** Waiting for unfinished jobs....
[root@rocky9-1 linux-6.0.12]# yum -y install bc
xargs: perl: No such file or directory
make[1]: *** [kernel/Makefile:158: kernel/kheaders_data.tar.xz] Error 127
make: *** [Makefile:1852: kernel] Error 2
[root@rocky9-1 linux-6.0.12]# yum -y install perl perl-devel
[root@rocky9-1 linux-6.0.12]# make -j16 module
make[1]: *** No rule to make target 'certs/rocky.pem', needed by 'certs/x509_certificate_list'.  Stop.
make[1]: *** Waiting for unfinished jobs....
[root@rocky9-1 linux-6.0.12]# cat .config | grep CONFIG_SYSTEM_TRUSTED_KEYS
#CONFIG_SYSTEM_TRUSTED_KEYS="certs/rocky.pem"
CONFIG_SYSTEM_TRUSTED_KEYS=""

[root@rocky9-1 linux-6.0.12]# make -j16 module
BTF: .tmp_vmlinux.btf: pahole (pahole) is not available
Failed to generate BTF for vmlinux
Try to disable CONFIG_DEBUG_INFO_BTF
make: *** [Makefile:1169: vmlinux] Error 1
[root@rocky9-1 linux-6.0.12]# cat .config | grep CONFIG_DEBUG_INFO_BTF
#CONFIG_DEBUG_INFO_BTF=y
CONFIG_DEBUG_INFO_BTF=n

上述问题排查完毕,再重新编译一次,确保无误

[root@rocky9-1 linux-6.0.12]# make -j16
# 安装相关模块
[root@rocky9-1 linux-6.0.12]# make modules_install
# 安装内核
[root@rocky9-1 linux-6.0.12]# make install
[root@rocky9-1 linux-6.0.12]# reboot

重启后查看内核信息

[root@rocky9-1 ~]# uname -a
Linux rocky9-1 6.0.12 #2 SMP PREEMPT_DYNAMIC Sun Dec 11 23:40:39 CST 2022 x86_64 x86_64 x86_64 GNU/Linux

6. 总结5个自我觉得比较有用的awk的使用场景,比如在什么情况下用awk处理文本效率最高,发散题,至少写1个。

#统计访问IP次数并排序取前10:
awk '{a[$1]++}END{for(v in a)print v,a[v]|"sort -k2 -nr |head -10"}' access.log
#统计访问最多的10个页面:
awk '{a[$7]++}END{for(v in a)print v,a[v]|"sort -k1 -nr|head -n10"}' access.log
#统计访问IP是404状态次数:
awk '{if($9~/404/)a[$1" "$9]++}END{for(i in a)print v,a[v]}' access.log
#awk正则表达式:去除掉文件空行(^$)或者是注释的行(^#)
awk '!/^$|^#/' /etc/fstab
#取磁盘固定分区的使用率
df -h |awk  -F'[ %]+'  '/\/dev\/sd*/{print $5}'
#预防DDOS攻击
ss -nt | awk -F " +|:" 'NR!=1{ip[$(NF-2)]++}END{for(i in ip){if(ip[i]>500){system("iptables -A INPUT -s "i" -j REJECT")}}}'

标签:12,make,6.0,linux,root,week4,homework,rocky9
From: https://www.cnblogs.com/dashuilvdou/p/16980870.html

相关文章

  • Introduction to Computer Science #Homework 07
    IntroductiontoComputerScienceHomework071.3.4.1b,c=2,4defg_func(d):globala#a为全局变量a=d*c#d为局部变量;a、c为全局变量,这里改变......
  • Introduction to Computer Science #Homework 06
    IntroductiontoComputerScienceHomework061.程序是如何执行的3.2.1给寄存器R赋值20CPU将寄存器R中的值存回a所在的地址3.2.2将主存中1200地址处的值读取到寄......
  • # Introduction to Computer Science #Homework 05
    IntroductiontoComputerScienceHomework051.关于期末大作业团队成员李纪远/席萱赫/祖家琪/刘立威游戏想法游戏名:西风哗哗?大赢家!游戏类型:大富翁like棋......
  • Homework 5: Social networking and recommendation systems
    Homework5:SocialnetworkingandrecommendationsystemsBackgroundRecommendationsystemsFacebooksuggestspeopleyoumaybe(ormightwanttobe)friendswi......
  • week4题解
    1.深度优先搜索   思路:以固定的移动顺序走迷宫,若能到终点则记一次到终点后回溯到前一个有分岔的地方,走另一条路线若走到死路也同样回溯到前一个有分叉的地方。最......
  • homework4
    什么是微软过程?         ......
  • ACM预备队week4(搜索)
    1.迷宫题目链接:P1605迷宫-洛谷|计算机科学教育新生态(luogu.com.cn)dfs1#include<bits/stdc++.h>2usingnamespacestd;3intsx,sy,fx,fy;4intn,m,......
  • homework2软件方法论
        什么是软件工程方法论?     1.软件工程是一个方法论,就是我们在开始一个项目时,大体框架一定要有这么一个概念,而具体实施时,必须根据公司一些特点,优化......
  • homework3
    软件工程与计算机的关系及区别     什么是软件工程?     软件工程借鉴传统工程的原则、方法,以提高质量、降低成本和改进算法。其中,计算机科学、数学......
  • MIT 6.828 Homework: Thread and locking
    任务:修改代码以实现对于每一个循环,让每一个线程都暂时阻塞直到所有线程都调用了barier函数实际上就是实现一个屏障,当线程运行到屏障之前,会被暂时挂起,直到所有线程都到达屏......