<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.8.5">Jekyll</generator><link href="/feed.xml" rel="self" type="application/atom+xml" /><link href="/" rel="alternate" type="text/html" /><updated>2020-04-08T07:59:54+00:00</updated><id>/feed.xml</id><title type="html">Chan’s blog</title><subtitle>随手记.</subtitle><entry><title type="html">hadoop的Pseudo-Distributed模式测试</title><link href="/hadoop/pseudo-distributed/2020/04/07/hadoop-pseudo-distributed.html" rel="alternate" type="text/html" title="hadoop的Pseudo-Distributed模式测试" /><published>2020-04-07T04:15:38+00:00</published><updated>2020-04-07T04:15:38+00:00</updated><id>/hadoop/pseudo-distributed/2020/04/07/hadoop-pseudo-distributed</id><content type="html" xml:base="/hadoop/pseudo-distributed/2020/04/07/hadoop-pseudo-distributed.html">&lt;h4 id=&quot;1安装jdk参考&quot;&gt;1.安装jdk，&lt;a href=&quot;/centos/java/jdk/2020/03/05/jdk-centos-install.html&quot;&gt;参考&lt;/a&gt;&lt;/h4&gt;

&lt;h4 id=&quot;2安装hadoop参考&quot;&gt;2.安装hadoop，&lt;a href=&quot;/hadoop/standalone/2020/04/06/hadoop-standalone.html&quot;&gt;参考&lt;/a&gt;&lt;/h4&gt;

&lt;h4 id=&quot;3配置文件修改&quot;&gt;3.配置文件修改&lt;/h4&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;## hadoop-env.sh &lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/hadoop-env.sh 
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JAVA_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/jdk1.8.0_144


&lt;span class=&quot;c&quot;&gt;## core-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/core-site.xml
&amp;lt;configuration&amp;gt;
	&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 指定HDFS中NameNode的地址 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
	&amp;lt;property&amp;gt;
	&amp;lt;name&amp;gt;fs.defaultFS&amp;lt;/name&amp;gt;
	    &amp;lt;value&amp;gt;hdfs://hadoop211:9000&amp;lt;/value&amp;gt;
	&amp;lt;/property&amp;gt;

	&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 指定Hadoop运行时产生文件的存储目录 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
	&amp;lt;property&amp;gt;
		&amp;lt;name&amp;gt;hadoop.tmp.dir&amp;lt;/name&amp;gt;
		&amp;lt;value&amp;gt;/opt/module/hadoop-2.7.2/data/tmp&amp;lt;/value&amp;gt;
	&amp;lt;/property&amp;gt;
&amp;lt;/configuration&amp;gt;


&lt;span class=&quot;c&quot;&gt;## hdfs-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/hdfs-site.xml
&amp;lt;configuration&amp;gt;
	&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 指定HDFS副本的数量 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
	&amp;lt;property&amp;gt;
		&amp;lt;name&amp;gt;dfs.replication&amp;lt;/name&amp;gt;
		&amp;lt;value&amp;gt;1&amp;lt;/value&amp;gt;
	&amp;lt;/property&amp;gt;
&amp;lt;/configuration&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;4启动集群&quot;&gt;4.启动集群&lt;/h4&gt;

&lt;p&gt;1).格式化NameNode（第一次启动时格式化，以后就不要总格式化）&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs namenode &lt;span class=&quot;nt&quot;&gt;-format&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).启动NameNode&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop-daemon.sh start namenode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3).启动DataNode&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop-daemon.sh start datanode
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4).确认是否启动成功&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 注意：jps是JDK中的命令，不是Linux命令。不安装JDK不能使用jps&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# jps
2176 NameNode
2259 DataNode
2333 Jps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;web端查看 http://hadoop211:50070/&lt;/p&gt;

&lt;p&gt;5).查看产生的Log日志&lt;/p&gt;

&lt;p&gt;说明：在企业中遇到Bug时，经常根据日志提示信息去分析问题、解决Bug。&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; /opt/module/hadoop-2.7.2/logs
total 64
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root 23979 Apr  7 16:49 hadoop-root-datanode-hadoop211.log
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root   714 Apr  7 16:49 hadoop-root-datanode-hadoop211.out
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root 27653 Apr  7 16:56 hadoop-root-namenode-hadoop211.log
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root  4960 Apr  7 16:56 hadoop-root-namenode-hadoop211.out

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;6).注意：为什么不能一直格式化NameNode，格式化NameNode，要注意什么？&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /opt/module/hadoop-2.7.2/data/tmp/dfs/name/current/VERSION
&lt;span class=&quot;c&quot;&gt;#Tue Apr 07 16:46:56 CST 2020&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;namespaceID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;1667612766
&lt;span class=&quot;nv&quot;&gt;clusterID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;CID-4b8e5f21-529e-40e5-8ff5-55fcf64f3cc0
&lt;span class=&quot;nv&quot;&gt;cTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0
&lt;span class=&quot;nv&quot;&gt;storageType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;NAME_NODE
&lt;span class=&quot;nv&quot;&gt;blockpoolID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;BP-1450470986-192.168.31.211-1586249216548
&lt;span class=&quot;nv&quot;&gt;layoutVersion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-63&lt;/span&gt;


&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /opt/module/hadoop-2.7.2/data/tmp/dfs/data/current/VERSION
&lt;span class=&quot;c&quot;&gt;#Tue Apr 07 16:49:29 CST 2020&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;storageID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;DS-79880931-ab57-4cee-8ce1-9c5fe21d0812
&lt;span class=&quot;nv&quot;&gt;clusterID&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;CID-4b8e5f21-529e-40e5-8ff5-55fcf64f3cc0
&lt;span class=&quot;nv&quot;&gt;cTime&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;0
&lt;span class=&quot;nv&quot;&gt;datanodeUuid&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;15e0af92-e7f4-49ff-b47f-17d508e14fa8
&lt;span class=&quot;nv&quot;&gt;storageType&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;DATA_NODE
&lt;span class=&quot;nv&quot;&gt;layoutVersion&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;-56&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;注意：格式化NameNode，会产生新的集群id,导致NameNode和DataNode的集群id不一致，集群找不到已往数据。所以，格式NameNode时，一定要先删除data数据和log日志，然后再格式化NameNode。&lt;/p&gt;

