大數據與人工智能入門到放棄(08 回顧篇 Hive多節點環境搭建)

記:

這是在加班時寫的

Hive多節點環境搭建

在上一篇文章中, 搭建單節點的hive時,我在master裝了單機的hive;node2中安裝了mysql,所以是node2進行hive的元數據管理服務;所以這次決定不去破壞hive的單節點;搭建多hive多節點時,我把機器node1作爲客戶端,node2作爲服務端。

(搭建過程可參考官網的多節點搭建配置https://cwiki.apache.org/confluence/display/Hive/AdminManual+Metastore+Administration#AdminManualMetastoreAdministration-RemoteMetastoreServer)

拷貝

直接在master這臺機器中將hive拷貝到node1和node2中,利用scp命令即可。我在node1和node2中創建了名爲app的文件,拷貝到此,之後就是修改環境變量,把hive加入環境變量,記得修改完後source一波。

修改配置文件

服務端(即node2):

1)修改hive-site.xml文件,爲了跟單節點的做區分,所以修改一下hdfs的存放路徑,和mysql存放的庫,修改後,內容如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<configuration>
        <property>
                <name>hive.metastore.warehouse.dir</name>
                <value>/user/hive/warehouse</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionURL</name>
                <value>jdbc:mysql://node2/hive?createDatabaseIfNotExist=true</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionDriverName</name>
                <value>com.mysql.jdbc.Driver</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionUserName</name>
                <value>root</value>
        </property>
        <property>
                <name>javax.jdo.option.ConnectionPassword</name>
                <value>root</value>
        </property>
</configuration>

客戶端(即是node1):

1)修改hive-site.xml文件,內容與服務端的差別還是比較大的,內容所以如下:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?><!--
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<configuration>
        <property>
                <name>hive.metastore.warehouse.dir</name>
                <value>/user/hive/warehouse</value>
        </property>
        <property>
                <name>hive.metastore.uris</name>
                <value> thrift://node2:9083</value>
        </property>
</configuration>

啓動

在服務端(即node2)中輸入hive --service metastore,啓動服務,這是一個阻塞式的窗口,輸入後會卡着不動的

在客戶端輸入hive,即可成功連入。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章