CentOS7自有服务和软件包

Posted 小基基o_O

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7自有服务和软件包相关的知识,希望对你有一定的参考价值。

文章目录

什么是服务

  • 什么是程序(Computer Program)?
    全称计算机程序电脑程式,简称程序,是一组计算机能识别和执行的指令
  • 什么是进程(Process)?
    计算机程序关于某数据集合上的一次运行活动
  • 什么是服务
    特定的进程
  • 什么是自有服务
    Linux系统开机后 自动运行的 服务
    例如:SSH服务

管理服务的命令:systemctl

列出服务

列出所有服务(含启动和冇启动的)

systemctl list-units --type service --all

列出所有启动的服务

systemctl list-units --type service

列出指定服务

systemctl list-units --type service mysqld.service
UNITLOADACTIVESUBDESCRIPTION
mysqld.serviceloadedactiverunningMySQL Server
原文译文
LOADReflects whether the unit definition was properly loaded单元是否被正确加载
ACTIVEThe high-level unit activation state, i.e. generalization of SUB高级单元活跃状态
SUBThe low-level unit activation state, values depend on unit type低级单元活跃状态

显示所有已安装的单元文件

systemctl list-unit-files

服务启停

systemctl 选项 服务名
选项说明
start启动
stop停止
restart重启

开机自动启动服务

允许 指定服务 开机自启

systemctl enable 服务名

禁用 指定服务 开机自启

systemctl disable 服务名

服务状态

systemctl status 服务名

例如:systemctl status mysqld

● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-11-16 19:55:58 CST; 21h ago
  Process: 9065 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
  Process: 8991 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 9069 (mysqld)
   CGroup: /system.slice/mysqld.service
           └─9069 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid

软件包

  • 软件安装包,有:源码包二进制包
  • 源码包:因为 计算机只识别机器语言,所以 要将源码编译为机器语言才能安装
  • 二进制包:源码包经过成功编译之后产生的包,可直接安装

RPM

  • 全称:RedHat Package Manager
  • 作用
    对Linux软件包进行管理,包括:查询、卸载、安装、更新
  • RPM依赖:如果 软件A 依赖 软件B,就 要先装B再装A 才能使A可运行
# 查询
rpm -q|--query [select-options] [query-options]
# 安装
rpm -i|--install [install-options] PACKAGE_FILE ...
# 升级
rpm -U|--upgrade [install-options] PACKAGE_FILE ...
# 删除
rpm -e|--erase [--allmatches] [--justdb] [--nodeps] [--noscripts] [--notriggers] [--test] PACKAGE_NAME ...

查询安装了什么软件

查询全部软件

rpm -qa

查询指定名称的软件

rpm -qa | grep 软件名称

-a--all:Query all installed packages.

卸载某个软件

rpm -e 软件的完整名称

安装某个软件

rpm -ivh 软件包名称
参数说明
-v打印详细信息
-hhash显示安装进度(要配合-v使用)

查询文件所属的包名

rpm -qf 被查询的文件

例如:rpm -qf /var/lib/mysql

查询软件安装后,生成了哪些文件

rpm -ql 软件名称

例如:rpm -ql mysql-community-server-5.7.16-1.el7.x86_64

