Thursday, February 7, 2013

How to Install NodeJS in Ubuntu 12.10 from package manager?

Instruction on how to install NodeJS in Ubuntu 12.10 64bit Server

Note: Line 2 is required if you encountered an error "Command Not Found" on Line 3.
Line 1: sudo apt-get install python-software-properties python g++ make
Line 2: sudo apt-get install software-properties-common
Line 3: sudo add-apt-repository ppa:chris-lea/node.js
You are about to add the following PPA to your system:Evented I/O for V8 javascript. Node's goal is to provide an easy way to build scalable network programs
More info: https://launchpad.net/~chris-lea/+archive/node.js
Press [ENTER] to continue or ctrl-c to cancel adding it
   gpg: keyring `/tmp/tmp2xgu27/secring.gpg' created
   gpg: keyring `/tmp/tmp2xgu27/pubring.gpg' created
   gpg: requesting key C7917B12 from hkp server keyserver.ubuntu.com
   gpg: /tmp/tmp2xgu27/trustdb.gpg: trustdb created
   gpg: key C7917B12: public key "Launchpad chrislea" imported
   gpg: Total number processed: 1
   gpg:               imported: 1  (RSA: 1)
   OK
Line 4: sudo apt-get update Line 5: sudo apt-get install nodejs npm
Enjoy NodeJS!!!

Friday, December 28, 2012

Maven - How to deploy WAR to vFabric TC Server remotely using Maven build?

Four easy steps on How to deploy the WAR file to vFabric TC 2.8.* server  or Tomcat 7 remotely using Maven build (pom.xml)

Step 1: Open your tomcat-user.xml from your <CATALINA_HOME>/conf folder and insert the code:

Code:
  <?xml version="1.0" encoding="UTF-8"?>
  <tomcat-users>
     <role rolename="manager-gui" />
     <role rolename="manage-script" />
     <role rolename="manager-status" />
     <role rolename="manager-jmx" />
     <user username="adminuser" password="adminpwd" roles="manager-gui" />
  </tomcat-users>

Note: Role name script, status and jmx are optional. In previous version of tomcat, you can use role "manager" but for tomcat 7, it was divided into four role. For depolyment, we need only "manager-gui".

Step 2: Update your Maven settings.xml with the following code. To check where is your maven settings located, just open a command prompt and type maven -X and it will show the global settings and user settings. I choose global settings since I will be allowing other users to use the same settings.

Open <MAVEN_HOME>/conf/settings.xml then insert the code:

Code:
  <?xml version="1.0" encoding="UTF-8"?>
  <settings>
   <servers>
     <server>
        <id>remoteserver</id>
        <username>adminuser</username>
        <password>adminpwd</password>
     </server>
   </servers>
  </settings>


Step 3: Open your pom.xml and insert the following code

  Code:
  <plugin>
      <groupId>org.apache.tomcat.maven</groupId>
      <!-- for tomcat 6 -->
      <!--
      <artifactId>tomcat6-maven-plugin</artifactId>
      -->
      <artifactId>tomcat7-maven-plugin</artifactId>
      <configuration>
         <url>http://<remote_ip_address>:<port>/manager/html</url>
         <server>remoteserver</server>
         <path>/your_web_context_path_here</path>
      </configuration>
  </plugin>


Note: if you have a parent pom.xml you need to insert the following code to your parent pom.xml

Code:
  <plugin>
     <groupId>org.apache.tomcat.maven</groupId>
     <artifactId>tomcat7-maven-plugin</artifactId>
     <version>2.0</version>
  </plugin>


Step 4: Deploy or Redeploy
  Run maven command to deploy
  Code:
   mvn tomcat7:deploy
  For redeploy:
  Code:
   mvn tomcat7:redeploy

Wednesday, December 12, 2012

MuleSoft - Building the JKS for the HTTPS Services for ESB Standalone

