GNU/Linux >> Tutoriales Linux >  >> Cent OS

Systemctl reemplaza los comandos Chkconfig y Service en CentOS 7

De nuestra experiencia previa de CentOS/RedHat , todos sabíamos que “ chkconfig El comando se usa para verificar y actualizar información de nivel de ejecución para servicios del sistema . Estos comandos heredados todavía se incluyen en CentOS 7 por compatibilidad con versiones anteriores, pero quedarán obsoletos en versiones futuras. En CentOS 7/Redhat 7  systemctl reemplaza chkconfig y service comandos Aquí hay un pequeño tutorial para ayudarlo a comprender y aprender el systemctl ¡comando!

Systemctl reemplaza los comandos Chkconfig y Service

Reiniciar los servicios del sistema en CentOS 7/Redhat 7

Dado que todos usamos CentOS/Redhat de manera extensiva, iniciaremos/reiniciaremos un servicio normalmente de la siguiente manera:

[root@root ~]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service

Pero, ¡puedes tomar nota de ese pequeño mensaje! diciendo:'Oye, las cosas han cambiado y para el futuro... comienza a usar systemctl comando en lugar de los comandos heredados”.

Así es como puedes usar systemctl comandos para iniciar/reiniciar el servicio como se muestra a continuación:

Iniciar el servicio

# systemctl start mysqld

Reiniciar el servicio:

# systemctl restart mysqld
Cómo encontrar el estado de un servicio en CentOS 7/Redhat 7

El comando anterior no proporciona ningún resultado sobre si el servicio se ha iniciado o no. Para averiguar el estado, use el siguiente comando:

# systemctl status mysqld
 mysqld.service - MySQL Server
 Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
 Active: active (running) since Thu 2017-11-09 09:32:57 CST; 1min 57s ago
 Docs: man:mysqld(8)
 http://dev.mysql.com/doc/refman/en/using-systemd.html
 Process: 1660 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
 Process: 1640 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
 Main PID: 1662 (mysqld)
 CGroup: /system.slice/mysqld.service
 ââ1662 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mys...

Nov 09 09:32:56 s119957 systemd[1]: Starting MySQL Serv...
Nov 09 09:32:57 s119957 systemd[1]: Started MySQL Server.
Hint: Some lines were ellipsized, use -l to show in full.

Chkconfig en CentOS 7

Si desea que sus servicios se inicien automáticamente al arrancar, no puede usar chkconfig (comando heredado en el viejo CentOS)! Sí, has escuchado bien. Ahora  systemctl reemplaza chkconfig comando también…

Servicio chkconfig activado:CentOS 7/Redhat 7:

#systemctl enable <service_name>

por ejemplo,

#systemctl enable mysqld

Servicio chkconfig desactivado:CentOS7/Redhat 7:

#systemctl disable <service_name>

por ejemplo,

#systemctl disable mysqld

lista de servicios particulares de chkconfig:CentOS 7/Redhat 7:

#systemctl is-enabled <service_name>

por ejemplo,

#systemctl is-enabled mysqld
enabled

chkconfig –lista – CentOS 7/Redhat 7:

#systemctl list-unit-files --type=service

UNIT FILE                                     STATE
arp-ethers.service                           disabled
auditd.service                               enabled
[email protected]                              enabled
blk-availability.service                     disabled
brandbot.service                             static
console-getty.service                        disabled
console-shell.service                        disabled
[email protected]                     static
cpupower.service                             disabled
...
...

Actualízate y disfruta trabajando en CentOS 7 🙂


Cent OS
  1. Iniciar, detener o reiniciar servicios en CentOS 8 - ¿Proceso paso a paso?

  2. Detener y deshabilitar Firewalld en CentOS 7:¿proceso paso a paso?

  3. ¿Centos 4.8 y Glibc 2.5?

  4. CentOS/RHEL:Cómo instalar e iniciar el servicio Apache httpd

  5. Cómo enmascarar o desenmascarar un servicio en CentOS/RHEL 7 y 8

Cómo instalar Prometheus y node_exporter en CentOS 7

Cómo instalar Prometheus Monitoring y node_exporter en CentOS 8

Comandos Systemctl para administrar el servicio Systemd

Cómo iniciar, detener o reiniciar servicios en CentOS 8

Cómo instalar Nagios Core y NRPE en CentOS 8

CentOS / RHEL 7:Guía para principiantes de unidades de servicio systemd