Sunday, February 28, 2016

Convert a XenServer HVM domain to PV (paravirtual) and back again


Convert a XenServer HVM domain to PV (paravirtual) and back again


After wading through complicated and poorly organized how-to’s for converting a XenServer HVM domain to PV (paravirtual), I wrote a quick and dirty tool to make the conversion in both directions. I was able to get Debian Lenny 5.0.8 paravirtual domain running without any issues. All memory, CPU, disk, and network stats shows up perfectly in XenCenter, too!
Usage:
[root@vps1a ~]# ./vmtool.pl
Usage: vmtool.pl --cmd (hvmtopv|pvtohvm) ([--vm name-label] or [--uuid uuid]) [--root partition_num]
Here’s an example of it running:
[root@vps1a ~]# ./vmtool.pl --cmd=hvmtopv --vm=c1068vm1
uuid = 7cf68fa6-3d07-0869-fa2d-40c89a724042
cmd = hvmtopv
Changing HVM-boot-policy
Changing PV-args
Setting disk boot flag
***Please update /etc/fstab, /etc/inittab. then reboot VM
Done.
If your root partition is anywhere except the 1st partition on the virtual disk, specify the partition number with the –root argument.
To reverse the process, change the –cmd argument from ‘hvmtopv’ to ‘pvtohvm’.
PV domains can be made into templates within XenCenter, so you don’t have to run the script all the time.
Here are steps to take on your domain after changingtour HVM domain to PV. Make sure to complete these steps (except 4) in HVM mode before rebooting. After the reboot, you can install the Xen tools and reboot again.
1. Install a Xen-aware kernel and make it the default boot option in grub.conf or menu.lst.
2. Update /etc/fstab entries – Example: replace /dev/hda1 with /dev/xvda1, /dev/hdd with /dev/xvdd, ect.
3. Update /etc/inittab – Example: replace tty1 with hvc0 so that the Console works properly
4. Make sure the /boot or / partition (depending on your partition layout) has the boot flag set. THIS IS IMPORTANT!
5. Install the Xen tools from the xs-tools CD so that memory, disk, and network usage appears properly in XenCenter
Get the script here:
It’s a shame that XenServer still caters to the Windows crowd by making HVM domains the default, with no way to easily switch to PV. Hopefully this script makes life easier for someone.

Thursday, January 14, 2016

About Starting and Stopping Components with Oracle Restart

About Starting and Stopping Components with Oracle Restart

Oracle Restart automatically restarts various Oracle components when required, and automatically stops Oracle components in an orderly fashion when you manually shut down your system. There may be times, however, when you want to manually start or stop individual Oracle components. Oracle Restart includes the Server Control (SRVCTL) utility that you use to manually start and stop Oracle Restart–managed components. When Oracle Restart is in use, Oracle strongly recommends that you use SRVCTL to manually start and stop components.
Oracle utilities such as SQL*Plus, the Listener Control utility (LSNRCTL), and ASMCMD are integrated with Oracle Restart. If you shut down the database with SQL*Plus, Oracle Restart does not interpret this as a database failure and does not attempt to restart the database. Similarly, if you shut down the Oracle ASM instance with SQL*Plus or ASMCMD, Oracle Restart does not attempt to restart it.
An important difference between starting a component with SRVCTL and starting it with SQL*Plus (or another utility) is the following:
* When you start a component with SRVCTL, any components on which this component depends are automatically started first, and in the proper order.
* When you start a component with SQL*Plus (or another utility), other components in the dependency chain are not automatically started; you must ensure that any components on which this component depends are started.

About Starting and Stopping Oracle Restart

The CRSCTL utility starts and stops Oracle Restart. You can also use the CRSCTL utility to enable or disable Oracle high availability services. Oracle Restart uses Oracle high availability services to start and stop automatically the components managed by Oracle Restart. For example, Oracle high availability services daemons automatically start databases, listeners, and Oracle ASM instances. When Oracle high availability services are disabled, none of the components managed by Oracle Restart are started when a node is rebooted.
Typically, you use the CRSCTL utility when you must stop all of the running Oracle software in an Oracle installation. For example, you might need to stop Oracle Restart when you are installing a patch or performing operating system maintenance. When the maintenance is complete, you use the CRSCTL utility to start Oracle Restart.

