控制服务和守护进程

1.systemd

1.1.systemd简介

systemd是用户空间的第一个应用程序,即 /sbin/init

init程序的类型

SysV风格:init(centos5),实现系统初始化时,随后的初始化操作都是借助于脚本来实现

特点:

脚本中含有大量的命令,每个命令都要启动一个进程,命令执行完以后就要终止这个进程。如此一来,系统初始化时将大量的创建进程,销毁进程,工作效率会非常低。

服务间可能会存在依赖关系,必须严格按照一定的顺序来启动服务,前一个服务没启动完后面的服务就无法执行启动过程。不能并行进行。

配置文件:/etc/inittab

Upstart风格:init(centos6),由ubuntu研发的,通过总线形式接近于并行的方式工作,效率比Sysv高。

特点:

基于总线方式能够让进程间互相通信的一个应用程序

不用等服务启动完成,只要一初始化就可以把自己的状态返回给其他进程

配置文件:/etc/inittab,/etc/init/*.conf

Systemd风格:systemd(centos7)

特点:启动速度比SysV和Upstar都快

不需要通过任何脚本来启动服务,systemd自身就可以启动服务,其本身就是一个强大的解释器,启动服务时不需要sh/bash的参与

systemd不真正在系统初始化时去启动任何一个服务

只要服务没有用到,它告诉你启动了,实际上并没有启动。仅当第一次去访问时才会真正启动服务

配置文件:/usr/lib/systemd/system,/etc/systemd/system

系统启动和服务器进程由systemd系统和服务管理器进行管理。此程序提供了一种方式,可以在启动时和运行中的系统上激活系统资源、服务器守护进程和其他进程。

守护进程是在执行各种任务的后台等待或运行的进程。为了倾听连接,守护进程使用套接字。套接字可以由守护进程创建,或者与守护进程分离,并且可能由另一个进程创建(如systemd),随后在客户端建立连接时将套接字传递到守护进程。

服务通常指的是一个或多个守护进程,但启动或停止一项服务可能会对系统的状态进行一次性更改(如配置网络接口),不会留下守护进程之后继续运行。

1.2.systemd的新特性

系统引导时实现服务并进行启动

按需激活进程

系统状态快照

基于依赖关系定义服务控制逻辑

1.3.systemd的核心概念Unit

systemd使用unit的概念来管理服务,这些unit表现为一个个配置文件。

systemd通过对这些配置文件进行标识和配置达到管理服务的目的:

  1. //这些unit文件中主要包含了系统服务、监听socket、保存的系统快照
  2. //及其它与init相关的信息保存至以下目录:
  3. /usr/lib/systemd/system
  4. /run/systemd/system
  5. /etc/systemd/system

Unit的类型

  1. Service unit //文件扩展名为.service,用于定义系统服务
  2. Target unit //文件扩展名为.target,用于模拟实现“运行级别”
  3. runlevel0.targetpoweroff.target //关机
  4. runlevel1.targetrescue.target //单用户模式
  5. runlevel2.targetmulti-user.target //对于systemd来说,2/3/4级别没有区别
  6. runlevel3.targetmulti-user.target //对于systemd来说,2/3/4级别没有区别
  7. runlevel4.targetmulti-user.target //对于systemd来说,2/3/4级别没有区别
  8. runlevel5.targetgraphical.target //图形级别
  9. runlevel6.targetreboot.target //重启
  10. Device unit //文件扩展名为.device,用于定义内核识别的设备
  11. Mount unit //文件扩展名为.mount,用于定义文件系统挂载点
  12. Socket unit //文件扩展名为.socket,用于标识进程间通信用的socket文件
  13. Snapshot unit //文件扩展名为.snapshot,用于管理系统快照
  14. Swap unit //文件扩展名为.swap,用于标识swap设备
  15. Automount unit //文件扩展名为.automount,用于实现文件系统的自动挂载点
  16. Path unit //文件扩展名为.path,用于定义文件系统中的一个文件或目录

Unit关键特性

  1. //基于socket的激活机制:
  2. socket与服务程序分离,当有人去访问时才会真正启动服务,以此来实现按需激活进程与服务的并行启动
  3. //基于bus的激活机制:
  4. 所有使用dbus实现进程间通信的服务,可以在第一次被访问时按需激活
  5. //基于device的激活机制:
  6. 支持基于device激活的系统服务,可以在特定类型的硬件接入到系统中时,按需激活其所需要用到的服务
  7. //基于path的激活机制:
  8. 某个文件路径变得可用,或里面出现新文件时就激活某服务
  9. //系统快照:
  10. 保存各unit的当前状态信息于持久存储设备中,必要时能自动载入
  11. //向后兼容sysv init脚本

不兼容特性

  1. //systemctl命令固定不变
  2. //非由systemd启动的服务,systemctl无法与之通信
  3. //只有已经启动的服务在级别切换时才会执行stop,在centos6以前是所有S开头的服务全部start,所有K开头的服务全部stop
  4. //系统服务不会读取任何来自标准输入的数据流
  5. //每个服务的unit操作均受5分钟超时时间限制

2.使用systemctl管理服务

  1. //语法:systemctl COMMAND name[.service|.target]
  2. //常用COMMAND:
  3. start name.service //启动服务
  4. stop name.service //停止服务
  5. restart name.service //重启服务
  6. status name.service //查看服务状态
  7. [root@localhost ~]# systemctl stop postfix.service
  8. [root@localhost ~]# systemctl status postfix.service
  9. postfix.service - Postfix Mail Transport Agent
  10. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  11. Active: inactive (dead) since 2019-09-25 15:11:46 CST; 23s ago
  12. Process: 2146 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
  13. Process: 1177 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  14. Process: 1165 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  15. Process: 1097 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
  16. Main PID: 1321 (code=killed, signal=TERM)
  17. 9 25 10:06:41 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  18. 9 25 10:06:43 localhost.localdomain postfix/postfix-script[1319]: starting the Postfix mail system
  19. 9 25 10:06:43 localhost.localdomain postfix/master[1321]: daemon started -- version 2.10.1, configuration ...fix
  20. 9 25 10:06:43 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  21. 9 25 15:11:46 localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent...
  22. 9 25 15:11:46 localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent.
  23. Hint: Some lines were ellipsized, use -l to show in full.
  24. [root@localhost ~]# systemctl start postfix.service
  25. [root@localhost ~]# systemctl status postfix.service
  26. postfix.service - Postfix Mail Transport Agent
  27. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  28. Active: active (running) since 2019-09-25 15:12:51 CST; 9s ago
  29. Process: 2146 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
  30. Process: 2168 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  31. Process: 2165 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  32. Process: 2163 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
  33. Main PID: 2240 (master)
  34. CGroup: /system.slice/postfix.service
  35. ├─2240 /usr/libexec/postfix/master -w
  36. ├─2241 pickup -l -t unix -u
  37. └─2242 qmgr -l -t unix -u
  38. 9 25 15:12:51 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  39. 9 25 15:12:51 localhost.localdomain postfix/master[2240]: daemon started -- version 2.10.1, configuration ...fix
  40. 9 25 15:12:51 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  41. Hint: Some lines were ellipsized, use -l to show in full.
  42. [root@localhost ~]# systemctl restart postfix.service
  43. [root@localhost ~]# systemctl status postfix.service
  44. postfix.service - Postfix Mail Transport Agent
  45. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  46. Active: active (running) since 2019-09-25 15:14:20 CST; 16s ago
  47. Process: 2250 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
  48. Process: 2264 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  49. Process: 2262 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  50. Process: 2259 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
  51. Main PID: 2336 (master)
  52. CGroup: /system.slice/postfix.service
  53. ├─2336 /usr/libexec/postfix/master -w
  54. ├─2337 pickup -l -t unix -u
  55. └─2338 qmgr -l -t unix -u
  56. 9 25 15:14:20 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  57. 9 25 15:14:20 localhost.localdomain postfix/master[2336]: daemon started -- version 2.10.1, configuration ...fix
  58. 9 25 15:14:20 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  59. Hint: Some lines were ellipsized, use -l to show in full.
  1. try-restart name.service //条件式重启服务,若服务已经启动则重启,若服务未启动则不做任何操作
  2. [root@localhost ~]# systemctl stop postfix.service
  3. [root@localhost ~]# systemctl try-restart postfix.service
  4. [root@localhost ~]# systemctl status postfix.service
  5. postfix.service - Postfix Mail Transport Agent
  6. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  7. Active: inactive (dead) since 2019-09-25 15:17:46 CST; 42s ago
  8. Process: 2346 ExecStop=/usr/sbin/postfix stop (code=exited, status=0/SUCCESS)
  9. Process: 2264 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  10. Process: 2262 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  11. Process: 2259 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
  12. Main PID: 2336 (code=killed, signal=TERM)
  13. 9 25 15:14:20 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  14. 9 25 15:14:20 localhost.localdomain postfix/master[2336]: daemon started -- version 2.10.1, configuration ...fix
  15. 9 25 15:14:20 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  16. 9 25 15:17:46 localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent...
  17. 9 25 15:17:46 localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent.
  18. Hint: Some lines were ellipsized, use -l to show in full.
  1. reload-or-restart name.service //重载或重启服务,能reload则reload,否则restart
  2. reload-or-try-restart name.service //重载或条件式重启服务,能reload则reload,否则try-restart
  3. mask name.service //禁止设定为开机自启
  4. unmask name.service //取消禁止设定为开机自启
  5. [root@localhost ~]# systemctl mask postfix.service
  6. Created symlink from /etc/systemd/system/postfix.service to /dev/null.
  7. [root@localhost ~]# systemctl status postfix.service
  8. postfix.service
  9. Loaded: masked (/dev/null; bad)
  10. Active: inactive (dead) since 2019-09-25 15:17:46 CST; 3min 11s ago
  11. Main PID: 2336 (code=killed, signal=TERM)
  12. 9 25 15:14:20 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  13. 9 25 15:14:20 localhost.localdomain postfix/master[2336]: daemon started -- version 2.10.1, configuration ...fix
  14. 9 25 15:14:20 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  15. 9 25 15:17:46 localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent...
  16. 9 25 15:17:46 localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent.
  17. Hint: Some lines were ellipsized, use -l to show in full.
  18. [root@localhost ~]# systemctl unmask postfix.service
  19. Removed symlink /etc/systemd/system/postfix.service.
  20. [root@localhost ~]# systemctl status postfix.service
  21. postfix.service - Postfix Mail Transport Agent
  22. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  23. Active: inactive (dead) since 2019-09-25 15:17:46 CST; 3min 27s ago
  24. Main PID: 2336 (code=killed, signal=TERM)
  25. 9 25 15:14:20 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  26. 9 25 15:14:20 localhost.localdomain postfix/master[2336]: daemon started -- version 2.10.1, configuration ...fix
  27. 9 25 15:14:20 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  28. 9 25 15:17:46 localhost.localdomain systemd[1]: Stopping Postfix Mail Transport Agent...
  29. 9 25 15:17:46 localhost.localdomain systemd[1]: Stopped Postfix Mail Transport Agent.
  30. Hint: Some lines were ellipsized, use -l to show in full.
  1. list-dependencies name.service //查看服务的依赖关系
  2. is-active name.service //查看某服务当前激活与否的状态
  3. is-enable name.service //查看服务是否开机自动启动
  4. [root@localhost ~]# systemctl list-dependencies postfix.service
  5. postfix.service
  6. ├─system.slice
  7. └─basic.target
  8. ├─microcode.service
  9. ├─rhel-autorelabel-mark.service
  10. ├─rhel-autorelabel.service
  11. ├─rhel-configure.service
  12. ├─rhel-dmesg.service
  13. ├─rhel-loadmodules.service
  14. ├─selinux-policy-migrate-local-changes@targeted.service
  15. ├─paths.target
  16. ├─slices.target
  17. ├─-.slice
  18. └─system.slice
  19. ├─sockets.target
  20. ├─dbus.socket
  21. ├─dm-event.socket
  22. ├─systemd-initctl.socket
  23. ├─systemd-journald.socket
  24. ├─systemd-shutdownd.socket
  25. ├─systemd-udevd-control.socket
  26. └─systemd-udevd-kernel.socket
  27. ├─sysinit.target
  28. ├─dev-hugepages.mount
  29. ├─dev-mqueue.mount
  30. ├─kmod-static-nodes.service
  31. ├─lvm2-lvmetad.socket
  32. ├─lvm2-lvmpolld.socket
  33. ├─lvm2-monitor.service
  34. ├─plymouth-read-write.service
  35. lines 2-30
  36. [root@localhost ~]# systemctl is-active postfix.service
  37. active
  38. [root@localhost ~]# systemctl status postfix.service
  39. postfix.service - Postfix Mail Transport Agent
  40. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  41. Active: active (running) since 2019-09-25 15:22:42 CST; 4min 22s ago
  42. Process: 2413 ExecStart=/usr/sbin/postfix start (code=exited, status=0/SUCCESS)
  43. Process: 2411 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  44. Process: 2408 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=0/SUCCESS)
  45. Main PID: 2485 (master)
  46. CGroup: /system.slice/postfix.service
  47. ├─2485 /usr/libexec/postfix/master -w
  48. ├─2486 pickup -l -t unix -u
  49. └─2487 qmgr -l -t unix -u
  50. 9 25 15:22:41 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  51. 9 25 15:22:42 localhost.localdomain postfix/master[2485]: daemon started -- version 2.10.1, configuration ...fix
  52. 9 25 15:22:42 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  53. Hint: Some lines were ellipsized, use -l to show in full.
  1. enable name.service //设定某服务开机自动启动
  2. disable name.service //禁止服务开机自动启动
  3. [root@localhost ~]# systemctl enable postfix.service
  4. [root@localhost ~]# systemctl status postfix.service
  5. postfix.service - Postfix Mail Transport Agent
  6. Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
  7. Active: active (running) since 2019-09-25 15:22:42 CST; 8min ago
  8. Main PID: 2485 (master)
  9. CGroup: /system.slice/postfix.service
  10. ├─2485 /usr/libexec/postfix/master -w
  11. ├─2486 pickup -l -t unix -u
  12. └─2487 qmgr -l -t unix -u
  13. 9 25 15:22:41 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  14. 9 25 15:22:42 localhost.localdomain postfix/master[2485]: daemon started -- version 2.10.1, configuration ...fix
  15. 9 25 15:22:42 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  16. Hint: Some lines were ellipsized, use -l to show in full.
  17. [root@localhost ~]# systemctl disable postfix.service
  18. Removed symlink /etc/systemd/system/multi-user.target.wants/postfix.service.
  19. [root@localhost ~]# systemctl status postfix.service
  20. postfix.service - Postfix Mail Transport Agent
  21. Loaded: loaded (/usr/lib/systemd/system/postfix.service; disabled; vendor preset: disabled)
  22. Active: active (running) since 2019-09-25 15:22:42 CST; 10min ago
  23. Main PID: 2485 (master)
  24. CGroup: /system.slice/postfix.service
  25. ├─2485 /usr/libexec/postfix/master -w
  26. ├─2486 pickup -l -t unix -u
  27. └─2487 qmgr -l -t unix -u
  28. 9 25 15:22:41 localhost.localdomain systemd[1]: Starting Postfix Mail Transport Agent...
  29. 9 25 15:22:42 localhost.localdomain postfix/master[2485]: daemon started -- version 2.10.1, configuration ...fix
  30. 9 25 15:22:42 localhost.localdomain systemd[1]: Started Postfix Mail Transport Agent.
  31. Hint: Some lines were ellipsized, use -l to show in full.
  1. isolate name.target //切换至某级别,如systemctl isolate graphical.target就是切换至图形界面
  2. list-unit-files --type service //查看所有服务的开机自动启动状态(是否开机自启)
  3. list-units --type service //查看所有已经激活的服务状态信息
  4. list-units --type target //查看所有已装载的级别
  5. list-units --type service --all //查看所有服务(已启动/已停止)的状态信息
  6. list -units --type target --all //查看所有的级别
  7. [root@localhost ~]# systemctl list-unit-files --type service
  8. UNIT FILE STATE
  9. arp-ethers.service disabled
  10. auditd.service enabled
  11. autovt@.service enabled
  12. blk-availability.service disabled
  13. brandbot.service static
  14. chrony-dnssrv@.service static
  15. chrony-wait.service disabled
  16. chronyd.service enabled
  17. console-getty.service disabled
  18. console-shell.service disabled
  19. container-getty@.service static
  20. cpupower.service disabled
  21. crond.service enabled
  22. dbus-org.fedoraproject.FirewallD1.service enabled
  23. dbus-org.freedesktop.hostname1.service static
  24. dbus-org.freedesktop.import1.service static
  25. dbus-org.freedesktop.locale1.service static
  26. dbus-org.freedesktop.login1.service static
  27. dbus-org.freedesktop.machine1.service static
  28. dbus-org.freedesktop.NetworkManager.service enabled
  29. dbus-org.freedesktop.nm-dispatcher.service enabled
  30. dbus-org.freedesktop.timedate1.service static
  31. dbus.service static
  32. debug-shell.service disabled
  33. dm-event.service disabled
  34. dracut-cmdline.service static
  35. dracut-initqueue.service static
  36. dracut-mount.service static
  1. get-default //查看默认运行级别
  2. set-default name.target //设置默认运行级别
  3. [root@localhost ~]# systemctl get-default
  4. multi-user.target
  5. [root@localhost ~]# systemctl set-default multi-user.target
  6. Removed symlink /etc/systemd/system/default.target.
  7. Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.
  1. rescue //切换至紧急救援模式(大多数服务不启动,但是会加载驱动)
  2. emergency //切换至emergency模式(驱动不会加载,系统不会初始化,服务不会启动)
  3. halt //关机
  4. poweroff //关机
  5. reboot //重启
  6. suspend //挂起系统,此时不能关机,否则无用
  7. hibernate //创建并保存系统快照,下次系统重启时会自动载入快照
  8. hybrid-sleep //混合睡眠,快照并挂起

Linux控制服务和守护进程的更多相关文章

  1. Linux_控制服务与守护进程

    一.systemd 1.systemd简介 1️⃣:systemd是用户空间的第一个应用程序,即/sbin/init 2️⃣:init程序的类型: SysV风格:init(centos5),实现系统初 ...

  2. Linux编程之《守护进程》

    Intro ----- 守护进程,也就是通常说的Daemon进程,是Linux中的后台服务进程.它是一个生存期较长的进程,通常独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件.守护进程常 ...

  3. Supervisor 为服务创建守护进程

    今天需要再服务上部署一个.net 方面的项目:当时开启服务的命令只能在前台执行:使用nohub CMD &等放在后台开启服务都会宕机:所以搜寻了Supervisor 这个解决办法,为服务创建守 ...

  4. Linux下一个简单守护进程的实现 (Daemon)

    在Linux/UNIX系统引导的时候会开启很多服务,这些服务称为守护进程(也叫Daemon进程).守护进程是脱离于控制终端并且在后台周期性地执行某种任务或等待处理某些事件的进程,脱离终端是为了避免进程 ...

  5. 一只简单的网络爬虫(基于linux C/C++)————守护进程

    守护进程,也就是通常说的Daemon进程,是Linux中的后台服务进程.它是一个生存期较长的进程,通常独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件.守护进程常常在系统引导装入时启动, ...

  6. Linux 下Qt实现守护进程实例(转)

     原文地址:Linux守护进程的编程方法(含实例) 作者:lingdxuyan 参考文献 Linux信号列表(zz) Linux 守护进程的编程方法 linux上编写守护进程的例程 Linux下后台守 ...

  7. Linux系统编程之--守护进程的创建和详解【转】

    本文转载自:http://www.cnblogs.com/mickole/p/3188321.html 一,守护进程概述 Linux Daemon(守护进程)是运行在后台的一种特殊进程.它独立于控制终 ...

  8. linux系统编程:守护进程详解及创建,daemon()使用

    一,守护进程概述 Linux Daemon(守护进程)是运行在后台的一种特殊进程.它独立于控制终端并且周期性地执行某种任务或等待处理某些发生的事件.它不需要用户输入就能运行而且提供某种服务,不是对整个 ...

  9. Linux基础命令---httpd守护进程

    httpd httpd是apache超文本传输协议的主程序,它被设计成一个独立运行的守护进程.httpd会建立一个线程池来处理http请求. 此命令的适用范围:RedHat.RHEL.Ubuntu.C ...

随机推荐

  1. Python之路Day07

    基础数据类型补充 str s.capitalize() -- 首字母大写 s.title() -- 每个单词首字母大写 s.swapcase() -- 大小写转换 s.center() -- 居中/填 ...

  2. war文件—Web项目部署

    war文件是什么? Web存档(war)文件包含Web应用程序的所有内容.它减少了传输文件所需要的时间.  war文件的优点 节省时间:war文件将所有文件合并为一个单位. 所以在将文件从客户端传输到 ...

  3. C# LINQ GroupBy

    一.先准备要使用的类: 1.Person类: class Person { public string Name { set; get; } public int Age { set; get; } ...

  4. Mysql数据多表查询及pymysql的使用

    Exists关键字表示存在,在使用exists关键字时,内增查询语句不返回查询记录,而是返回一个真假值,True或者False,返回True外层语句才会进行查询:返回False时,外层查询语句不会进行 ...

  5. 图像滤波—opencv函数

      函数原型 方框滤波 ,-), bool normalize = true, int borderType = BORDER_DEFAULT) 均值滤波 ,-), int borderType = ...

  6. eclipse出错

    程序初次build project没有问题,代码没有做任何修改再次build project却出现了make[1]: ***这样的错误,这是为什么?尝试过修改一点代码后重新编译也可能出现make[1] ...

  7. 第三十三篇 玩转数据结构——红黑树(Read Black Tree)

    1.. 图解2-3树维持绝对平衡的原理: 2.. 红黑树与2-3树是等价的 3.. 红黑树的特点 简要概括如下: 所有节点非黑即红:根节点为黑:NULL节点为黑:红节点孩子为黑:黑平衡 4.. 实现红 ...

  8. 题解【洛谷P2863】 [USACO06JAN]牛的舞会The Cow Prom

    题面 题解 \(Tarjan\)板子题. 统计出大小大于\(1\)的强连通分量数量输出即可. 代码 #include <iostream> #include <cstdio> ...

  9. java程序员摸爬滚打的三年,这些经历你值得借鉴

    不知不觉都2020年2月底了,小羊同学从毕业快开始都一直从事java开发这个行业,前两天开通了头条号,想借此发文分享一下这几年的经历吧,如果你是还没毕业的大学生或者刚入行不久,也许会对你有帮助. 1: ...

  10. HTML学习(9)头部

    HTML <head> 元素 <head> 元素包含了所有的头部标签元素.在 <head>元素中你可以插入脚本(scripts), 样式文件(CSS),及各种met ...