[TIL] 在 MacOSX 上面透過 Docker 來跑 X11 原生視窗 App

原文 Bring Linux apps to the Mac Desktop with Docker 好處: 某些 App 只出 Linux App 版本,卻沒有 MacOSX 透過 sandbox 的方式執行程式 相關準備: 先裝 X11 Client - xquartz brew install Caskroom/cask/xquartz 安裝 TCP/UDP mapping 工具 SOCAT brew install socat 撰寫相關的 Dockerfile vi Dockerfile 內容直接複製貼上… 開始吧 先下載這次範例程式 slack linux 版本 wget https://downloads.slack-edge.com/linux_releases/slack-desktop-2.1.0-amd64.deb 先在另外一個 teminal 跑 SOCAT socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" 記得不要關掉,這是對應 X11 Client/Server 對應的部分 編譯 Docker Image docker build -t slack:2.1.0 . 跑起來吧 docker run -e DISPLAY=192.168.0.15:0 --name slack -d slack:2.1.0
繼續閱讀

[Golang] FOSDEM 2016: Building Data applications with Go: from Bloom filters to Data pipelines 心得

前提: 這一篇主要是看FOSDEM 2016 影片的簡單心得(投影片在這裡),順便把之前學的 Bloom Filter 複習一下. 這裡有我之前寫的程式. 心得 這篇文章主要都介紹透過 Golang 來開發一個 Data Application . 從 Bloom Filter 到 Count-Min (透過 Hash 方式來存放資料,主要是記錄有出現多少次),到了 HyperLogLog ( 關於 Bloom Filter 這是什麼? Bloom Filter 是一個資料結構.主要是拿來能夠快速的確認一個數值有沒有存在的資料結構.具有以下特性: 極小使用空間(由於不存在原本的 Value ) 只需要儲存 k 個資料結構就好. 具有 可以判斷該數值絕對不存在 效率 ( 也就是不具有 False Nagative ,但是具有 False Postive ). 搜尋時間複雜度: \(O(n)\)  使用場景: 爬蟲可以記錄該網址是否有爬過 Google 惡意 URL 判斷 Canssandra 判斷該 Partition 是否有存放該數值 參考鏈結 FOSDEM 2016: Building Data applications with Go: from Bloom filters to Data pipelines Wiki: Bloom Filter https://github.com/pmylund/go-bloom https://github.com/willf/bloom
繼續閱讀

[DevOps] Mesos 與 DC/OS 安裝學習

安裝 Mesos 在本地端透過 Vagrant 來安裝 Mesos 可以參考 Install Mesos via Vagrant. 心得: 雖然官方文件相當的清楚,但是 Vagrant 本身就有一些雷要踩.不論是 Vagrant SSH key insert failed. Vagrant Shared files between node Vagrant node IP 亂跑的問題 加上如果沒注意到記憶體跟 CPU 極有可能在 Mesos 裡面會出現無法 Scale Task 的狀況. 關於雷的部分,講明白點…. vagrant 的 private IP 不是每次 vagrant up 都會正確,經常會跑掉.得要 vagrant restart. vagrant 彼此間要共享檔案,可以透過 /vagrant 這個資料夾.不過 /vagrant 只是 guest OS 跟 host OS 溝通的共享資料夾,如果兩個 guest OS 要共享,還是得透過 host OS. 然而,共享並不是 real time 而是啟動的時候由 host 帶過去到 guest 的 /vagrant,如果要複製 guest file 到 host 是可以即時,如果要另外一個 guest 拿到,就得要重啟 guest. 安裝 Mesos CLI 流程 先安裝 pip curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py sudo python get-pip.py 在來安裝 virtualenv sudo pip install virtualenv 安裝 mesos.cli sudo pip install mesos.cli 在 GCE (Google Compute Engine) 安裝 DC/OS 參考這一篇 幾個東西要注意一下: 記得要先登入 Google Cloud 帳戶 gcloud auth login 在修改 https://github.com/dcos-labs/dcos-gce 安裝設定的 group_vars/all 的時候,記得以下資料: bootstrap_public_ip: 要參考原先設定 bootstrap 的 IP.必須確認該 IP 的格式與必須要確認一開始的 bootstrap 機器跟你要建立的 master 與 agent 是同個 subnet. subnet: 必須要設定一個新的 subnet (不能使用 default) 一定得建立一個新的 subnet ....
繼續閱讀

[TIL] Survey about Chubby/Zookeeper and their fault tolerance

Difference between Chubby and Zookeeper Consensus Algorithm: Chubby: Using Paxos consensus algorithm Zookeeper: Using ZAB (which is a modified algorithm of Paxos) Access Path: Chubby: Must through leader, follower don’t accept any command directly. Zookeeper: Can accept any command from all follower, but will go back to leader. Data Out-Of-Date: Chubby: No rish on out-of-date, because all data fro Leader. Zookeeper: Will get out-of-date data, if read without sync command. Sync command will force ask follower ask Leader first before return result to client. The tolerance of Quorum-Backup and Primary-Backup: Majority Quorums: For Paxos or ZAB, A leader election need meet majority quorum ( n/2 +1 ) . It means if n=2f at most the service can tolerance f service failed at the same time. ( Quorum-Backup Replica ). Primary-Backup All data must confirm by all follower confirmed. Much slower than “Quorum-Backup”. Kafka ISR (In-Sync Replica) In-Sync Replica is a...
繼續閱讀

[DevOps] 學習 Kubernetes 筆記之二: 透過 Google Compute Engine (Google Cloud) 來繼續學習 Kubernetes

使用 Google Kubernetes Engine (Container Enginer) 由於剛學完 Udacity 上面的 “Scalable Microservices with Kubernetes” 接下來的例子主要是課堂上有教的部分. 先使用 Container Enginer 來建立一個新的 Container Cluster (P.S. 你需要記住你的 GKE 名稱 (ex: mygke)) 透過 kubectl 來連接你的 Cotainer Cluster gcloud container clusters get-credentials mygke 建立一個具有 TLS 的 nginx 連線 建立 TLS 確認你已經有 key ls tls > ca-key.pem ca.pem cert.pem key.pem 使用 kubectl 建立一個 tls secret kubectl create secret generic tls-certs --from-file=tls/ > secret "tls-certs" created 顯示 tls secret 的內容 kubectl describe secrets tls-certs > Name: tls-certs > Namespace: default > Labels: <none> > Annotations: <none> > > Type: Opaque > > Data > ==== > ca-key.pem: 1679 bytes > ca.pem: 1180 bytes > cert.pem: 1249 bytes > key.pem: 1675 bytes 建立一個給 nginx proxu 的 config map kubectl create configmap nginx-proxy-conf --from-file=nginx/proxy.conf > configmap "nginx-proxy-conf" created 詳細了解 nginx-proxy-conf configmap kubectl describe configmap nginx-proxy-conf > Name: nginx-proxy-conf > Namespace: default > Labels: <none> > Annotations: <none> > Data > ====...
繼續閱讀

[DevOps] 學習 Kubernetes 筆記之一: 透過單機版的 Kubernetes (miniKube) 來玩 K8S

miniKube 單機版的 Kubernetes miniKube 是 Google 發布可以在單機上面跑 Kubernetes 的工具,安裝跟使用都相當簡單.由於會在本地跑一個 VM ,所以也不用擔心會被 Google Cloud 不小心付費的問題. 安裝 curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.6.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/ 啟動 minikube start 連接進該 VM minikube ssh 打開並且顯示 minikube 的 dashboard minikube dashboard 接下來,安裝 Kubernetes 安裝 Google Cloud SDK curl https://sdk.cloud.google.com | bash 安裝好之後,會有 gcloud, gsutil 但是還需要安裝 kubectl 透過 Google Cloud SDK 安裝 Kubernetes gcloud components install kubectl 簡單 Tutorial # Startup miniKube minikube start # Create a deployment kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080 # Expose it kubectl expose deployment hello-minikube --type=NodePort # Check pod kubectl get pod # Scale kubectl scale deployment hello-minikube --replicas=4 # Direct link to hello-minikube curl $(minikube service hello-minikube --url) How to Rolling Update on Kubernetes kubectl edit deployment hello-minikube Update your service version and apply it (save it back). You can also update this file via minikube dashboard Edit “deployment” Update “spec”->”spec”-> “image” version. Kubernetes 與...
繼續閱讀