Oracle Restart Configuration

Oracle Restart maintains a list of all the Oracle components that it manages, and maintains configuration information for each component. All of this information is collectively known as theOracle Restart configuration. When Oracle Restart starts a component, it starts the component according to the configuration information for that component. For example, the Oracle Restart configuration includes the location of the server parameter file (SPFILE) for databases, and the TCP port to listen on for listeners.
If you install Oracle Restart and then create your database with Database Configuration Assistant (DBCA), DBCA automatically adds the database to the Oracle Restart configuration. When DBCA then starts the database, the required dependencies between the database and other components (for example disk groups in which the database stores data) are established, and Oracle Restart begins to manage the database.
You can manually add and remove components from the Oracle Restart configuration with SRVCTL commands. For example, if you install Oracle Restart onto a host on which a database is already running, you can use SRVCTL to add that database to the Oracle Restart configuration. When you manually add a component to the Oracle Restart configuration and then start it with SRVCTL, Oracle Restart begins to manage the component, restarting it when required.

Thursday, December 31, 2015

HP-UX networking related tools and commands

HP-UX networking related tools and commands

As my journey continues to exploring HP-UX I found couple of nice utilities and tools to configure and administrate HP-UX networking subsystem.
FILES
  • /etc/hosts - Hosts configuration file (resolve hosts and IPs)
  • /etc/rc.config.d/netconf – IP address, routeing address and hostname stored in this file
SCRIPTS
  • /etc/init.d/net start – Use to start, stop network service
HPUX Commands
(a) Display lan interface info:
# lanscan
(b) All in one lan configuration utility (lan0 is first Ethernet interface) to configure and view the system IP address:
# ifconfig lan0 - Display IP info such as IP address netmask etc.
# ifconfig lan0 up - Up network interface (allow traffic)
# ifconfig lan0 down - Down network interactive (deny traffc)
# ifconfig lan0 192.168.1.1 netmask 255.255.255.0 up - Setup/change IP adddress
(c) Displaying host name
# hostname
(d) Arp administration (cache)
# arp -a
(e) Display routing table/info:
# netstat -nr
(f) Define new route:
# route add default 192.168.1.254 1
(g) HP's LAN diagnostic tool
# lanadmin
(h) Test a remote host connectivity
ping host.mycorp.com
(i) Setup various lan properties, dns client, NIS client configuration etc using GUI tool:
# sam
# set_parms
(j) Check dns connectivity:
$ nslookup www.google.co.uk

Monday, December 14, 2015

How to Shrink SQL Server 2012 Transaction log file

How to Shrink SQL Server 2012 Transaction log file


use eSPTest;
go
alter database eSPTest set recovery simple;
go
dbcc shrinkfile(eSPTest_log,200)
go
alter database eSPTest set recovery full;
go

Thursday, December 10, 2015

HP-UX OS installation date

HP-UX OS installation date


1. # head /var/adm/sw/swagent.log 

2. # swlist -v -l bundle | more

3. # /opt/ignite/bin/print_manifest

Very useful command, displays a lot og information.

Friday, December 4, 2015

Oracle VM: Server Not Owned By This Manager

Oracle VM: Server Not Owned By This Manager

So if you've ever lost your Oracle VM Manager and not been able to recover it because you never took a backup, shame on you, you should have followed the procedure documented here 4.12 Backing Up Oracle VM Manager; says he having been in this situation many times.

For the hundreds of you left I'll walk you through the options to get out of the mess you're in.

The first option and only currently supported option is to re-install the OVM Manager and specify the UUID on installation as discussed in 4.13 Restoring Oracle VM Manager.

If like me you've done neither and you already have another OVM Manager and you just want to move the old servers to it don't panic all is not lost.

When you install an Oracle Virtual Server it creates a number of Berkeley DB files in /etc/ovs-agent/db.

[root@someserver1 ~]# ls -ltrh /etc/ovs-agent/db/
total 44K
-rw-r--r-- 1 root root 12K Jun 24  2013 repository
-rw-r--r-- 1 root root 12K Mar 17 16:47 aproc
-rw------- 1 root root 12K Jun 13 17:48 exports
-rw-r--r-- 1 root root 12K Aug  6 15:49 server