&lt;h4 id=&quot;5操作集群&quot;&gt;5.操作集群&lt;/h4&gt;

&lt;p&gt;1).在HDFS文件系统上创建一个input文件夹&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /user/bigdata/input

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).将测试文件内容上传到文件系统上&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-put&lt;/span&gt; /opt/tmp/hadoop/wcinput/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;  /user/bigdata/input/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3).查看上传的文件是否正确&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-ls&lt;/span&gt;  /user/bigdata/input/
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-cat&lt;/span&gt;  /user/bigdata/input/hadoop-policy.xml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4).运行MapReduce程序&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 wordcount /user/bigdata/input/ /user/bigdata/output
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;5).查看输出结果&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-cat&lt;/span&gt; /user/bigdata/output/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;6).将测试文件内容下载到本地&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-get&lt;/span&gt; /user/bigdata/output/part-r-00000 /root/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;7).删除输出结果&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; /user/bigdata/output
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;h4 id=&quot;6启动yarn并运行mapreduce程序&quot;&gt;6.启动YARN并运行MapReduce程序&lt;/h4&gt;

&lt;p&gt;1).配置&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;## 配置yarn-env.sh&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/yarn-env.sh

&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JAVA_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/jdk1.8.0_144


&lt;span class=&quot;c&quot;&gt;## 配置yarn-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/yarn-site.xml

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; Reducer获取数据的方式 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
	&amp;lt;name&amp;gt;yarn.nodemanager.aux-services&amp;lt;/name&amp;gt;
	&amp;lt;value&amp;gt;mapreduce_shuffle&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 指定YARN的ResourceManager的地址 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
	&amp;lt;name&amp;gt;yarn.resourcemanager.hostname&amp;lt;/name&amp;gt;
	&amp;lt;value&amp;gt;hadoop211&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;


&lt;span class=&quot;c&quot;&gt;## 配置 mapred-env.sh&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/mapred-env.sh

&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JAVA_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/jdk1.8.0_144


&lt;span class=&quot;c&quot;&gt;## 配置： (对mapred-site.xml.template重新命名为) mapred-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /opt/module/hadoop-2.7.2/etc/hadoop/mapred-site.xml.template &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
	/opt/module/hadoop-2.7.2/etc/hadoop/mapred-site.xml 
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/mapred-site.xml 

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 指定MR运行在YARN上 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
		&amp;lt;name&amp;gt;mapreduce.framework.name&amp;lt;/name&amp;gt;
		&amp;lt;value&amp;gt;yarn&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).启动集群&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;启动前必须保证NameNode和DataNode已经启动&lt;/li&gt;
  &lt;li&gt;启动&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;## 启动ResourceManager&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh start resourcemanager

&lt;span class=&quot;c&quot;&gt;## 启动NodeManager&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh start nodemanager
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3).集群操作&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;YARN的浏览器页面查看 http://hadoop211:8088/cluster&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;## 删除文件系统上的output文件&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; /user/bigdata/output

&lt;span class=&quot;c&quot;&gt;## 执行MapReduce程序&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  wordcount /user/bigdata/input  /user/bigdata/output

&lt;span class=&quot;c&quot;&gt;## 查看运行结果&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-cat&lt;/span&gt; /user/bigdata/output/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4).配置历史服务器&lt;/p&gt;

&lt;p&gt;为了查看程序的历史运行情况，需要配置一下历史服务器。具体配置步骤如下：&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;## 配置mapred-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/mapred-site.xml

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 历史服务器端地址 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
	&amp;lt;name&amp;gt;mapreduce.jobhistory.address&amp;lt;/name&amp;gt;
	&amp;lt;value&amp;gt;hadoop211:10020&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;
&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 历史服务器web端地址 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
    &amp;lt;name&amp;gt;mapreduce.jobhistory.webapp.address&amp;lt;/name&amp;gt;
    &amp;lt;value&amp;gt;hadoop211:19888&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;ul&gt;
  &lt;li&gt;启动历史服务器&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# mr-jobhistory-daemon.sh start historyserver

&lt;span class=&quot;c&quot;&gt;##	查看历史服务器是否启动&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# jps
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;查看JobHistory http://hadoop211:19888/jobhistory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;5).配置日志的聚集&lt;/p&gt;

&lt;p&gt;日志聚集概念：应用运行完成以后，将程序运行日志信息上传到HDFS系统上。
日志聚集功能好处：可以方便的查看到程序运行详情，方便开发调试。
注意：开启日志聚集功能，需要重新启动NodeManager 、ResourceManager和HistoryManager。
开启日志聚集功能具体步骤如下：&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;##	配置yarn-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/yarn-site.xml
&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 日志聚集功能使能 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;yarn.log-aggregation-enable&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 日志保留时间设置7天 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;yarn.log-aggregation.retain-seconds&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;604800&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;


&lt;span class=&quot;c&quot;&gt;##	关闭NodeManager 、ResourceManager和HistoryManager&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh stop resourcemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh stop nodemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# mr-jobhistory-daemon.sh stop historyserver


&lt;span class=&quot;c&quot;&gt;##	启动NodeManager 、ResourceManager和HistoryManager&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh start resourcemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh start nodemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# mr-jobhistory-daemon.sh start historyserver


&lt;span class=&quot;c&quot;&gt;## 删除HDFS上已经存在的输出文件&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; /user/atguigu/output


&lt;span class=&quot;c&quot;&gt;##	执行WordCount程序&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
  wordcount /user/bigdata/input /user/bigdata/output
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;查看日志，http://hadoop101:19888/jobhistory&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;6). 配置日志的聚集&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;
    &lt;p&gt;日志聚集概念：应用运行完成以后，将程序运行日志信息上传到HDFS系统上。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;日志聚集功能好处：可以方便的查看到程序运行详情，方便开发调试。&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;注意：开启日志聚集功能，需要重新启动NodeManager 、ResourceManager和HistoryManager。&lt;/p&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;开启日志聚集功能具体步骤如下：&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;## 配置yarn-site.xml&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /opt/module/hadoop-2.7.2/etc/hadoop/yarn-site.xml

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 日志聚集功能使能 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;yarn.log-aggregation-enable&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;true&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;

