Jonathan Hutchins' Blog
Thursday, March 16, 2017
 
Connecting to a remote DB2 Database with PHP from RHEL6
Connecting to a remote database using PHP on RHEL6.

Starting from a default server installation with Apache and PHP.

Jonathan R. Hutchins, 10 February 2012
------------------------------------------------------------------

Add the "Optional" software channel to your channel subscriptions for the machine. This is usually done from the administrative subscription management screen at http://rhn.redhat.com.

This will allow you to get php-devel, which is required for installing modules with pecl.
You will also need to install gcc.


Add user db2inst1 which will have access to the CLI db2 connection for testing.


mkdir /db2home
groupadd -g 999 db2iadm1
useradd -u 1004 -g db2iadm1 -m -d /db2home/db2inst1 db2inst1
passwd db2inst1
?


Install the DB2 Data Server Client. This is currently provided in v9.7fp5_linuxia32_client.tar.gz from IBM. Un-tar the file, change to the ~/client directory it creates, and run ./db2_install

Create the db2 "instance" which creates the files, links, and sets the environment for user db2inst1:

/opt/ibm/db2/V9.7/instance/db2icrt db2inst1

Map the remote connections to local aliases for easier connectivity. (This also allows the remote database to be changed and re-mapped without having to change internal code.)

su - db2inst1

The following commands catalog remote database DMTEST on server GENDATAT port 50015 as local database DMTEST and remote database DMPROD on GENDATAB3 port 50010 as DMPROD:

db2 "catalog tcpip node GDT remote GENDATAT server 50015"
db2 "catalog tcpip node GDB3 remote GENDATAB3 server 50010"
db2 terminate
db2 "catalog database DMTEST as DMTEST at node GDT"
db2 "catalog database DMPROD as DMPROD at node GDB3"
db2 terminate

The terminate command flushes the cache and is necessary for the catalogged items to be used.

Typeos can be corrected with the command

db2 "uncatalog [node|database] "

Note that the local database alias and node names can not exceed 8 characters, hence the abbreviated node names above.

Now db2 connect to DMTEST user should prompt for a password.

Next, install the PHP module:

pecl install ibm_db2

Either add the following line to php.ini (/etc/php.ini) or create a file in /etc/php.d/ with this line:

extension=ibm_db2.so

Current practice is to use the file in php.ini - may require an ini extension.

Restart the apache server. You can use phpinfo () to check that it's enabled.

You should now be able to use php -r "echo db2_connect ('DMTEST','', '');", which should return the connection status.

Wednesday, August 26, 2015
 

Shutting down spare ttys with upstart

A lot of people will still be dealing with upstart even as the stamped to systemd takes us into new territory. Company environments not ready to move off of RedHat or CentOS 6 for the most part, including many government organizations. Most of my admin knowledge is still in SysV init, and I'm still learning upstart while trying to gradually duplicate my skills in systemd.

In SysV, if you had a headless system where six virtual consoles didn't make sense and cluttered up the process list, you simply commented out for or five in /etc/inittab. Then we went to inittab and got the message that things had moved.

In RH?Centos 6, the number of ttys to start is set by an environment variable in /etc/init/start-ttys.conf. What I do is change ACTIVE_CONSOLES from /dev/tty[1-6] to [1-2]. This covers starting the ttys at boot, but if you change it and kill the ttys they still respawn.

What you need to do is

initctl stop tty TTY=/dev/tty3


Then repeat this for each of the other spare

You can do this with a for loop:

for f in {3..6};do stop tty TTY=/dev/tty$f;done


There may be prettier ways to do this, but it works.

J. Hutchins, 26 August 2015
Wednesday, November 07, 2012
 
