Spark安裝

請先安裝好Hadoop~~

下載Spark,解壓,換名字

cd /home/hadoop
wget http://apache.stu.edu.tw/spark/spark-2.4.1/spark-2.4.1-bin-hadoop2.7.tgz
tar -xvf spark-2.4.1-bin-hadoop2.7.tgz
mv spark-2.4.1-bin-hadoop2.7 spark

export HADOOP_CONF_DIR=/home/hadoop/hadoop/etc/hadoop
export SPARK_HOME=/home/hadoop/spark
export LD_LIBRARY_PATH=/home/hadoop/hadoop/lib/native:$LD_LIBRARY_PATH

(續…)

 

如何安裝Hadoop – 以Hadoop3.1.2為例

安裝好Fedora後(詳見這篇),接著要安裝Hadoop

首先,連到網頁下載Hadoop binary的網址

在fedora下指令:

wget http://apache.stu.edu.tw/hadoop/common/hadoop-3.1.2/hadoop-3.1.2.tar.gz

等待下載完成

並解壓縮:

tar vzxf hadoop-3.1.2.tar.gz

然後參考https://hadoop.apache.org/docs/r3.1.2/hadoop-project-dist/hadoop-common/SingleCluster.html

進行設定與操作

安裝JAVA

sudo dnf install java-11-openjdk

設定PATH

在下指令:

bin/hadoop

來確認可以使用

 

Hadoop Cluster 測試 – HDFS

在各Node上,必須先確認其IP與hostname

可下指令修改hostname

sudo hostnamectl set-hostname vm1

再利用指令尋找Node的IP

ip addr

如下圖已修改hostname為vm1,且得知IP為 192.168.56.102

 

將IP位置與命名加入各node的/etc/hosts檔案中

在各個node加入名為hadoop的使用者,並設定密碼

sudo -u root useradd hadoop

sudo -u root passwd hadoop

以hadoop使用者登入主要的node,並建立ssh key

ssh-keygen -t rsa (一路ENTER下去)

再把ssh key送到各個node上

ssh-copy-id hadoop@vm0

ssh-copy-id hadoop@vm1

用hadoop ssh登入vm0,並下載hadoop,解壓,與重新命名binary: http://ftp.tc.edu.tw/pub/Apache/hadoop/common/hadoop-3.1.2/hadoop-3.1.2.tar.gz

wget http://ftp.tc.edu.tw/pub/Apache/hadoop/common/hadoop-3.1.2/hadoop-3.1.2.tar.gz

tar -xzf hadoop-3.1.2.tar.gz

mv hadoop-3.1.2 hadoop

調整JAVA_HOME 至 /usr/lib/jvm/jre

vi hadoop/etc/hadoop/hadoop-env.sh

在各Node設定NameNode (~/hadoop/etc/hadoop/core-site.xml)

vi ~/hadoop/etc/hadoop/core-site.xml

同樣的,設定HDFS Path

設定 yarn

vi ~/hadoop/etc/hadoop/mapred-site.xml

vi ~/hadoop/etc/hadoop/yarn-site.xml

設定workers

vi ~/hadoop/etc/hadoop/workers

設定記憶體相關(DEFAULT值給8G RAM用的)

vi ~/hadoop/etc/hadoop/yarn-site.xml

vi ~/hadoop/etc/hadoop/mapred-site.xml

致此,設定完成

將相關的設定檔案COPY至每個Node

scp hadoop-*.tar.gz vm1:/home/hadoop

SSH連進Node

ssh vm1

解壓,重命名,然後離開

tar -xzf hadoop-3.1.2.tar.gz
mv hadoop-2.8.1 hadoop
exit

for node in node1 node2; do
scp ~/hadoop/etc/hadoop/* $node:/home/hadoop/hadoop/etc/hadoop/;
done

格式化HDFS (在vm0上) hadoop/bin/hdfs namenode -format

然後啟動HDFS

hadoop/sbin/start-dfs.sh

可連上網頁觀看 http://vm0:9870

此至,HDFS設定完成

如何在QGIS 鏈接 PostGIS?

Connect QGIS with PostGIS tutorial

Open QGIS.

Select PostgreSQL icon on the left hand side of QGIS.

A menu name “Add PostGIS table” will appear.

Select “New” to create a connection to PostGIS and enter the “Name”, “Host”, “Port” and “Database”.

After fill up all required data, please select “Connect” to connect PostGIS. Layers that available in database will be shown.

 

 

Select layers that you need.

Selected layers will be shown in QGIS.