{"id":1308,"date":"2009-10-16T14:12:10","date_gmt":"2009-10-16T19:12:10","guid":{"rendered":"http:\/\/jianmingli.com\/wp\/?p=1308"},"modified":"2009-10-16T16:19:47","modified_gmt":"2009-10-16T21:19:47","slug":"linux-services-and-routing","status":"publish","type":"post","link":"https:\/\/jianmingli.com\/wp\/?p=1308","title":{"rendered":"Linux Services"},"content":{"rendered":"<span id=\"Starting_Services\"><h2>Starting Services<\/h2><\/span>\n<span id=\"init_daemon\"><h3>init daemon<\/h3><\/span>\n<p>* Run when system boots or enter a run level.<br \/>\n* Starts all rc scripts starting with &#8220;S&#8221; in a run level&#8217;s rc subdirectory (e.g. \/etc\/rc.d\/rc.3).<br \/>\n* Restarts a service if service dies in a particular run level and marked by respawn (e.g. x:5:respawn:\/etc\/X11\/prefdm -nodaemon).<\/p>\n<span id=\"Run_levels\"><h4>Run levels<\/h4><\/span>\n<p>* Defined in \/etc\/inittab file<br \/>\n* Total 7 run levels (0 to 6).<br \/>\n* Default run level defined by &#8220;id:5:initdefault:&#8221; (5 for GUI, 3 for non-GUI).<br \/>\n* System can only be at one run level at a time.<br \/>\n* \/sbin\/runlevel: current run level.<\/p>\n<span id=\"Manages_init_Script_Symbolic_Links\"><h3>Manages init Script Symbolic Links<\/h3><\/span>\n<span id=\"sbinchkconfig\"><h4>\/sbin\/chkconfig<\/h4><\/span>\n<p>* Copy startup script, e.g. myscript, to \/etc\/init.d directory.<br \/>\n* Add to the beginning of myscript:<\/p>\n<pre>\r\n# chkconfig: 234 99 90\r\n# description: myscript runs my daemon at runlevel 2, 3, or 4\r\n<\/pre>\n<p>* Run chkconfig:<\/p>\n<pre>\r\nchkconfig --delete myscript\r\nchkconfig --add myscript\r\n<\/pre>\n<p>* This will create symbolic links named &#8220;S99myscript&#8221; in the rc.2, rc.3, rc.4 directories and &#8220;K90myscript&#8221; in the rc.0, rc.1, rc.5, rc.6 directories.<\/p>\n<span id=\"StartStop_Services\"><h3>Start\/Stop Services<\/h3><\/span>\n<pre>\r\n\/etc\/init.d\/myscript start\r\n\/etc\/init.d\/myscript stop\r\n\r\n# Redhat\r\nservice myscript start\r\nservice myscript stop\r\nservice myscript restart\r\n<\/pre>\n<span id=\"heartbeat\"><h3>heartbeat<\/h3><\/span>\n<p>* When service starts or need a resource<br \/>\n* Better to have redundant heartbeat connections<br \/>\n&#8211; Serial cable<br \/>\n&#8211; Ethernet cable<br \/>\n* Partitioned clusters<br \/>\n&#8211; When both assume primary server role<br \/>\n&#8211; Resolution: stonith<br \/>\n* Heartbeat configuration files<br \/>\n&#8211; \/etc\/ha.d\/ha.cf # specifies how ha daemons communicate with each other<br \/>\n&#8211; \/etc\/ha.d\/haresources # specifies which server should act as primary for a resource<br \/>\n&#8211; \/etc\/ha.d\/authkeys # specifies how ha packets should be encrypted<\/p>\n<span id=\"xinetd:_when_network_request_comes_in\"><h3>xinetd: when network request comes in<\/h3><\/span>\n<span id=\"Other_non-standard_method\"><h3>Other non-standard method<\/h3><\/span>\n<span id=\"Secondary_IP_Addresses\"><h3>Secondary IP Addresses<\/h3><\/span>\n<pre>\r\n# View both primary and secondary ip addresses\r\nip addr sh\r\nip addr sh dev eth0\r\n\r\n# Add secondary ip\r\nip addr add 209.100.100.3\/24 broadcast 209.100.100.255 dev eth0\r\n\r\n# Remove secondary ip\r\nip addr del 209.100.100.3\/24 broadcast 209.100.100.255 dev eth0\r\n\r\n<\/pre>\n<span id=\"References\"><h2>References<\/h2><\/span>\n<p>The Linux Enterprise Cluster by Karl Kopper <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Starting Services init daemon * Run when system boots or enter a run level. * Starts all rc scripts starting with &#8220;S&#8221; in a run level&#8217;s rc subdirectory (e.g. \/etc\/rc.d\/rc.3). * Restarts a service if service dies in a particular &hellip; <a href=\"https:\/\/jianmingli.com\/wp\/?p=1308\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[61,1],"tags":[],"class_list":["post-1308","post","type-post","status-publish","format-standard","hentry","category-linux","category-uncategorized"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8cRUO-l6","_links":{"self":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1308","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1308"}],"version-history":[{"count":5,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1308\/revisions"}],"predecessor-version":[{"id":1316,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/1308\/revisions\/1316"}],"wp:attachment":[{"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jianmingli.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}