Setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3

Here, I was able to setup Huawei E1552 SMS Gateway in Raspbian using SMSTools3.

Requirements:

Steps:

  1. Install/Burn Raspbian to your microsd card. Instructions here.
  2. After burning/installing the image to your SD card. Install it to your Raspberry PI and configure it so you can SSH into it properly. Sadly, SSH daemon is not automatically configured to start on boot.
  3. To Enable SSH to autostart on boot… do
  4. :> update-rc.d ssh defaults
    :> update-rc.d ssh enable
  5. Restart and try to login remotely
  6. If you can not login, sshd may be configured to deny any remote root connection
  7. Got to /etc/ssh/ and edit sshd_config
  8. Look for this line…
  9. PermitRootLogin.......
  10. And change it to…
  11. PermitRootLogin yes

    Continue Reading

JPMorgan Quorum Cakeshop Setup Ubuntu 16.04.2

I wanted to study JPMorgan’s Quorum Blockchain and going to install Cakeshop, their development environment, under Ubuntu 16.04.2 and Tomcat8 web server.
There were some bumps that were unavoidable but the developer was very helpful in debugging and help me setup the server. Shout out to fixanoid

  • Install Ubuntu 16.04.2
  • Update to latest updates
  • Install Java 8 (Open JDK)
  • Install Tomcat8
  • Follow the installation instruction here… BUT don’t start the server yet.
  • Instead of setenv.sh, edit Tomcat8 startup script under /etc/init.d/ folder.
  • Under catalina_sh() function, go to TOMCAT_SH= line
  • Before that, add this command…. JAVA_OPTS=”$JAVA_OPTS -Dspring.profiles.active=local -Deth.config.dir=[Your/folder/path/accessible/to/tomcat8/user]”
  • Start the server /etc/init.d/tomcat start, then stop it /etc/init.d/tomcat8 stop
  • The server will not yet run peroperly and error logs will populate catalina.out logs, but this will populate config files int the folder you passed in JAVA_OPTS (eth.config.dir=[Your/folder/path/accessible/to/tomcat8/user])
  • No go to the folder, under the local folder, edit application.properties
  • Locate geth.identity=
  • Add any node name you want it to be
  • Save the file, exit and start the server again
  • This should start the server properly now. You check the catalina.out logs.
  • You can access the site via http://IP_ADDRESS:8080/cakeshop/

MariaDB Unknown/unsupported storage engine: InnoDB

I had this problem re-occurring in one of my servers. MariaDB wont start due to this error.

To fix my problem, remove these log files…

/var/lib/mysqld/ib_logfile0
/var/lib/mysql/ib_logfile1
/var/lib/mysql/aria_log_control

ib_logfile may be 0 or 1

If you want to be safe.. just rename it to another file temporarily to see if it works.

Sources for the fix can be found Here and Here

Ubuntu 16.04.02 Hang on Reboot or Shutdown

Had a problem after an update that when I force a restart or a shutdown on my server, it hangs on the last part of the process.

To fix my problem, I had to edit the /etc/default/grub config file and added acpi=force apm=power_off to the config line, between the double quotation marks…

1
GRUB_CMDLINE_LINUX_DEFAULT=""

and

1
GRUB_CMDLINE_LINUX=""

do a update-grub after saving then reboot one more time.. ( force sa restart when it hangs )
After the restart, try another reboot, it should work now without hanging.

Source of the fix is from Here

Heap Dump and Remote Tomcat 8-OpenJDK 8 Memory Monitoring

Memory problem.. the thorn of web apps… I have to connect to my remote server to monitor its memory usage and produce a heap dump.
Bellow is the steps I had to configure the server to allow me to connect a remote monitor tool.

Requirement: VisualVM app, download here

  1. Access your catalina.sh file.
  2. Look for JAVA_OPTS, if none found, you can add your own.
  3. Add …
    1
    
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/

    to the line if found, if not, you can do

    1
    
    JAVA_OPTS="JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/heap/dump/folder/"

    The above code will force a heamp dump when the server encounter a out-of-mem exception.

  4. Next, to enable remote memory monitoring, add these commands after the line above, within the quotation mark, add proper spacing after each command…
    1
    2
    3
    4
    
    -Dcom.sun.management.jmxremote.port=<port_num>
    -Dcom.sun.management.jmxremote.ssl=false
    -Dcom.sun.management.jmxremote.authenticate=false
    -Djava.rmi.server.hostname=<host_ip_add>
  5. Now, run VisualVM and create a new JMX remote connection, under the CONNECTION field, add host_ip_address:port_num
    ex. 111.111.1.1:5555

