Monday, 21 December 2015

Learn Linux, 101: Customize and use the shell environment


Learn how to customize your Linux shell environment and write simple bash functions. You can use the material in this tutorial to study for the LPI 102 exam for Linux system administrator certification, or to learn for fun.

Overview

In this tutorial, learn to customize your Linux bash shell environment to meet user needs. Learn to:

• Modify global and user profiles
• Set environment variables when you log in or spawn a new shell
• Create bash functions for frequently used sequences of commands
• Maintain skeleton directories for new user accounts
• Set your command search path

Thursday, 17 December 2015

Using watch to loop in Bash

I wanted to monitor a particular set of TCP/IP listeners, on an ongoing basis, and thought "I wonder how I do this?".

A quick Google led me here: -


specifically to the /usr/bin/watch command: -

       watch - execute a program periodically, showing output fullscreen

Here's my command: -

watch -n5 'netstat -a | grep db2'

which watches the output from the netstat command, and updates the display every 5 seconds, resulting in this: -

Every 5.0s: netstat -a | grep db2                                                                                                                                                   Thu Dec 17 13:29:07 2015

tcp        0   0 *:ibm-db2                   *:*                         LISTEN
tcp        0   0 bpm856.uk.ibm.com:39889     db2two.uk.ibm.com:60007     ESTABLISHED
tcp        0   0 bpm856.uk.ibm.com:39888     db2two.uk.ibm.com:60007     ESTABLISHED
tcp        0   0 bpm856.uk.ibm.com:39890     db2two.uk.ibm.com:60007     ESTABLISHED
udp        0   0 *:ibm-db2                   *:*


which is nice :-)

Tuesday, 15 December 2015

Reminder - DB2 HADR and SQL1768N rc7

Reminder to self: -

If I see SQL1768N rc7 when attempting to use DB2 HADR, there's a good chance that I've forgotten to update /etc/hosts meaning that one/both hosts is returning the loopback / localhost address of 127.0.0.1 when attempting to connect to itself via hostname.

For the record, /etc/hosts should look similar to this: -

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.153.100 bpm856.uk.ibm.com bpm856
192.168.153.110 db2one.uk.ibm.com db2one
192.168.153.120 db2two.uk.ibm.com db2two

In other words, there must be no other hostname alongside the localhost entries.

Monday, 7 December 2015

How to tune a guitar and a Business Process Manager (BPM) topology at the same time

I found this whilst searching for something pertaining to Java2 Security: -


<snip>

As such, here's a quick checklist of tuning tips that cover all areas of your IBM Business Process Manager (BPM) environment:

  • Use a 64-bit JVM for all servers.
  • Disable tracing, logging, and monitoring when possible.
  • Ensure all of your databases are well-tuned.
  • If security is required, use Application security, not Java2 security.
  • Use an appropriate hardware configuration for performance measurement (not notebooks or desktops).
  • If hardware virtualization is used, ensure that adequate processor, memory, and I/O resources are allocated to each virtual machine.
  • Minimize network latency and ensure sufficient network bandwidth between all systems in the configuration.
  • Do not run production servers in development mode or with a development profile.
  • Tune external service providers and external interfaces to ensure that they do not cause a system bottleneck.
  • Configure:
    • Message-driven bean (MDB) activation specifications.
    • Thread pool sizes.
    • Settings of data sources for connection pool size and prepared statement cache size.
  • Increase the maximum number of connections in the data pool to greater than or equal to the sum of all maximum thread pool sizes.


This list represents just the fundamental requirements for optimal performance. See IBM Business Process Manager V8.0 Performance Tuning and Best Practices, REDP-4935-00 for a complete list of tuning recommendations for all areas of your IBM Business Process Manager topology. 

</snip>

Sunday, 6 December 2015

More textile manipulation with sed and bash

One of my colleagues was looking for a way to manipulate an XML file, using sed on Linux.

In essence, he wanted to remove an XML tag at the current end of the file, and insert a new line BELOW the current end of the file, making the new line the new end of the file :-)

Here's a mockup of my solution.

I used a file called foobar.bak as my input file, mainly so that I could quickly see/compare the changes between input and output.

Input file - foobar.bak

The quick brown fox
Jumped over the lazy dog
In the pouring rainfall


( Note the tab characters; they're there because my friends' XML file had tabs for pagination )

Script - replace.sh

#!/bin/bash
cp foobar.bak foobar.txt

file="foobar.txt"
replace="fall"
insert="That is all"
sed -i'' "$ s/$replace//g" $file
sed -i'' "$ a\ \t \t$insert" $file


In essence, I'm copying the foobar.bak file to foobar.txt each time I run the script, meaning that I preserve the original file :-)

I'm then setting some variables, one for the filename, one for the character to be replaced, and one for the new line.

I then use sed to replace ( remove ) the to-be-replaced string.

Finally, I again use sed to insert a new line - note that I'm using sed twice, mainly because I couldn't work out how to replace and then insert a blank line in sed I even messed about with ^M characters, but to no avail.

Output file - foobar.txt

The quick brown fox
Jumped over the lazy dog
In the pouring rain
    That is all


Again, note the tabs for pagination ( they're handled with \t above ).

*UPDATE*

I then thought about the two occurrences of sed again, and came up with this improvement: -

#!/bin/bash
cp foobar.bak foobar.txt

file="foobar.txt"
replace="fall"
insert="That is all"
sed -i'' "$ s/$replace/\n\t\t$insert/g" $file


which has the same effect, but does everything in a single sed statement :-)



Note to self - Firefox and local connections

 Whilst trying to hit my NAS from Firefox on my Mac, I kept seeing errors such as:- Unable to connect Firefox can’t establish a connection t...