&amp;lt;&lt;span class=&quot;o&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt; 日志保留时间设置7天 &lt;span class=&quot;nt&quot;&gt;--&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt;
&amp;lt;property&amp;gt;
&amp;lt;name&amp;gt;yarn.log-aggregation.retain-seconds&amp;lt;/name&amp;gt;
&amp;lt;value&amp;gt;604800&amp;lt;/value&amp;gt;
&amp;lt;/property&amp;gt;


&lt;span class=&quot;c&quot;&gt;## 关闭NodeManager 、ResourceManager和HistoryManager&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# mr-jobhistory-daemon.sh stop historyserver
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh stop nodemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh stop resourcemanager


&lt;span class=&quot;c&quot;&gt;## 启动NodeManager 、ResourceManager和HistoryManager&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh start resourcemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# yarn-daemon.sh start nodemanager
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# mr-jobhistory-daemon.sh start historyserver


&lt;span class=&quot;c&quot;&gt;## 删除HDFS上已经存在的输出文件&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hdfs dfs &lt;span class=&quot;nt&quot;&gt;-rm&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; /user/bigdata/output


&lt;span class=&quot;c&quot;&gt;## 执行WordCount程序&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]#  hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 wordcount /user/bigdata/input /user/bigdata/output
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;查看日志，http://hadoop101:19888/jobhistory&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><summary type="html">1.安装jdk，参考</summary></entry><entry><title type="html">安装hadoop并在standalone模式下简单测试</title><link href="/hadoop/standalone/2020/04/06/hadoop-standalone.html" rel="alternate" type="text/html" title="安装hadoop并在standalone模式下简单测试" /><published>2020-04-06T15:46:38+00:00</published><updated>2020-04-06T15:46:38+00:00</updated><id>/hadoop/standalone/2020/04/06/hadoop-standalone</id><content type="html" xml:base="/hadoop/standalone/2020/04/06/hadoop-standalone.html">&lt;p&gt;1.安装jdk，&lt;a href=&quot;/centos/java/jdk/2020/03/05/jdk-centos-install.html&quot;&gt;参考&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.下载hadoop二进制包&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# wget http://archive.apache.org/dist/hadoop/common/hadoop-2.7.2/hadoop-2.7.2.tar.gz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3.设置hadoop环境变量&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-zxvf&lt;/span&gt; hadoop-2.7.2.tar.gz &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; /opt/module

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# vi /etc/profile

&lt;span class=&quot;c&quot;&gt;# 在文件尾部增加&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;## HADOOP_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;HADOOP_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/hadoop-2.7.2
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;:&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;/bin
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;:&lt;span class=&quot;nv&quot;&gt;$HADOOP_HOME&lt;/span&gt;/sbin

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; /etc/profile

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop version
Hadoop 2.7.2
Subversion https://git-wip-us.apache.org/repos/asf/hadoop.git &lt;span class=&quot;nt&quot;&gt;-r&lt;/span&gt; b165c4fe8a74265c792ce23f546c64604acf0e41
Compiled by jenkins on 2016-01-26T00:08Z
Compiled with protoc 2.5.0
From &lt;span class=&quot;nb&quot;&gt;source &lt;/span&gt;with checksum d0fda26633fa762bff87ec759ebe689c
This &lt;span class=&quot;nb&quot;&gt;command &lt;/span&gt;was run using /opt/module/hadoop-2.7.2/share/hadoop/common/hadoop-common-2.7.2.jar

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4.跑两个官方示例&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;官方Grep案例&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /opt/tmp/hadoop/input
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /opt/module/hadoop-2.7.2/etc/hadoop/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.xml /opt/tmp/hadoop/input
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 &lt;span class=&quot;nb&quot;&gt;grep&lt;/span&gt; /opt/tmp/hadoop/input /opt/tmp/hadoop/output &lt;span class=&quot;s1&quot;&gt;'dfs[a-z.]+'&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /opt/tmp/hadoop/output/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;ul&gt;
  &lt;li&gt;官方WordCount案例&lt;/li&gt;
&lt;/ul&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /opt/tmp/hadoop/wcinput
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /opt/module/hadoop-2.7.2/etc/hadoop/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;.xml /opt/tmp/hadoop/wcinput
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# hadoop jar /opt/module/hadoop-2.7.2/share/hadoop/mapreduce/hadoop-mapreduce-examples-2.7.2.jar &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
 wordcount /opt/tmp/hadoop/wcinput /opt/tmp/hadoop/wcoutput
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop211]# &lt;span class=&quot;nb&quot;&gt;cat&lt;/span&gt; /opt/tmp/hadoop/wcoutput/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">1.安装jdk，参考</summary></entry><entry><title type="html">使用git的submodule方式管理微服务架构代码</title><link href="/git/submodule/microservices/code/2020/04/02/git-submodule-for-microservices.html" rel="alternate" type="text/html" title="使用git的submodule方式管理微服务架构代码" /><published>2020-04-02T07:40:24+00:00</published><updated>2020-04-02T07:40:24+00:00</updated><id>/git/submodule/microservices/code/2020/04/02/git-submodule-for-microservices</id><content type="html" xml:base="/git/submodule/microservices/code/2020/04/02/git-submodule-for-microservices.html">&lt;p&gt;创建整体项目repo，此处命名为parent
该repo不做具体代码提交用，仅做流水线发布拉取代码的主repo。&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;parent
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;parent
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git init
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git remote origin set-url http://localhost:3000/demo-multi-module/parent.git
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;不同的微服务模块放在不同代码仓库 module 中，创建具体的 repo，此处命名module。&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;module
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;module
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git init
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git remote origin set-url http://localhost:3000/demo-multi-module/module.git
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;将module添加为parent的子目录&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git submodule add http://localhost:3000/demo-multi-module/module.git module
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;some comment&quot;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;后面具体module提交代码就在自己repo中&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'first line'&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&amp;gt;&lt;/span&gt; example.txt
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git commit &lt;span class=&quot;nt&quot;&gt;-m&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;'add example.txt'&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;git push 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;由于当module具体需要更新时，在parent的repo要cd进入目录去 git pull比较繁琐，
以下为遍历更新多个module目录的脚本&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#! /bin/bash&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;path&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;

