Microsoft_LinuxHaving been in the IT industry for a while, I’ve learned a few things. One of those so called things is, Microsoft and Linux are different worlds. I mean, every other computer operating system is POSIX based but Windows. In fact, back in the Ballmer days (circa 2001), Linux was deemed a cancer. So obviously, when it was announced that SQL would run on Linux, Windows was getting a Linux subsystem, and Azure is ran on Linux it started to make sure sense why the Linux mascot is a penguin. Hell is starting to freeze.

What’s more even more, Microsoft is porting tools over to Linux, well MacOS (which is a Linux variant) as well: Office,  Visual Studio and eventually SSMS. I’ve watched a number of demos where Microsoft employees are running MacBooks. So you know the Ballmer days are long gone, thankfully. At least well be spared someone jumping around the stage for 10 minutes yelling Developers, Developers, Developers.

Sigh….it’s almost like a precursor to the Trump administration huh?

Windows powered by Linux?

The point of this post is, I’ve been thinking a little bit about this marvelous change of direction from Microsoft and I have been wondering. Is Microsoft going to switch to a Linux kernel like Apple did back in the day? Ok, to be fair….MacOS is closer to Unix than Linux, but that’s not the point. The point is, are we starting to witness the conversion/migration of Windows to a more POSIX type of operating system? In 5-10 years, are we going to wake up to an announcement that the next version of Windows for the desktop and server is Linux/POSIX driven?

I mean seriously, think about that for a minute. It wouldn’t take much more for that happen would it? Microsoft has done the heavy lifting with Azure and SQL. It has experience now porting applications. If Azure is running on Linux, then they have had to solve issues moving Exchange to it right, after all….Office 365 runs on Azure. With PCs in decline, tablets and smartphones taking over with Cloud backends, businesses are not going to continue to invest heavily in desktops except for maybe IT departments. So that’s a major loss of revenue for Microsoft. That’s also incentive for software vendors to move into the cloud, like we’re seeing now.

Definitely not something I was expecting to see in my life time. I guess we’re just going to have to wait and see.

 

 

If you work, or have worked, in a shop with lots of SQL servers then you either have, or will, experience an issue with storage. Like for instance you’re storage controllers go down, knocking down your SQL instances. As we all know, this is a good way to corrupt databases. That’s why Sys Admins should never just hit the power button on a database servers, but I digress.

I’ve recently encountered this problem recently, a couple of times in fact. While weekly DBCC checks are run, I was tasked with a way to check lots of databases for corruption quickly. It was decided that we would only do a physical check with DBCC, the databases should be under 1GB in size, and we wanted to be able to run the query across multiple servers quickly. Obviously the size of the database can be modified.

I came up with this.

--create table variable

declare @dbcc_physical Table (
 name varchar(50) not null
);

-- select database names who are under 1GB in size, and store in table variable
INSERT INTO @dbcc_physical
SELECT name from sys.master_files
WHERE type = 0 
AND size < 1024
AND name != 'modeldev';


-- create dynamic sql to execute dbcc check
DECLARE @tableCursor CURSOR,
@databaseName VARCHAR(100);

SET @tableCursor = CURSOR FOR SELECT * FROM @dbcc_physical;

OPEN @tableCursor;
FETCH NEXT FROM @tableCursor INTO @databaseName;
WHILE(@@FETCH_STATUS = 0)
BEGIN;
EXECUTE ('DBCC CHECKDB(' + @databaseName + ') WITH PHYSICAL_ONLY;');

FETCH NEXT FROM @tableCursor INTO @databaseName
END;
 
CLOSE @tableCursor;
DEALLOCATE @tableCursor;

 

#tsql2sdayT-SQL Tuesday is a monthly blog party that is the brain child of Adam Machanic (b/t). This month the blog party is being hosted by Raul Gonzalez (b/t). This month’s topic is about lessons learned the hard way.


Oh the things I have learned…

I can’t say that I have learned these things in the SQL world, because I am relatively new to the SQL world, having only been a SQL DBA for the last 3 and half years. Now, in my past lives as a Windows System Admin, a Linux Admin, and a Systems Analyst/DBA on AS/400’s I have learned quite a bit about things you shouldn’t do. Like for instance….

Are you sure?

Microsoft has this thing about asking the user if they are sure they want to do something. Are you sure if you want to delete this file? Do you really want to restart? Are you sure…? Believe me, this “feature” has saved me a few times. However, this “feature” is a Microsoft thing. It doesn’t exist in say, the Linux world. If you type the command line command of “init 6” to reboot the Linux server, there isn’t an are you sure box….Linux just reboots. I learned this the hard way when I was a Linux Admin at EDS and prematurely hit return on “init 6” before I had nicely shutdown a couple of instances of MySQL. Lets just say the DBAs at the time were not happy with me, as they shouldn’t have been.

