libvirtd not enabled after install and shuts down after 2 mins - python

I have a brand new Fedora Server 36 minimal install and all it will run is KVM.
Did the install with dnf group install "Headless Virtualization" and restarted the server.
systemctl status libvirtd showed it was not running; i.e.
[root#dell-fedora-kvm ~]# systemctl status libvirtd
○ libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: inactive (dead)
TriggeredBy: ○ libvirtd-tcp.socket
○ libvirtd-admin.socket
○ libvirtd-ro.socket
○ libvirtd-tls.socket
○ libvirtd.socket
Docs: man:libvirtd(8)
https://libvirt.org
so I started and enabled it with systemctl start libvirtd and systemctl enable libvirtd
restarted but it still doesn't start automatically. When I start it manually systemctl start libvirtd, this is what I get with status. Not sure this tells us where the issue could be.
root#dell-fedora-kvm ~]# systemctl status libvirtd
● libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: active (running) since Sun 2022-07-03 16:32:23 AEST; 52s ago
TriggeredBy: ○ libvirtd-tcp.socket
● libvirtd-admin.socket
● libvirtd-ro.socket
○ libvirtd-tls.socket
● libvirtd.socket
Docs: man:libvirtd(8)
https://libvirt.org
Main PID: 857 (libvirtd)
Tasks: 21 (limit: 32768)
Memory: 44.8M
CPU: 480ms
CGroup: /system.slice/libvirtd.service
├─ 857 /usr/sbin/libvirtd --timeout 120
├─ 957 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
└─ 958 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
Jul 03 16:32:23 dell-fedora-kvm systemd[1]: Started libvirtd.service - Virtualization daemon.
Jul 03 16:32:24 dell-fedora-kvm dnsmasq[957]: started, version 2.86 cachesize 150
Jul 03 16:32:24 dell-fedora-kvm dnsmasq[957]: compile time options: IPv6 GNU-getopt DBus no-UBus no-i18n IDN2 DHCP DHCPv6 no-Lua TFTP conntrack ipset auth cryptoh>
Jul 03 16:32:24 dell-fedora-kvm dnsmasq-dhcp[957]: DHCP, IP range 192.168.122.2 -- 192.168.122.254, lease time 1h
Jul 03 16:32:24 dell-fedora-kvm dnsmasq-dhcp[957]: DHCP, sockets bound exclusively to interface virbr0
Jul 03 16:32:24 dell-fedora-kvm dnsmasq[957]: reading /etc/resolv.conf
Jul 03 16:32:24 dell-fedora-kvm dnsmasq[957]: using nameserver 127.0.0.53#53
Jul 03 16:32:24 dell-fedora-kvm dnsmasq[957]: read /etc/hosts - 2 addresses
Jul 03 16:32:24 dell-fedora-kvm dnsmasq[957]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jul 03 16:32:24 dell-fedora-kvm dnsmasq-dhcp[957]: read /var/lib/libvirt/dnsmasq/default.hostsfile
However the service shuts down after about 2 mins...
[root#dell-fedora-kvm ~]# systemctl status libvirtd
○ libvirtd.service - Virtualization daemon
Loaded: loaded (/usr/lib/systemd/system/libvirtd.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Sun 2022-07-03 16:37:25 AEST; 6s ago
TriggeredBy: ○ libvirtd-tcp.socket
● libvirtd-admin.socket
● libvirtd-ro.socket
○ libvirtd-tls.socket
● libvirtd.socket
Docs: man:libvirtd(8)
https://libvirt.org
Process: 994 ExecStart=/usr/sbin/libvirtd $LIBVIRTD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 994 (code=exited, status=0/SUCCESS)
Tasks: 2 (limit: 32768)
Memory: 31.7M
CPU: 330ms
CGroup: /system.slice/libvirtd.service
├─ 957 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
└─ 958 /usr/sbin/dnsmasq --conf-file=/var/lib/libvirt/dnsmasq/default.conf --leasefile-ro --dhcp-script=/usr/libexec/libvirt_leaseshelper
Jul 03 16:35:25 dell-fedora-kvm systemd[1]: Starting libvirtd.service - Virtualization daemon...
Jul 03 16:35:25 dell-fedora-kvm systemd[1]: Started libvirtd.service - Virtualization daemon.
Jul 03 16:35:25 dell-fedora-kvm dnsmasq[957]: read /etc/hosts - 2 addresses
Jul 03 16:35:25 dell-fedora-kvm dnsmasq[957]: read /var/lib/libvirt/dnsmasq/default.addnhosts - 0 addresses
Jul 03 16:35:25 dell-fedora-kvm dnsmasq-dhcp[957]: read /var/lib/libvirt/dnsmasq/default.hostsfile
Jul 03 16:37:25 dell-fedora-kvm systemd[1]: libvirtd.service: Deactivated successfully.
Jul 03 16:37:25 dell-fedora-kvm systemd[1]: libvirtd.service: Unit process 957 (dnsmasq) remains running after unit stopped.
Jul 03 16:37:25 dell-fedora-kvm systemd[1]: libvirtd.service: Unit process 958 (dnsmasq) remains running after unit stopped.
I have not made any changes to libvirtd.service. Any idea what's going on?

In Fedora 35, the libvirt default installation was switched to use virtqemud
https://fedoraproject.org/wiki/Changes/LibvirtModularDaemons
Furthermore, regardless of whether an install is configured to use libvirtd or virtqemud, there is no need for the services to be running at install time. They all make use of systemd socket activation, so they will start automatically whenever some application tries to use libvirt. They will stay running as long as application is connected, and shutdown 2 minutes after the last app disconnects (unless VMs are actively running).

Related

How do I debug a exit-code failure for the specific service for my app?

I'm trying to run a Flask app through Apache. When I run
systemctl list-units --type=service
I see that the unit for this specific app, "SITENAME.service" has failed.
When I run
sudo systemctl status SITENAME.service
I
get an error saying:
Loaded: loaded (/etc/systemd/system/SITENAMEenv.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2023-01-01 21:26:25 UTC; 1min 1s ago
Process: 787 ExecStart=/home/ubuntu/SITENAME/SITENAMEenv/bin/uwsgi --ini SITENAMEenv.ini (code=exited, status=1/FAILURE)
Main PID: 787 (code=exited, status=1/FAILURE) Jan 01 21:26:25 ip-172-31-88-10 systemd[1]:
SITENAME.service: Main process exited, code=exited, status=1/FAILURE Jan 01 21:26:25 ip-172-31-88-10 systemd[1]: SITENAME.service: Failed with result 'exit-code'.
Where can I get more information on this failure? I can't tell if this is a python issue in the actual application code, or something else.
The site stopped working a little while ago, but there were no major changes to the code. The service that is not working has the description "uWSGI instance to serve SITENAME"

Cannot run python script as service systemctl Cent

I have following systemctl service
[Unit]
Description=Ml api
[Service]
#user=root
ExecStart=/usr/local/bin/python3.9 -u /home/a.nikitin#corp.bsv.legal/bsv_ml_api/app.py
ExecStop=/bin/kill -15 $MAINPID
Type=forking
#KillMode=process
#SyslogIdentifier=ml-api
#SyslogFacility=daemon
Restart=on-failure
[Install]
WantedBy=multiuser.target
When i run it i got an error. The sudo journalctl -u ml.service -e shows
ml.service - Ml api
Loaded: loaded (/usr/lib/systemd/system/ml.service; disabled; vendor preset: disabled)
Active: failed (Result: start-limit) since Fri 2022-06-10 11:38:38 MSK; 1 day 23h ago
Main PID: 77614 (code=exited, status=203/EXEC)
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: Unit ml.service entered failed state.
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: ml.service failed.
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: ml.service holdoff time over, scheduling restart.
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: Stopped Ml api.
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: start request repeated too quickly for ml.service
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: Failed to start Ml api.
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: Unit ml.service entered failed state.
Jun 10 11:38:38 srv-ml-api.corp.bsv.legal systemd[1]: ml.service failed.
However, if i run directly
/usr/local/bin/python3.9 -u /home/a.nikitin#corp.bsv.legal/bsv_ml_api/app.py
Everything is ok and the script started
INFO: Started server process [4401]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:1111 (Press CTRL+C to quit)
I don't know where the problem is. It's FastAPI + uvicorn app.
Turns out i need to specify python env
Environment="PYTHONPATH=$PYTHONPATH:/home/a.nikitin#corp.bsv.legal/.local/lib/python3.9/site-packages"

Nginx unit requires using port 80 for initial setting?

I installed Nginx unit
systemctl status unit
● unit.service - NGINX Unit
Loaded: loaded (/lib/systemd/system/unit.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2021-09-02 15:33:30 JST; 4min 29s ago
Process: 2288597 ExecStart=/usr/sbin/unitd $DAEMON_ARGS (code=exited, status=0/SUCCESS)
Main PID: 2288600 (unitd)
Tasks: 3 (limit: 2282)
Memory: 5.6M
CGroup: /system.slice/unit.service
├─2288600 unit: main v1.25.0 [/usr/sbin/unitd]
├─2288613 unit: controller
└─2288614 unit: router
Sep 02 15:33:30 tk2-243-31156 systemd[1]: Starting NGINX Unit...
Sep 02 15:33:30 tk2-243-31156 unitd[2288597]: 2021/09/02 15:33:30 [info] 2288597#2288597 unit started
Sep 02 15:33:30 tk2-243-31156 systemd[1]: Started NGINX Unit.
Now,I try to first test
sudo curl --unix-socket /var/run/unit/control.sock http://localhost/
However it returns curl: (7) Couldn't connect to server
I guess on this service apache works ,so port 80 is used....
Is there any work around??

Can't deploy telegram bot on ubuntu server

HI i've made telegram bot and trying to deploy it on Ubuntu 18.04
Requirements:
firebase==3.0.1
firebase-admin==4.3.0
pyTelegramBotAPI==3.7.1
grpcio==1.29.0
requests==2.23.0
I installed this on server:
build-essential
libssl-dev
libffi-dev
python3-pip
python3-dev
python3-setuptools
python3-venv
After creating venv, i go to /etc/systemd/system/ and made uba.service
uba.service
[Unit]
Description=uba
After=network.target
[Service]
User=uba
Group=uba
WorkingDirectory=/home/kokoto/uba/
Environment="PYTHONPATH=/home/kokoto/uba/"
ExecStart=/home/kokoto/uba/.venv/bin/python /home/kokoto/uba/bot_bd.py
[Install]
WantedBy=multi-user.target
But when i'm running bot, i have this errors:
uba.service - uba
Loaded: loaded (/etc/systemd/system/uba.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-09-21 17:48:05 MSK; 16h ago
Process: 10282 ExecStart=/home/kokoto/uba/.venv/bin/python /home/kokoto/uba/bot_bd.py (code=exited, status=216/GROUP)
Main PID: 10282 (code=exited, status=216/GROUP)
Sep 21 17:48:05 s307229 systemd[1]: Started uba.
Sep 21 17:48:05 s307229 systemd[10282]: uba.service: Failed to determine group credentials: No such process
Sep 21 17:48:05 s307229 systemd[10282]: uba.service: Failed at step GROUP spawning /home/kokoto/uba/.venv/bin/python: No such process
Sep 21 17:48:05 s307229 systemd[1]: uba.service: Main process exited, code=exited, status=216/GROUP
Sep 21 17:48:05 s307229 systemd[1]: uba.service: Failed with result 'exit-code'.
I am not sure, but may be ubuntu uses python2 version. Try to change python to python3
ExecStart=/home/kokoto/uba/.venv/bin/python3 /home/kokoto/uba/bot_bd.py

AWS EC2 Linux instance, after updating bindIp mongod service failing

I have an EC2 instance associated with ElasticBeanstalk on which my flask app is deployed. I have implemented some rest APIs using flask, python.
I created another EC2 instance on Linux 2, on which installed MongoDB community edition. I noticed that it has a local ip mapped in /etc/mongod.conf file:
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
As per my understanding I need to map the private IP of EC2 instance - flask app to it:
# network interfaces
net:
port: 27017
bindIp: <private ip of EC2 with flask app>
So that I can access the MongoDB installed at this instance from the flask app.
# configuring mongo
application.config["MONGO_DBNAME"] = "my_db"
application.config["MONGO_URI"] = "mongodb://public_ip_of_mongodb:27017/my_app"
For some reasons, as soon as I edit the '/etc/mongod.conf file' mongod service starts failing:
mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Tue 2020-08-04 17:17:28 UTC; 1min 11s ago
Docs: https://docs.mongodb.org/manual
Process: 2019 ExecStart=/usr/bin/mongod $OPTIONS (code=exited, status=48)
Process: 2015 ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 2012 ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb (code=exited, status=0/SUCCESS)
Process: 2010 ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb (code=exited, status=0/SUCCESS)
Main PID: 1651 (code=exited, status=0/SUCCESS)
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal systemd[1]: Starting MongoDB Database Server...
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal mongod[2019]: about to fork child process, waiting until server is ready for connections.
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal mongod[2019]: forked process: 2023
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal systemd[1]: mongod.service: control process exited, code=exited status=48
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal systemd[1]: Failed to start MongoDB Database Server.
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal systemd[1]: Unit mongod.service entered failed state.
Aug 04 17:17:28 ip-172-31-5-131.ap-east-1.compute.internal systemd[1]: mongod.service failed.
Even if I revert the bindId to 127.0.0.1 it still fails.
Am I missing anything over here?

Categories