# # AUTHOR , YEAR. # msgid "" msgstr "" "Project-Id-Version: 0\n" "POT-Creation-Date: 2010-12-15T23:32:36\n" "PO-Revision-Date: 2010-12-15 23:37+0800\n" "Last-Translator: Charlie Chen \n" "Language-Team: None\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" #. Tag: title #, no-c-format msgid "Apache - Adding More Services" msgstr "Apache - 添加更多的服务" #. Tag: para #, no-c-format msgid "Now that we have a basic but functional active/passive two-node cluster, we’re ready to add some real services. We’re going to start with Apache because its a feature of many clusters and relatively simple to configure." msgstr "现在我们有了一个基本的但是功能齐全的双节点集群,我们已经可以往里面加些真的服务了。我们准备启动一个Apache服务,因为它是许多集群的主角,并且相对来说比较容易配置。" #. Tag: title #, no-c-format msgid "Installation" msgstr "安装Apache" #. Tag: para #, no-c-format msgid "Before continuing, we need to make sure Apache is installed on both hosts." msgstr "在继续之前,我们先确保两个节点安装了Apache." #. Tag: screen #, no-c-format msgid "" "\n" "[root@ppcmk-1 ~]# yum install -y httpd\n" "Setting up Install Process\n" "Resolving Dependencies\n" "--> Running transaction check\n" "---> Package httpd.x86_64 0:2.2.13-2.fc12 set to be updated\n" "--> Processing Dependency: httpd-tools = 2.2.13-2.fc12 for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: apr-util-ldap for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: /etc/mime.types for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Running transaction check\n" "---> Package apr.x86_64 0:1.3.9-2.fc12 set to be updated\n" "---> Package apr-util.x86_64 0:1.3.9-2.fc12 set to be updated\n" "---> Package apr-util-ldap.x86_64 0:1.3.9-2.fc12 set to be updated\n" "---> Package httpd-tools.x86_64 0:2.2.13-2.fc12 set to be updated\n" "---> Package mailcap.noarch 0:2.1.30-1.fc12 set to be updated\n" "--> Finished Dependency Resolution\n" "\n" "Dependencies Resolved\n" "\n" "=======================================================================================\n" " Package               Arch             Version                Repository         Size\n" "=======================================================================================\n" "Installing:\n" " httpd               x86_64           2.2.13-2.fc12            rawhide           735 k\n" "Installing for dependencies:\n" " apr                 x86_64           1.3.9-2.fc12             rawhide           117 k\n" " apr-util            x86_64           1.3.9-2.fc12             rawhide            84 k\n" " apr-util-ldap       x86_64           1.3.9-2.fc12             rawhide            15 k\n" " httpd-tools         x86_64           2.2.13-2.fc12            rawhide            63 k\n" " mailcap             noarch           2.1.30-1.fc12            rawhide            25 k\n" "\n" "Transaction Summary\n" "=======================================================================================\n" "Install       6 Package(s)\n" "Upgrade       0 Package(s)\n" "\n" "Total download size: 1.0 M\n" "Downloading Packages:\n" "(1/6): apr-1.3.9-2.fc12.x86_64.rpm                                   | 117 kB     00:00     \n" "(2/6): apr-util-1.3.9-2.fc12.x86_64.rpm                             |  84 kB     00:00     \n" "(3/6): apr-util-ldap-1.3.9-2.fc12.x86_64.rpm                         |  15 kB     00:00     \n" "(4/6): httpd-2.2.13-2.fc12.x86_64.rpm                               | 735 kB     00:00     \n" "(5/6): httpd-tools-2.2.13-2.fc12.x86_64.rpm                         |  63 kB     00:00     \n" "(6/6): mailcap-2.1.30-1.fc12.noarch.rpm                             |  25 kB     00:00     \n" "----------------------------------------------------------------------------------------\n" "Total                                                       875 kB/s | 1.0 MB     00:01     \n" "Running rpm_check_debug\n" "Running Transaction Test\n" "Finished Transaction Test\n" "Transaction Test Succeeded\n" "Running Transaction\n" "  Installing     : apr-1.3.9-2.fc12.x86_64                                         1/6 \n" "  Installing     : apr-util-1.3.9-2.fc12.x86_64                                     2/6 \n" "  Installing     : apr-util-ldap-1.3.9-2.fc12.x86_64                               3/6 \n" "  Installing     : httpd-tools-2.2.13-2.fc12.x86_64                                 4/6 \n" "  Installing     : mailcap-2.1.30-1.fc12.noarch                                     5/6 \n" "  Installing     : httpd-2.2.13-2.fc12.x86_64                                       6/6 \n" "\n" "Installed:\n" "  httpd.x86_64 0:2.2.13-2.fc12                                                         \n" "\n" "Dependency Installed:\n" "  apr.x86_64 0:1.3.9-2.fc12            apr-util.x86_64 0:1.3.9-2.fc12\n" "  apr-util-ldap.x86_64 0:1.3.9-2.fc12  httpd-tools.x86_64 0:2.2.13-2.fc12\n" "  mailcap.noarch 0:2.1.30-1.fc12  \n" "\n" "Complete!\n" "[root@pcmk-1 ~]#\n" msgstr "" "\n" "[root@ppcmk-1 ~]# yum install -y httpd\n" "Setting up Install Process\n" "Resolving Dependencies\n" "--> Running transaction check\n" "---> Package httpd.x86_64 0:2.2.13-2.fc12 set to be updated\n" "--> Processing Dependency: httpd-tools = 2.2.13-2.fc12 for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: apr-util-ldap for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: /etc/mime.types for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.13-2.fc12.x86_64\n" "--> Running transaction check\n" "---> Package apr.x86_64 0:1.3.9-2.fc12 set to be updated\n" "---> Package apr-util.x86_64 0:1.3.9-2.fc12 set to be updated\n" "---> Package apr-util-ldap.x86_64 0:1.3.9-2.fc12 set to be updated\n" "---> Package httpd-tools.x86_64 0:2.2.13-2.fc12 set to be updated\n" "---> Package mailcap.noarch 0:2.1.30-1.fc12 set to be updated\n" "--> Finished Dependency Resolution\n" "\n" "Dependencies Resolved\n" "\n" "=======================================================================================\n" " Package               Arch             Version                Repository         Size\n" "=======================================================================================\n" "Installing:\n" " httpd               x86_64           2.2.13-2.fc12            rawhide           735 k\n" "Installing for dependencies:\n" " apr                 x86_64           1.3.9-2.fc12             rawhide           117 k\n" " apr-util            x86_64           1.3.9-2.fc12             rawhide            84 k\n" " apr-util-ldap       x86_64           1.3.9-2.fc12             rawhide            15 k\n" " httpd-tools         x86_64           2.2.13-2.fc12            rawhide            63 k\n" " mailcap             noarch           2.1.30-1.fc12            rawhide            25 k\n" "\n" "Transaction Summary\n" "=======================================================================================\n" "Install       6 Package(s)\n" "Upgrade       0 Package(s)\n" "\n" "Total download size: 1.0 M\n" "Downloading Packages:\n" "(1/6): apr-1.3.9-2.fc12.x86_64.rpm                                   | 117 kB     00:00     \n" "(2/6): apr-util-1.3.9-2.fc12.x86_64.rpm                             |  84 kB     00:00     \n" "(3/6): apr-util-ldap-1.3.9-2.fc12.x86_64.rpm                         |  15 kB     00:00     \n" "(4/6): httpd-2.2.13-2.fc12.x86_64.rpm                               | 735 kB     00:00     \n" "(5/6): httpd-tools-2.2.13-2.fc12.x86_64.rpm                         |  63 kB     00:00     \n" "(6/6): mailcap-2.1.30-1.fc12.noarch.rpm                             |  25 kB     00:00     \n" "----------------------------------------------------------------------------------------\n" "Total                                                       875 kB/s | 1.0 MB     00:01     \n" "Running rpm_check_debug\n" "Running Transaction Test\n" "Finished Transaction Test\n" "Transaction Test Succeeded\n" "Running Transaction\n" "  Installing     : apr-1.3.9-2.fc12.x86_64                                         1/6 \n" "  Installing     : apr-util-1.3.9-2.fc12.x86_64                                     2/6 \n" "  Installing     : apr-util-ldap-1.3.9-2.fc12.x86_64                               3/6 \n" "  Installing     : httpd-tools-2.2.13-2.fc12.x86_64                                 4/6 \n" "  Installing     : mailcap-2.1.30-1.fc12.noarch                                     5/6 \n" "  Installing     : httpd-2.2.13-2.fc12.x86_64                                       6/6 \n" "\n" "Installed:\n" "  httpd.x86_64 0:2.2.13-2.fc12                                                         \n" "\n" "Dependency Installed:\n" "  apr.x86_64 0:1.3.9-2.fc12            apr-util.x86_64 0:1.3.9-2.fc12\n" "  apr-util-ldap.x86_64 0:1.3.9-2.fc12  httpd-tools.x86_64 0:2.2.13-2.fc12\n" "  mailcap.noarch 0:2.1.30-1.fc12  \n" "\n" "Complete!\n" "[root@pcmk-1 ~]#\n" #. Tag: para #, no-c-format msgid "Also, we need the wget tool in order for the cluster to be able to check the status of the Apache server." msgstr "同样的,为了检测Apache服务器,我们要安装wget这个工具。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# yum install -y wget\n" "Setting up Install Process\n" "Resolving Dependencies\n" "--> Running transaction check\n" "---> Package wget.x86_64 0:1.11.4-5.fc12 set to be updated\n" "--> Finished Dependency Resolution\n" "\n" "Dependencies Resolved\n" "\n" "===========================================================================================\n" " Package        Arch             Version                      Repository               Size\n" "===========================================================================================\n" "Installing:\n" " wget         x86_64          1.11.4-5.fc12                   rawhide                393 k\n" "\n" "Transaction Summary\n" "===========================================================================================\n" "Install       1 Package(s)\n" "Upgrade       0 Package(s)\n" "\n" "Total download size: 393 k\n" "Downloading Packages:\n" "wget-1.11.4-5.fc12.x86_64.rpm                                            | 393 kB     00:00     \n" "Running rpm_check_debug\n" "Running Transaction Test\n" "Finished Transaction Test\n" "Transaction Test Succeeded\n" "Running Transaction\n" "  Installing     : wget-1.11.4-5.fc12.x86_64                                            1/1 \n" "\n" "Installed:\n" "  wget.x86_64 0:1.11.4-5.fc12\n" "\n" "Complete!\n" "[root@pcmk-1 ~]#\n" msgstr "" "\n" "[root@pcmk-1 ~]# yum install -y wget\n" "Setting up Install Process\n" "Resolving Dependencies\n" "--> Running transaction check\n" "---> Package wget.x86_64 0:1.11.4-5.fc12 set to be updated\n" "--> Finished Dependency Resolution\n" "\n" "Dependencies Resolved\n" "\n" "===========================================================================================\n" " Package        Arch             Version                      Repository               Size\n" "===========================================================================================\n" "Installing:\n" " wget         x86_64          1.11.4-5.fc12                   rawhide                393 k\n" "\n" "Transaction Summary\n" "===========================================================================================\n" "Install       1 Package(s)\n" "Upgrade       0 Package(s)\n" "\n" "Total download size: 393 k\n" "Downloading Packages:\n" "wget-1.11.4-5.fc12.x86_64.rpm                                            | 393 kB     00:00     \n" "Running rpm_check_debug\n" "Running Transaction Test\n" "Finished Transaction Test\n" "Transaction Test Succeeded\n" "Running Transaction\n" "  Installing     : wget-1.11.4-5.fc12.x86_64                                            1/1 \n" "\n" "Installed:\n" "  wget.x86_64 0:1.11.4-5.fc12\n" "\n" "Complete!\n" "[root@pcmk-1 ~]#\n" #. Tag: title #, no-c-format msgid "Preparation" msgstr "准备工作" #. Tag: para #, no-c-format msgid "First we need to create a page for Apache to serve up. On Fedora the default Apache docroot is /var/www/html, so we’ll create an index file there." msgstr "首先我们为Apache创建一个主页。在Fedora上面默认的Apache docroot是/var/www/html,所以我们在这个目录下面建立一个主页。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# cat <<-END >/var/www/html/index.html\n" " <html>\n" " <body>My Test Site - pcmk-1</body>\n" " </html>\n" " END\n" "[root@pcmk-1 ~]#\n" msgstr "" "\n" "[root@pcmk-1 ~]# cat <<-END >/var/www/html/index.html\n" " <html>\n" " <body>My Test Site - pcmk-1</body>\n" " </html>\n" " END\n" "[root@pcmk-1 ~]#\n" #. Tag: para #, no-c-format msgid "For the moment, we will simplify things by serving up only a static site and manually sync the data between the two nodes. So run the command again on pcmk-2." msgstr "为了方便,我们简化所用的页面并人工地在两个节点直接同步数据。所以在pcmk-2上面运行这个命令。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-2 ~]# cat <<-END >/var/www/html/index.html\n" " <html>\n" " <body>My Test Site - pcmk-2</body>\n" " </html>\n" " END\n" "[root@pcmk-2 ~]#\n" msgstr "" "\n" "[root@pcmk-2 ~]# cat <<-END >/var/www/html/index.html\n" " <html>\n" " <body>My Test Site - pcmk-2</body>\n" " </html>\n" " END\n" "[root@pcmk-2 ~]#\n" #. Tag: title #, no-c-format msgid "Enable the Apache status URL" msgstr "开启 Apache status URL" #. Tag: para #, no-c-format msgid "In order to monitor the health of your Apache instance, and recover it if it fails, the resource agent used by Pacemaker assumes the server-status URL is available. Look for the following in /etc/httpd/conf/httpd.conf and make sure it is not disabled or commented out:" msgstr "为了监控Apache实例的健康状态,并在它挂掉的时候恢复Apache服务,资源agent会假设 server-status URL是可用的。查看/etc/httpd/conf/httpd.conf并确保下面的选项没有被禁用或注释掉。" #. Tag: screen #, no-c-format msgid "" "\n" "<Location /server-status>\n" " SetHandler server-status\n" " Order deny,allow\n" " Deny from all\n" " Allow from 127.0.0.1\n" "</Location>\n" "\t " msgstr "" "\n" "<Location /server-status>\n" " SetHandler server-status\n" " Order deny,allow\n" " Deny from all\n" " Allow from 127.0.0.1\n" "</Location>\n" "\t " #. Tag: title #, no-c-format msgid "Update the Configuration" msgstr "更新配置文件" #. Tag: para #, no-c-format msgid "At this point, Apache is ready to go, all that needs to be done is to add it to the cluster. Lets call the resource WebSite. We need to use an OCF script called apache in the heartbeat namespace Compare the key used here ocf:heartbeat:apache with the one we used earlier for the IP address: ocf:heartbeat:IPaddr2 , the only required parameter is the path to the main Apache configuration file and we’ll tell the cluster to check once a minute that apache is still running." msgstr "现在 ,Apache已经可以添加到集群中了。我们管这个资源叫WebSite。我们需要用一个叫做apache的OCF脚本,这个脚本在heartbeat这个名字空间里,唯一一个需要设定的参数就是Apache的主配置文件路径,并且我们告诉集群每一分钟检测一次Apache是否运行。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm configure primitive WebSite ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" " params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" " op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm configure primitive WebSite ocf:heartbeat:apache params configfile=/etc/httpd/conf/httpd.conf op monitor interval=1min\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" " params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" " op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" #. Tag: para #, no-c-format msgid "After a short delay, we should see the cluster start apache" msgstr "过了一会,我们可以看到集群把apache启动起来了。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:12:49 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-1\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:12:49 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-1\n" #. Tag: para #, no-c-format msgid "Wait a moment, the WebSite resource isn’t running on the same host as our IP address!" msgstr "等等!WebSite这个资源跟IP没有跑在同一个节点上面!" #. Tag: title #, no-c-format msgid "Ensuring Resources Run on the Same Host" msgstr "确保资源在同一个节点运行" #. Tag: para #, no-c-format msgid "To reduce the load on any one machine, Pacemaker will generally try to spread the configured resources across the cluster nodes. However we can tell the cluster that two resources are related and need to run on the same host (or not at all). Here we instruct the cluster that WebSite can only run on the host that ClusterIP is active on. If ClusterIP is not active anywhere, WebSite will not be permitted to run anywhere." msgstr "为了减少每个机器的负载,Pacemaker会智能地尝试将资源分散到各个节点上面。 然而我们可以告诉集群某两个资源是有联系并且要在同一个节点运行(或不同的节点运行)。这里我们告诉集群WebSite只能在有ClusterIP的节点上运行。如果ClusterIP在哪个节点都不存在,那么WebSite也不能运行。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm configure colocation website-with-ip INFINITY: WebSite ClusterIP\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:14:34 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-2\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm configure colocation website-with-ip INFINITY: WebSite ClusterIP\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:14:34 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-2\n" #. Tag: title #, no-c-format msgid "Controlling Resource Start/Stop Ordering" msgstr "控制资源的启动停止顺序" #. Tag: para #, no-c-format msgid "When Apache starts, it binds to the available IP addresses. It doesn’t know about any addresses we add afterwards, so not only do they need to run on the same node, but we need to make sure ClusterIP is already active before we start WebSite. We do this by adding an ordering constraint. We need to give it a name (chose something descriptive like apache-after-ip), indicate that its mandatory (so that any recovery for ClusterIP will also trigger recovery of WebSite) and list the two resources in the order we need them to start." msgstr "当Apache启动了,它跟可用的IP绑在了一起。它不会知道我们后来添加的IP,所以我们不仅需要控制他们在相同的节点运行,也要确保ClusterIP在WebSite之前就启动了。我们用添加ordering约束来达到这个效果。我们需要给这个order取个名字(apache-after-ip之类 描述性的),并指出他是托管的(这样当ClusterIP恢复了,同时会触发WebSite的恢复) 并且写明了这两个资源的启动顺序。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm configure order apache-after-ip mandatory: ClusterIP WebSite\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "order apache-after-ip inf: ClusterIP WebSite\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm configure order apache-after-ip mandatory: ClusterIP WebSite\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "order apache-after-ip inf: ClusterIP WebSite\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" #. Tag: title #, no-c-format msgid "Specifying a Preferred Location" msgstr "指定优先的 Location" #. Tag: para #, no-c-format msgid "Pacemaker does not rely on any sort of hardware symmetry between nodes, so it may well be that one machine is more powerful than the other. In such cases it makes sense to host the resources there if it is available. To do this we create a location constraint. Again we give it a descriptive name (prefer-pcmk-1), specify the resource we want to run there (WebSite), how badly we’d like it to run there (we’ll use 50 for now, but in a two-node situation almost any value above 0 will do) and the host’s name." msgstr "Pacemaker 并不要求你机器的硬件配置是相同的,可能某些机器比另外的机器配置要好。这种状况下我们会希望设置:当某个节点可用时,资源就要跑在上面之类的规则。为了达到这个效果我们创建location约束。同样的,我们给他取一个描述性的名字(prefer-pcmk-1),指明我们想在上面跑WebSite这个服务,多想在上面跑(我们现在指定分值为50,但是在双节点的集群状态下,任何大于0的值都可以达到想要的效果),以及目标节点的名字:" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm configure location prefer-pcmk-1 WebSite 50: pcmk-1\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "location prefer-pcmk-1 WebSite 50: pcmk-1\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:17:35 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-2\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm configure location prefer-pcmk-1 WebSite 50: pcmk-1\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "location prefer-pcmk-1 WebSite 50: pcmk-1\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:17:35 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-2\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-2\n" #. Tag: para #, no-c-format msgid "Wait a minute, the resources are still on pcmk-2!" msgstr "等等,资源还是在pcmk-2上面跑的!" #. Tag: para #, no-c-format msgid "Even though we now prefer pcmk-1 over pcmk-2, that preference is (intentionally) less than the resource stickiness (how much we preferred not to have unnecessary downtime)." msgstr "即使我们更希望资源在pcmk-1上面运行,但是 这个优先值还是比资源黏性值要小。" #. Tag: para #, no-c-format msgid "To see the current placement scores, you can use a tool called ptest" msgstr "如果要看现在的分值,可以用ptest这个命令" #. Tag: para #, no-c-format msgid "ptest -sL" msgstr "ptest -sL" #. Tag: para #, no-c-format msgid "Include output" msgstr "Include output" #. Tag: para #, no-c-format msgid "There is a way to force them to move though..." msgstr "这里有个办法强制地移动资源" #. Tag: title #, no-c-format msgid "Manually Moving Resources Around the Cluster" msgstr "在集群中手工地移动资源" #. Tag: para #, no-c-format msgid "There are always times when an administrator needs to override the cluster and force resources to move to a specific location. Underneath we use location constraints like the one we created above, happily you don’t need to care. Just provide the name of the resource and the intended location, we’ll do the rest." msgstr "经常性的会有管理员想要无视集群然后强制把资源移动到指定的地方。 底层的操作就像我们上面创建的location约束一样。只要提供资源和目标地址,我们会补全剩余部分。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm resource move WebSite pcmk-1\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:19:24 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-1\n" "Notice how the colocation rule we created has ensured that ClusterIP was also moved to pcmk-1.\n" "For the curious, we can see the effect of this command by examining the configuration\n" "crm configure show\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "location cli-prefer-WebSite WebSite \\\n" " rule $id=\"cli-prefer-rule-WebSite\" inf: #uname eq pcmk-1\n" "location prefer-pcmk-1 WebSite 50: pcmk-1\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm resource move WebSite pcmk-1\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:19:24 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" "ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1\n" "WebSite        (ocf::heartbeat:apache):        Started pcmk-1\n" "Notice how the colocation rule we created has ensured that ClusterIP was also moved to pcmk-1.\n" "For the curious, we can see the effect of this command by examining the configuration\n" "crm configure show\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "location cli-prefer-WebSite WebSite \\\n" " rule $id=\"cli-prefer-rule-WebSite\" inf: #uname eq pcmk-1\n" "location prefer-pcmk-1 WebSite 50: pcmk-1\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" #. Tag: para #, no-c-format msgid "Highlighted is the automated constraint used to move the resources to pcmk-1" msgstr "斜体部分是用来移动资源到pcmk-1约束,它是自动生成的。" #. Tag: title #, no-c-format msgid "Giving Control Back to the Cluster" msgstr "把控制权交还给集群" #. Tag: para #, no-c-format msgid "Once we’ve finished whatever activity that required us to move the resources to pcmk-1, in our case nothing, we can then allow the cluster to resume normal operation with the unmove command. Since we previously configured a default stickiness, the resources will remain on pcmk-1." msgstr "当我们完成那些要求要资源移动到pcmk-1的操作--在我们的例子里面啥都没干 --我们可以用unmove命令把集群恢复到强制移动前的状态。因为我们之前配置了默认的资源黏性值,恢复了以后资源还是会在pcmk-1上面。" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm resource unmove WebSite\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "location prefer-pcmk-1 WebSite 50: pcmk-1\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm resource unmove WebSite\n" "[root@pcmk-1 ~]# crm configure show\n" "node pcmk-1\n" "node pcmk-2\n" "primitive WebSite ocf:heartbeat:apache \\\n" "        params configfile=\"/etc/httpd/conf/httpd.conf\" \\\n" "        op monitor interval=\"1min\"\n" "primitive ClusterIP ocf:heartbeat:IPaddr2 \\\n" "        params ip=\"192.168.122.101\" cidr_netmask=\"32\" \\\n" "        op monitor interval=\"30s\"\n" "location prefer-pcmk-1 WebSite 50: pcmk-1\n" "colocation website-with-ip inf: WebSite ClusterIP\n" "property $id=\"cib-bootstrap-options\" \\\n" "        dc-version=\"1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\" \\\n" "        cluster-infrastructure=\"openais\" \\\n" "        expected-quorum-votes=\"2\" \\\n" "        stonith-enabled=\"false\" \\\n" "        no-quorum-policy=\"ignore\"\n" "rsc_defaults $id=\"rsc-options\" \\\n" "        resource-stickiness=\"100\"\n" #. Tag: para #, no-c-format msgid "Note that the automated constraint is now gone. If we check the cluster status, we can also see that as expected the resources are still active on pcmk-1." msgstr "可以看到自动生成的约束已经没有了。如果我们查看集群的状态,我们也可以看到就如我们所预期的,资源还是在pcmk-1上面跑" #. Tag: screen #, no-c-format msgid "" "\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:20:53 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" " ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1\n" " WebSite        (ocf::heartbeat:apache):        Started pcmk-1\n" msgstr "" "\n" "[root@pcmk-1 ~]# crm_mon\n" "============\n" "Last updated: Fri Aug 28 16:20:53 2009\n" "Stack: openais\n" "Current DC: pcmk-2 - partition with quorum\n" "Version: 1.0.5-462f1569a43740667daf7b0f6b521742e9eb8fa7\n" "2 Nodes configured, 2 expected votes\n" "2 Resources configured.\n" "============\n" "\n" "Online: [ pcmk-1 pcmk-2 ]\n" "\n" " ClusterIP        (ocf::heartbeat:IPaddr):        Started pcmk-1\n" " WebSite        (ocf::heartbeat:apache):        Started pcmk-1\n" #~ msgid "At this point, Apache is ready to go, all that needs to be done is to add it to the cluster. Lets call the resource WebSite. We need to use an OCF script called apache in the heartbeat namespace" #~ msgstr "现在 ,Apache已经可以添加到集群中了。我们管这个资源叫WebSite。我们需要用一个叫做apache的OCF脚本" #~ msgid "Compare the key used here ocf:heartbeat:apache with the one we used earlier for the IP address: ocf:heartbeat:IPaddr2" #~ msgstr "把我现在所用的关键字ocf:heartbeat:apache 跟之前IP地址所用的比较一下: ocf:heartbeat:IPaddr2" #~ msgid ", the only required parameter is the path to the main Apache configuration file and we’ll tell the cluster to check once a minute that apache is still running." #~ msgstr ",这个脚本在heartbeat这个名字空间里,唯一一个需要设定的参数就是Apache的主配置文件路径,并且我们告诉集群每一分钟检测一次apache是否运行。"