Buying Books
Do you buy books? I've been through a couple of phases of my life when I did. From the late 70's when I had exhausted school libraries and had F&SF to guide me, I bought paperback Science Fiction. Chain bookstores were thriving and often would have all the volumes of a series - they kept stocking the early volumes as later ones came out. Then that ceased to be true, and there were some times when the price of a paperback just didn't fit my "spend nothing" budget. I moved on to the KC library, which for a while wasn't too bad about having a whole series. You often need to request them via ILL, but it's possible to follow an author - or it was, until a recent series where I found that while they had the first four books, they had one copy in trade paperback, and someone else was interested in them. We had a hold war for a while, then I gave up. There were times I went back to buying before the chain stores dried up and went away. Last I remember trade paperbacks were getting up around $5 - $6. In a desire to make sure I'd read all of Marrion Zimmer Bradley, I started buying her books on-line. Often a hardcover could be had for a few dollars, less than the cost of a new paperback. That stopped last time paychecks stopped, and I have not yet found an author I want enough to go that route with. I always feel a little guilty that the author doesn't get anything from me when I do that. Yeah, me buying gives the book residual value that helps justify the initial purchase which does pay the author, but still. I've had my Kindle for a year now, and have yet to buy a book. One of Marilyn's co-workers is sharing her fantasy collection with me, and between that and library books it hasn't come down to "buy new", and there aren't any used eBooks for sale on Amazon at bargain prices. I look at the prices of eBooks though - today I was reminded that I haven't read the latest Neal Stevenson, "Reamde", and went looking. $1!? What are trade paperbacks going for these days? Amazon shows $12.91, but then lists a low price (alternate vendor) of $5.99, which is what I would expect. I wouldn't object to trying eBooks for real. Amazon books sync to the Kindle, my Blackberry, and my computer, even "remembering" where I read last from device to device. Even with a comfortable income though, I can't bring myself to pay twice the retail price of a hardcopy book just to try it out. What do you think? What do you pay for books?
Thursday, September 27, 2012
 
Saturday Night Live - A Minor Rant
Saturday Night Live was a TV show from the late 1970s. It debuted in 1975 under the title "NBC's Saturday Night". It was produced by Lorne Michaels and starred "The Not Ready For Prime-Time Players": Laraine Newman, John Belushi, Jane Curtin, Gilda Radner, Dan Aykroyd, Garrett Morris and Chevy Chase. The show began to break up toward the end of the decade as the cast found success in movies, and by 1980 when Michaels left most of the original cast was gone. Although NBC has continued to run various similar shows under the title "Saturday Night Live" ever since, Saturday Night Live ENDED in 1980. People are confused by the title, but the show is not, can not, be Saturday Night Live. The times are different, the guest hosts are not the same, and the music has indelibly changed. If you watched Saturday Night Live last weekend, you watched it on tape.
Monday, November 30, 2009
 
The Real Terrorists
Cory Doctorow commenting on a photographer who was stopped from taking pictures of St. Paul's Cathedral in London:

"The real damage from terrorist attacks doesn't come from the explosion. The real damage is done after the explosion, by the victims, who repeatedly and determinedly attack themselves, giving over reason in favor of terror. Every London cop who stops someone from taking a picture of a public building, every TSA agent who takes away your kid's toothpaste, every NSA spook who wiretaps your email, does the terrorist's job for him. Terrorism is about magnifying one mediagenic act of violence into one hundred billion acts of terrorized authoritarian idiocy. There were two al Quaeda operatives at St Paul's that day: the cop and her sidekick, who were about Osama bin Laden's business in London all day long."
Monday, November 23, 2009
 
Wheel Shopping
Consensus of several knowledgeable people who've looked at the wheel: You might away with it. You won't find one like it. Looks like four new wheels. I am NOT driving that trailer on the highway with my horses on a wheel that "might" not come off.

(They all agreed that the lug nuts, which have thousands of trailer miles on them, are not the right ones for those wheels.)

The only vehicle big enough to transport all four wheels is the truck, so I guess they go two at a time.
Thursday, November 19, 2009
 
Progress!
Wednesday turned out to be an ugly weather day too, but today it was nice, and I'm sharper and better rested.

Pushed the wheel all the way on, backed the adjuster all the way off and finally was able to pull it free. Nothing seriously damaged in the brake assembly. Took the wheel to the Machine Shop; they have to order more studs but say that it's fairly trivial to replace them. If the hub comes off of the brake drum easily, they'll turn that flange of rust that caught the shoes off, otherwise they'll leave it alone. Should be done tomorrow.

Need to order lug nut. The only local chain that carries them is Auto Zone, and each store stocks two. I'm going to replace all eight on that wheel.

Talked to a couple of wheel shops, they say as long as the holes haven't worn oval, the wheel should be fine. I'll have one more close look at it, but I'm going to have to hope the studs were the problem. I still need to verify the proper torque - maybe a Chevrolet dealer?

Powered by Blogger