[root@someserver1 ~]# file server
server: Berkeley DB (Hash, version 8, native byte-order)

So what I hear you ask, well while unsupported these files can be manipulated using the OVS command line utilities.

[root@someserver1 ~]# ls -ltrh /usr/sbin/ovs-agent*
-rwxr-xr-x 1 root root 1.2K Feb  5  2013 /usr/sbin/ovs-agent-userdel
-rwxr-xr-x 1 root root 1.4K Feb  5  2013 /usr/sbin/ovs-agent-useradd
-rwxr-xr-x 1 root root 3.6K Feb  5  2013 /usr/sbin/ovs-agent-rpc
-rwxr-xr-x 1 root root 3.1K Feb  5  2013 /usr/sbin/ovs-agent-passwd
-rwxr-xr-x 1 root root 2.1K Feb  5  2013 /usr/sbin/ovs-agent-keygen
-rwxr-xr-x 1 root root 2.6K Feb  5  2013 /usr/sbin/ovs-agent-fake-uuid
-rwxr-xr-x 1 root root 2.3K Feb  5  2013 /usr/sbin/ovs-agent-dlm
-rwxr-xr-x 1 root root 5.6K Feb  5  2013 /usr/sbin/ovs-agent-db

For example ovs-agent-db allows you to both query and update items in these files;

[root@someserver1 ~]# /usr/sbin/ovs-agent-db --help
usage: ovs-agent-db [option] ...

Examples:
  ovs-agent-db create_db db
  ovs-agent-db delete_db db
  ovs-agent-db dump_db db
  ovs-agent-db truncate_db db
  ovs-agent-db update_db db value
  ovs-agent-db read_item db key
  ovs-agent-db delete_item db key
  ovs-agent-db write_item db key value
  ovs-agent-db upgrade_databases
  ovs-agent-db get_cluster_db_home

Use python syntax to specify the "value" parameters:
  * None: "None"
  * string: "'some string'"
  * number: "1234.5678", "0x1234"
  * boolean: "True", "False"
  * list: "['foo', 1234]"
  * tuple: "('foo', 1234)"
  * dict: "{'foo': 'bar', 1: 2}"

options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -d DB_HOME, --db-home=DB_HOME
                        specify db home [default: /etc/ovs-agent/db]
  -c, --cluster-db-home
                        use cluster db home

So to dump the contents of the server DB file you would simply do;

[root@someserver1 ~]# /usr/sbin/ovs-agent-db dump_db server
{'cluster_state': 'DLM_Ready',
 'clustered': True,
 'is_master': False,
 'manager_core_api_url': 'https://{some_encrypted username}:{some_encrypted_password}@{some_ip_address}:7002/ovm/core/OVMManagerCoreServlet',
 'manager_uuid': '0004fb000001000dontdothisforreal',
 'node_number': 1,
 'pool_alias': 'MyServerPool1',
 'pool_member_ip_list': ['{someserver1_ip}', '{someserver2_ip}', '{someserver3_ip}'],
 'pool_uuid': '0004fb000002000018facb931f623134',
 'pool_virtual_ip': '{someserver_pool_ip}',
 'poolfs_nfsbase_uuid': '',
 'poolfs_target': '/dev/mapper/360014059ac279e4d573bd4c38d9c9cd6',
 'poolfs_type': 'lun',
 'poolfs_uuid': '0004fb000005000078a55251d7d969ad',
 'registered_hostname': '{some_server}',
 'registered_ip': '{some_server_ip}',
 'roles': set(['xen', 'master', 'utility']),
 'stat_interval': 160}

The values in {} have been changed to protect the innocent and they also don't appear in the output.

Before you can change move these servers over to the new manager you need to find your current OVM Manager UUID, you can get this by clicking on "Help" followed by "About" in the OVM Manager user interface.


The UUID is also available on the OVM Manager file system in the /etc/sysconfig/ovmm file.

[root@ovmmserver ~]# cat /etc/sysconfig/ovmm
RUN_OVMM=YES
JVM_MEMORY_MAX=4096m
JVM_MAX_PERM=512m
DBBACKUP=/u01/app/oracle/mysql/dbbackup
DBBACKUP_CMD=/opt/mysql/meb-3.8/bin/mysqlbackup
UUID=0004fb0000010000d1b7eca67025e1c1