/etc/logrotate.d/mysql
/etc/my.cnf
/etc/my.cnf.d
/usr/bin/innochecksum
/usr/bin/lz4_decompress
/usr/bin/my_print_defaults
/usr/bin/myisam_ftdump
/usr/bin/myisamchk
/usr/bin/myisamlog
/usr/bin/myisampack
/usr/bin/mysql_install_db
/usr/bin/mysql_plugin
/usr/bin/mysql_secure_installation
/usr/bin/mysql_ssl_rsa_setup
/usr/bin/mysql_tzinfo_to_sql
/usr/bin/mysql_upgrade
/usr/bin/mysqld_pre_systemd
/usr/bin/mysqldumpslow
/usr/bin/perror
/usr/bin/replace
/usr/bin/resolve_stack_dump
/usr/bin/resolveip
/usr/bin/zlib_decompress
/usr/lib/systemd/system/mysqld.service
/usr/lib/systemd/system/mysqld@.service
/usr/lib/tmpfiles.d/mysql.conf
/usr/lib64/mysql/mecab
/usr/lib64/mysql/mecab/dic
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_euc-jp/unk.dic
/usr/lib64/mysql/mecab/dic/ipadic_sjis
/usr/lib64/mysql/mecab/dic/ipadic_sjis/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_sjis/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_sjis/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_sjis/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_sjis/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_sjis/unk.dic
/usr/lib64/mysql/mecab/dic/ipadic_utf-8
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/char.bin
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/dicrc
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/left-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/matrix.bin
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/pos-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/rewrite.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/right-id.def
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/sys.dic
/usr/lib64/mysql/mecab/dic/ipadic_utf-8/unk.dic
/usr/lib64/mysql/mecab/etc
/usr/lib64/mysql/mecab/etc/mecabrc
/usr/lib64/mysql/plugin
/usr/lib64/mysql/plugin/adt_null.so
/usr/lib64/mysql/plugin/auth_socket.so
/usr/lib64/mysql/plugin/debug
/usr/lib64/mysql/plugin/debug/adt_null.so
/usr/lib64/mysql/plugin/debug/auth_socket.so
/usr/lib64/mysql/plugin/debug/ha_example.so
/usr/lib64/mysql/plugin/debug/innodb_engine.so
/usr/lib64/mysql/plugin/debug/keyring_file.so
/usr/lib64/mysql/plugin/debug/keyring_udf.so
/usr/lib64/mysql/plugin/debug/libmemcached.so
/usr/lib64/mysql/plugin/debug/libpluginmecab.so
/usr/lib64/mysql/plugin/debug/locking_service.so
/usr/lib64/mysql/plugin/debug/mypluglib.so
/usr/lib64/mysql/plugin/debug/mysql_no_login.so
/usr/lib64/mysql/plugin/debug/mysqlx.so
/usr/lib64/mysql/plugin/debug/rewrite_example.so
/usr/lib64/mysql/plugin/debug/rewriter.so
/usr/lib64/mysql/plugin/debug/semisync_master.so
/usr/lib64/mysql/plugin/debug/semisync_slave.so
/usr/lib64/mysql/plugin/debug/validate_password.so
/usr/lib64/mysql/plugin/debug/version_token.so
/usr/lib64/mysql/plugin/ha_example.so
/usr/lib64/mysql/plugin/innodb_engine.so
/usr/lib64/mysql/plugin/keyring_file.so
/usr/lib64/mysql/plugin/keyring_udf.so
/usr/lib64/mysql/plugin/libmemcached.so
/usr/lib64/mysql/plugin/libpluginmecab.so
/usr/lib64/mysql/plugin/locking_service.so
/usr/lib64/mysql/plugin/mypluglib.so
/usr/lib64/mysql/plugin/mysql_no_login.so
/usr/lib64/mysql/plugin/mysqlx.so
/usr/lib64/mysql/plugin/rewrite_example.so
/usr/lib64/mysql/plugin/rewriter.so
/usr/lib64/mysql/plugin/semisync_master.so
/usr/lib64/mysql/plugin/semisync_slave.so
/usr/lib64/mysql/plugin/validate_password.so
/usr/lib64/mysql/plugin/version_token.so
/usr/sbin/mysqld
/usr/sbin/mysqld-debug
/usr/share/doc/mysql-community-server-5.7.16
/usr/share/doc/mysql-community-server-5.7.16/COPYING
/usr/share/doc/mysql-community-server-5.7.16/ChangeLog
/usr/share/doc/mysql-community-server-5.7.16/INFO_BIN
/usr/share/doc/mysql-community-server-5.7.16/INFO_SRC
/usr/share/doc/mysql-community-server-5.7.16/README
/usr/share/doc/mysql-community-server-5.7.16/my-default.cnf
/usr/share/man/man1/innochecksum.1.gz
/usr/share/man/man1/lz4_decompress.1.gz
/usr/share/man/man1/my_print_defaults.1.gz
/usr/share/man/man1/myisam_ftdump.1.gz
/usr/share/man/man1/myisamchk.1.gz
/usr/share/man/man1/myisamlog.1.gz
/usr/share/man/man1/myisampack.1.gz
/usr/share/man/man1/mysql.server.1.gz
/usr/share/man/man1/mysql_install_db.1.gz
/usr/share/man/man1/mysql_plugin.1.gz
/usr/share/man/man1/mysql_secure_installation.1.gz
/usr/share/man/man1/mysql_ssl_rsa_setup.1.gz
/usr/share/man/man1/mysql_tzinfo_to_sql.1.gz
/usr/share/man/man1/mysql_upgrade.1.gz
/usr/share/man/man1/mysqldumpslow.1.gz
/usr/share/man/man1/mysqlman.1.gz
/usr/share/man/man1/perror.1.gz
/usr/share/man/man1/replace.1.gz
/usr/share/man/man1/resolve_stack_dump.1.gz
/usr/share/man/man1/resolveip.1.gz
/usr/share/man/man1/zlib_decompress.1.gz
/usr/share/man/man8/mysqld.8.gz
/usr/share/mysql/dictionary.txt
/usr/share/mysql/fill_help_tables.sql
/usr/share/mysql/innodb_memcached_config.sql
/usr/share/mysql/install_rewriter.sql
/usr/share/mysql/magic
/usr/share/mysql/my-default.cnf
/usr/share/mysql/mysql-log-rotate
/usr/share/mysql/mysql_security_commands.sql
/usr/share/mysql/mysql_sys_schema.sql
/usr/share/mysql/mysql_system_tables.sql
/usr/share/mysql/mysql_system_tables_data.sql
/usr/share/mysql/mysql_test_data_timezone.sql
/usr/share/mysql/uninstall_rewriter.sql
/var/lib/mysql
/var/lib/mysql-files
/var/lib/mysql-keyring
/var/run/mysqld

