normalian blog

Let's talk about Microsoft Azure, ASP.NET and Java!

Data copy from FTP server to SQL Data Lake using Azure Data Factory

You can achieve to setup data copy scenarios with Azure Data Factory from your FTP server to your SQL Data Lake by following this article. I believe this scenario is quite simple, but you can avoid to be confused by utilizing this article.

How to setup FTP server on Microsoft Azure

Create a Linux, CentOS7, virtual machine at first. After that, connect the VM with ssh, and run below commands.

[root@ftpsourcevm ~]# sudo su -
[root@ftpsourcevm ~]# yum -y update && yum -y install vsftpd

Please setup this vsftp server as passive mode with below sample. As far as I have confirmed, Azure Data Factory supports only passive mode ftp servers.

[root@ftpsourcevm ~]# vi /etc/vsftpd/vsftpd.conf

# When "listen" directive is enabled, vsftpd runs in standalone mode and
# listens on IPv4 sockets. This directive cannot be used in conjunction
# with the listen_ipv6 directive.
listen=YES
#
# This directive enables listening on IPv6 sockets. By default, listening
# on the IPv6 "any" address (::) will accept connections from both IPv6
# and IPv4 clients. It is not necessary to listen on *both* IPv4 and IPv6
# sockets. If you want that (perhaps because you want to listen on specific
# addresses) then you must run two copies of vsftpd with two configuration
# files.
# Make sure, that one of the listen options is commented !!
listen_ipv6=NO

pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES

pasv_enable=YES
pasv_addr_resolve=YES
pasv_min_port=60001 ( you need add this port to this VM NSG setup
pasv_max_port=60010 ( you need add this port to this VM NSG setup
pasv_address=(update global ip address of your ftp server vm e.g. 52.1xx.47.xx)

Run below commands to reflect your config change.

[root@ftpsourcevm ~]# systemctl restart vsftpd
[root@ftpsourcevm ~]# systemctl enable vsftpd

Finally, you need to add allow port configuration between pasv_min_port and pasv_max_port into NSG. Please refer below image.
f:id:waritohutsu:20170829212808p:plain

How to setup Azure Data Lake for Azure Data Factory

Just create your Azure Data Lake instance, and add a directory for Azure Data Factory like below.
f:id:waritohutsu:20170829212827p:plain

How to setup Azure Data Factory to copy from your FTP server to your Azure Data Lake

After creating your Azure Data Factory instance, choose "Copy data (PREVIEW)" to setup this.
f:id:waritohutsu:20170829214430p:plain

Change this schedule period if it's needed.
f:id:waritohutsu:20170829212934p:plain

Choose "FTP" as "CONNECT TO A DATA SOURCE", but you can also choose other data sources such like S3 and other cloud data sources.
f:id:waritohutsu:20170829212957p:plain

Change to "Disable SSL" at "Secure Transmission" in this sample, and please setup SSL when you will deploy this pipeline in your production environments. Input a global in address of your ftp server and credential account info of your ftp server. You will get a connection error if you setup active mode FTP servers.
f:id:waritohutsu:20170829213020p:plain

Choose a folder for data source of Azure Data Factory. In this sample, we setup as binary copy mode. But you can setup other data copy types such like cvs and others.
f:id:waritohutsu:20170829213121p:plain

Choose "Azure Data Lake Store" as "CONNECT TO A DATA STORE" in this article.
f:id:waritohutsu:20170829213141p:plain

Choose your Azure Data Lake Store instance for storing data like below.
f:id:waritohutsu:20170829213202p:plain

Choose a folder for data storing destination.
f:id:waritohutsu:20170829213224p:plain

Confirm your setup info, and submit to deploy this pipeline.
f:id:waritohutsu:20170829213246p:plain

Confirm your setup

You can view your data copy pipeline in your Azure Data Factory like below. Azure Data Factory will copy your data on your FTP server into your Azure Data Lake following your schedule.
f:id:waritohutsu:20170829215545p:plain

Get started with Apache Storm on HDInsight for your jar files

HDInsight provides you to create Apache Storm clusters easily. Please read reference articles in this post if you don't know overview of Apache Storm.

Create Storm Cluster on HDInsight

Follow https://docs.microsoft.com/en-us/azure/hdinsight/hdinsight-apache-storm-tutorial-get-started-linux article until "Create a Storm cluster" section. It takes about 15 minutes to create your Storm cluster, and pick up below info to connect your Storm cluster.

  • SSH login URL: engiyoistorm02-ssh.azurehdinsight.net
  • Dashboard URL: https://"your cluster name".azurehdinsight.net/
  • StormUI URL: https://"your cluster name".azurehdinsight.net/stormui/index.html

Deploy your jar files into your Storm cluster

Create your jar file including Topology class to deploy into your Storm Cluster. Please refer below example if you don't have such Java projects.
https://github.com/apache/storm/tree/master/examples/storm-starter

After making your jar file, try to connect to your cluster via ssh. Here is a sample connecting to your cluster using WinSCP.
f:id:waritohutsu:20170724143720p:plain
Transfer your jar file from your computer into your cluster. Now, you can run your jar file into your cluster.

Connect to you cluster via ssh. Here is a sample connecting to your cluster using putty.
f:id:waritohutsu:20170724143739p:plain
Follow below commands to run your jar file. Specify second argument as topology class and third argument as topology name.

sshuser@xxxxxxxx:~$ storm jar /home/sshuser/hellostorm-0.0.1-SNAPSHOT.jar com.mydomain.hellostorm.HelloTopology hello-topology
sshuser@xxxxxxxx:~$ storm list
6244 [main] INFO  o.a.s.u.NimbusClient - Found leader nimbus : 10.0.0.10:6627
Topology_name        Status     Num_tasks  Num_workers  Uptime_secs
-------------------------------------------------------------------
hello-topology       ACTIVE     8          3            8758

Monitor your application

Open https://"your cluster name".azurehdinsight.net/stormui/index.html via your browser. You can find you topology in Storm UI.
f:id:waritohutsu:20170724143827p:plain

Azure Container Service overview of Kubernetes for Java applications

Here is a sample architecture ACS Kubernetes. People sometimes confuse components of Container Services, because there are so many components such like Java, Docker Windows, private registry, cluster and others. This architecture helps such people to understand overview of ACS Kubernetes.
f:id:waritohutsu:20170713014405p:plain

Steps to run your Java applications using ACS Kubernetes

Follow below steps to run your Java applications.

  1. Build your Java applications
  2. Create Docker images
  3. Push your Docker images into Private Registry on Azure
  4. Get Kubernetes credentials
  5. Deploy your docker images using “kubectl” command

How to install kubectl into your client machine on "Bash on Ubuntu on Windows"

Run below commands.

normalian@DESKTOP-QJCCAGL:~$ echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
[sudo] password for normalian:
deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main
normalian@DESKTOP-QJCCAGL:~$ sudo apt-key adv --keyserver packages.microsoft.com --recv-keys 417A0893
normalian@DESKTOP-QJCCAGL:~$ sudo apt-get install apt-transport-https
normalian@DESKTOP-QJCCAGL:~$ sudo apt-get update && sudo apt-get install azure-cliExecuting: gpg --ignore-time-conflict --no-options --no-default-keyring --homedir /tmp/tmp.5tm3Sb994i --no-auto-check-trustdb --trust-model always --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyserver packages.microsoft.com --recv-keys 417A0893

...


normalian@DESKTOP-QJCCAGL:~$ az

Welcome to Azure CLI!
---------------------
Use `az -h` to see available commands or go to https://aka.ms/cli.

...


normalian@DESKTOP-QJCCAGL:~$ az login
To sign in, use a web browser to open the page https://aka.ms/devicelogin and enter the code XXXXXXXXX to authenticate.

...


normalian@DESKTOP-QJCCAGL:~$ az acs kubernetes install-cli
Downloading client to /usr/local/bin/kubectl from https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/linux/amd64/kubectl
Connection error while attempting to download client ([Errno 13] Permission denied: '/usr/local/bin/kubectl')
normalian@DESKTOP-QJCCAGL:~$ sudo az acs kubernetes install-cli
Downloading client to /usr/local/bin/kubectl from https://storage.googleapis.com/kubernetes-release/release/v1.7.0/bin/linux/amd64/kubectl
normalian@DESKTOP-QJCCAGL:~$ az acs kubernetes get-credentials --resource-group=<resource group name> --name=<cluster name>  --ssh-key-file=<ssh key file>
normalian@DESKTOP-QJCCAGL:~$ kubectl get pods
NAME                             READY     STATUS    RESTARTS   AGE

How to update your Java application in ACS Kubernetes

This post is continuation of . Please read the post before this one if you haven't read it. I will show you how to update your Java application in ACS kubernetes in this post.

Update your Java application - Run this section at your Windows Docker Client

At first, update your Java application. Modify your "index.jsp" file like below.

<html>
 <head>
  <title>Docker deployed apps !!update!!</title>
 </head>
 <body>
  <h2>Hello World! on Docker !!update!!</h2>
 </body>
</html>

And run "mvn package" command in the Java project folder. After create new war file in "helloworld/target/helloworld.war", create new Docker image and launch the application by running below commands.

helloworld>docker build --no-chache -t normalian/wildfly-helloworld .

helloworld>docker images
REPOSITORY                                                  TAG                 IMAGE ID            CREATED             SIZE
normalian/wildfly-helloworld                                latest              xxxx2536f9e2        11 seconds ago      584MB
xxxxxxxxxxxxxxxxx.azurecr.io/normalian/wildfly-helloworld   latest              xxxx171bcbcf        40 minutes ago      584MB
jboss/wildfly                                               latest              xxxx152f84f9        5 days ago          584MB

helloworld>docker run -it --rm -p 8080:8080 normalian/wildfly-helloworld

After above, access http://localhost:8080/helloworld. Stop the application if you can check your update.

Push your Docker image into your private repository on Azure by running below commands.

helloworld>docker tag normalian/wildfly-helloworld xxxxxxxxxxxxxxxxx.azurecr.io/normalian/wildfly-helloworld

helloworld>docker push xxxxxxxxxxxxxxxxx.azurecr.io/normalian/wildfly-helloworld
The push refers to a repository [xxxxxxxxxxxxxxxxx.azurecr.io/normalian/wildfly-helloworld]
xxxx02afd48c: Pushed
xxxx5bc19b9a: Pushed
xxxx11518954: Layer already exists
xxxx13dfbb96: Layer already exists
xxxx519728f4: Layer already exists
xxxx7c284ded: Layer already exists
xxxx8d9413e4: Layer already exists
latest: digest: sha256:xxxxxxxxxxxxxxxxx1522ee990cd74155116034b15ab51198ecc9a7e246a926 size: 1789

Update your Java application - Run this section at Kubernetes master node

Connect Kubernetes master node by SSH(e.x, Bash on Ubuntu on Windows). Run below commands.

azureuser@k8s-master-3AEAFCA1-0:~$ kubectl set image deployment my-java-app01 my-java-app01=xxxxxxxxxxxxxxxxx.azurecr.io/normalian/wildfly-helloworld
deployment "my-java-app01" image updated

azureuser@k8s-master-3AEAFCA1-0:~$ kubectl get pod
NAME                             READY     STATUS              RESTARTS   AGE
my-java-app01-2735613267-h0gsp   0/1       ContainerCreating   0          5s
my-java-app01-979249178-1k5c9    1/1       Running             0          35m

azureuser@k8s-master-3AEAFCA1-0:~$ kubectl get services
NAME            CLUSTER-IP    EXTERNAL-IP    PORT(S)          AGE
kubernetes      10.0.0.1      <none>         443/TCP          3d
my-java-app01   10.0.174.35   23.99.81.xxx   8080:32298/TCP   1h

After above, access http://23.99.81.xxx:8080/helloworld via browser. You can check your updated Java application.

Please note "kubectl set image deployment my-java-app01 my-java-app01=xxxxxxxxxxxxxxxxx.azurecr.io/normalian/wildfly-helloworld:latest" won't work when you use "latest" tag for your Docker images.

What should you do when you got "Error response from daemon ... [::1]:53: read udp [::1]:33230->[::1]:53: read: connection refused"?

When I tried to run "docker login" command, I got below error.

Error response from daemon: Get https://xxxxxxxx.azurecr.io/v2/: dial tcp: lookup xxxxxxxx.azurecr.io on [::1]:53: read udp [::1]:33230->[::1]:53: read: connection refused

I'm not sure what's this, but I found this article.
github.com

Following the article, I re-install Docker Windows. I finally succeed to login remote Docker repository.

C:\Users\normalian>docker login xxxxxxxx.azurecr.io
Username (xxxxxxxx):
Password:
Login Succeeded

ロサンゼルス生活日誌 ~その2 ロサンゼルス国際空港はどんなところ?~

(現地時間的に)おはようございます。今回は日本の方が最初に到着するであろうロサンゼルス国際空港(通称 LAX)について紹介したいと思います。当然ですが、アメリカ合衆国における西の玄関ともいわれる空港であるので非常に大きいです。
f:id:waritohutsu:20170710023658p:plain

乗り換えて国内移動をさらに行う場合はさておき、日本の方なら国際線で来ると思いますので、原則以下の Tom Bradley International Terminal という場所に到着するはずです。
f:id:waritohutsu:20170710023732p:plain

今回はこちらに到着後、何をどうしたものか的なところを紹介したいと思います。

空港内での WiFi はどうしよう?

無料の WiFi が提供されています。以下の投稿でも記載がありますが「_LAX Free WiFi」という SSID が利用可能です。


こちらの英語記事にステップが記載されていますが、SSID を指定して接続後、ブラウザで「広告を見る代わりに45分接続するよ」という旨の英語ボタンを押せば利用可能になります。
http://yourhelloworld.com/wifi-details-for-los-angeles-international-airport-lax/

45分以上の利用は再度ブラウザ経由でログインする必要がありますが、何回ログインするかの制限はないので、相手が待ち合わせに遅れた場合等で連絡する際に困ることはないと思います。

出口周辺での待ち合わせスポットは?

ロサンゼルスに到着後、原則 1F に到着します。入国審査・荷物受け取り後は以下の場所に到着するので、ストリートビュー等で風景を確認してみるとわかりやすいです。
f:id:waritohutsu:20170710023757p:plain

ストリートビューの風景は以下になりますが、出口近辺に Coffee Beans があるので時間があるなら一息ついてみるのも良いと思います。クレジットカード(日本のものでもOK)を持っていれば一杯数ドルでコーヒーが飲めます。
更に、この場所でも「_LAX Free WiFi」は使えるはずなので、こちらを待ち合わせ場所にするのも悪くないと思います。
f:id:waritohutsu:20170710023817p:plain

Uber に乗る場合はどうしよう?

慣れない場所に来た以上、いきなりレンタカーよりも Uber を使う方が多いと思います。この際に要注意なのが、LAX 周辺では任意の場所に Uber 配車を指定することが原則できません(おそらく混雑しすぎているのが原因だと思いますが、強引にしても Uber のあんちゃんがキャンセルしてくること多しです…)。こちらは以下の Uber 記事にも載っています。
https://www.uber.com/drive/los-angeles/airports/los-angeles-international-airport/

上記の英語記事のうち「Step by step pickups at LAX」の箇所に画像がありますが、以下の B と C どちらかの箇所に配車をお願いするケースが多いと思います。
f:id:waritohutsu:20170710023847p:plain

配車を実施後に注意が「到着は1Fだが、Uber が配車されるのは2F」という点です。移動時には気を付けてください。

レンタカーをいきなり利用する場合は?

私は AVIS レンタカーしか利用したことがありませんが、空港から離れた場所にあります。そのため、バスに乗って移動するので注意してください。5分~10分毎くらいでバスが周遊しているので、ちょっと待てばすぐきます。空港入り口を出て数百メートル程度の距離にあります。

ロサンゼルス生活日誌 ~その1 ロサンゼルスはどんな町?~

こんにちは。先月からロサンゼルス勤務となったので、色々と出来事なり今後米国(特にロサンゼルス)に来る方へ参考になる情報を色々と書いていきたいと思います。2回の出張を経ておおよそひと月の滞在になるものの、分からないがゆえに困ったことや戸惑ったことも多く、多くの日本人の方も同様に困るものが多いなと思ったといいます。ロサンゼルスに情報は偏りますが、せっかくなのでこちらでノウハウをまとめていきます。今後、米国移住を考えている方に少しでも役にたてば幸いです。

ロサンゼルスってどこにあるの?

米国の南西側にあるカリフォルニア州に位置しますが、Wikipedia の項目 によればニューヨークに次ぐ全米有数の世界都市とのこと。
以下は Bing Maps のスクリーンショットですが、メキシコの国境にかなり近いので都市部にはメキシカンの方々が多いです。メキシカンの方も多いですが、白人の方、黒人の方はもちろんアジア人も多いので、ふらふら歩いてると色んな方を見かけます(ロサンゼルスは地区により人種比率が大きく変動します)。
f:id:waritohutsu:20170709112143p:plain
地図上から見るとサンフランシスコが近く見えますが、車で移動すると5時間位はかかるとのことなので気軽な旅はできません(汗

ロサンゼルスの交通事情

ロサンゼルスにも電車やバスはありますが、車を購入できる程度の所得がある人は車を購入して車で移動する文化です。そのため、以下の様に日中の道路は常に込みまくりです。

上記の投稿で記載がある「フリーウェイ」は日本でいう「首都高速」のようなものですが、首都高速と違って誰でも無料で利用できるので常に混んでおりいてこんな状況です。
f:id:waritohutsu:20170709113259p:plain
ロサンゼルス在住歴が長い知人は出勤時間をずらしたりフリーウェイを利用しない方法で渋滞を回避していますが、同僚曰くで「渋滞がなければ1時間の道が3時間かかったよ」の発言もあったりするのでかなり深刻な社会問題の様です。

ロサンゼルスの天気

常に晴れており天気は最高です。体感ベースでは「8割快晴、2割が晴れ」位の割合で、ひと月くらいは滞在していますが一度も雨が降ったことがありません。
f:id:waritohutsu:20170415133009j:plain
日差しが強力なので女性に限らずUVカットは必須だと思われますが、かなり乾燥しているので蒸し暑さがなく、日陰に入るとかなり快適です。もっとも生活する上では乾燥しすぎるきらいはあるので、快適に過ごすためには加湿器はかなり必須だと思います。

まずはで軽く解説させて頂きましたが、引き続きいろんな情報を載せていきたいと思います。