Congrats! You should now be able to connect to your server and monitor your memory usage!

Enable Ubuntu 16.04 SSH Tunneling at Boot Time

I wanted to connect to a remote server and setup a tunnel for my MariaDB replication ( yes I migrated to MariaDB ),
the only problem was that sometimes the net is erratic and can’t connect right away on boot time.
Found a code online to check for ping reply, if it does, continue with the tunneling.
I modified this to suit my needs.

In summary, the script checks for a ping reply from Google infinitely. Once it receives a response, it then creates the tunnel.
Source for the code here

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
((count = 0))
while [[ $count -ne 1 ]] ; do
    ping -c 1 8.8.8.8
    rc=$?
    if [[ $rc -eq 0 ]] ; then
        ((count = 1))                      # If okay, flag to exit loop.
    fi
 
done
 
if [[ $rc -eq 0 ]] ; then                  # Make final determination.
 
    screen -dm -S tunnel autossh -M 0 -o "ServerAliveInterval 60" -o "ServerAliveCountMax 3" -p <PORT> <IP_ADDRESS> -L <LOCAL_TUNNEL_PORT>:localhost:<MYSQL_PORT>
 
 
    echo `date` >> log.txt
 
else
    echo "Tunnel Timeout...." `date` >> log.txt
fi

Regenerate Missing MariaDB/MySQL Config(my.cnf) File

I ran into this problem after upgrading/intalling MariaDB, the config file was missing.

 

To regenerate the config file… try executing…

1
dpkg --force-confmiss -i /var/cache/apt/archives/mysql-common*.deb

Ubuntu has changed its network naming scheme starting 15.04

I recently updated to Ubuntu 16.04.1 LTS from 14.04 and ran into this problem as not having my network adapter detected on startup.

No network adapter, no connection to the internet, no updates…

I did some research and digging and it seems that starting  Ubuntu 15.04, as quoted from one of the forums..

“…starting with systemd/udev will automatically assign predictable, stable network interface names for all local Ethernet, Wlan and Wwan interfaces.”

Whole info at this link.

Well there it was, no more eth0 on default installation. The system gave me ens160 as a network adapter name.

One way of fixing it is to retain the new name and just rename the network name in the interface file to the new naming scheme. Sample here

 

How to revert to the old naming scheme?

Here are some tips and tricks.

  1. Edit your grub file, this is located at /etc/default/grub
  2. Look for GRUB_CMDLINE_LINUX=””
  3. Add net.ifnames=0 biosdevname=0  between the double quotes.
  4. Save and create new grub config by executing the command grub-mkconfig -o /boot/grub/grub.cfg
  5. If your using dhcp, no need to rename your network name in the interface file back to eth0.
  6. Reboot system after that.

Source Link

MySQL 5.6 and Up: High Memory Usage

Had a problem with a fresh install of MySQL 5.7 using more than normal memory.

Researching around the net, one feature that was added (5.6?) that fixed my problem was performance schema ( performance_schema ).

Disabling is easy enough as adding performance_schema=0 in my.cnf config file.

 

Thanks to Joel Abraham for the fix.

Connecting to MySQL on a Remote Server through Port Forwarding and Reverse SSH Tunnel

I had a problem connecting to a remote server that has its ports blocked by the ISP. So technically, I can’t port forward my way into the server. The only way around this is to SSH connect from my remote server to my main server and access the remote server via reverse SSH tunneling. This tutorial will show the steps on how I connected to my database server on the remote server via port forwarding on my PC and reverse SSH tunneling on my main server.

  1. Connect from the remote server (B) to the main server (A).
    • #> screen autossh -R22222:localhost:22 your_remote_IP_address
      • screen – new terminal so you can disconnect and work on other stuffs
      • autossh – reconnects if ssh is broken or is disconnected
      • -R -> tells the client that the remote port to open for the reverse tunnel
      • 22222 -> of course, the port to be used on the other end
      • localhost:22 -> anything attached on port 22222 will reach localhost port 22
      • your_remote_IP_address – not much explaining needed
  2. Now on the main server ( A ), to connect to remote server via the SSH tunnel created.
    • #> ssh -p 22222 username@localhost -L 4406:localhost:3306
      • -p 22222 -> instructs the SSH client to connect to localhost via port 22222
      • -L 4406:localhost:3306 -> this tells the client to forward all packets that is sent on port 4406 to localhost and target port 3306. That’s if the connection succeeds, will be on the remote server already.
  3. On my dev machine, I setup my SSH client ( putty ) to bind to port 99999 and forward  it to the main server on port 4406.
  4. I then have my DB Client attach to port 99999 on connect

Image shown below….

Sources: StackExchange

diagram