2016年2月25日 星期四

[hadoop] hadoop client failed on connection exception: java.net.ConnectException: Connection refused 解決方法


在 hadoop client 執行 hdfs 的指令 發生了下面的錯誤


[root@vagrant-centos652 conf]# hadoop fs -ls /
ls: Call From vagrant-centos652.vagrantup.com/127.0.0.1 to vagrant-centos65.vagrantup.com:8020 failed on connection exception: java.net.ConnectException: Connection refused; For more details see:  http://wiki.apache.org/hadoop/ConnectionRefused



一般來說就是 client 並沒有辦法連結到 namenode ,
  • 先檢查一下 該來電腦 ping 的到 master 嗎?
  • telnet master-host port  
  • telnet  vagrant-centos65.vagrantup.com 8020
vagrant-centos65.vagrantup.com 是我的master 的hostname 已經寫在 /etc/hosts內了。

若是發現 telnet  Connection refused , 回到 namenode node 檢查 ip 是 bind 在哪個 ip 上

[vagrant@vagrant-centos65 ~]$ netstat -anpt  | grep "8020"
(No info could be read for "-p": geteuid()=500 but you should be root.)
tcp        0      0 10.1.193.179:8020           0.0.0.0:*                   LISTEN      -                   
tcp        0      0 10.1.193.179:8020           10.1.193.149:56089          ESTABLISHED -                   
tcp        0      0 10.1.193.179:54539          10.1.193.179:8020           TIME_WAIT   -      

如果  bind 127.0.0.1  可以檢查一下 /etc/hosts內的設定
[vagrant@vagrant-centos65 ~]$ cat /etc/hosts
127.0.0.1   localhost
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
10.1.193.149  vagrant-centos652.vagrantup.com
10.1.193.179  vagrant-centos65.vagrantup.com

===
查看 hostname 是不是跟 127.0.0.1 寫在一起,有的單機的環境教學會建議寫在 localhost 同一行


其他的 error message 還可能會發生

16/02/24 15:12:35 WARN hdfs.DFSClient: DataStreamer Exception
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /tmp/x1._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and no node(s) are excluded in this operation.


[hdfs@vagrant-centos65 tmp]$ hdfs dfs -put /tmp/x1 /tmp
16/02/24 15:12:35 WARN hdfs.DFSClient: DataStreamer Exception
org.apache.hadoop.ipc.RemoteException(java.io.IOException): File /tmp/x1._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and no node(s) are excluded in this operation.
at org.apache.hadoop.hdfs.server.blockmanagement.BlockManager.chooseTarget(BlockManager.java:1384)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getAdditionalBlock(FSNamesystem.java:2503)
at org.apache.hadoop.hdfs.server.namenode.NameNodeRpcServer.addBlock(NameNodeRpcServer.java:555)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolServerSideTranslatorPB.addBlock(ClientNamenodeProtocolServerSideTranslatorPB.java:387)
at org.apache.hadoop.hdfs.protocol.proto.ClientNamenodeProtocolProtos$ClientNamenodeProtocol$2.callBlockingMethod(ClientNamenodeProtocolProtos.java:59582)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Server$ProtoBufRpcInvoker.call(ProtobufRpcEngine.java:585)
at org.apache.hadoop.ipc.RPC$Server.call(RPC.java:928)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2053)
at org.apache.hadoop.ipc.Server$Handler$1.run(Server.java:2049)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:396)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1491)
at org.apache.hadoop.ipc.Server$Handler.run(Server.java:2047)