&lt;span class=&quot;nb&quot;&gt;ls&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$path&lt;/span&gt; | &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;read &lt;/span&gt;line
&lt;span class=&quot;k&quot;&gt;do
	if&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-d&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;then
		&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; is a directory&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
		git pull&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
		&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ..
	&lt;span class=&quot;k&quot;&gt;else
		&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$line&lt;/span&gt; is a file&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
	&lt;span class=&quot;k&quot;&gt;fi
done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考：&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;https://blog.csdn.net/guotianqing/article/details/82391665&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><summary type="html">创建整体项目repo，此处命名为parent 该repo不做具体代码提交用，仅做流水线发布拉取代码的主repo。 $ mkdir parent $ cd parent $ git init $ git remote origin set-url http://localhost:3000/demo-multi-module/parent.git $ git push</summary></entry><entry><title type="html">[转载]CentOS 7安装Python 2.6（与已有版本共存）</title><link href="/centos/python/2.7/2.6/2020/03/10/python-2.7-and-2.6-at-centos.html" rel="alternate" type="text/html" title="[转载]CentOS 7安装Python 2.6（与已有版本共存）" /><published>2020-03-10T17:33:24+00:00</published><updated>2020-03-10T17:33:24+00:00</updated><id>/centos/python/2.7/2.6/2020/03/10/python-2.7-and-2.6-at-centos</id><content type="html" xml:base="/centos/python/2.7/2.6/2020/03/10/python-2.7-and-2.6-at-centos.html">&lt;ol&gt;
  &lt;li&gt;安装需要用到的包
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# yum &lt;span class=&quot;nb&quot;&gt;install&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; zlib-devel bzip2-devel openssl-devel xz-libs wget 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;下载 Python 2.6.8 版本
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# wget https://www.python.org/ftp/python/2.6.8/Python-2.6.8.tgz
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;解压文件
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# &lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-xzvf&lt;/span&gt; Python-2.6.8.tgz &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; /opt/python/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;进入解压后文件的目录
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# &lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;Python-2.6.8
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;配置安装信息.
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# ./configure  &lt;span class=&quot;nt&quot;&gt;--enable-shared&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--prefix&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/python2.6
&lt;span class=&quot;c&quot;&gt;#（添加参数：--enable-shared，这样即会生成libpython2.6.so.1.0）&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;编译文件
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# make
&lt;span class=&quot;c&quot;&gt;#（若失败提示：configure: error: no acceptable C compiler found in $PATH&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 安装GCC：yum install gcc）&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;安装编译好的文件
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# make altinstall      &lt;span class=&quot;c&quot;&gt;# 使用 altinstall 安装, 不影响其他 Python 版本&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
  &lt;li&gt;设置软链接, 方便随时切换 Python 版本
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /opt/module/python2.6/bin/python2.6 /usr/bin/python2.6
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /opt/module/python2.6/lib/libpython2.6.so.1.0  /usr/lib/libpython2.6.so.1.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;9.执行python2.6时出现错误：&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# python2.6
python: error &lt;span class=&quot;k&quot;&gt;while &lt;/span&gt;loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;原因：linux系统默认没有把lib路径加入动态库搜索路径 
解决：&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# vim /etc/ld.so.conf
&lt;span class=&quot;c&quot;&gt;# 添加如下一行内容&lt;/span&gt;
/opt/module/python2.6/lib　　#python2.6的路径
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# ldconfig  &lt;span class=&quot;c&quot;&gt;# 使新添加的路径生效&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# /sbin/ldconfig &lt;span class=&quot;nt&quot;&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;参考：&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;https://www.cnblogs.com/MWCloud/p/11354591.html&lt;/li&gt;
  &lt;li&gt;https://blog.csdn.net/lyq19870515/article/details/80449386&lt;/li&gt;
&lt;/ul&gt;</content><author><name></name></author><summary type="html">安装需要用到的包 [root@hadoop102 ~]# yum install -y zlib-devel bzip2-devel openssl-devel xz-libs wget</summary></entry><entry><title type="html">Cloudera Manager在CentOS上安装</title><link href="/cloudera/manager/centos/install/2020/03/07/cloudera-manager-install.html" rel="alternate" type="text/html" title="Cloudera Manager在CentOS上安装" /><published>2020-03-07T05:55:24+00:00</published><updated>2020-03-07T05:55:24+00:00</updated><id>/cloudera/manager/centos/install/2020/03/07/cloudera-manager-install</id><content type="html" xml:base="/cloudera/manager/centos/install/2020/03/07/cloudera-manager-install.html">&lt;p&gt;1.CM下载地址&lt;/p&gt;

&lt;p&gt;1).&lt;a href=&quot;http://archive.cloudera.com/cm5/cm/5/&quot;&gt;CM下载地址&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2).&lt;a href=&quot;http://archive.cloudera.com/cdh5/parcels&quot;&gt;离线库下载地址&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.CM安装&lt;/p&gt;

&lt;p&gt;注：以下所有操作均使用root用户&lt;/p&gt;

&lt;p&gt;1).创建/opt/module/cm目录&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; –p /opt/module/cm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).上传cloudera-manager-el6-cm5.12.1_x86_64.tar.gz到hadoop102的/opt/software目录，并解压到/opt/module/cm目录&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# &lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-zxvf&lt;/span&gt; cloudera-manager-el6-cm5.12.1_x86_64.tar.gz &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; /opt/module/cm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3).分别在hadoop102、hadoop103、hadoop104创建用户cloudera-scm&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# 
useradd &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--system&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/cm/cm-5.12.1/run/cloudera-scm-server &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--no-create-home&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--shell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/bin/false &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--comment&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Cloudera SCM User&quot;&lt;/span&gt; cloudera-scm

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop103 module]# 
useradd &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--system&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/cm/cm-5.12.1/run/cloudera-scm-server &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--no-create-home&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--shell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/bin/false &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--comment&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Cloudera SCM User&quot;&lt;/span&gt; cloudera-scm

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop104 module]# 
useradd &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--system&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--home&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/cm/cm-5.12.1/run/cloudera-scm-server &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--no-create-home&lt;/span&gt; &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--shell&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/bin/false &lt;span class=&quot;se&quot;&gt;\&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;--comment&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;Cloudera SCM User&quot;&lt;/span&gt; cloudera-scm

