[TIL] Learning note about Docker Swarm Mode

Start Docker Swarm Mode Docker Swarm Mode is specific for Docker Swarm Version 2 which only enable after Docker 1.12. It is cluster management system for Docker. Install Docker-Machine: Better to prepare at least 3 docker-machine for swarm node. If you use Docker for Mac or Docker for Windows beta, you still need install `docker-machine. Install docker-machine: curl -L https://github.com/docker/machine/releases/download/v0.7.0/docker-machine-`uname -s`-`uname -m` > /usr/local/bin/docker-machine && \ chmod +x /usr/local/bin/docker-machine Run Docker Swarm Start to create 3 docker machine for cluster management. docker-machine create --driver virtualbox v1 docker-machine create --driver virtualbox v2 docker-machine create --driver virtualbox v3 Init cluster leader in v1 docker-machine ssh v1 For example if your v1 node IP address is 192.168.99.110. docker swarm init --listen-addr 192.168.99.110:2377 --advertise-addr 192.168.99.110 Init Other Worker Node v2, v3 Let v2, v3 join cluster as nodes. Login and Control v2. docker-machine ssh v2 docker swarm join --token SWMTKN-1-3h0ndq6j0agkl1inb7sd9gnrk1va4e0sggw74jsaj7xkx75c7n-31coul06qcdb7g411ww8jnurw 192.168.99.110:2377 > This node...
繼續閱讀

[TIL] Learning note about Cassandra

Keyspace keyspace == database in SQL CREATE KEYSPACE KEYSPACE_NAME WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 3 }; then use KEYSPACE_NAME; in cqlsh before you create/alter/drop/select tables. Special Data Operation in Cassandra (Set/List/Map/Nested Type/Frozen/Tuple/JSON) Set data Table schema for set. CREATE TABLE users ( user_id text PRIMARY KEY, first_name text, last_name text, emails set<text> ); Insert data into table INSERT INTO users (user_id, first_name, last_name, emails) VALUES('frodo', 'Frodo', 'Baggins', {'[email protected]', '[email protected]'}); List data Table schema CREATE TABLE users ( user_id text PRIMARY KEY, first_name text, last_name text, top_places list<text> ); Data Insertion. INSERT INTO users (user_id, first_name, last_name, emails) VALUES('frodo', 'Frodo', 'Baggins', [ 'rivendell', 'rohan' ]); Map Data Table schema CREATE TABLE users ( user_id text PRIMARY KEY, first_name text, last_name text, todo map<timestamp, text>; ); Data Insertion. INSERT INTO users (user_id, first_name, last_name, emails) VALUES('frodo', 'Frodo', 'Baggins', { '2012-9-24' : 'enter mordor', '2014-10-2 12:00' : 'throw ring...
繼續閱讀

[TIL] 如何快速在 Google Cloud Platform 上面架設一個 Docker 環境

Using docker-machine is another way to host your google compute instance with docker. docker-machine create \ --driver google \ --google-project $PROJECT \ --google-zone asia-east1-c \ --google-machine-type f1-micro $YOUR_INSTANCE If you want to login this machine on google cloud compute instance, just use docker-machine ssh $YOUR_INSTANCE Refer to docker machine driver gce Note: The progress of docker-machine might be slow because it need connect to Google Compute Engine. Do not use multiple docker-machine creation, because docker need to write related information on docker.sock. You might occur error on Wrapper Docker Machine process exiting due to closed plugin server (unexpected EOF). Using docker-machine to create local vbox vm will install docker 1.12 rc1, but on GCP will using 1.11. So, we could use docker swarm mode :(
繼續閱讀

[TIL] Google Cloud Storage Quickstart

Google Cloud Storage: 扁平的檔案結構,其主要架構為: Bucket (ex: gs://example) 就像是 git repo 一樣. Object 就像是檔案一樣. 存取方式 這裡先介紹透過 Google Cloud SDK 來安裝,透過以下方式可以安裝: curl https://sdk.cloud.google.com | bash 建立 Bucket gsutil mb gs://YOUR_BUCKET_NAME 複製檔案過去 gsutil cp SOURCE DESTNATION 根據這樣指令架構. 檔案放上 Google Cloud Storage: gsutil cp ./111.txt gs://YOUR_BUCKET_NAME 拉回本地端: gsutil cp gs://YOUR_BUCKET_NAME/111.txt ./ 參考: Google Doc: gcs docs GoogleCloudPlatform/storage-getting-started-go: This is a simple example of calling the Google Cloud Storage API in Go.
繼續閱讀

[Golang][FB] 教學如何快速透過 Golang 與 Heroku 架設一個臉書機器人

1. Just Deploy the same on Heroku Remember your heroku ID and app address. ex: https://APP_ADDRESS.herokuapp.com/ 2. Create a Facebook Page Make sure you already have Facebook account, if you need use FB Bot. 3. Go to Facebook Developer to create App Create App, need select as follow: New App type [Web App], create app Add new product [Messenger] 4. Configuration Messenger Bot Get token from Faccebook page. Select a “Page” you own. Go to “Meseenger” product. It will generate token copy it and store it. 5. Paste Token to Heroku Go to heroku dashboard, go to “Setting” -> “Config Variables”. Add “Config Vars” Name -> “TOKEN” Value use token facebook app. 6. Back Facebook App configuration Go to “Messenger” product Go to “Setup Webhooks” Fill https://APP_ADDRESS.herokuapp.com/webhook in callback URL. Fill your token in “token”. Checked the checkbox “message_deliveres”, “messages”. If your configuration is correct, it will show “completed”. Also...
繼續閱讀

程式設計週記[2016/06/24]: COSCUP 要開賣, Docker Swarm v2 帶來集群管理

這是什麼? 程式週記主要內容如下: Gihub project 介紹: 主要會貼一些github,但是會盡量寫上一些有用的評語(或是我容易想到的關鍵詞)幫助以後查詢 網路文章心得: 會寫些心得,強迫自己閱讀. “程式週記”並且定期週期性更新. 大部分內容在我的twitter都會有,這邊只是將一些簡單的心得與感想註解一下. 本週摘要 正式上班第一週,大部分時間都在開會 @_@ .本週最大的事情大概就是COSCUP 要開賣還有就是 Docker 出了自己的集群管理系統 Docker Swarm v2 . 本週還是寫了一個專案,不過不會記錄到 Project52,大家也要繼續寫喔. Go Short Introduction to Bleve 一個文字搜尋的套件,支援相當多的語系.這裡有 Github GO: MARSHAL AND UNMARSHAL JSON WITH TIME AND URL DATA 講解如何透過 Custom Marshaller 透過 JSON 來處理 time 或是其他類型資料.這裡有更仔細的影片教學可以看 from Francesc Campoy -. http://elliot.land/go-subtests-and-sub-benchmarks 主要是講解 Go 1.7 新增的 subtest 跟 subbenchmark 的部分. HOW TO WRITE ROUTER TESTS IN GO Python Android/JAVA/NODE.JS/Scala Spark Streaming Programming Guide - Spark 1.1.0 Documentation Send data to spark streaming directly via pipe Docker Youtube: Docker 1.12 Release Candidate 2 About Docker Swarm V2, 內建 SwarmKit 之後.類似 Mesos 一樣可以很方便的建置出資源控管. More Microservices Bliss with Docker 1.12 and Swarm only 專門幫 Docker port 到 PI (ARMed) 的 HyPriot 也把 1.12 開始導入了,這篇也有一些介紹. DockerCon 2016 D1 主题演讲 紀錄 DockerCon 2016 第一天的重點,主要還是集群管理的部分. Swarm Reboot in Docker 1.12 SwarmKit 在 Docker 1.12 之後會整合進 Docker Swarm 中,這篇文章做一個簡單的介紹. Building serverless apps with Docker 若有參加 Docker...
繼續閱讀