After following this instruction https://docs.mulesoft.com/cloudhub/building-an-https-service to build a sample hello application. We need to replace the JKS file. Follow the instruction below:

1) Generate key with AES256
openssl genrsa -aes256 -out server.key 1024
2) Generate a Certificate Request for CA
openssl req -x509 -sha256 -new -key server.key -out server.csr
Enter pass phrase for server.key: <ENTER_YOUR_PASSWORD_YOU'VE_CREATED on STEP 1>
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:<ENTER THE COUNTRY 2 LETTER CODE i.e. US>
State or Province Name (full name) [Some-State]:<ENTER YOUR STATE IN FULL i.e. KANSAS>
Locality Name (eg, city) []:<ENTER YOUR CITY i.e. KANSAS CITY>
Organization Name (eg, company) [Internet Widgits Pty Ltd]:<ENTER YOUR COMPANY NAME i.e. MyCompany>
Organizational Unit Name (eg, section) []:<ENTER YOUR DEPARMENT i.e. Research>
Common Name (e.g. server FQDN or YOUR name) []:<ENTER YOUR DOMAIN NAME i.e. www.mywebsite.com or localhost>
Email Address []:<LEAVE IT BLANK just PRESS ENTER>

3) Generate a self signed certificate that will expire for 360 days
openssl x509 -sha256 -days 360 -in server.csr -signkey server.key -out selfsigned.crt
Getting Private key
Enter pass phrase for server.key:<ENTER_YOUR_PASSWORD_YOU'VE CREATED on STEP 1>

4) Create PKCS12 keystore from private key and public certificate
openssl pkcs12 -export -name servercert -in selfsigned.crt -inkey server.key -out keystore.p12
Enter pass phrase for server.key:
Enter Export Password:
Verifying - Enter Export Password:

5) Convert PKCS12 keystone into a JKS Keystore
keytool -importkeystore -destkeystore keystore.jks -srckeystore keystore.p12 -srcstoretype pkcs12 -alias servercert
Enter destination keystore password:  
Re-enter new password: 
Enter source keystore password:  

6) Verify the content of the JKS
keytool -list -v -keystore keystore.jks
Enter keystore password:  

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: servercert
Creation date: Mar 15, 2016
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: O=Internet Widgits Pty Ltd, ST=Some-State, C=US
Issuer: O=Internet Widgits Pty Ltd, ST=Some-State, C=US
Serial number: a829076439b2c11f
Valid from: Tue Mar 15 08:31:22 CDT 2016 until: Fri Mar 10 07:31:22 CST 2017
Certificate fingerprints:
MD5:  0B:F0:2C:64:86:50:80:29:3F:41:09:80:9C:F0:FF:CA
SHA1: 8C:26:4A:4B:FA:55:49:B7:4E:FE:33:13:90:AA:6F:15:B7:A3:E6:DE
SHA256: BB:B2:7C:A2:A8:EF:F5:AE:E8:F1:2D:13:15:ED:46:F5:16:21:AF:18:9D:74:A0:AA:BE:2A:D2:55:68:27:68:D5
Signature algorithm name: SHA256withRSA
Version: 3

Extensions: 

#1: ObjectId: 2.5.29.35 Criticality=false
AuthorityKeyIdentifier [
KeyIdentifier [
0000: 2B C6 1B 1C 65 24 F4 95   F2 46 E0 1F 07 94 B8 C9  +...e$...F......
0010: F4 25 F0 1C                                        .%..
]
[O=Internet Widgits Pty Ltd, ST=Some-State, C=US]
SerialNumber: [    a8290764 39b2c11f]
]

#2: ObjectId: 2.5.29.19 Criticality=false
BasicConstraints:[
  CA:true
  PathLen:2147483647
]

#3: ObjectId: 2.5.29.14 Criticality=false
SubjectKeyIdentifier [
KeyIdentifier [
0000: 2B C6 1B 1C 65 24 F4 95   F2 46 E0 1F 07 94 B8 C9  +...e$...F......
0010: F4 25 F0 1C                                        .%..
]
]
*******************************************