参数说明：
&lt;span class=&quot;nt&quot;&gt;--system&lt;/span&gt; 创建一个系统账户
&lt;span class=&quot;nt&quot;&gt;--home&lt;/span&gt; 指定用户登入时的主目录，替换系统默认值/home/&amp;lt;用户名&amp;gt;
&lt;span class=&quot;nt&quot;&gt;--no-create-home&lt;/span&gt; 不要创建用户的主目录
&lt;span class=&quot;nt&quot;&gt;--shell&lt;/span&gt; 用户的登录 shell 名
&lt;span class=&quot;nt&quot;&gt;--comment&lt;/span&gt; 用户的描述信息
注意：Cloudera Manager默认去找用户cloudera-scm，创建完该用户后，将自动使用此用户。

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4).修改CM Agent配置&lt;/p&gt;

&lt;p&gt;修改文件/opt/module/cm/cm-5.12.1/etc/cloudera-scm-agent/ config.ini的主机名称&lt;/p&gt;

&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cloudera-scm-agent]# vim /opt/module/cm/cm-5.12.1/etc/cloudera-scm-agent/config.ini
&lt;span class=&quot;c&quot;&gt;# 修改主机名称&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;server_host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;hadoop102
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;5).配置CM的数据库&lt;/p&gt;

&lt;p&gt;拷贝mysql-connector-java-5.1.27-bin.jar文件到目录 /usr/share/java/&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cm]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; –p /usr/share/java/
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-zxvf&lt;/span&gt; mysql-connector-java-5.1.27.tar.gz

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;cp&lt;/span&gt; /opt/software/mysql-libs/mysql-connector-java-5.1.27/mysql-connector-java-5.1.27-bin.jar /usr/share/java/

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /usr/share/java/mysql-connector-java-5.1.27-bin.jar /usr/share/java/mysql-connector-java.jar
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;注意：jar包名称要修改为mysql-connector-java.jar&lt;/p&gt;

&lt;p&gt;6).使用CM自带的脚本，在MySQL中创建CM库&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cm-5.12.1]# 
/opt/module/cm/cm-5.12.1/share/cmf/schema/scm_prepare_database.sh mysql cm &lt;span class=&quot;nt&quot;&gt;-hhadoop102&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-uroot&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p000000&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--scm-host&lt;/span&gt; hadoop102 scm scm scm

&lt;span class=&quot;nv&quot;&gt;JAVA_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/jdk1.8.0_144
Verifying that we can write to /mnt/nas/hadoop102/module/cm/cm-5.12.1/etc/cloudera-scm-server
Creating SCM configuration file &lt;span class=&quot;k&quot;&gt;in&lt;/span&gt; /mnt/nas/hadoop102/module/cm/cm-5.12.1/etc/cloudera-scm-server
Executing:  /opt/module/jdk1.8.0_144/bin/java &lt;span class=&quot;nt&quot;&gt;-cp&lt;/span&gt; /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/mnt/nas/hadoop102/module/cm/cm-5.12.1/share/cmf/schema/../lib/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; com.cloudera.enterprise.dbutil.DbCommandExecutor /mnt/nas/hadoop102/module/cm/cm-5.12.1/etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;                          main] DbCommandExecutor              INFO  Successfully connected to database.
All &lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;, your SCM database is configured correctly!

参数说明
&lt;span class=&quot;nt&quot;&gt;-h&lt;/span&gt;：Database host
&lt;span class=&quot;nt&quot;&gt;-u&lt;/span&gt;：Database username
&lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt;：Database Password
&lt;span class=&quot;nt&quot;&gt;--scm-host&lt;/span&gt;：SCM server&lt;span class=&quot;s1&quot;&gt;'s hostname
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;7).修改服务端启动对应的数据地址、端口、用户、密码&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# vi /opt/module/cm/cm-5.12.1/etc/cloudera-scm-server/db.properties
...
com.cloudera.cmf.db.host&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;hadoop102
com.cloudera.cmf.db.name&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;cm
com.cloudera.cmf.db.user&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;root
com.cloudera.cmf.db.password&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;000000
...

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;8).分发cm&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# xsync /opt/module/cm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;9).创建Parcel-repo&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /opt/cloudera/parcel-repo
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# &lt;span class=&quot;nb&quot;&gt;chown &lt;/span&gt;cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;10).拷贝下载文件manifest.json 、CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel.sha1 、CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel到hadoop102的/opt/cloudera/parcel-repo/目录下&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 parcel-repo]# &lt;span class=&quot;nb&quot;&gt;ls
&lt;/span&gt;CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel  CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel.sha1  
manifest.json
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;11).将CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel.sha1：需改名为 CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel.sha&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 parcel-repo]# &lt;span class=&quot;nb&quot;&gt;mv &lt;/span&gt;CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel.sha1 CDH-5.12.1-1.cdh5.12.1.p0.3-el6.parcel.sha
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;12).在hadoop102上创建目录/opt/cloudera/parcels，并修改该目录的所属用户及用户组为cloudera-scm&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /opt/cloudera/parcels 
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 module]# &lt;span class=&quot;nb&quot;&gt;chown &lt;/span&gt;cloudera-scm:cloudera-scm /opt/cloudera/parcels
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;13).分发/opt/cloudera/&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 opt]# xsync /opt/cloudera/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3.启动CM服务&lt;/p&gt;

&lt;p&gt;1).启动服务节点：hadoop102&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-server start
Starting cloudera-scm-server:                              &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;确定]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).启动工作节点：hadoop102、hadoop103、hadoop104&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-agent start

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop103 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-agent start