at org.apache.hadoop.ipc.Client.call(Client.java:1347)
at org.apache.hadoop.ipc.Client.call(Client.java:1300)
at org.apache.hadoop.ipc.ProtobufRpcEngine$Invoker.invoke(ProtobufRpcEngine.java:206)
at $Proxy9.addBlock(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invokeMethod(RetryInvocationHandler.java:186)
at org.apache.hadoop.io.retry.RetryInvocationHandler.invoke(RetryInvocationHandler.java:102)
at $Proxy9.addBlock(Unknown Source)
at org.apache.hadoop.hdfs.protocolPB.ClientNamenodeProtocolTranslatorPB.addBlock(ClientNamenodeProtocolTranslatorPB.java:330)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.locateFollowingBlock(DFSOutputStream.java:1231)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.nextBlockOutputStream(DFSOutputStream.java:1078)
at org.apache.hadoop.hdfs.DFSOutputStream$DataStreamer.run(DFSOutputStream.java:514)
put: File /tmp/x1._COPYING_ could only be replicated to 0 nodes instead of minReplication (=1).  There are 1 datanode(s) running and no node(s) are excluded in this operation.



[hadoop] hadoop namenode format 格式化 hdfs / 重置 hdfs 空間


[hadoop] hadoop namenode format 格式化 hdfs /  重置 hdfs 空間  


安裝 hadoop hdfs 重要的一步就是 namenode format ,如果檔案損毀想要放棄 測試用的cluster 或是重置所有的資料,也可以使用 hadoop namenode format

"The first step to starting up your Hadoop installation is formatting the Hadoop filesystem, which is implemented on top of the local filesystems of your cluster. You need to do this the first time you set up a Hadoop installation. Do not format a running Hadoop filesystem, this will cause all your data to be erased."

先切換 成 hdfs user
一般來說是用 hdfs 去建立相關的資料夾

su hdfs

% $HADOOP_INSTALL/hadoop/bin/hadoop namenode -format


GettingStartedWithHadoop - Hadoop Wiki
https://wiki.apache.org/hadoop/GettingStartedWithHadoop#Formatting_the_Namenode

2016年2月23日 星期二

[hadoop] hadoop namenode 怎麼離開 safemode Name node is in safe mode.


[hadoop] hadoop namenode 怎麼離開 safemode Name node is in safe mode. 


操作 HDFS 時,可能會遇到 Name node is in safe mode. 這種情況。

如果只是在開發測試環境,可以直接嘗試下面的作法離開 safemode。單機情況下,可以直接離開safemode。
(當 hdfs file 都符合 replica 的條件,才會脫離 safemode 。)

Safemode

During start up the NameNode loads the file system state from the fsimage and the edits log file. It then waits for DataNodes to report their blocks so that it does not prematurely start replicating the blocks though enough replicas already exist in the cluster. During this time NameNode stays in Safemode. Safemode for the NameNode is essentially a read-only mode for the HDFS cluster, where it does not allow any modifications to file system or blocks. Normally the NameNode leaves Safemode automatically after the DataNodes have reported that most file system blocks are available. If required, HDFS could be placed in Safemode explicitly using bin/hdfs dfsadmin -safemode command. NameNode front page shows whether Safemode is on or off. A more detailed description and configuration is maintained as JavaDoc for setSafeMode().



[root@vagrant-centos65 conf]#  sudo -u hdfs hadoop fs -mkdir -p /test
mkdir: Cannot create directory /test. Name node is in safe mode.

[root@vagrant-centos65 conf]# sudo -u hdfs hdfs dfsadmin -safemode leave

Safe mode is OFF

Google 建立的帳戶數量已達上限 同一支電話註冊上限 gmail


當你使用同一個電話驗證的時候,如果出現了這個情況。
可能是已經達到同一個電話號碼有25個帳號,或是連續註冊的情況發生了。

「建立的帳戶數量已達上限」


如果您看到「以這個電話號碼建立的帳戶數量已達上限」錯誤訊息,請改用其他號碼。為了保護使用者並防止服務遭到濫用,我們對於每個電話號碼能夠建立的帳戶數量設有限制。

"Maximum number of accounts reached"


If you see the error message, "This phone number has already created the maximum number of accounts," you'll have to use a different number. In an effort to protect our users from abuse, we limit the number of accounts each phone number can create.

2016年2月21日 星期日

[startup] 關於 Nextdoor 國外的 LBS social network 服務


Nextdoor: Join the free private social network for your neighborhood
https://nextdoor.com/

國外LBS的服務其實好像還是滿多的,而且都很蓬勃發展。
台灣人因為上班工作時間太長,所以根本沒有其他這種需求。

導致台灣的創業環境裏面這種服務好像不太多。
頂多就是追求美食之類的小確幸服務。

但是外國人就會有很多這種跟鄰近地區的服務與需求。


2016年2月20日 星期六

關於學習 2016 之一 關於 學習Flash


關於學習的模式,這是一個很多人一直在探討的的議題。
當心思沈靜的時候,你才會注意到自己的思考,也就是說你才能反觀自己,了解自己到底再做怎樣的一個思考,怎麼樣使用一些習以為常的脈絡。

不過,紛亂與無心思的投入,確實會讓自己忘了思想與模式。

回想起最初的學習,都是投入一段時間,反覆的練習而獲得成果的。

我記得我學習Flash 的時候,大概在國一國二,幾乎就是每天如果是4點放學,冬天的話應該4點十五分就會到家。吃完點心,就趕快開始照著書本上的範例一個一個的練習,練習到晚餐6點的時候。

我相信要是沒有當時投入時間的試誤,不會有現在對電腦與系統的敏銳度。

曾幾何時,我也差點忘了這是必然的投入。

如果沒有投入,怎麼會有像是反射動作的成果呢。


2016年2月19日 星期五

[mac] 使用 Monolingual 節省 mac 空間 移除沒用到的多國語系檔


使用 SSD 較小的 Mac air 常常發現自己的檔案沒有使用到這麼多空間,有些是軟體安裝所佔用的。軟體裡面還有很多國語系檔。
Monolingual 就是一套幫你清理那些用不到的語系檔的軟體。




Monolingual

Monolingual is a program for removing unnecessary language resources from OS X, in order to reclaim several hundred megabytes of disk space. It requires a 64-bit capable Intel-based Mac and at least OS X 10.11 (El Capitan).
I don't know about you, but I use my computer in only one (human) language — English. And I'm willing to bet that you do too, albeit perhaps not English. So why do you have a bunch of localization files for the operating system filling up your hard drive? Enter Monolingual — a handy utility for reclaiming your space for more useful things… like international mp3 files, email or whatever you like.
Version 1.6.7 is the last version for OS X 10.10 (Yosemite). Version 1.5.10 is the last version for Mac OS X 10.7 (Lion), OS X 10.8 (Mountain Lion) and OS X 10.9 (Mavericks). Version 1.4.5 is the last version for Mac OS X 10.6 (Snow Leopard) which also includes PowerPC support. Version 1.3.9 is the last version for Mac OS X 10.4 (Tiger).


Monolingual
https://ingmarstein.github.io/Monolingual/

2016年2月18日 星期四

[docker] 使用 socks5 當做 docker 的 http proxy


[docker] 使用 socks5 當做 docker 的 http proxy

環境 Ubuntu Linux
  • 先建好要使用的 socks5

    ssh -D 8118 user@server 
  • 安裝  tsocks - transparent network access through a SOCKS 4 or 5 proxy

    sudo apt-get install tsocks
  • 設定 docker 使用 http proxy

    vim /etc/systemd/system/docker.service.d/http-proxy.conf

    加入

    [Service]
    Environment="HTTP_PROXY=http://127.0.0.1:8118/"
  • 使用 tsocks 啟動 docker 
tsocks /usr/bin/docker -d

看到 docker的log就知道 已經使用設定好的socks5 當做 http proxy server了

2016年1月29日 星期五

Parse.com ObjectId 產生方法 unique id


Parse.com 將於 2017 .01.28 結束服務,伴隨著提供了一些 Migration 方案,跟自家 Parse Server open source
ParsePlatform/parse-server: Parse-compatible API server module for Node/Express
https://github.com/ParsePlatform/parse-server

Parse.com ObjectId  unique id 產生方法

從 Parse Server 中可以看到 Parse Server 裡面產生 ObjectId 的方式,
是使用 random char 的方式產生長度 10 的 objectId 。

// Returns a string that's usable as an object id.
// Probably unique. Good enough? Probably!
function newObjectId() {
  var chars = ('ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
               'abcdefghijklmnopqrstuvwxyz' +
               '0123456789');
  var objectId = '';
  for (var i = 0; i < 10; ++i) {
    objectId += chars[Math.floor(Math.random() * chars.length)];
  }
  return objectId;
}
parse-server/RestWrite.js at master · ParsePlatform/parse-server
https://github.com/ParsePlatform/parse-server/blob/master/RestWrite.js#L707


Moving On
http://blog.parse.com/announcements/moving-on/
Introducing Parse Server and the Database Migration Tool
http://blog.parse.com/announcements/introducing-parse-server-and-the-database-migration-tool/

相關連結

[tech_note] hackpad 的 unique padid 產生方式 / etherpad 與 appjet - peicheng note
http://peichengnote.blogspot.com/2015/10/technote-hackpad-unique-padid-etherpad.html

Parse.com 將在 January 28, 2017 結束服務

Mark 結束育嬰假以後,帶回了這個消息
Parse.com 將在 January 28, 2017 結束服務

今天一看片地哀號,不少大型的app 都是直接產用 Parse.com 這樣的劇變實在讓人很難接受,甚至還沒有付費的方案可以選擇 BaaS (Back end as a Service) 。

或許是收集的移動資料已經足夠,這個BaaS 就算收費也是一個滿大的支出。

所以,他們把結束的時間拉到 2017 ,甚至是 open source了 parse server ,希望使用者可以自己 hosts 。

Parse Server 目前提供 Backend 介接的 mongodb interface ,
目前還沒看到,Parse.com 自家使用的 MongoDB + RocksDB at Parse
MongoDB + RocksDB at Parse
http://blog.parse.com/announcements/mongodb-rocksdb-parse/
大型的service 可能真的需要一段時間來想想下一步的架構了。


不過,少了 BaaS 平台,要自己 host 我想不是大家選擇使用 Parse 所想要的。
(就是因為不想 host backend 才使用 parse.com 阿)

既然這已成為事實,就期待下一個後繼者吧。
(Google 也有提供 FireBase的服務)


We have a difficult announcement to make. Beginning today we’re winding down the Parse service, and Parse will be fully retired after a year-long period ending on January 28, 2017. We’re proud that we’ve been able to help so many of you build great mobile apps, but we need to focus our resources elsewhere.
We understand that this won’t be an easy transition, and we’re working hard to make this process as easy as possible. We are committed to maintaining the backend service during the sunset period, and are providing several tools to help migrate applications to other services.
First, we’re releasing a database migration tool that lets you migrate data from your Parse app to any MongoDB database. During this migration, the Parse API will continue to operate as usual based on your new database, so this can happen without downtime. Second, we’re releasing the open source Parse Server, which lets you run most of the Parse API from your own Node.js server. Once you have your data in your own database, Parse Server lets you keep your application running without major changes in the client-side code. For more details, check out our migration guide here.
We know that many of you have come to rely on Parse, and we are striving to make this transition as straightforward as possible. We enjoyed working with each of you, and we have deep admiration for the things you’ve built. Thank you for using Parse.
Moving On
http://blog.parse.com/announcements/moving-on/

ps.
 - parse.com 最迷人的無外乎他的 Free Plan 居然提供了 20G的 database storage 。
基本上,要是超過這個方案,你大概都已經發了。

2016年1月27日 星期三

Tony Robbins 12 Keys to An Extraordinary Life 要點節錄

Tony Robbins: 12 Keys to An Extraordinary Life 


1. balance your body
2. help others
3. master your time : feed your mind and put your N.E.T (No extra time ) to use
4. Always know your purpose
5. build a money machine
6. discover true wealth
7. optimize and maximize
8. align with your true nature
9. adopt empowering beliefs
10. live in the present and create a beautiful state
11. keep the passion alive
12. put your partner first

從投影片中把標題節錄出來
可以從下面連結得到更多資訊

Tony Robbins: 12 Keys to An Extraordinary Life
https://www.tonyrobbins.com/extraordinary-life/
12 Keys to an Extraordinary Life | Tony Robbins | LinkedIn
https://www.linkedin.com/pulse/12-keys-extraordinary-life-tony-robbins?trk=hp-feed-article-title-publish

2016年1月19日 星期二

[python] convert an integer to a binary bit 把 數值轉乘 binary 的 bit 表示


[python] convert an integer to a binary bit 把 數值轉乘 binary 的 bit 表示

想要把integer 表示成 bit 的形式,可以使用 format 。

print "{0:b}".format(i)

7.1. string — Common string operations — Python 2.7.11 documentation
https://docs.python.org/2/library/string.html#formatspec

記於 2016 1月18日 後



謝謝各位的祝福,邁向下一個偉大航道了 ~~~


2016年1月15日 星期五

facebook apps 發佈內容只有管理者可以看見 解決方法 make this app and all its live features available to the general public


facebook apps publish photo to timeline not work

使用 facebook apps 使用 page token 來管理 fans page, 發現使用 apps 發的post 其他人都是不可見的。

這時候要在

https;//developers.facebook.com/apps/

Settings 的地方先填入 email , Status and Review 的地方才可以更改
從






Do you want to make this app and all its live features available to the general public?

從 No 改為 Yes ,看到 apps name的旁邊亮起綠燈,之後這個 apps 發佈的內容就可以被其他使用者看到了。




如果從 Yes 調回 No 會看到

Switch to development mode? 

Are you sure you want to put your app in development mode? It will no longer be publicly available.



ps.
之前沒有使用一般使用者view去看一下管理的 fans page 結果發現原來發文只有我才看的到。

2016年1月14日 星期四

查詢特定網址的 facebook like 分享與按贊次數



facebook deprecated 的 rest api  裡面有個 links. getStats 的 method 目前還可以使用。

http://api.facebook.com/restserver.php?method=links.getStats&urls=http://peichengnote.blogspot.com&format=json

沒有加上 format 的話,預設是回傳 xml 格式


以下是ptt.cc 的摘要


Normalized URL
http://www.ptt.cc/
The normalized URL for the page being shared.
Share count
3201
The number of times users have shared the page on Facebook.
Like count
7514
The number of times Facebook users have "Liked" the page, or liked any comments or re-shares of this page.
Comment count
1418
The number of comments users have made on the shared story.
Total count
12133
The total number of times the URL has been shared, liked, or commented on.

2016年1月12日 星期二

控制我們人的三個決定 Tony Robbins


Tony Robbins 6 hrs ·
 Three decisions that we all control each moment of our lives:
what we focus on,
what things mean,
and what to do in spite of the challenges that may appear to limit us.


Tony Robbins 說的 控制我們人生活的每個時刻的三個決定因素,

  1. 我們專注的是什麼
  2. 這代表著什麼意義
  3. 要如何去做

2016年1月9日 星期六

[python] SpeechRecognition Reason: image not found 解決方案


使用 python  SpeechRecognition 出現  Reason: image not found


dyld: Library not loaded: /usr/local/Cellar/flac/1.3.1/lib/libFLAC.8.dylib
  Referenced from: /usr/local/lib/python2.7/site-packages/speech_recognition/flac-mac
  Reason: image not found

少裝了 flac ,使用 brew 安裝

$ brew install flac
==> Downloading https://homebrew.bintray.com/bottles/flac-1.3.1.el_capitan.bottle.tar.gz
######################################################################## 100.0%
==> Pouring flac-1.3.1.el_capitan.bottle.tar.gz

🍺  /usr/local/Cellar/flac/1.3.1: 50 files, 2.3M

SpeechRecognition 3.1.3 : Python Package Index
https://pypi.python.org/pypi/SpeechRecognition/

2016年1月7日 星期四

[linux] Ubuntu Linux 連 windows 網路芳鄰

[linux] Ubuntu Linux 連 windows 網路芳鄰

在桌面環境下連網路芳鄰其實滿容易的

在這裡使用了是LXDE , 開啟一個資料夾 在網址列打上 smb://host/dir

填入你的目的server跟資料夾,就會跳出輸入 帳號 domain 密碼的視窗。

接著就像,操作一般資料夾一樣

子夜未眠


昨日中午與您談完
昨晚子夜未眠
腦海裡面回溯的是在一起建構的時光跟記憶,還有許多未完成的事情
很多約定如何如何,或是下次再去
更多是,一起經歷的那個鮮明的當下。

感傷
不知道那是不是轉化昇華成另外一種情感

更是一種割捨
一種一個人再次獨自面對的情感,很赤裸裸的攤開在陽光下

一幕幕的回顧,是我,是你,是我們,一個很美好的記憶。

總是在這個時候,才又更真實的面對自己,原來,已經習慣選擇的是逃避,是忽視。

都忘了,這是種心痛的感覺。對於我是更多這段時間的回憶跟反思。

期望我能記起這段時間的學習,不用在放下後,才更好的對待,要在平時,就更加珍惜。

2016.01.07 冬 記


ps,
覺得不敢在告訴你 是怕你放不下 更是怕我放不下
很Nice的人 但是值得更好的選擇 我不能再讓你耽擱了

是你讓我看見了一個不同的世界,有著不同的體驗,那些都是寶貴的經驗與回憶。

這是我所珍惜的

2016年1月3日 星期日

2015 回顧與展望



2015 回顧
2015 年是個充滿著是情緒的一年。

  • 一月二月,其實都等待著去參與 elastic{ON} 15 的興奮跟等待
  • 三月是踏入美洲大陸,踏入一個世界的中心, 到 San Francisco 參加 elastic{ON} 15  (15/03/09 ~ 15/03/12 ) 。從 15/03/08 ~ 15/03/22 都在體驗矽谷的文化,去了Yosemite 看看壯闊的大石頭。讓我反思什麼是身為一個”工程師”,什麼是改變世界的力量。什麼的叫做生活。
  • 四五月擔心父的身體,六月在告別父的憂傷。
  • 15/07/24 (五) ~ 15/07/27(一) 與家人去了趟澎湖遊
  • 150904 (六) ~ 150914(一) 與  x 既上次 新加坡之旅後再次同行15 日本東京 十日遊 散策之旅  ,去了東京 河口湖 箱根 藤澤 鎌倉 橫濱
  • 十一月,開始知道霍老師,要把和平東路的拳館收起來了。這端時間前後讓師兄指點了很多推手與力的掌控。
  • 九月十月,啟動了另外的網站計畫,十一二月破了 15  $/d  的目標

知道一個改變世界的力量,自己的世界也改變了。
更要獨立的去處理很多事情。
更要堅定自己的希望的目標,更有效率的往前行。

2016 期望著新的開始展望