openstack组件服务的入口寻找方法
在centos7系统上,安装openstack服务以后,可以通过以下命令,查找到该系统上,已经安装的openstack服务
[root@xzto01n010027244133 ~]# systemctl list-unit-files | grep openstack openstack-cinder-api.service enabled openstack-cinder-backup.service disabled openstack-cinder-scheduler.service enabled openstack-cinder-volume.service disabled openstack-glance-api.service enabled openstack-glance-glare.service disabled openstack-glance-registry.service enabled openstack-glance-scrubber.service disabled openstack-nova-api.service enabled openstack-nova-conductor.service enabled openstack-nova-console.service disabled openstack-nova-consoleauth.service disabled openstack-nova-metadata-api.service disabled openstack-nova-novncproxy.service enabled openstack-nova-os-compute-api.service disabled openstack-nova-scheduler.service enabled openstack-nova-xvpvncproxy.service disabled [root@xzto01n010027244133 ~]#
neutron服务命名比较特殊,通过如下命令行进行查找
[root@xzto01n010027244133 ~]# systemctl list-unit-files | grep neutron neutron-dhcp-agent.service disabled neutron-l3-agent.service disabled neutron-linuxbridge-cleanup.service disabled neutron-metadata-agent.service disabled neutron-netns-cleanup.service disabled neutron-openvswitch-agent.service disabled neutron-ovs-cleanup.service disabled neutron-server.service enabled
所有可用的单元文件存放在 /usr/lib/systemd/system/ 和 /etc/systemd/system/ 目录(后者优先级更高),openstack各服务的文件一般放在/usr/lib/systemd/system/目录下,命令如下:
[root@xzto01n010027244133 ~]# ls -lh /usr/lib/systemd/system/ | grep openstack -rw-r--r-- 1 root root 343 Nov 12 2017 openstack-cinder-api.service -rw-r--r-- 1 root root 335 Nov 12 2017 openstack-cinder-backup.service -rw-r--r-- 1 root root 344 Nov 12 2017 openstack-cinder-scheduler.service -rw-r--r-- 1 root root 389 Nov 12 2017 openstack-cinder-volume.service -rw-r--r-- 1 root root 285 Mar 21 2017 openstack-glance-api.service -rw-r--r-- 1 root root 256 Mar 21 2017 openstack-glance-glare.service -rw-r--r-- 1 root root 258 Mar 21 2017 openstack-glance-registry.service -rw-r--r-- 1 root root 254 Mar 21 2017 openstack-glance-scrubber.service -rw-r--r-- 1 root root 230 Oct 15 10:43 openstack-nova-api.service -rw-r--r-- 1 root root 242 Oct 15 10:43 openstack-nova-conductor.service -rw-r--r-- 1 root root 251 Oct 15 10:43 openstack-nova-consoleauth.service -rw-r--r-- 1 root root 244 Oct 15 10:43 openstack-nova-console.service -rw-r--r-- 1 root root 248 Oct 15 10:43 openstack-nova-metadata-api.service -rw-r--r-- 1 root root 304 Oct 15 10:43 openstack-nova-novncproxy.service -rw-r--r-- 1 root root 248 Oct 15 10:43 openstack-nova-os-compute-api.service -rw-r--r-- 1 root root 242 Oct 15 10:43 openstack-nova-scheduler.service -rw-r--r-- 1 root root 216 Oct 15 10:43 openstack-nova-xvpvncproxy.service [root@xzto01n010027244133 ~]# cd /usr/lib/systemd/system/ [root@xzto01n010027244133 system]# pwd /usr/lib/systemd/system
查看neutron服务文件,ls -lh /usr/lib/systemd/system/ | grep neutron,命令行如下:
[root@xzto01n010027244133 system]# ls -lh /usr/lib/systemd/system/ | grep neutron -rw-r--r-- 1 root root 516 Oct 15 11:23 neutron-dhcp-agent.service -rw-r--r-- 1 root root 512 Oct 15 11:23 neutron-l3-agent.service -rw-r--r-- 1 root root 1.1K Oct 15 11:23 neutron-linuxbridge-cleanup.service -rw-r--r-- 1 root root 536 Oct 15 11:23 neutron-metadata-agent.service -rw-r--r-- 1 root root 987 Oct 15 11:23 neutron-netns-cleanup.service -rw-r--r-- 1 root root 734 Oct 15 11:23 neutron-openvswitch-agent.service -rw-r--r-- 1 root root 1.0K Oct 15 11:23 neutron-ovs-cleanup.service -rw-r--r-- 1 root root 569 Oct 15 11:23 neutron-server.service
通过服务文件找对应的启动脚本
[root@xzto01n010027244133 system]# cat openstack-nova-api.service [Unit] Description=OpenStack Nova API Server After=syslog.target network.target [Service] Type=notify NotifyAccess=all TimeoutStartSec=0 Restart=always User=nova ExecStart=/usr/bin/nova-api [Install] WantedBy=multi-user.target [root@xzto01n010027244133 system]# pwd /usr/lib/systemd/system [root@xzto01n010027244133 system]#
重点是红线部分,openstack-nova-api的启动命令,启动脚本为/usr/bin/nova-api
通过启动命令找对应的入口代码
[root@xzto01n010027244133 system]# cat /usr/bin/nova-api #!/usr/bin/python2 # PBR Generated from u'console_scripts' import sys from nova.cmd.api import main if __name__ == "__main__": sys.exit(main()) [root@xzto01n010027244133 system]# pwd /usr/lib/systemd/system