&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop104 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-agent start
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;注意：启动过程非常慢，Manager启动成功需要等待5分钟左右，过程中会在数据库中创建对应的表需要耗费一些时间。&lt;/p&gt;

&lt;p&gt;如果遇到，启动失败，日志文件/opt/module/cm/cm-5.12.1/log/cloudera-scm-agent/cloudera-scm-agent.out
提示 /usr/bin/env: python2.6: No such file or directory ，则需要单独设置python2.6环境，&amp;lt;&lt;a href=&quot;&quot;&gt;参考&lt;/a&gt;&amp;gt;&lt;/p&gt;

&lt;p&gt;3).查看被占用则表示安装成功了！！！&lt;/p&gt;
&lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[root@hadoop102 cm]# netstat -anp | grep 7180
tcp        0      0 0.0.0.0:7180                0.0.0.0:*                   LISTEN      5498/java 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4).访问http://hadoop102:7180，（用户名、密码：admin）&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/2020/img00015.png&quot; alt=&quot;img&quot; /&gt;&lt;/p&gt;

&lt;p&gt;4.关闭CM服务&lt;/p&gt;

&lt;p&gt;1).关闭工作节点：hadoop102、hadoop103、hadoop104&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-agent stop
Stopping cloudera-scm-agent:                               &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;确定]
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop103 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-agent stop
Stopping cloudera-scm-agent:                               &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;确定]
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop104 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-agent stop
Stopping cloudera-scm-agent:                               &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;确定]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).关闭服务节点：hadoop102&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 cm]# /opt/module/cm/cm-5.12.1/etc/init.d/cloudera-scm-server stop
停止 cloudera-scm-server：                                 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;确定]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">1.CM下载地址</summary></entry><entry><title type="html">集群整体操作脚本</title><link href="/xcall/shell/script/2020/03/06/xcall-shell-script.html" rel="alternate" type="text/html" title="集群整体操作脚本" /><published>2020-03-06T09:39:24+00:00</published><updated>2020-03-06T09:39:24+00:00</updated><id>/xcall/shell/script/2020/03/06/xcall-shell-script</id><content type="html" xml:base="/xcall/shell/script/2020/03/06/xcall-shell-script.html">&lt;p&gt;1）在/root/bin目录下创建脚本xcall.sh&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 bin]&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vim xcall.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2）在脚本中编写如下内容&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#! /bin/bash&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;i &lt;span class=&quot;k&quot;&gt;in &lt;/span&gt;hadoop102 hadoop103 hadoop104
&lt;span class=&quot;k&quot;&gt;do
        &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;---------&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;----------&lt;/span&gt;
        ssh &lt;span class=&quot;nv&quot;&gt;$i&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$*&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;3）修改脚本执行权限&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 bin]&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;777 xcall.sh
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">1）在/root/bin目录下创建脚本xcall.sh [root@hadoop102 bin]$ vim xcall.sh</summary></entry><entry><title type="html">集群文件同步脚本</title><link href="/xsnyc/shell/script/2020/03/06/xsync-shell-script.html" rel="alternate" type="text/html" title="集群文件同步脚本" /><published>2020-03-06T09:39:24+00:00</published><updated>2020-03-06T09:39:24+00:00</updated><id>/xsnyc/shell/script/2020/03/06/xsync-shell-script</id><content type="html" xml:base="/xsnyc/shell/script/2020/03/06/xsync-shell-script.html">&lt;p&gt;1）在/root目录下创建bin目录，并在bin目录下创建文件xsync，文件内容如下：&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; ~
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;mkdir &lt;/span&gt;bin
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd &lt;/span&gt;bin/
&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;vi xsync
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2)在该文件中编写如下代码&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#!/bin/bash&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#1 获取输入参数个数，如果没有参数，直接退出&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;pcount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$#&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;pcount&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;==&lt;/span&gt;0&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;then
&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;no args&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;exit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;fi&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#2 获取文件名称&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;p1&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$1&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;fname&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;basename&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$p1&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;fname&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$fname&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#3 获取上级目录到绝对路径 #pdir=`cd -P $(dirname $p1); pwd`&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;#3 获取上级目录的路径&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;pdir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; &lt;span class=&quot;si&quot;&gt;$(&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;dirname&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$p1&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;pwd&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;echo &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;pdir&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$pdir&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#4 获取当前用户名称&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;whoami&lt;/span&gt;&lt;span class=&quot;sb&quot;&gt;`&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;#5 循环&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;for&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;((&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;103&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; host&amp;lt;105&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; host++&lt;span class=&quot;o&quot;&gt;))&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;do
        &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-------------------&lt;/span&gt; hadoop&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--------------&lt;/span&gt;
        rsync &lt;span class=&quot;nt&quot;&gt;-av&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$pdir&lt;/span&gt;/&lt;span class=&quot;nv&quot;&gt;$fname&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$user&lt;/span&gt;@hadoop&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt;:&lt;span class=&quot;nv&quot;&gt;$pdir&lt;/span&gt;
&lt;span class=&quot;k&quot;&gt;done&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3）修改脚本 xsync 具有执行权限&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;nv&quot;&gt;$ &lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;chmod &lt;/span&gt;777 xsync
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">1）在/root目录下创建bin目录，并在bin目录下创建文件xsync，文件内容如下： $ cd ~ $ mkdir bin $ cd bin/ $ vi xsync</summary></entry><entry><title type="html">关闭SELINUX</title><link href="/jekyll/update/2020/03/06/centos-selinux.html" rel="alternate" type="text/html" title="关闭SELINUX" /><published>2020-03-06T02:06:24+00:00</published><updated>2020-03-06T02:06:24+00:00</updated><id>/jekyll/update/2020/03/06/centos-selinux</id><content type="html" xml:base="/jekyll/update/2020/03/06/centos-selinux.html">&lt;p&gt;安全增强型Linux（Security-Enhanced Linux）简称SELinux，它是一个 Linux 内核模块，也是Linux的一个安全子系统。&lt;/p&gt;

