{"id":554,"date":"2014-07-11T14:48:04","date_gmt":"2014-07-11T14:48:04","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=554"},"modified":"2014-07-11T14:48:04","modified_gmt":"2014-07-11T14:48:04","slug":"%e5%9c%a8ubuntu12-04-x32%e4%b8%8a%e4%bd%bf%e7%94%a8parallel%e5%91%bd%e4%bb%a4","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/554.html","title":{"rendered":"\u5728Ubuntu12.04 x32\u4e0a\u4f7f\u7528parallel\u547d\u4ee4"},"content":{"rendered":"<h5>\u5728Ubuntu12.04 x32\u4e0a\u4f7f\u7528parallel\u547d\u4ee4<\/h5>\n<p>\u665a\u4e0a\u5728\u6574\u7406\u4e4b\u524d\u641c\u96c6\u7684\u7b14\u8bb0\/\u6587\u7ae0\u7684\u65f6\u5019\u53d1\u73b0\u4e86\u4e00\u7bc7\u540d\u4e3a&#8221;<a href=\"http:\/\/www.vaikan.com\/use-multiple-cpu-cores-with-your-linux-commands\/\" target=\"_blank\">\u5982\u4f55\u5229\u7528\u591a\u6838CPU\u6765\u52a0\u901f\u4f60\u7684Linux\u547d\u4ee4 &#8212; awk, sed, bzip2, grep, wc\u7b49<\/a>&#8220;\u7684\u6587\u7ae0\uff0c\u6bd4\u8f83\u611f\u5174\u8da3\uff0c\u4e8e\u662f\u60f3\u5c1d\u8bd5\u4e00\u4e0b\uff0c\u770b\u770b\u5230\u5e95\u6709\u6ca1\u6709\u6587\u7ae0\u4e2d\u8bf4\u7684\u90a3\u79cd\u6548\u679c\u3002<br \/>\n\u6240\u4ee5\uff0c\u5148\u770b\u770b\u5176\u5e2e\u52a9\u4fe1\u606f # parallel -h \uff0c\u62a5\u9519\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true\">The program 'parallel' is currently not installed. You can install it by typing:apt-get install moreutils<\/pre>\n<p>\u4e8e\u662f\u6309\u7167\u5b83\u7684\u6307\u5bfc\u8fdb\u884c\u4e86\u5b89\u88c5\uff0c\u518d\u8fd0\u884c\u547d\u4ee4\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># parallel -h\nparallel [OPTIONS] command -- arguments\nfor each argument, run command with argument, in parallel\nparallel [OPTIONS] -- commands\nrun specified commands in parallel<\/pre>\n<p>o(\u256f\u25a1\u2570)o\uff0c\u611f\u89c9\u8bb2\u7684\u597d\u62bd\u8c61\uff0c\u8fd8\u662f\u53bb\u770bmanual\u624b\u518c\u5427\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># man -t parallel | ps2pdf -&gt; parallel_manual.pdf\nThe program 'ps2pdf' is currently not installed. You can install it by typing:\napt-get install ghostscript<\/pre>\n<p>\u5148\u751f\u6210\u4e00\u4e2a\u6d4b\u8bd5\u6587\u4ef6\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># perl -e 'for(1..1000000){print \"$_n\"}' &gt; num1000000<\/pre>\n<p>\u7136\u540e\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># cat num1000000 | parallel --pipe wc\nparallel: invalid option -- '-'\nparallel [OPTIONS] command -- arguments\nfor each argument, run command with argument, in parallel\nparallel [OPTIONS] -- commands\nrun specified commands in parallel<\/pre>\n<p>\u53bb\u4e0b\u8f7d\u6e90\u7801\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<pre class=\"lang:default decode:true  \"># wget http:\/\/ftp.gnu.org\/gnu\/parallel\/parallel-20140622.tar.bz2\n# wget http:\/\/ftp.gnu.org\/gnu\/parallel\/parallel-20140622.tar.bz2.sig<\/pre>\n<p>\u9a8c\u8bc1\u4e00\u4e0b\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># gpg --verify parallel-20140622.tar.bz2.sig parallel-20140622.tar.bz2\ngpg: Signature made Mon 23 Jun 2014 09:27:19 AM CST using RSA key ID 88888888\ngpg: Can't check signature: public key not found<\/pre>\n<p>\u9700\u8981\u5148\u5bfc\u5165key\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># gpg --recv-keys 88888888\ngpg: requesting key 88888888 from hkp server keys.gnupg.net\ngpg: \/root\/.gnupg\/trustdb.gpg: trustdb created\ngpg: key 88888888: public key \"Ole Tange &lt;ole@tange.dk&gt;\" imported\ngpg: no ultimately trusted keys found\ngpg: Total number processed: 1\ngpg: imported: 1 (RSA: 1)<\/pre>\n<pre class=\"lang:default decode:true\"># gpg --verify --verbose parallel-20140622.tar.bz2.sig parallel-20140622.tar.bz2\n\ngpg: armor header: Version: GnuPG v1.4.12 (GNU\/Linux)\ngpg: Signature made Mon 23 Jun 2014 09:27:19 AM CST using RSA key ID 88888888\ngpg: using PGP trust model\ngpg: Good signature from \"Ole Tange &lt;ole@tange.dk&gt;\"\ngpg: aka \"Ole Tange &lt;tange@gnu.org&gt;\"\ngpg: aka \"[jpeg image of size 6001]\"\ngpg: WARNING: This key is not certified with a trusted signature!\ngpg: There is no indication that the signature belongs to the owner.\nPrimary key fingerprint: CDA0 1A42 08C4 F745 0610 7E7B D1AB 4516 8888 8888\ngpg: binary signature, digest algorithm SHA512<\/pre>\n<p>\u5b89\u88c5\uff1a<\/p>\n<pre class=\"lang:default decode:true\"># tar jxf parallel-20140622.tar.bz2\n# cd parallel-20140622\/\n# .\/configure &amp;&amp; make &amp;&amp; make install<\/pre>\n<p>\u5b89\u88c5\u5b8c\u4e86\u4e4b\u540e\uff0c\u76f4\u63a5\u4f7f\u7528parallel\u547d\u4ee4\u8fd8\u662f\u4f1a\u548c\u521a\u624d\u4e00\u6837\u62a5\u9519\uff0c\u540e\u6765\u91cd\u542f\u4e86\u4e4b\u540e\uff0c\u6211\u627e\u5230\u6e90\u7801\u5b89\u88c5\u76ee\u5f55\u91cc\u9762\u7684src\u76ee\u5f55\u4e2d\u7684parallel\u53ef\u6267\u884c\u811a\u672c\uff0c\u8fd0\u884c\u547d\u4ee4\uff1a<\/p>\n<pre class=\"lang:default decode:true  \">root@hi:~\/download\/parallel-20140622# cat \/root\/tmp\/num1000000 | .\/src\/parallel \u2013pipe -j4 wc\nWhen using programs that use GNU Parallel to process data for publication please cite:\nO. Tange (2011): GNU Parallel \u2013 The Command-Line Power Tool,\n;login: The USENIX Magazine, February 2011:42-47.\nThis helps funding further development; and it won't cost you a cent.\nTo silence this citation notice run 'parallel \u2013bibtex' once or use '\u2013no-notice'.\n165668 165668 1048571\n149797 149797 1048579\n149796 149796 1048572\n149797 149797 1048579\n85349 85349 597444\n149797 149797 1048579\n149796 149796 1048572<\/pre>\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u6309\u7167\u90a3\u7bc7\u6587\u7ae0\u4e2d\u4ecb\u7ecd\u7684\u65b9\u6cd5\u53bb\u4eab\u53d7parallel\u5e26\u6765\u7684\u52a0\u901f\u4e86\uff08\u524d\u63d0\u6761\u4ef6\u662f\uff1a\u591a\u6838\uff0c\u6211\u7684VPS\u56e0\u4e3a\u662f\u5355\u6838\u7684\uff0c\u6240\u4ee5\u5c31\u65e0\u6cd5\u4eab\u53d7\u52a0\u901f\u5ea6\u5e26\u6765\u7684\u5feb\u611f\u4e86::&gt;_&lt;:: \uff09<\/p>\n<pre class=\"lang:default decode:true\"># find \/ -name parallel\n\/root\/download\/parallel-20140622\/src\/parallel\n\/usr\/include\/c++\/4.6\/parallel\n\/usr\/local\/bin\/parallel\n\/usr\/local\/share\/doc\/parallel\n\/usr\/bin\/parallel\n\n# file \/usr\/bin\/parallel\n\/usr\/bin\/parallel: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU\/Linux 2.6.15, BuildID[sha1]=0xc39a37f03a41bc1b1096aa6175a2c427b28bfb23, stripped\n\n# file \/usr\/local\/bin\/parallel\n\/usr\/local\/bin\/parallel: a perl script, ASCII text executable, with escape sequences\n\n# which parallel\n\/usr\/local\/bin\/parallel<\/pre>\n<p>\u4f60\u4f1a\u53d1\u73b0\uff0c\u5176\u5b9eparallel\u5c31\u662f\u4e00\u4e2a\u53ef\u6267\u884c\u7684Perl\u811a\u672c\uff0c\u5982\u679c\u53ef\u4ee5\u7684\u8bdd\u4f60\u4e5f\u53ef\u4ee5\u81ea\u5df1\u53bb\u8bd5\u7740\u5199\u4e00\u4e2a`(*\u2229_\u2229*)\u2032<\/p>\n<h6>\u66f4\u591a\u53c2\u8003\u6587\u7ae0\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.rankfocus.com\/use-cpu-cores-linux-commands\/\" target=\"_blank\">Use multiple CPU Cores with your Linux commands &#8212; awk, sed, bzip2, grep, wc, etc. | RankFocus \u2013 Systems and Data<\/a><\/li>\n<li><a href=\"http:\/\/ftp.gnu.org\/gnu\/parallel\/\" target=\"_blank\">parallel\u7684\u4e0b\u8f7d\u5730\u5740<\/a><\/li>\n<li><a href=\"http:\/\/pi.dk\/3\/\" target=\"_blank\">\u5feb\u901f\u5b89\u88c5\u811a\u672c\u7684\u4e0b\u8f7d\u5730\u5740<\/a><\/li>\n<li><a href=\"http:\/\/www.3gcomet.com\/?p=205\" target=\"_blank\">\u4f7f\u7528sig\u6587\u4ef6\u751f\u6210\u548c\u9a8c\u8bc1\u6570\u5b57\u7b7e\u540d<\/a><\/li>\n<li><a href=\"https:\/\/www.gnu.org\/software\/parallel\/parallel_tutorial.html\" target=\"_blank\">GNU Parallel Tutorial<\/a><\/li>\n<li><a href=\"https:\/\/www.biostars.org\/p\/63816\/\" target=\"_blank\">Gnu Parallel \u2013 Parallelize Serial Command Line Programs Without Changing Them<\/a><\/li>\n<\/ul>\n<h6>\u4e00\u4e9bparallel\u547d\u4ee4\u7684\u5feb\u901f\u5165\u95e8\u6559\u5b66\u89c6\u9891\uff1a<\/h6>\n<ul>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=OpaiGYxkSuQ&amp;index=2&amp;list=PL284C9FF2488BC6D1\" target=\"_blank\">https:\/\/www.youtube.com\/watch?v=OpaiGYxkSuQ&amp;index=2&amp;list=PL284C9FF2488BC6D1<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=P40akGWJ_gY&amp;index=3&amp;list=PL284C9FF2488BC6D1\" target=\"_blank\">https:\/\/www.youtube.com\/watch?v=P40akGWJ_gY&amp;index=3&amp;list=PL284C9FF2488BC6D1<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=1ntxT-47VPA&amp;index=4&amp;list=PL284C9FF2488BC6D1\" target=\"_blank\">https:\/\/www.youtube.com\/watch?v=1ntxT-47VPA&amp;index=4&amp;list=PL284C9FF2488BC6D1<\/a><\/li>\n<li><a href=\"https:\/\/www.youtube.com\/watch?v=fOX1EyHkQwc&amp;index=5&amp;list=PL284C9FF2488BC6D1\" target=\"_blank\">https:\/\/www.youtube.com\/watch?v=fOX1EyHkQwc&amp;index=5&amp;list=PL284C9FF2488BC6D1<\/a><\/li>\n<\/ul>\n<p>====<\/p>\n<h5>Linux\u4e0b\u4f7f\u7528.sig\u7b7e\u540d\u6587\u4ef6\u9a8c\u8bc1\u7b7e\u540d<\/h5>\n<p>\u7f51\u4e0a\u4e00\u4e9b\u4e0b\u8f7d\u8d44\u6e90\u4f1a\u540c\u65f6\u63d0\u4f9b\u4e0b\u8f7d\u8d44\u6e90\u540d\u79f0\u52a0&#8221;.sig&#8221;\u4e3a\u6587\u4ef6\u540d\u7684\u5206\u79bb\u7b7e\u540d\u6587\u4ef6\uff0c\u7528\u6765\u6821\u9a8c\u4e0b\u8f7d\u8d44\u6e90\u7684\u5b8c\u6574\u6027\u3002<\/p>\n<p>\u4ee5grub\u4e3a\u4f8b\uff0c\u5f53\u524d\u6700\u65b0\u7248\u672c\u7684grub\u4e3a2.00\u7248\u672c\uff0c\u53ef\u4ece ftp:\/\/ftp.gnu.org\/gnu\/grub\/ \u4e0b\u8f7d\uff0c\u6709\u4e24\u4e2a\u6587\u4ef6\uff1agrub-2.00.tar.gz.sig\u548cgrub-2.00.tar.gz\u3002<\/p>\n<h6>\u9a8c\u8bc1\u65b9\u6cd5\uff1a<\/h6>\n<pre class=\"lang:default decode:true\">$ gpg --verify grub-2.00.tar.gz.sig grub-2.00.tar.gz\ngpg: \u4e8e 2012\u5e7406\u670828\u65e5 \u661f\u671f\u56db 08\u65f611\u520654\u79d2 CST \u521b\u5efa\u7684\u7b7e\u540d\uff0c\u4f7f\u7528 DSA\uff0c\u94a5\u5319\u53f7 E82E4209\ngpg: \u65e0\u6cd5\u68c0\u67e5\u7b7e\u540d\uff1a\u627e\u4e0d\u5230\u516c\u94a5<\/pre>\n<p>\u8fd9\u8bf4\u660e\u627e\u4e0d\u5230\u5bf9\u5e94\u7684\u516c\u94a5\uff0c\u540c\u65f6\u4f1a\u63d0\u793a\u5f53\u524d\u9a8c\u8bc1\u7684\u94a5\u5319\u53f7\u4e3a E82E4209\uff0c\u6839\u636e\u8fd9\u4e2a\u94a5\u5319\u53f7\u5bfc\u5165\u516c\u94a5\uff1a<\/p>\n<pre class=\"lang:default decode:true\">$ gpg --recv-keys E82E4209\ngpg: \u4e0b\u8f7d\u5bc6\u94a5'E82E4209'\uff0c\u4ece hkp \u670d\u52a1\u5668 keys.gnupg.net\ngpg: \u5bc6\u94a5 E82E4209\uff1a\u516c\u94a5\"Vladimir 'phcoder' Serbinenko &lt;phcoder@gmail.com&gt;\"\u5df2\u5bfc\u5165\ngpg: \u6ca1\u6709\u627e\u5230\u4efb\u4f55\u7edd\u5bf9\u4fe1\u4efb\u7684\u5bc6\u94a5\ngpg: \u5408\u8ba1\u88ab\u5904\u7406\u7684\u6570\u91cf\uff1a1\ngpg: \u5df2\u5bfc\u5165\uff1a1<\/pre>\n<pre class=\"lang:default decode:true\">$ gpg --verify --verbose grub-2.00.tar.gz.sig grub-2.00.tar.gz\ngpg: \u4e8e 2012\u5e7406\u670828\u65e5 \u661f\u671f\u56db 08\u65f611\u520654\u79d2 CST \u521b\u5efa\u7684\u7b7e\u540d\uff0c\u4f7f\u7528 DSA\uff0c\u94a5\u5319\u53f7 E82E4209\ngpg: \u4f7f\u7528 PGP \u4fe1\u4efb\u6a21\u578b\ngpg: \u5b8c\u597d\u7684\u7b7e\u540d\uff0c\u6765\u81ea\u4e8e\"Vladimir 'phcoder' Serbinenko &lt;phcoder@gmail.com&gt;\"\ngpg: \u8b66\u544a\uff1a\u8fd9\u628a\u5bc6\u94a5\u672a\u7ecf\u53d7\u4fe1\u4efb\u7684\u7b7e\u540d\u8ba4\u8bc1\uff01\ngpg: \u6ca1\u6709\u8bc1\u636e\u8868\u660e\u8fd9\u4e2a\u7b7e\u540d\u5c5e\u4e8e\u5b83\u6240\u58f0\u79f0\u7684\u6301\u6709\u8005\u3002\n\u4e3b\u94a5\u6307\u7eb9\uff1a E53D 497F 3FA4 2AD8 C9B4 D1E8 35A9 3B74 E82E 4209\ngpg: \u4e8c\u8fdb\u5236 \u7b7e\u540d\uff0c\u6563\u5217\u7b97\u6cd5 SHA512<\/pre>\n<p>====<\/p>\n<h5>\u8865\u5145\uff1aparallel\u7684\u591a\u79cd\u5b89\u88c5\u65b9\u6cd5<\/h5>\n<p>GNU Parallel makes sure output from the commands is the same output as you would get had you run the commands sequentially. This makes it possible to use output from GNU Parallel as input for other programs.<\/p>\n<h6>= 10 seconds installation =<\/h6>\n<p>The 10 seconds installation will try do to a full installation; if that fails, a personal installation; if that fails, a minimal installation.<\/p>\n<pre class=\"lang:default decode:true\">(wget -O \u2013 pi.dk\/3 || curl pi.dk\/3\/ || fetch -o \u2013 http:\/\/pi.dk\/3) | bash<\/pre>\n<p>This will literally install faster than reading the rest of this\u00a0document.<\/p>\n<h6>= Full installation =<\/h6>\n<p>Full installation of GNU Parallel is as simple as:<\/p>\n<pre class=\"lang:default decode:true\">wget http:\/\/ftpmirror.gnu.org\/parallel\/parallel-20140622.tar.bz2\nbzip2 -dc parallel-20140622.tar.bz2 | tar xvf \u2013\ncd parallel-20140622\n.\/configure &amp;&amp; make &amp;&amp; make install<\/pre>\n<h6>= Personal installation =<\/h6>\n<p>If you are not root you can add ~\/bin to your path and install in ~\/bin and ~\/share:<\/p>\n<pre class=\"lang:default decode:true\">wget http:\/\/ftpmirror.gnu.org\/parallel\/parallel-20140622.tar.bz2\nbzip2 -dc parallel-20140622.tar.bz2 | tar xvf \u2013\ncd parallel-20140622\n.\/configure \u2013prefix=$HOME &amp;&amp; make &amp;&amp; make install<\/pre>\n<p>Or if your system lacks &#8216;make&#8217; you can simply copy src\/parallel src\/sem src\/niceload src\/sql to a dir in your path.\uff08\u5982\u679c\u4e0d\u60f3\u5b89\u88c5\u6216\u662f\u7cfb\u7edf\u4e2d\u7f3a\u5c11make\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u5c06\u4ece\u6e90\u7801\u89e3\u538b\u51fa\u6765\u7684src\/parallel src\/sem src\/niceload src\/sql \u590d\u5236\u5230\u5728\u4f60\u7684$PATH\u8def\u5f84\u4e2d\u7684\u76ee\u5f55\u91cc\u9762\u53bb\u5373\u53ef\uff09<\/p>\n<h6>= Minimal installation =<\/h6>\n<p>If you just need parallel and do not have &#8216;make&#8217; installed (maybe the system is old or Microsoft Windows):<\/p>\n<pre class=\"lang:default decode:true\">wget http:\/\/git.savannah.gnu.org\/cgit\/parallel.git\/plain\/src\/parallel\nchmod 755 parallel\ncp parallel sem\nmv parallel sem dir-in-your-$PATH\/bin\/<\/pre>\n<h6>= Test the installation =<\/h6>\n<p>After this you should be able to do:<br \/>\nparallel -j0 ping -nc 3 ::: foss.org.my gnu.org freenetproject.org<br \/>\nThis will send 3 ping packets to 3 different hosts in parallel and print the output when they complete.<br \/>\nWatch the intro video for a quick introduction:<br \/>\n<a href=\"https:\/\/www.youtube.com\/playlist?list=PL284C9FF2488BC6D1\" target=\"_blank\">https:\/\/www.youtube.com\/playlist?list=PL284C9FF2488BC6D1<\/a><br \/>\nWalk through the tutorial (man parallel_tutorial). You command line will love you for it.<br \/>\nWhen using programs that use GNU Parallel to process data for publication please cite:<br \/>\nO. Tange (2011): GNU Parallel \u2013 The Command-Line Power Tool,<br \/>\n;login: The USENIX Magazine, February 2011:42-47.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Ubuntu12.04 x32\u4e0a\u4f7f\u7528parallel\u547d\u4ee4 \u665a\u4e0a\u5728\u6574\u7406\u4e4b\u524d\u641c\u96c6\u7684\u7b14\u8bb0\/\u6587\u7ae0\u7684\u65f6\u5019\u53d1\u73b0\u4e86\u4e00\u7bc7\u540d\u4e3a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,12],"tags":[230,231],"class_list":["post-554","post","type-post","status-publish","format-standard","hentry","category-linux","category-tools","tag-gpg","tag-parallel"],"views":3081,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/554","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=554"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/554\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=554"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=554"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=554"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}