{"id":183,"date":"2024-06-29T16:33:08","date_gmt":"2024-06-29T08:33:08","guid":{"rendered":"https:\/\/abytelalala.cn\/?p=183"},"modified":"2024-06-30T13:57:38","modified_gmt":"2024-06-30T05:57:38","slug":"%e7%ac%ac%e4%b8%80%e4%b8%aaspark%e4%bd%bf%e7%94%a8%e5%b0%8f%e6%a1%88%e4%be%8b","status":"publish","type":"post","link":"https:\/\/abytelalala.cn\/index.php\/2024\/06\/29\/%e7%ac%ac%e4%b8%80%e4%b8%aaspark%e4%bd%bf%e7%94%a8%e5%b0%8f%e6%a1%88%e4%be%8b\/","title":{"rendered":"\u7b2c\u4e00\u4e2aspark\u4f7f\u7528\u5c0f\u6848\u4f8b"},"content":{"rendered":"\n<p>spark\u6ca1\u642d\u5efa\u597d\u7684\u53ef\u4ee5\u67e5\u770b\u4e4b\u524d\u7684\u6559\u7a0b<a href=\"https:\/\/abytelalala.cn\/index.php\/2024\/06\/26\/%e5%9f%ba%e4%ba%8eubentu%e4%b8%8adocker%ef%bc%8chbase%e7%9a%84spark%e9%83%a8%e7%bd%b2\/\">https:\/\/abytelalala.cn\/index.php\/2024\/06\/26\/%e5%9f%ba%e4%ba%8eubentu%e4%b8%8adocker%ef%bc%8chbase%e7%9a%84spark%e9%83%a8%e7%bd%b2\/<\/a><\/p>\n\n\n\n<p>\u9996\u5148\u8fdb\u5165hadoop01<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker exec -it hadoop01 bash\nsu -\napt-get update --fix-missing\napt install python3-pip\npip --version\npip install --upgrade six==1.15\npip install happybase\nmkdir \/py \/\/\u6211\u4eec\u4e3a\u4e86\u65b9\u4fbf\u6784\u9020\u4e00\u4e2a\u811a\u672c\u76ee\u5f55\nexit<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u63d0\u4ea4\u4efb\u52a1\u4e86\uff0c\u6211\u4eec\u8fd9\u91cc\u4ee5python\u4e3a\u4f8b\u5b50\u3002<br>\u6709\u4e00\u4e2aexample.py\u7684\u811a\u672c\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from pyspark.sql import SparkSession\n\ndef main():\n&nbsp; &nbsp; spark = SparkSession.builder.appName(\"ExampleApp\").getOrCreate()\n&nbsp; &nbsp; data = &#91;(\"Alice\", 1), (\"Bob\", 2), (\"Cathy\", 3)]\n&nbsp; &nbsp; df = spark.createDataFrame(data, &#91;\"Name\", \"Value\"])\n&nbsp; &nbsp; df.show()\n&nbsp; &nbsp; spark.stop()\n\nif __name__ == \"__main__\":\n&nbsp; &nbsp; main() <\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u521b\u5efapy\u6587\u4ef6\u5939\uff0c\u4f60\u9700\u8981\u624b\u52a8\u628a\u811a\u672c\u62d6\u8fdb\u53bbpy\u6587\u4ef6\u5939\u91cc<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>docker cp \/home\/cust\/py\/example.py hadoop01:\/py\/ \/\/\u79fb\u52a8\u5230docker\u91cc<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/\u7136\u540e\u5728\u4e3b\u8282\u70b9\u4e0a\u76f4\u63a5\u8fd0\u884c\u8fd9\u4e2a\n\/usr\/local\/spark\/bin\/spark-submit --master spark:\/\/192.168.1.110:7077 --executor-memory 1G --total-executor-cores 2 \/py\/example.py<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>spark\u6ca1\u642d\u5efa\u597d\u7684\u53ef\u4ee5\u67e5\u770b\u4e4b\u524d\u7684\u6559\u7a0bhttps:\/\/abytelalala.cn\/index.php\/202 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[14],"class_list":["post-183","post","type-post","status-publish","format-standard","hentry","category-7","tag-spark"],"_links":{"self":[{"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/posts\/183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/comments?post=183"}],"version-history":[{"count":13,"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions"}],"predecessor-version":[{"id":273,"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/posts\/183\/revisions\/273"}],"wp:attachment":[{"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/media?parent=183"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/categories?post=183"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/abytelalala.cn\/index.php\/wp-json\/wp\/v2\/tags?post=183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}