&lt;p&gt;有如下两种关闭方法&lt;/p&gt;

&lt;p&gt;1.临时关闭（不建议使用）&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# setenforce 0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;但是这种方式只对当次启动有效，重启机器后会失效。&lt;/p&gt;

&lt;p&gt;2.永久关闭（建议使用）
修改配置文件/etc/selinux/config&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# vim /etc/selinux/config
将SELINUX&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;enforcing 改为SELINUX&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;disabled
&lt;span class=&quot;nv&quot;&gt;SELINUX&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;disabled
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3.同步/etc/selinux/config配置文件&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# xsync /etc/selinux/config
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4.重启主机&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 ~]# reboot
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">安全增强型Linux（Security-Enhanced Linux）简称SELinux，它是一个 Linux 内核模块，也是Linux的一个安全子系统。</summary></entry><entry><title type="html">Mysql5.6在Centos7上的安装排错过程</title><link href="/mysql5.6/centos/install/2020/03/05/mysql-centos-install.html" rel="alternate" type="text/html" title="Mysql5.6在Centos7上的安装排错过程" /><published>2020-03-05T07:26:38+00:00</published><updated>2020-03-05T07:26:38+00:00</updated><id>/mysql5.6/centos/install/2020/03/05/mysql-centos-install</id><content type="html" xml:base="/mysql5.6/centos/install/2020/03/05/mysql-centos-install.html">&lt;p&gt;首先准备mysql5.6相关的安装包&lt;/p&gt;

&lt;p&gt;注意：一定要用root用户操作如下步骤；先卸载MySQL再安装&lt;/p&gt;

&lt;p&gt;1.准备安装包&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# ll
总用量 76048
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root 18509960 3月  26 2015 MySQL-client-5.6.24-1.el6.x86_64.rpm
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root  3575135 12月  1 2013 mysql-connector-java-5.1.27.tar.gz
&lt;span class=&quot;nt&quot;&gt;-rw-r--r--&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt; 1 root root 55782196 3月  26 2015 MySQL-server-5.6.24-1.el6.x86_64.rpm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2.检查并卸载本地的自带默认msyql及依赖&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;#查看MySQL是否安装&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# rpm &lt;span class=&quot;nt&quot;&gt;-qa&lt;/span&gt;|grep mysql
mysql-libs-5.1.73-7.el6.x86_64
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# rpm &lt;span class=&quot;nt&quot;&gt;-qa&lt;/span&gt;| &lt;span class=&quot;nb&quot;&gt;grep &lt;/span&gt;mariadb
mariadb-libs-5.5.64-1.el7.x86_64

&lt;span class=&quot;c&quot;&gt;#如果安装了就先卸载&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# rpm &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--nodeps&lt;/span&gt; mysql-libs-5.1.73-7.el6.x86_64
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# rpm &lt;span class=&quot;nt&quot;&gt;-e&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;--nodeps&lt;/span&gt; mariadb-libs-5.5.64-1.el7.x86_64
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3.安装MySQL服务器&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 安装&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# yum localinstall MySQL-server-5.6.24-1.el6.x86_64.rpm

&lt;span class=&quot;c&quot;&gt;# 查看MySQL状态&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# service mysql status

&lt;span class=&quot;c&quot;&gt;# 启动MySQL&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# service mysql start
Starting MySQL..The server quit without updating PID file &lt;span class=&quot;o&quot;&gt;([&lt;/span&gt;FAILED]/mysql/hadoop102.pid&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 启动不了，如遇上述状况，查看 /var/lib/mysql/hadoop102.err&lt;/span&gt;
200306 10:53:15 mysqld_safe Starting mysqld daemon with databases from /data/mysql
2020-03-06 10:53:15 0 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use &lt;span class=&quot;nt&quot;&gt;--explicit_defaults_for_timestamp&lt;/span&gt; server option &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;see documentation &lt;span class=&quot;k&quot;&gt;for &lt;/span&gt;more details&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;nb&quot;&gt;.&lt;/span&gt;
2020-03-06 10:53:15 0 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Note] /usr/sbin/mysqld &lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;mysqld 5.6.24&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt; starting as process 2919 ...
2020-03-06 10:53:15 2919 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Note] Plugin &lt;span class=&quot;s1&quot;&gt;'FEDERATED'&lt;/span&gt; is disabled.
/usr/sbin/mysqld: Table &lt;span class=&quot;s1&quot;&gt;'mysql.plugin'&lt;/span&gt; doesn&lt;span class=&quot;s1&quot;&gt;'t exist
2020-03-06 10:53:15 2919 [ERROR] Can'&lt;/span&gt;t open the mysql.plugin table. Please run mysql_upgrade to create it.
2020-03-06 10:53:15 2919 &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;Note] InnoDB: Using atomics to ref count buffer pool pages

&lt;span class=&quot;c&quot;&gt;# 提示Table 'mysql.plugin' doesn't exist&lt;/span&gt;
&lt;span class=&quot;c&quot;&gt;# 执行以下操作，找到 mysql_install_db 所在目录做一次初始化&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# find / &lt;span class=&quot;nt&quot;&gt;-name&lt;/span&gt; mysql_install_db
/usr/bin/mysql_install_db

&lt;span class=&quot;c&quot;&gt;# 执行/usr/bin/mysql_install_db 初始化数据库&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# /usr/bin/mysql_install_db &lt;span class=&quot;nt&quot;&gt;--user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mysql
FATAL ERROR: please &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;the following perl modules before executing /usr/bin/mysql_install_db:
Data::Dumper

&lt;span class=&quot;c&quot;&gt;# 如出现上述错误执行下&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs] yum &lt;span class=&quot;nt&quot;&gt;-y&lt;/span&gt; &lt;span class=&quot;nb&quot;&gt;install &lt;/span&gt;autoconf
&lt;span class=&quot;c&quot;&gt;# 再执行&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# /usr/bin/mysql_install_db &lt;span class=&quot;nt&quot;&gt;--user&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;mysql

