{"id":779,"date":"2021-03-04T21:54:18","date_gmt":"2021-03-04T16:24:18","guid":{"rendered":"https:\/\/adilfahim.com\/myblog\/?p=779"},"modified":"2024-02-27T19:11:07","modified_gmt":"2024-02-27T13:41:07","slug":"how-to-run-db2-commands-for-sap","status":"publish","type":"post","link":"https:\/\/adilfahim.com\/myblog\/how-to-run-db2-commands-for-sap\/","title":{"rendered":"How to run DB2 commands for SAP"},"content":{"rendered":"<p>useful DB2 commands which needs to run to administer the DB2 Database for SAP workloads.<\/p>\n<p>#To start DB2<br \/>\ndb2start<\/p>\n<p>#To connect to particular database<br \/>\ndb2 connect to <em>dbname<\/em><\/p>\n<p>#To check DB configuration\/parameters<br \/>\ndb2 get db cfg for <em>dbname<\/em><\/p>\n<p>#To update DB configuration\/parameters<br \/>\ndb2 update db cfg for <em>dbname<\/em> using LOGARCHMETH1 DISK:\/db2\/TST\/archivelog<\/p>\n<p>This is an example, you can update any parameter as per your requirement. LOGARCHMETH1 is parameter which need to update to keep the archive logs, This parameter is visible by check DB configuration command &#038; after updating any parameter, DB restart requires &#038; sometimes offline DB backup requires before starting up the DB.<\/p>\n<p>#Backup DB2 Database<br \/>\ndb2 backup database <em>dbname<\/em> to <em>\/location<\/em><\/p>\n<p>#Restore DB2 Database<br \/>\ndb2 restore db <em>dbname<\/em> from <em>\/location<\/em> on \/db2\/TST\/sapdata1<\/p>\n<p>The above command will restore the DB on \/db2\/TST\/sapdata1 folder. Make sure to check the DB parameters once restore completed as it always point to old configuration. After restore many times DB can&#8217;t start &#038; throw roll forwarding error, in this case you need to complete the roll forwarding with below command &#8211; <\/p>\n<p>#To end the roll forward status<br \/>\ndb2 rollforward db TST to end of logs &#038; complete<\/p>\n<p>#To deactivate DB before shutting down<br \/>\ndb2 deactivate db <em>dbname<\/em><\/p>\n<p>#To shut down DB normally<br \/>\ndb2stop<\/p>\n<p>#To shut down db forcefully as application connections were still exists<br \/>\ndb2stop force<\/p>\n<p>#To check all schema in DB2 DB<br \/>\ndb2 select schemaname from syscat.schemata<\/p>\n<p>#To list all the tables for all DB&#8217;s<br \/>\ndb2 list tables for all<\/p>\n<p>#To list all the tables in respective DB<br \/>\ndb2 list tables for schema <em>dbname<\/em><\/p>\n<p>#To manually generate the archive logs<br \/>\ndb2 archive log for database <em>dbname<\/em><\/p>\n<p>#Unlock DDIC or any other user in DB2<br \/>\ndb2 &#8220;update SAPSID.USR02 set UFLAG=0 where BNAME=&#8217;DDIC&#8217; and MANDT=&#8217;000&#8242;<\/p>\n<p>#Check HA\/DR status in DB2<br \/>\ndb2pd -d <em>dbname<\/em> -hadr | grep -i hadr<\/p>\n<p><strong>DB2 HA\/DR Cluster Stop \/ Start<\/strong><\/p>\n<p>SAP application should be shut down before stopping the DB2 cluster.<\/p>\n<p>Azure SUSE Linux host running on SBD cluster &#8211; Cluster should be set on maintenance mode<br \/>\n(This is a mandatory step otherwise Virtual Name will switch to other host if DB get down in Primary mode. By setting up maintenance mode, it stick on the same node until maintenance mode OFF)<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nShut down sequence &#8211; Primary DB &#038; then Secondary DB<br \/>\nStartup sequence &#8211; Secondary DB &#038; then Primary DB<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>Login to Primary DB host &#038; verify the crm_status<\/p>\n<p>#Stop the HADR<br \/>\ndb2 stop hadr on db <em>dbname<\/em><br \/>\ndb2 deactivate db <em>dbname<\/em><br \/>\ndb2stop<\/p>\n<p>Login to Secondary DB host and run below commands<\/p>\n<p>#Stop the HADR<br \/>\ndb2 stop hadr on db <em>dbname<\/em><br \/>\ndb2 deactivate db <em>dbname<\/em><br \/>\ndb2stop<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;<\/p>\n<p>#Start the HADR on Standby\/Secondary host first<br \/>\ndb2start<br \/>\ndb2start hadr on db <em>dbname<\/em> as standby<\/p>\n<p>#Start the HADR on Primary host<br \/>\ndb2start<br \/>\ndb2start hadr on db <em>dbname<\/em> as primary<br \/>\n&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>#Verify the HADR status on both hosts<br \/>\ndb2pd -d <em>dbname<\/em> -hadr | grep -i hadr<\/p>\n<p>I will update the list with more commands very soon&#8230;. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>useful DB2 commands which needs to run to administer the DB2 Database for SAP workloads. #To start DB2 db2start #To connect to particular database db2 connect to dbname #To check DB configuration\/parameters db2 get db cfg for dbname #To update DB configuration\/parameters db2 update db cfg for dbname using LOGARCHMETH1 DISK:\/db2\/TST\/archivelog This is an example, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[8],"tags":[616,692,688,697,698,696,689,690,695,691,693,694],"class_list":["post-779","post","type-post","status-publish","format-standard","hentry","category-sap-updates","tag-db2","tag-db2-backup","tag-db2-comamnds","tag-db2-hadr","tag-db2-rollforward","tag-db2pd","tag-db2start","tag-db2stop","tag-db2stop-force","tag-db2vend","tag-logarchmeth1","tag-logprimary"],"_links":{"self":[{"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/posts\/779","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/comments?post=779"}],"version-history":[{"count":4,"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/posts\/779\/revisions"}],"predecessor-version":[{"id":781,"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/posts\/779\/revisions\/781"}],"wp:attachment":[{"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/media?parent=779"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/categories?post=779"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adilfahim.com\/myblog\/wp-json\/wp\/v2\/tags?post=779"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}