Now onto actually changing the values but checking that you get your commands right first;

[root@someserver1 ~]# ovs-agent-db read_item server manager_uuid
'0004fb000001000dontdothisforreal'

[root@someserver1 ~]# ovs-agent-db write_item server manager_uuid "'0004fb0000010000d1b7eca67025e1c1'"

[root@someserver1 ~]# ovs-agent-db read_item server manager_uuid
'0004fb0000010000d1b7eca67025e1c1'

Don't go patting yourself on the back, were not done yet.  So now we need to re-discover the server in the new OVM Manager but before we do we need to fix the mounted pool file systems and repositories and make them think that they are also owned by the same OVM Manager.

So let's look at the mounted file systems;

[root@someserver1 ~]# df -kh
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             421G  1.2G  398G   1% /
/dev/sda1              99M   28M   67M  29% /boot
tmpfs                 286M     0  286M   0% /dev/shm
none                  286M   40K  286M   1% /var/lib/xenstored
/dev/mapper/360014059ac279e4d573bd4c38d9c9cd6
                       20G  271M   20G   2% /poolfsmnt/0004fb000005000078a55251d7d969ad
/dev/mapper/360014057549345adab90d4b2ddab8ed6
                     1000G  590G  411G  59% /OVS/Repositories/0004fb000003000074aaa55a9bad117a
someserver1.example.com:/nfs
                      421G  1.2G  398G   1% /OVS/Repositories/0004fb00000300000284796418b4eb9d

You'll notice that on my system I have an NFS mount back to itself, I'll explain this in another blog but essentially I am presenting the wasted space on /dev/sda back to the server so that it can be put to good use.

Server Pool Filesystem

Inside each of the mounted pool file systems you will find a .ovspool file which contains the value OVS_POOLFS_MGR_UUID which represents the old OVM Manager UUID,  This needs to be changed too.

[root@someserver1 ~]# cat /poolfsmnt/0004fb000005000078a55251d7d969ad/.ovspoolfs
OVS_POOLFS_UUID=0004fb000005000078a55251d7d969ad
OVS_POOLFS_MGR_UUID=0004fb000001000042f6cecb9c3dc70f
OVS_POOLFS_VERSION=3.0
OVS_POOLFS_POOL_UUID=0004fb000002000018facb931f623134
OVS_POOLFS_LUN_UUID=360014059ac279e4d573bd4c38d9c9cd6

Each Pool Filesystem contains other Berkeley DB files that do not need to be changed, but I'm listing them here for completeness.

[root@someserver1 ~]# ls -ltrh /poolfsmnt/0004fb000005000078a55251d7d969ad/db
total 36K
-rw------- 1 root root 12K Jul 22  2013 monitored_vms
-rw------- 1 root root 12K Feb 18 16:01 server_pool_servers
-rw------- 1 root root 12K Aug  5 17:10 server_pool

Reminder to dump the contents of these files use ovs-agent-db command but this time you have to specify the --db-home parameter which points to the location of the database files.

File: server_pool

This file describes the server pool characteristics.

[root@someserver1 ~]# ovs-agent-db --db-home=/poolfsmnt/0004fb000005000078a55251d7d969ad/db dump_db server_pool
{'auto_remaster': True,
 'pool_alias': 'MyServerPool1',
 'pool_master_hostname': '{someserver1.example.com}',
 'pool_member_ip_list': ['{someserver1_ip}', '{someserver2_ip}', '{someserver3_ip}'],
 'pool_uuid': '0004fb000002000018facb931f623134',
 'pool_virtual_ip': '{someserver_pool_ip}'}

File: server_pool_servers

This file contains details about the servers which are part of the pool.

[root@someserver1 ~]# ovs-agent-db --db-home=/poolfsmnt/0004fb000005000078a55251d7d969ad/db dump_db server_pool_servers
{'someserver1.example.com': {'is_master': False,
                               'node_number': 0,
                               'registered_ip': '{someserver1_ip}',
                               'roles': set(['xen', 'utility'])},
 'someserver2.example.com': {'is_master': False,
                               'node_number': 1,
                               'registered_ip': '{someserver2_ip}',
                               'roles': set(['xen', 'master', 'utility'])},
 'someserver3.example.com': {'is_master': False,
                               'node_number': 2,
                               'registered_ip': '{someserver3_ip}',
                               'roles': set(['xen', 'master', 'utility'])}}