&lt;span class=&quot;c&quot;&gt;# 再次启动&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# service mysql start
Starting MySQL..                                           &lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;  OK  &lt;span class=&quot;o&quot;&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4、更换持久化数据目录，目的是以后服务器销毁还能保留，如无该需求此步可忽略&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 在NAS挂载盘中创建对应目录，并做好本机软链&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /mnt/nas/hadoop102/data/
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;ln&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-s&lt;/span&gt; /mnt/nas/hadoop102/data/ /data
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;mkdir&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p&lt;/span&gt; /data/mysql

&lt;span class=&quot;c&quot;&gt;# 停止服务器&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# service mysql stop

&lt;span class=&quot;c&quot;&gt;# 修改mysql服务的启动文件数据目录&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# vi /etc/rc.d/init.d/mysql
&lt;span class=&quot;c&quot;&gt;# 找到开头 datadir= 的地方改为 datadir=/data/mysql&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 剪切 /var/lib/mysql 下的所有文件到 /data/mysql 下&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# &lt;span class=&quot;nb&quot;&gt;mv&lt;/span&gt; /var/lib/mysql/&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt; /data/mysql/

&lt;span class=&quot;c&quot;&gt;# 再次启动服务器&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# service mysql start

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;5.安装MySQL客户端并重置用户权限&lt;/p&gt;

&lt;p&gt;1).安装MySQL客户端&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# yum localinstall MySQL-client-5.6.24-1.el6.x86_64.rpm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2).链接MySQL并修改密码&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# mysql
mysql&amp;gt;SET &lt;span class=&quot;nv&quot;&gt;PASSWORD&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;PASSWORD&lt;span class=&quot;o&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'000000'&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
mysql&amp;gt;exit
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3).修改MySQL中user表中主机配置，配置只要是root用户+密码，在任何主机上都能登录MySQL数据库。&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 进入MySQL&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 mysql-libs]# mysql &lt;span class=&quot;nt&quot;&gt;-uroot&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-p000000&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 显示数据库&lt;/span&gt;
mysql&amp;gt;show databases&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 使用MySQL数据库&lt;/span&gt;
mysql&amp;gt;use mysql&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 展示MySQL数据库中的所有表&lt;/span&gt;
mysql&amp;gt;show tables&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 展示user表的结构&lt;/span&gt;
mysql&amp;gt;desc user&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 查询user表&lt;/span&gt;
mysql&amp;gt;select User, Host, Password from user&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 修改user表，把Host表内容修改为%&lt;/span&gt;
mysql&amp;gt;update user &lt;span class=&quot;nb&quot;&gt;set &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'%'&lt;/span&gt; where &lt;span class=&quot;nv&quot;&gt;host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'localhost'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 删除root用户的其他host&lt;/span&gt;
mysql&amp;gt;delete from user where &lt;span class=&quot;nv&quot;&gt;Host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'hadoop102'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
mysql&amp;gt;delete from user where &lt;span class=&quot;nv&quot;&gt;Host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'127.0.0.1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
mysql&amp;gt;delete from user where &lt;span class=&quot;nv&quot;&gt;Host&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;'::1'&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 刷新使权限生效&lt;/span&gt;
mysql&amp;gt;flush privileges&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;c&quot;&gt;# 退出&lt;/span&gt;
mysql&amp;gt;quit&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;</content><author><name></name></author><summary type="html">首先准备mysql5.6相关的安装包</summary></entry><entry><title type="html">在CentOS安装JDK</title><link href="/centos/java/jdk/2020/03/05/jdk-centos-install.html" rel="alternate" type="text/html" title="在CentOS安装JDK" /><published>2020-03-05T03:26:38+00:00</published><updated>2020-03-05T03:26:38+00:00</updated><id>/centos/java/jdk/2020/03/05/jdk-centos-install</id><content type="html" xml:base="/centos/java/jdk/2020/03/05/jdk-centos-install.html">&lt;p&gt;在CentOS安装JDK&lt;/p&gt;

&lt;p&gt;1.解压JDK到/opt/module目录下，并修改文件的所有者和所有者组为root&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# &lt;span class=&quot;nb&quot;&gt;ls &lt;/span&gt;jdk&lt;span class=&quot;k&quot;&gt;*&lt;/span&gt;
jdk-8u144-linux-x64.tar.gz
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# &lt;span class=&quot;nb&quot;&gt;tar&lt;/span&gt; &lt;span class=&quot;nt&quot;&gt;-zxvf&lt;/span&gt; jdk-8u144-linux-x64.tar.gz &lt;span class=&quot;nt&quot;&gt;-C&lt;/span&gt; /opt/module/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;2.修改文件的所有者和所有者组为root&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# &lt;span class=&quot;nb&quot;&gt;cd&lt;/span&gt; /opt/module
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# &lt;span class=&quot;nb&quot;&gt;chown &lt;/span&gt;root:root &lt;span class=&quot;nt&quot;&gt;-R&lt;/span&gt; /opt/module/jdk1.8.0_144/
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;3.配置JDK环境变量&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c&quot;&gt;# 打开/etc/profile文件，在文件末尾添加JDK路径&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# vi /etc/profile

&lt;span class=&quot;c&quot;&gt;#JAVA_HOME&lt;/span&gt;
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;JAVA_HOME&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;/opt/module/jdk1.8.0_144
&lt;span class=&quot;nb&quot;&gt;export &lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;PATH&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$PATH&lt;/span&gt;:&lt;span class=&quot;nv&quot;&gt;$JAVA_HOME&lt;/span&gt;/bin

&lt;span class=&quot;c&quot;&gt;# 保存退出&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;4.让修改后的文件生效&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# &lt;span class=&quot;nb&quot;&gt;source&lt;/span&gt; /etc/profile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;5.测试JDK是否安装成功&lt;/p&gt;
&lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;o&quot;&gt;[&lt;/span&gt;root@hadoop102 software]# java &lt;span class=&quot;nt&quot;&gt;-version&lt;/span&gt;
java version &lt;span class=&quot;s2&quot;&gt;&quot;1.8.0_144&quot;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;6.确认java版本无误后完成&lt;/p&gt;</content><author><name></name></author><summary type="html">在CentOS安装JDK</summary></entry></feed>