筆記一下
brew update
brew search elasticsearch ==> 查看目前有的版本
eg.
elasticsearch
homebrew/versions/elasticsrach22
homebrew/versions/elasticsrach17
brew install homebrew/versions/elasticsrach22 ==> 指定安裝版本
參考資料
http://effectif.com/mac-os-x/installing-specific-version-of-homebrew-formula
2016年4月1日 星期五
2016年3月18日 星期五
Build & Package with SBT
做個筆記
開發是使用 IntelliJ IDEA
要直接使用 SBT build
1. Download & install SBT
http://www.scala-sbt.org/download.html
2. 確認 build.sbt 中
mainClass in assembly := Some("Your.main.class")
不改也可以在執行 .jar 時指定
3. 執行 sbt assembly
4. 可在 [your project]\target\scala-2.11\ 下找到 [your project].jar
2016年3月3日 星期四
JavaMail API - Send Mail
1. 下載 JavaMail Library
http://www.oracle.com/technetwork/java/javamail/index-138643.html
我用的是 1.4.5
後來發現比較新的是 1.5.0
2. 使用JavaMail API
網路上很多範例, 尤其是使用Gmail SMTP server 的
建議有時間的話先看一下 the most common mistakes people make
另外, API 中有分 SSL 與 STARTTLS.
許多 Gmail SMTP 範例會分 SSL 與 TLS, 但範例中的 TLS 通常是指 STARTTLS , 容易誤導
關於 SSL, TLS, STARTTLS 的區分說明可看這篇
Note: 若要透過 Gmail 發信, 則該 Gmail 帳號需降低安全性, 修改方式可看這裡
3. Sample: SSL/TLS for my mail server
val host = "host.mymailserver.com"
val port = 465
val username = "myaccount"
val password = "mypasswd"
設定 connection property
val properties = System.getProperties
properties.put("mail.smtp.auth", "true")
properties.put("mail.smtp.ssl.enable", "true")
因為是未認證的 mail server, 另外加這段
properties.put("mail.smtp.ssl.checkserveridentity", "false")
properties.put("mail.smtp.ssl.trust", "*")
準備信件內容
val session = Session.getInstance(properties)
val message = new MimeMessage(session)
message.setFrom(new InternetAddress(" noreply@mymailserver.com"))
message.setRecipients(Message.RecipientType.TO, "receipient@gmail.com")
message.setSubject("Greetings")
message.setText( "THIS IS TEST MAIL")
connect & send mail
val transport = session.getTransport("smtp")
transport.connect(host, port, username, password)
transport.sendMessage(message, message.getAllRecipients)
transport.close()
參考資料
https://www.fastmail.com/help/technical/ssltlsstarttls.html
http://www.oracle.com/technetwork/java/javamail/faq/index.html
http://puremonkey2010.blogspot.tw/2010/12/java-javamail-gmail.html
http://www.oracle.com/technetwork/java/javamail/index-138643.html
我用的是 1.4.5
後來發現比較新的是 1.5.0
2. 使用JavaMail API
網路上很多範例, 尤其是使用Gmail SMTP server 的
建議有時間的話先看一下 the most common mistakes people make
另外, API 中有分 SSL 與 STARTTLS.
許多 Gmail SMTP 範例會分 SSL 與 TLS, 但範例中的 TLS 通常是指 STARTTLS , 容易誤導
關於 SSL, TLS, STARTTLS 的區分說明可看這篇
Note: 若要透過 Gmail 發信, 則該 Gmail 帳號需降低安全性, 修改方式可看這裡
3. Sample: SSL/TLS for my mail server
val host = "host.mymailserver.com"
val port = 465
val username = "myaccount"
val password = "mypasswd"
設定 connection property
val properties = System.getProperties
properties.put("mail.smtp.auth", "true")
properties.put("mail.smtp.ssl.enable", "true")
因為是未認證的 mail server, 另外加這段
properties.put("mail.smtp.ssl.checkserveridentity", "false")
properties.put("mail.smtp.ssl.trust", "*")
準備信件內容
val session = Session.getInstance(properties)
val message = new MimeMessage(session)
message.setFrom(new InternetAddress(" noreply@mymailserver.com"))
message.setRecipients(Message.RecipientType.TO, "receipient@gmail.com")
message.setSubject("Greetings")
message.setText( "THIS IS TEST MAIL")
connect & send mail
val transport = session.getTransport("smtp")
transport.connect(host, port, username, password)
transport.sendMessage(message, message.getAllRecipients)
transport.close()
參考資料
https://www.fastmail.com/help/technical/ssltlsstarttls.html
http://www.oracle.com/technetwork/java/javamail/faq/index.html
http://puremonkey2010.blogspot.tw/2010/12/java-javamail-gmail.html
2016年2月23日 星期二
Cassandra Config (3.3.0)
裝完 Cassandra 後試著做兩件事
1. 將 listen interface 由 localhost 改為其他 IP, 支援外部連線
2. 建帳號
兩者皆由修改 ~/cassandra/conf/cassandra.yaml 著手
1. Change IP
目前只是先試出來有兩個地方要改
#listen_address: localhost
待有空再來研究
[另外試了 Cassandra 3.2.1 則是兩者都要設 ip address, 也是奇怪]
2. Create User
預設執行 cql 是不需要 username/password
但當要執行 create user 時, 會出現類似以下 error:
InvalidRequest: code=2200 [Invalid query] message="org.apache.cassandra.auth.CassandraRoleManager doesn't support PASSWORD"
同樣需要修改 config
#authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator
#authorizer: AllowAllAuthorizer
authorizer: CassandraAuthorizer
這兩項改完可以預設帳號登入(cassandra/cassandra) 並 create user
ex.
~/cassandra/bin/cqlsh 192.168.2.129 -u cassandra -p cassandra
Connected to Test Cluster at 192.168.2.129:9042.
[cqlsh 5.0.1 | Cassandra 3.2.1 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh> create user test with password 'test' ;
參考資料:
http://stackoverflow.com/questions/31820914/in-cassandra-2-2-unable-to-create-role-containing-password
1. 將 listen interface 由 localhost 改為其他 IP, 支援外部連線
2. 建帳號
兩者皆由修改 ~/cassandra/conf/cassandra.yaml 著手
1. Change IP
目前只是先試出來有兩個地方要改
#listen_address: localhost
listen_interface: [your interface] ex. eth1
#rpc_address: localhost
rpc_address: [your ip] ex. 192.168.2.129
比較奇怪的是,
看說明, 應該設 listen_address 就可以, 但直到改了 rpc_address 才真的 listen 在指定的 IP上
另外我目前 listen_address 要改用 listen_interface 才行. 否則執行 cassandra 會有error.待有空再來研究
[另外試了 Cassandra 3.2.1 則是兩者都要設 ip address, 也是奇怪]
2. Create User
預設執行 cql 是不需要 username/password
但當要執行 create user 時, 會出現類似以下 error:
InvalidRequest: code=2200 [Invalid query] message="org.apache.cassandra.auth.CassandraRoleManager doesn't support PASSWORD"
同樣需要修改 config
#authenticator: AllowAllAuthenticator
authenticator: PasswordAuthenticator
#authorizer: AllowAllAuthorizer
authorizer: CassandraAuthorizer
ex.
~/cassandra/bin/cqlsh 192.168.2.129 -u cassandra -p cassandra
Connected to Test Cluster at 192.168.2.129:9042.
[cqlsh 5.0.1 | Cassandra 3.2.1 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cassandra@cqlsh> create user test with password 'test' ;
參考資料:
http://stackoverflow.com/questions/31820914/in-cassandra-2-2-unable-to-create-role-containing-password
2016年2月5日 星期五
Install cassandra on ubuntu 14.04
1. 先安裝 Java JDK
目前的是 Java 8, Java 9 官方還不建議使用
$sudo add-apt-repository -y ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java8-installer
2. 安裝 Cassandra
目前從官網看到的最新版是 3.2.1
下載
$ wget http://apache.stu.edu.tw/cassandra/3.2.1/apache-cassandra-3.2.1-bin.tar.gz
目前的是 Java 8, Java 9 官方還不建議使用
$sudo add-apt-repository -y ppa:webupd8team/java
$sudo apt-get update
$sudo apt-get install oracle-java8-installer
2. 安裝 Cassandra
目前從官網看到的最新版是 3.2.1
下載
$ wget http://apache.stu.edu.tw/cassandra/3.2.1/apache-cassandra-3.2.1-bin.tar.gz
$ tar -xvzf apache-cassandra-1.2.4-bin.tar.gz
$ mv apache-cassandra-1.2.4 ~/cassandra
安裝&設定
$sudo mkdir /var/lib/cassandra
$sudo mkdir /var/log/cassandra
$sudo chown -R $USER:$GROUP /var/lib/cassandra
$sudo chown -R $USER:$GROUP /var/log/cassandra
$export CASSANDRA_HOME=~/cassandra
$export PATH=$PATH:$CASSANDRA_HOME/bin
啟動 cassandra
$ ./cassandra/bin/cassandra
原本是用 sudo 去執行, console 上會顯示訊息建議不要用 root 權限啟動 cassandra, 所以就拿掉囉
執行 cql
$ ./cassandra/bin/cqlsh
顯示:
Connected to Test Cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.2.1 | CQL spec 3.4.0 | Native protocol v4]
Use HELP for help.
cqlsh>
參考資料
http://tecadmin.net/install-oracle-java-8-jdk-8-ubuntu-via-ppa/#
http://idroot.net/tutorials/how-to-install-apache-cassandra-on-ubuntu-14-04/
http://wiki.apache.org/cassandra/GettingStarted
http://wiki.apache.org/cassandra/GettingStarted
訂閱:
文章 (Atom)