{"id":138,"date":"2018-03-27T09:52:48","date_gmt":"2018-03-27T00:52:48","guid":{"rendered":"http:\/\/www7390uo.sakura.ne.jp\/wordpress\/?p=138"},"modified":"2022-07-17T11:59:46","modified_gmt":"2022-07-17T02:59:46","slug":"138","status":"publish","type":"post","link":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/archives\/138","title":{"rendered":"systemd\u3067OS\u8d77\u52d5\u6642\u306bMySQL\u3092\u81ea\u52d5\u8d77\u52d5\u3055\u305b\u308b"},"content":{"rendered":"\n<p>OS: Ubuntu Server 16.04<br>MySQL 5.7.21<\/p>\n\n\n\n<p>\u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u30bd\u30fc\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068systemd\u306e\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u4ed8\u5c5e\u3057\u306a\u3044\u3053\u3068\u304c\u591a\u3044\u3088\u3046\u306b\u611f\u305a\u308b\u3002MySQL\u3082\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u305d\u3046\u3067\u3042\u3063\u305f\u3002\u3057\u304b\u3057\u4e4d\u3089\u3001cmake\u5b9f\u884c\u306e\u969b\u306b<code>-DWITH_SYSTEMD=1<\/code>\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u308b\u3068\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u62f5\u3048\u3066\u304f\u308c\u308b\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p>-DWITH_SYSTEMD=bool<\/p><p>Whether to enable installation of systemd support files. By default, this option is disabled. When enabled, systemd support files are installed, and scripts such as mysqld_safe and the System V initialization script are not installed. On platforms where systemd is not available, enabling WITH_SYSTEMD results in an error from CMake.<\/p><cite><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/source-configuration-options.html#option_cmake_with_systemd\" target=\"_blank\" rel=\"noreferrer noopener\">2.9.7&nbsp;MySQL Source-Configuration Options<\/a><\/cite><\/blockquote>\n\n\n\n<p><code>make install<\/code>\u5f8c\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b<code>mysqld.service<\/code>\u3068\u3044\u3046\u540d\u3067\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u653e\u308a\u8fbc\u307e\u308c\u3066\u5c45\u305f\u3002\u6b64\u308c\u3092\u7136\u308b\u3079\u304d\u5834\u6240\u3078\u914d\u7f6e\u3059\u308b\u3002\u7136\u308b\u3079\u304d\u5834\u6240\u306f\u4e09\u7b87\u6240\u3042\u308a\u3001<a href=\"https:\/\/access.redhat.com\/documentation\/ja-jp\/red_hat_enterprise_linux\/7\/html\/system_administrators_guide\/chap-managing_services_with_systemd#tabl-Managing_Services_with_systemd-Introduction-Units-Locations\">Red Hat\u306e\u89e3\u8aac<\/a>\u306b\u8a73\u3057\u3044\u3002\u512a\u5148\u9806\u4f4d\u306f\u9ad8\u3044\u307b\u3046\u304b\u3089<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\/etc\/systemd\/system\/<\/li><li>\/run\/systemd\/system\/<\/li><li>\/usr\/lib\/systemd\/system\/<\/li><\/ol>\n\n\n\n<p>\u3068\u3044\u3046\u3053\u3068\u3067\u3042\u308b\u3002\u4e00\u5148\u305a\u3082\u3063\u3068\u3082\u512a\u5148\u5ea6\u306e\u9ad8\u3044<code>\/etc\/systemd\/system\/<\/code>\u3092\u9078\u629e\u3059\u308c\u3070\u3088\u304b\u308d\u3046\u3068\u304a\u3082\u3046\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cd \/usr\/local\/mysql\n$ sudo cp -av mysqld.service \/etc\/systemd\/system\/<\/pre>\n\n\n\n<p>\u6b21\u306bMySQL\u306e\u8d77\u52d5\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u8a2d\u5b9a\u3059\u308b\u3002\u5185\u5bb9\u306f<code>\/etc\/default\/mysql<\/code>\u306b\u7f6e\u304f\u3053\u3068\u3068\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi \/etc\/default\/mysql\nMYSQLD_OPTS=\"--basedir=\/usr\/local\/mysql --datadir=\/usr\/local\/mysql\/data --plugin-dir=\/usr\/local\/mysql\/lib\/plugin --user=mysql --log-error=mysql.err --pid-file=\/usr\/local\/mysql\/data\/mysql.pid\"<\/pre>\n\n\n\n<p>\u305d\u308c\u304b\u3089\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u5185\u5bb9\u3082\u4e00\u90e8\u66f8\u304d\u63db\u3048\u305f\u3002\u30c7\u30d5\u30a9\u30eb\u30c8\u306e\u307e\u307e\u3067\u3042\u308b\u3068PID\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u8fbc\u307f\u306b\u5931\u6557\u3057\u3066\u3057\u307e\u3063\u305f\u306e\u3067<code>PIDFile<\/code>\u3084<code>ExecStart<\/code>\u3092\u7de8\u96c6\u3057\u3001<code>EnvironmentFile<\/code>\u306b\u306f\u5148\u306b\u4f5c\u6210\u3057\u305f\u8d77\u52d5\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u66f8\u304d\u4ed8\u3051\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u6307\u5b9a\u3057\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo vi \/etc\/systemd\/system\/mysqld.service\n#PIDFile=\/var\/run\/mysqld\/mysqld.pid\n<strong class=\"orange\">PIDFile=\/usr\/local\/mysql\/data\/mysql.pid<\/strong>\n\n#ExecStart=\/usr\/local\/mysql\/bin\/mysqld --daemonize --pid-file=\/var\/run\/mysqld\/mysqld.pid $MYSQLD_OPTS\n<strong class=\"orange\">ExecStart=\/usr\/local\/mysql\/bin\/mysqld --daemonize $MYSQLD_OPTS<\/strong>\n\n#EnvironmentFile=-\/etc\/sysconfig\/mysql\n<strong class=\"orange\">EnvironmentFile=-\/etc\/default\/mysql<\/strong><\/pre>\n\n\n\n<p>\u6700\u5f8c\u306bOS\u8d77\u52d5\u6642\u306bMySQL\u30b5\u30fc\u30d0\u30fc\u304c\u7acb\u3061\u4e0a\u304c\u308b\u3088\u3046<code>systemctl enable<\/code>\u3092\u5b9f\u884c\u3059\u308b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudo systemctl enable mysqld.service\nCreated symlink from \/etc\/systemd\/system\/multi-user.target.wants\/mysqld.service to \/etc\/systemd\/system\/mysqld.service.<\/pre>\n\n\n\n<p>\u8a66\u307f\u306bOS\u3092\u518d\u8d77\u52d5\u3057\u3066\u307f\u308b\u3068MySQL\u304c\u7121\u4e8b\u3001\u81ea\u52d5\u3067\u7acb\u3061\u4e0a\u304c\u3063\u3066\u3044\u305f\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ systemctl status mysqld.service\n<strong class=\"green\">\u25cf<\/strong> mysqld.service - MySQL Server\n   Loaded: loaded (\/etc\/systemd\/system\/mysqld.service; enabled; vendor preset: enabled)\n   Active: <strong class=\"green\">active (running)<\/strong> since Thu 2018-03-22 20:42:22 JST; 15s ago\n(snip)\nMar 22 20:42:22 mysql-systemd-test systemd[1]: Started MySQL Server.<\/pre>\n\n\n\n<h3 class=\"link\">\u53c2\u8003:<\/h3>\n<ul>\n <li><a href=\"https:\/\/www.freedesktop.org\/software\/systemd\/man\/systemd.exec.html#EnvironmentFile=\">systemd.exec<\/a><\/li>\n <li><a href=\"https:\/\/wiki.archlinux.jp\/index.php\/Systemd\">systemd &#8211; ArchWiki<\/a><\/li>\n <li><a href=\"https:\/\/ja.wikipedia.org\/wiki\/Systemd\">systemd &#8211; Wikipedia<\/a><\/li>\n <li><a href=\"https:\/\/dev.mysql.com\/doc\/refman\/5.7\/en\/using-systemd.html\">2.5.10 Managing MySQL Server with systemd<\/a><\/li>\n <li><a href=\"https:\/\/unix.stackexchange.com\/questions\/350662\/what-is-options-in-a-systemd-service-file\">What is $OPTIONS in a systemd service file?<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>OS: Ubuntu Server 16.04MySQL 5.7.21 \u30df\u30c9\u30eb\u30a6\u30a7\u30a2\u3092\u30bd\u30fc\u30b9\u304b\u3089\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3059\u308b\u3068systemd\u306e\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u304c\u4ed8\u5c5e\u3057\u306a\u3044\u3053\u3068\u304c\u591a\u3044\u3088\u3046\u306b\u611f\u305a\u308b\u3002MySQL\u3082\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u305d\u3046\u3067\u3042\u3063\u305f\u3002\u3057\u304b\u3057\u4e4d\u3089\u3001cmake\u5b9f\u884c\u306e\u969b\u306b-DWITH_SYSTEMD=1\u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u3051\u308b\u3068\u30e6\u30cb\u30c3\u30c8\u30d5\u30a1\u30a4\u30eb\u3092\u62f5\u3048\u3066\u304f\u308c\u308b\u3002 -DWITH_SYSTEMD=bool Whether to &#8230; <a title=\"systemd\u3067OS\u8d77\u52d5\u6642\u306bMySQL\u3092\u81ea\u52d5\u8d77\u52d5\u3055\u305b\u308b\" class=\"read-more\" href=\"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/archives\/138\" aria-label=\"systemd\u3067OS\u8d77\u52d5\u6642\u306bMySQL\u3092\u81ea\u52d5\u8d77\u52d5\u3055\u305b\u308b \u306b\u3064\u3044\u3066\u3055\u3089\u306b\u8aad\u3080\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":991,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[157],"tags":[164,212],"class_list":["post-138","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-mysql","tag-systemd"],"views":10529,"_links":{"self":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/posts\/138","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/comments?post=138"}],"version-history":[{"count":0,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/posts\/138\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/media\/991"}],"wp:attachment":[{"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/media?parent=138"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/categories?post=138"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www7390uo.sakura.ne.jp\/wordpress\/wp-json\/wp\/v2\/tags?post=138"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}