File: monitored_vms

Finally the VM guests being monitored by this pool.

[root@someserver1 ~]# ovs-agent-db --db-home=/poolfsmnt/0004fb000005000078a55251d7d969ad/db dump_db monitored_vms
{'0004fb00-0006-0000-54df-920567f90cd6': {'repo_id': '0004fb000003000074aaa55a9bad117a',
                                          'vm_id': '0004fb000006000054df920567f90cd6'},
 '0004fb00-0006-0000-63e2-a5ccff965b20': {'repo_id': '0004fb00000300000284796418b4eb9d',
                                          'vm_id': '0004fb000006000063e2a5ccff965b20'}}

Repository Filesystem

Inside each of the mounted repository file systems you will find a .ovsrepo file which contains the 
value OVS_REPO_MGR_UUID which represents the old OVM Manager UUID,  This needs to be changed too.  

[root@someserver1 ~]# cat /OVS/Repositories/0004fb000003000074aaa55a9bad117a/.ovsrepo
OVS_REPO_UUID=0004fb000003000074aaa55a9bad117a
OVS_REPO_VERSION=3.0
OVS_REPO_MGR_UUID=0004fb0000010000d1b7eca67025e1c1
OVS_REPO_ALIAS=MY QNAP TS-119

Having made all those changes its now time to re-discover the servers.  At this point I didn't choose to use the re-discovery option, instead I chose to first remove the server and then re-add it from within the UI.

During the discovery OVM Manager will also discover the storage and server pools that this server knows about, however it will not use the 'pool_alias' as was shown when we ran the 'ovs-agent-db dump' command.  The new server pool will be shown in the UI with the 'pool_uuid' value, you can edit this after discovery.


If you don't change any of the values correctly you could end up in the same position as me with a slightly schizophrenic environment where the repositories claim to be owned by another manager so be very careful but don't worry too much as they can be changed after the event by refreshing them from the UI.



Good luck and make sure you follow the proper procedures in future.

Friday, November 20, 2015

Password aging policies in HP-UX

Password aging policies in HP-UX



# /usr/lbin/getprpw test
uid=101, bootpw=NO, audid=13, audflg=1, mintm=2, maxpwln=-1, exptm=30, lftm=40,
spwchg=Thu Nov 21 18:07:34 2002, upwchg=-1, acctexp=-1, llog=-1, expwarn=2, usrp
ick=DFT, syspnpw=DFT, rstrpw=DFT, nullpw=DFT, admnum=-1, syschpw=DFT, sysltpw=DF
T, timeod=-1, slogint=Thu Nov 21 16:08:10 2002, ulogint=Thu Nov 21 16:07:13 2002
, sloginy=-1, culogin=-1, uloginy=-1, umaxlntr=-1, alock=NO, lockout=0000100


Password Format Policies:

maxpwln ==> Maximum Password Length
nullpw ==> Allow Null Passwords
rstrpw ==> Use Restriction Rules
usrpick ==> User Specifies
syschpw ==> System Generates Character
sysltpw ==> System Generates Letters only
syspnpw ==> System Generates Pronounceable

Password Aging Policies

exptm ==> Password Expiration Time (days)
expwarn ==> Password Expiration Warning Time (days)
lftm ==> Password Life Time (days)
mintm ==> Time Between Password Changes (days)

NOTE: If password aging is disabled, all above parameters are set
to 0.

General User Account Policies

bootpw ==> Require Login Upon Boot To Single-User State
llog ==> Maximum Inactive Time (days)
umaxlntr ==> Unsuccessful login Tries Allowed

NOTE: If Lock Inactive Accounts is disabled, llog is set to 0.

Terminal Security Policies

dlylntr ==> Delay Between Login Tries (sec)
lntmout ==> Login Timeout Value (sec)

  DAILY CHECKLIST Oracle Database instance is running or not select name,open_mode from V$database; Note: Check the Oracle databases are ru...