7) Copy the keystore.jks file to MuleSoft Project /<PROJECT>/src/main/resources

8) Run the application and invoke your HTTPS://<IP>:<PORT> using browser

Tuesday, October 30, 2012

Tips and trick

My common unix command while administering a server:

How to find text in a file:
find . -type f -exec grep -i "my string to find" {} \; -print

Find and replace text inside the file using unix
sed -e 's/OLD TEXT/NEW TEXT/' -i myfiles*


Thursday, October 18, 2012

Mule ESB Cluster - MMC - Server Not showing in Server List drop down

I couldn't find this in any of the MMC forum so I tried to solve it and I found a way how to make it work.

The problem was, when you have two ESB server and both server were in a Group Server and under your permission group, you don't want the user to restart the server or view what's inside the server. All you want to do is to allow the user to deploy the application and the user can view the flows and of course, it must be a cluster configuration so I make both server into Cluster using the MMC, unfortunately, after converting it to cluster, the server dropdown list is empty and error in flows like somekind of authority.

I found a workaround for this and it took me a while to solve it. The mule support suggested to check the Server View under Server Group Permission ALL, but this approach, the user will be able to see what's inside the Cluster like Node, JVM, Property, etc and I don't want that the user is allowed to do that because it is so risky especially the ESB has multiple application running.

The mule support create a defect ticket on this to MMC Engineering team.

If you want the solution for this, let me know...

To be continued...

Mulesoft MMC 3.3.1 Could not register server: Could not pair servers (500) with MuleSoft ESB 3.3.1



To fix this error:

For RedHat specific with Virtual IP running and load balancing using Pulse:

Configuration:
    Server A - MMC IP  : 110.100.100.1
    Server B - ESB IP 1: 110.100.101.1

First and foremost, stop your ESB Server in Server B

Note: If you don't use PULSE in Virtual IP, please ignore Step 1 and Step 8.

1. Disable the "PULSE" service in Server B (i.e. sudo service pulse stop;)
2. Open your Server A hosts file (/etc/hosts)
Add the following to your hosts file
110.100.101.1 <your ESB dns name>
3. Open your Server B hosts file (/etc/hosts)
Add the following to your hosts file
110.100.101.1 <your ESB dns name>
4. Go to your Server B and open the wrapper.conf file under your <MULE_HOME>/conf and add the following:
wrapper.java.additional.4=-Dmule.mmc.bind.host=110.100.101.1
     Note: 

         For wrapper.java.additional.4 I choose "4" because that's available
5. Delete the folder ".mule" (i.e. rm <MULE_HOME>/.mule -R)
6. Start your ESB Server B
7. Go to your MMC Web Console and now register it.
8. Start your PULSE service in Server B to enable the Load Balancing again (i.e. sudo service pulse start;)
9. Enjoy...



Wednesday, May 16, 2012

How To Remove Recommended For You pop-up from your browser?

I've been searching for the solution but most of the solution is to run a spyware which I don't like it because it will just slow down my machine and I think in my opinion, I'm just adding new risk for letting a software sniff my transaction.

The solution is pretty simple:
    Replace your Windows "hosts" file or reset it. 

Anyway, just follow the steps below:

Step 1: Open a command prompt. (If you're using Windows 7, make sure you "Run As Administrator")
Step 2: Backup Hosts File. "copy %systemroot%\system32\drivers\etc\hosts c:\hosts
Step 4: Open the hosts file "notepad %systemroot%\system32\drivers\etc\hosts"
Step 4: Delete all text below ::: localhost
Step 5: You now save the file and exit.

Lesson learned:
    Don't install any software that you're not familiar with or not needed. Also, before clicking anything from the browser please Read Before Click.
For reference about "How to Reset Host File" :  http://support.microsoft.com/kb/972034