What was my take away from that experience? Always…and I mean always, double check the command before you execute it. If you’re not sure of the outcome ask someone else to double check it, verify the command verbally or online, or test it on a dev/test environment first. Whatever you do, if you are unsure, is to blindly run the command. If the server goes down, the query locks down the instance, or the update/delete query doesn’t have a where clause or not wrapped in transaction….all of which are you going to make you have a bad day. And when you do screw up, because you will, OWN it. Don’t hide behind your mistake and don’t blame others.

Rebooting isn’t a fix

Another lesson I learned the hard way was rebooting isn’t a fix. It was a bad, lazy habitat that I was allowed to slip into my early days of my career. That’s not to say there are not times where a reboot is the appropriate action. However, if you have constant memory or cpu issues than you need to be doing a deeper dive into what’s wrong with your server. Again, back to my days at EDS, we had an application running on Linux that was hitting one of the MySQL databases hard. Instead of troubleshooting the app, the developers had us just reboot the server as needed. That is until management had enough of that stupidity and had us take it out of the app pool.

That’s not just a Linux thing either, when I was the DBA/Sys Admin for an AS/400 at a bank, a technician for the banking application suggested we reboot the AS/400 to solve an application problem. For those that don’t know, restarting a mainframe (actual term is IPL) takes anywhere from 30 minutes to over an hour, sometimes two. It just isn’t done. You can bounce subsystems all day, but you just don’t IPL the system. In 7 years of working with 400s, I was only forced to IPL one once because an application locked up the 400. That just doesn’t happen.

learning

Continued Learning

I mention these things because Microsoft is seemingly making a huge investment in Linux as a hosting OS. DBAs, Developers, and Sys Admins that have spent their careers only in the Microsoft world are going to have to change their thinking a bit. Not only is Microsoft Linux, they are embracing the MacOS (ok, it’s just a another Linux OS in a metal case) which for Microsoft is a huge about-face from the days of Steve Ballmer referring to Linux as a cancer.

Being open minded about your tools and how they are changing the landscape is going to be paramount in Microsoft careers. It’s always going to be paramount that with new tools, comes a new way of thinking with a new set of guidelines. Embracing these concepts can help staff from learning some lessons the hard way. However, also keep in mind, from our failures comes our greatest lessons in what not to do. Oh and don’t forget to forgive yourself, or your team, for mistakes. It’s a fundamental part of learning.

 

I mentioned in my last post that I was feeling a bit burnt out. Applying a lot of pressure to myself, feeling like I had to learn everything right now. I took 6 days off over the 4th of July weekend to go camping and a class on Fly Fishing. It put some things into perspective for me.

Camping

Camping in the Rockies always makes things better. Granted, I wasn’t far from people and I still had a good cell service (including internet access). I made a conscious choice not to check work email, which then shortly expanded into not checking any email. Of course I was still checking Facebook on occasion and occasionally Twitter but for the most part I was relatively unplugged. I ultimately relaxed and had fun.

Fly Fishing

Did something new

The day after we got back, my wife and I took a class on Fly Fishing. Something that I have wanted to try for a long time but have never found the time for. I really enjoyed it learning.The instructor made the evening fun, answered all of our silly questions, and made what seemed like a complicated activity relatively simple in concept. My biggest away? Was understanding it’s about technique verses power. There’s a rhythm to fly fishing, there’s a style to it. To borrow from A River Runs Through It , it’s a 4 part rhythm at it’s base and until you find your own rhythm built of the 4 part rhythm. Just like in music.

What does this have to do with being a DBA?

Sometimes as Data Professionals we forget to unplug and relax. We’re always focused on the uptime, or security, or performance of our servers/programs/stored procedures that we forget to see the forest for the trees. Oh sure, we’re aware of the bigger picture but are we present in the big picture? Do we just see he rest of the environment from the perspective of the databases? Or can you see the big picture from a different perspective such as from the business or application side?

My point here is, had I not relaxed and cleared my mind, that is to say I needed to relax and be open to a new perspective, my fly fishing lesson would have been a waste of money. Why? Because I would just seen it from the eyes of someone who had spent their life spin cast fishing and would have missed the nuances. Just the same as when I got back to work this week feeling relaxed and refresh, being open to new information. For me personally this equated to taking a step back to see that my focus doesn’t have to be in 10 different areas at once. So while I can be at work doing my regular job, I can put my focus on learning new things a little bit a time to really understand the nuances of what I’m learning.

I’m also really stoked that I figured out how to use picture of a guy fly fishing in a post about technology….how cool is that?