給進程設置的優先級就是nice。nice的範圍是-20~20
。nice值越小佔用的系統資源就越多,就是這個進程不nice。緩存
# 使用top命令查看時 會有一列時NI 就是nice值 top - 14:01:36 up 9 min, 2 users, load average: 0.08, 0.23, 0.18 Tasks: 494 total, 2 running, 492 sleeping, 0 stopped, 0 zombie %Cpu(s): 16.7 us, 16.7 sy, 0.0 ni, 66.7 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3742 root 20 0 619884 18616 12072 R 60.4 1.0 0:00.85 gnome-terminal- 3778 root 20 0 123924 1940 1152 R 60.4 0.1 0:00.43 top 1 root 20 0 53692 7660 2524 S 0.0 0.4 0:03.93 systemd 2 root 20 0 0 0 0 S 0.0 0.0 0:00.07 kthreadd 3 root 20 0 0 0 0 S 0.0 0.0 0:00.34 ksoftirqd/0 5 root 0 -20 0 0 0 S 0.0 0.0 0:00.00 kworker/0:0H 7 root rt 0 0 0 0 S 0.0 0.0 0:00.66 migration/0
# 執行4個 dd命令 一致在吃資源 PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3985 root 20 0 107920 624 532 R 95.6 0.0 0:14.21 dd if=/dev/zero of=/dev/null 3977 root 20 0 107920 624 532 R 93.7 0.0 0:15.64 dd if=/dev/zero of=/dev/null 3981 root 20 0 107920 620 532 R 86.4 0.0 0:14.18 dd if=/dev/zero of=/dev/null 3973 root 20 0 107920 624 532 R 84.4 0.0 0:16.26 dd if=/dev/zero of=/dev/null # renice 其那兩個nice值爲-20 renice -19 3977 renice -20 3985 renice +19 3981 renice +19 3973 #再次查看top PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 3977 root 1 -19 107920 624 532 R 100.0 0.0 10:14.42 dd if=/dev/zero of=/dev/null 3985 root 0 -20 107920 624 532 R 100.0 0.0 10:38.96 dd if=/dev/zero of=/dev/null 3981 root 39 19 107920 620 532 R 96.5 0.0 10:01.17 dd if=/dev/zero of=/dev/null 3973 root 39 19 107920 624 532 R 88.6 0.0 9:55.61 dd if=/dev/zero of=/dev/null # 修改後-20的進程一直比19nice值得佔用的多,此時若是再開一個進程會更明顯,可是虛擬機卡住了,作不了任何操做
# 查看 [root@master /]# timedatectl Local time: Fri 2019-08-30 14:21:58 CST Universal time: Fri 2019-08-30 06:21:58 UTC RTC time: Fri 2019-08-30 14:21:58 Timezone: Asia/Shanghai (CST, +0800) NTP enabled: yes NTP synchronized: no RTC in local TZ: no DST active: n/a # 設置時間 [root@master /]# timedatectl set-time "2019-08-30 14:24:20" [root@master /]# date Fri Aug 30 14:24:23 CST 2019 # 查看全部時區 [root@master /]# timedatectl list-timezones # 設置時區 [root@master /]# timedatectl set-timezone Asia/Hong_Kong # 設置ntp同步爲yes timedatectl set-ntp 1
使用的時服務 chronyd。redhat7自帶的。bash
# 編輯配置文件,註釋掉默認的4行,增長阿里雲的同步時間配置 [root@master ~]# vi /etc/chrony.conf #server 0.rhel.pool.ntp.org iburst #server 1.rhel.pool.ntp.org iburst #server 2.rhel.pool.ntp.org iburst #server 3.rhel.pool.ntp.org iburst server ntp6.aliyun.com iburst [root@localhost ~]# vi /etc/chrony.conf [root@localhost ~]# vi /etc/chrony.conf [root@localhost ~]# systemctl restart chronyd [root@localhost ~]# systemctl enable chronyd
什麼時RPM:RPM package manager 包管理markdown
包的全名:架構
httpd-tools-2.4.6-17.el7.x86_64.rpm # httpd-tools是名字 # 2.4.6是版本 # 17是發行班號(發行的次數) # .el7是radhat7平臺 # .x86_64處理器cpu的架構 # .noarch是32位64位均可以
[root@localhost /]# mount /dev/sr0 /mnt mount: /dev/sr0 is write-protected, mounting read-only [root@localhost /]# cd /mnt/Packages/ # packages下面全都是rpm包 # -i 安裝 -v詳細信息 -h 顯示進度條 [root@localhost Packages]# rpm -ivh tree-1.6.0-10.el7.x86_64.rpm warning: tree-1.6.0-10.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] Updating / installing... 1:tree-1.6.0-10.el7 ################################# [100%] # 卸載 [root@localhost Packages]# rpm -evh tree Preparing... ################################# [100%] Cleaning up / removing... 1:tree-1.6.0-10.el7 ################################# [100%] # 查看包 [root@localhost Packages]# rpm -q tree tree-1.6.0-10.el7.x86_64 #查看全部包,太多了不直接顯示 [root@localhost Packages]# rpm -qa|grep "tree" tree-1.6.0-10.el7.x86_64 # 查看包的詳細 [root@localhost Packages]# rpm -qi tree Name : tree Version : 1.6.0 Release : 10.el7 Architecture: x86_64 Install Date: Fri 30 Aug 2019 04:16:26 PM CST Group : Applications/File Size : 89505 License : GPLv2+ Signature : RSA/SHA256, Thu 03 Apr 2014 05:33:48 AM CST, Key ID 199e2f91fd431d51 Source RPM : tree-1.6.0-10.el7.src.rpm Build Date : Tue 28 Jan 2014 01:29:58 AM CST Build Host : x86-020.build.eng.bos.redhat.com Relocations : (not relocatable) Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla> Vendor : Red Hat, Inc. URL : http://mama.indstate.edu/users/ice/tree/ Summary : File system tree viewer Description : The tree utility recursively displays the contents of directories in a tree-like format. Tree is basically a UNIX port of the DOS tree utility. # 查看包裝在哪裏 [root@localhost Packages]# rpm -ql tree /usr/bin/tree /usr/share/doc/tree-1.6.0 /usr/share/doc/tree-1.6.0/LICENSE /usr/share/doc/tree-1.6.0/README /usr/share/man/man1/tree.1.gz # 查看文件從哪一個包來的 [root@localhost Packages]# rpm -qf /usr/share/doc/tree-1.6.0 tree-1.6.0-10.el7.x86_64
關於rpm 包的依賴問題app
樹形依賴: a->b->c
直接按照提示從下層一個個裝就能夠,按照c>b>a的順序ui
環形依賴:a->b->c->a
將三個包名寫在一塊兒,直接一次裝阿里雲
模塊依賴:用httpd舉例.net
# 須要一些模塊 [root@localhost Packages]# rpm -ivh httpd-2.4.6-17.el7.x86_64.rpm warning: httpd-2.4.6-17.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY error: Failed dependencies: /etc/mime.types is needed by httpd-2.4.6-17.el7.x86_64 httpd-tools = 2.4.6-17.el7 is needed by httpd-2.4.6-17.el7.x86_64 libapr-1.so.0()(64bit) is needed by httpd-2.4.6-17.el7.x86_64 libaprutil-1.so.0()(64bit) is needed by httpd-2.4.6-17.el7.x86_64 # 訪問 http://www.rpmfind.net/ 去查找這個模塊在哪一個包中,安裝那個包
什麼是yum : yellow dog update manage黃狗更新管理器rest
使用rpm安裝yumcode
[root@master Packages]# rpm -ivh yum-3.4.3-118.el7.noarch.rpm warning: yum-3.4.3-118.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY Preparing... ################################# [100%] package yum-3.4.3-118.el7.noarch is already installed
###注:考試給一個http的鏈接給啥寫啥### # 將iso光盤掛在到/mnt目錄上 sudo mount -o /dev/sr0 /mnt # 查看目錄掛載 [kane@master mnt]$ df -H Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 19G 3.3G 16G 18% / devtmpfs 949M 0 949M 0% /dev tmpfs 958M 152k 958M 1% /dev/shm tmpfs 958M 9.4M 949M 1% /run tmpfs 958M 0 958M 0% /sys/fs/cgroup /dev/sda1 521M 125M 397M 24% /boot /dev/sr0 3.8G 3.8G 0 100% /mnt # 咱們將iso中的package配置成yum源 sudo yum-config-manager --add-repo=file:///mnt # 到 yum源目錄下 [root@master request-key.d]# cd /etc/yum.repos.d/ # 追加內容gpgcheck=0。讓其不檢查 [root@master yum.repos.d]# echo "gpgcheck=0" >> ./mnt.repo # 刷新緩存 [root@master yum.repos.d]# yum makechahe
# 安裝httpd [root@master yum.repos.d]# yum install httpd # 查看安裝歷史 [root@master yum.repos.d]# yum history Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 5 | kane <kane> | 2019-10-22 13:45 | Install | 5 history list # 回滾某次安裝 使用ID [root@master yum.repos.d]# yum history undo 5 # 再次查看,會多一個抹去的操做 [root@master yum.repos.d]# yum history Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. ID | Login user | Date and time | Action(s) | Altered ------------------------------------------------------------------------------- 6 | kane <kane> | 2019-10-22 13:47 | Erase | 5 5 | kane <kane> | 2019-10-22 13:45 | Install | 5 history list # 此處看不到每一個Id都是作什麼的,咱們能夠查看yum安裝log [root@master yum.repos.d]# cat /var/log/yum.log Oct 22 13:45:09 Installed: apr-1.4.8-3.el7.x86_64 Oct 22 13:45:09 Installed: apr-util-1.5.2-6.el7.x86_64 Oct 22 13:45:09 Installed: httpd-tools-2.4.6-17.el7.x86_64 Oct 22 13:45:09 Installed: mailcap-2.1.41-2.el7.noarch Oct 22 13:45:11 Installed: httpd-2.4.6-17.el7.x86_64 Oct 22 13:47:04 Erased: httpd-2.4.6-17.el7.x86_64 Oct 22 13:47:04 Erased: httpd-tools-2.4.6-17.el7.x86_64 Oct 22 13:47:04 Erased: mailcap-2.1.41-2.el7.noarch Oct 22 13:47:04 Erased: apr-util-1.5.2-6.el7.x86_64 Oct 22 13:47:05 Erased: apr-1.4.8-3.el7.x86_64
[root@master yum.repos.d]# yum groups list Loaded plugins: langpacks, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. There is no installed groups file. Maybe run: yum groups mark convert (see man yum) Available environment groups: Minimal Install Infrastructure Server File and Print Server Basic Web Server Virtualization Host Server with GUI Available Groups: Compatibility Libraries Console Internet Tools Development Tools Graphical Administration Tools Legacy UNIX Compatibility Scientific Support Security Tools Smart Card Support System Administration Tools System Management Done