YUM

  • 全称:Yellow dog Updater, Modified
  • 一个在Fedora和RedHat以及CentOS中的Shell前端软件包管理器
    类似于 电脑的软件管家、手机的应用市场
  • 基于RPM,能够从指定的服务器(YUM源)自动下载RPM并安装
    自动处理依赖关系,并一次安装所有依赖的软件包
  • YUM源
    源,是指软件安装包的来源,也称软件仓库
    YUM源:使用YUM时,这个软件安装包的来源
  • .repo文件
    是Fedora中YUM源的配置文件
    定义了一个或多个软件仓库的细节内容,例如我们将从哪里下载需要安装或升级的软件包

云服务器上的YUM源的部分默认配置

命令

yum [options] [command] [package ...]
常用command说明
search搜索软件包
install安装软件
remove删除软件
update更新软件
clean清除所有缓存
makecache重新生成缓存

示例:安装软件

yum [-y] install 名称

-y可选,表示yes自动确认安装

epel-release

  • Extra Packages for Enterprise Linux
    EPEL提供更多高质量软件包
    安装EPEL后,相当于添加了一个第三方源;安装命令如下
yum -y install epel-release

使用yum安装时会有找不到rpm的情况,是因为 基础的CentOS提供的rpm包不够丰富

以上是关于CentOS7自有服务和软件包的主要内容,如果未能解决你的问题,请参考以下文章

私有化即时通讯软件

企业什么要建设自有即时通讯软件系统

跪求centos7.1iso镜像 64位官方版软件百度云资源

NIS - 深入了解如何搭建NIS环境

Linux云服务器yum 不能用

阿里云ECS CentOS7服务器上部署web项目简单办法