#ファイル名を分解し、日付情報を取得,削除対象日付とファイル名から取得した日付を比較,削除
foreach filename (`ls ${JBATCH_LOG_PATH} | grep '[0-9]\{8\}.*\.log$'`)
logDEBUG ${jobID} "実行ログファイル名:${filename}"
set iFileDate = `echo ${filename} | sed 's/.*\([0-9]\{8\}\).*/\1/g'`
logDEBUG ${jobID} "日付情報:${iFileDate}"
set iDelFlg = 0
@ iDelFlg = ${iDelDate} - ${iFileDate}
if(${iDelFlg} >= 0) then
rm -f ${JBATCH_LOG_PATH}/${filename}
@ iLogNumDel = ${iLogNumDel} + 1
if( ${status} != 0 ) then
set strMessage = `getMessage "RAMWAR16"`
logWARNING ${jobID} "${filename} ${strMessage}"
set iContinueFLG = 1
goto __LAST
endif
endif
end
2008年4月28日月曜日
Adding a new disk to a VMWare Virtual Machine in Linux
http://www.matttopper.com/?p=25
Home Papers and Presentations About Me
Oracle Stuff and My Thoughts on Other Tech TopicsAdding a new disk to a VMWare Virtual Machine in Linux
Bloged in VMWare, Technology, General by Topper Sunday May 7, 2006
I’ve been using VMWare for a while now and I always get asked some common questions about it. One of those is how to add a new virtual disk to a Linux virtual machine. So in response to that, here are the steps to adding a new SCSI based virtual disk to a CentOS Linux virtual machine. The steps for adding a disk to a Windows machine is very much the same except you would use the Disk Management utility from the Control Panel.
Step 1: Open virtual machine settings
Select your virtual machine, as you can see from the photo I selected the Infrastructure virtual machine. Next press the “Edit virtual machine settings’ to open the Virtual Machine Settings dialog.
Step 2: Add new hardware
From the “Virtual Machine Settings” dialog select the “Add…” button at the bottom of the screen. From this dialog you can also modify how much memory you dedicate to the machine when it boots.
Step 4: Select new hard disk
From this screen we can see the many types of hardware we can add to a virtual machine. You can emulate just about any piece of hardware that one can expect in a modern operating system. It definitely makes testing with different configurations and devices much easier. For our example we want to select “Hard Disk” and then select the “Next >” button.
Step 5: Create the virtual disk
In the next screen we see the three options for adding a new disk. We can “Create a new virtual disk”, this will create a brand new disk on the guest operating system. The second option, “Use an existing virtual disk”, allows you to mount a disk from another virtual machine. I like to do this with my “source” drive. I have one virtual disk that I’ve made that has all the Oracle and Linux CDs on it, that way I can just mount it to the machine I need when I have to do a new install instead of copying the binaries I need across disks, its definitely a big time saver. The last option is to “Use a physical disk”, this allows you to mount a local physical disk to the operating system. This option is akin to NFS mounting a drive to a virtual machine. To add a new disk we select the “Create a new virtual disk” option and select the “Next >” button.
Step 6: Select type of disk
Next we want to select the type of disk. I’ve been using VMWare for a long time and agree that the recommended Virtual Disk Type should be SCSI. I don’t know why, but I’ve had much better success with the SCSI virtual disks than the IDE ones. So in this step we want to select “SCSI (Recommended)” and the “Next >” button.
Step 7: Set disk size and options
Now we want to set the size of the disk we are creating. One of the nice features of VMWare is that you don’t have to allocate all of the disk when you create it. So if you create a 40 GB disk it doesn’t have to take it all right away, the disk will grow as your virtual machine needs it. I will say this is a big performance hit you take when the disk has to extend, but for most applications its OK. Also, I will warn that if the virtual disk grows and there is no physical disk left on the host operating system you will see a catastrophic failure and in most cases both the host and guest operating systems lock up and become unusable. (Don’t say I didn’t warn you) Lastly, you can split the files into 2GB sizes, while this isn’t necessary, it just makes all the disks much easier to manage and move around. For this step we want to set our disk size (12 GB in this case), I chose not to allocate the disk space right now (the machine has a 300 GB drive and has only 20 GB on it) and Split disk into 2 GB files.
Step 8: Name the disk file
This is actually pretty simple in that you decide what you want to physically call the disk and where to put it. .vmdk is the extension for VMWare virtual disks. After we name the disk we can select the “Finish” button which adds the disk to the virtual machine.
Step 9: Ensure new disk exists
So now we can see that the new disk has been added to the “Virtual Machine Settings” within the selected virtual machine. From here the disk acts just like it would if you added a new disk to a standalone server. So we select the “OK” button to continue.
Step 10: Boot the virtual machine
From here we just start the virtual machine like we would normally, either by selecting the button on the toolbar or selecting the “Start this virtual machine” link.
Step 11: Virtual machine start up
The machine boots normally as it would any other time.
Step 12: Create the Partition
After we’ve logged in and accessed a terminal window as root (or another user with root/sudo privs) we first want to run fdisk on the newly created drive. In Linux the first SCSI drive is sda, the second sdb, the third sdc, etc. since this was the second SCSI drive we added to the system, the device is known as /dev/sdb
The first command we want to run is fdisk /dev/sdb (NOTE: Thanks to everyone that caught my typo here) this utility works very much like the DOS utility of the old days and allows you to create and manage partitions. To create a new partition we enter the command n to create a new partition. This is going to be a primary partition p, and the first partition number 1. Because I want this disk to consume the full 12 GB I specified earlier we start at the first cylinder and end it at the last cylinder. We then want to write the partition table with the new partition we have just created so we enter the command w which writes the new table and exits fdisk.
Step 13: Format the partition
Now that we’ve create the partition, we now want to format the first with the new file system. I’ve decided to use ext3 filesystem for this disk, ext3 provides all the features of the classic ext2 file system plus journaling which helps to prevent disk corruption in the event of an improper shutdown and speeds up the recovery process. For a good overview of Linux standard file systems check out this article: http://linux.org.mt/article/filesystems So, to format the new partition we enter the command mkfs -t ext3 /dev/sdb1. This command makes a new files system with the type t ext3 on the /dev/sdb1 partition, this is the first partition on the sdb disk.
Step 14: Create the mount point
Determine where you want to add the new virtual disk you’ve created. I like to create a partition specifically for all the software I install after the basic Linux install called /software to do that we run mkdir /software, just a simple make directory command. Once that is complete we then want to mount the newly created partition. Because we haven’t added the partition to the /etc/fstab yet we have to mount it manually. To do that we run mount -t ext3 /dev/sdb1 /software. To break down this command we run mount with the ext3 filesystem type, the partition /dev/sdb1 to the directory /software. Pretty simple and straight forward. To check that the partition is properly mounted we run df -k which shows us the mounted partitions and the amount of available space.
Step 15: Open the fstab file
The fstab file holds all of the used disks and partitions, and determines how they are supposed to be used by the operating system. So we edit the file to add the newly created partition
http://www.matttopper.com/images/blog/adding_disk_to_vmware/15.jpg
Step 16: Modify the fstab for the new partition
After we open the fstab file in the previous step we add the following line:
/dev/sdb1 /software ext3 defaults 1 1
The first column is the partition name, the second is the default mount point, the third is the filesystem type. The fourth is the mount options, in this case I used default which mounts the drive rw, suid, dev, exec, auto, nouser and asynchronous. The 5th and 6th options are for the dump and fsck options. If dump is set to 1 the filesystem is marked to be backed up, if you are going to have sensitive material on the drive its a good idea to set it to 1. If fsck is set to greater than 1, then the operating system uses the number to determine in what order fsck should be run during start up. If it is set to 0 it will be ignored such as in the case of a cdrom drive since its a solid state disk. For more information on the fstab file check out this article: http://www.tuxfiles.org/linuxhelp/fstab.html
Lastly, we write and quit the file with the :wq command.
So now that the fstab has been written the drive will be mounted and unmounted when the machine is either started or shutdown. So there you have it, the quick and dirty process for adding a brand new disk to a virtual machine. Until next time…
ShareThis
Trackback ·
Close
Forgot password?
Please put in your email: Send me my password! Close message
This blog postAll blog postsSubscribe to this blog post's comments through...
RSS Feed
Subscribe to this blog's comments through...
RSS Feed
Follow the discussion Login CommentsSort by: Date Rating Last Activity
Close
Login to an existing account
Email: Password: Use OpenID! Forgot login? Login Close
Login with your OpenID
OpenID URL: Back Login Dashboard | Edit profile | Logout Logged in as 0Vote upVote down RishiD Hey,
Just wanted to say thanks for the tutorial.
Worked great. Post reply » 9 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Stan Raichlen I agree: Nice complete and very useful tutorial. I have found several sites previously, but none of them met my needs prior to this site. Thanks! Post reply » 8 weeks ago
This comment has 0 hidden replies. Show them! +1Vote upVote down Rick Karcher • 1p Thanks Matt !! Great Tutorial , could It be possible to replace for example the /var partition and to add a new /var with more space and copy all the content to the new /var partition ?
Thanks ,
Regards . Post reply » 8 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Eric Thanks Matt. I kinda knew what I had to do but couldn't see the /dev/sdb that I added. I rebooted the server and it showed up. It's always nice to find a howto for EXACTLY what you are doing. :) Post reply » 7 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Albin Thanks Matt. It's exactly what I need. Post reply » 7 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Geoffrey useful tutorial, thanks ! Post reply » 7 weeks ago
This comment has 0 hidden replies. Show them! Thread active 4 weeks agoCollapse thread Expand thread 0Vote upVote down Josef Thanks for this Matt. It is very helpful.
God bless! Post reply » 5 weeks ago
0Vote upVote down Gregg Rask These directions are great. I ran into an issue. A new disc was created pointing to /opt/software and when installing into the directory that relates to the newly created disc the / directory is consumed instead of the /opt/software directory structure.
What are your thoughts? Post reply » 4 weeks ago
This comment has 1 hidden reply. Show it! 0Vote upVote down JoseT Thanks Matt! This is what I was looking for to jog my memory, been awhile since I had to add disks to my VM's! Post reply » 3 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down satyanarayana Thank you it helped. Post reply » 3 weeks ago
This comment has 0 hidden replies. Show them! Thread active 3 weeks agoCollapse thread Expand thread 0Vote upVote down Abdul Mateen you are great Matt!!.. this tutorial really helped me.. Post reply » 3 weeks ago
0Vote upVote down Erez thanks a lot! great tutorial and great help Post reply » 3 weeks ago
This comment has 1 hidden reply. Show it! 0Vote upVote down Meng Thans very very much... Your tutorial very very helpful Post reply » 1 week ago
0Vote upVote down Jack THANKS! Post reply » 6 days ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Ntseh Sweet! Easy to read and follow. Post reply » 5 days ago
This comment has 0 hidden replies. Show them! Post a new comment
(Logout)Enter text right here! Name * Email (track replies) Blog URL Claim my comments! Why? | Login Your OpenID * Claim my comments! Why? | Login Submit Comment Or post using OpenID Go back Get better comments for your blog Go to Intense Debate Posting AnonymouslyEnter text right here! Name * Email (track replies) Blog URL Claim my comments! Why? | Login OpenID URL * Claim my comments! Why? | Login Cancel | Submit Comment Or post using OpenID Go back
About Me
Matt Topper
Email: matt@matttopper.com
Phone: 586.855.4595
Disclaimer
The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Calendar
April 2008 S M T W T F S
« Jan
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Categories
Auto Industry
BI Server
BIEE
Business Intelligence
Data Integrator
Discoverer
General
Identity Management
MapViewer / GIS
Music
ora-click
Oracle
Oracle Access Manager
Oracle Adaptive Access Manger (OAAM)
Oracle Identity Manager
Oracle Virtual Directory
Personal
Portal
Technology
VMWare
Archives:
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
June 2007
May 2007
April 2007
March 2007
January 2007
October 2006
September 2006
July 2006
June 2006
May 2006
April 2006
November 2005
October 2005
September 2005
August 2005
June 2005
January 2005
December 2004
Links
Meta:
Login
RSS
Comments RSS
Valid XHTML
WP
Copyright © 2004 - 2006 Matt Topper 22 queries. 0.923 seconds.
Home Papers and Presentations About Me
Oracle Stuff and My Thoughts on Other Tech TopicsAdding a new disk to a VMWare Virtual Machine in Linux
Bloged in VMWare, Technology, General by Topper Sunday May 7, 2006
I’ve been using VMWare for a while now and I always get asked some common questions about it. One of those is how to add a new virtual disk to a Linux virtual machine. So in response to that, here are the steps to adding a new SCSI based virtual disk to a CentOS Linux virtual machine. The steps for adding a disk to a Windows machine is very much the same except you would use the Disk Management utility from the Control Panel.
Step 1: Open virtual machine settings
Select your virtual machine, as you can see from the photo I selected the Infrastructure virtual machine. Next press the “Edit virtual machine settings’ to open the Virtual Machine Settings dialog.
Step 2: Add new hardware
From the “Virtual Machine Settings” dialog select the “Add…” button at the bottom of the screen. From this dialog you can also modify how much memory you dedicate to the machine when it boots.
Step 4: Select new hard disk
From this screen we can see the many types of hardware we can add to a virtual machine. You can emulate just about any piece of hardware that one can expect in a modern operating system. It definitely makes testing with different configurations and devices much easier. For our example we want to select “Hard Disk” and then select the “Next >” button.
Step 5: Create the virtual disk
In the next screen we see the three options for adding a new disk. We can “Create a new virtual disk”, this will create a brand new disk on the guest operating system. The second option, “Use an existing virtual disk”, allows you to mount a disk from another virtual machine. I like to do this with my “source” drive. I have one virtual disk that I’ve made that has all the Oracle and Linux CDs on it, that way I can just mount it to the machine I need when I have to do a new install instead of copying the binaries I need across disks, its definitely a big time saver. The last option is to “Use a physical disk”, this allows you to mount a local physical disk to the operating system. This option is akin to NFS mounting a drive to a virtual machine. To add a new disk we select the “Create a new virtual disk” option and select the “Next >” button.
Step 6: Select type of disk
Next we want to select the type of disk. I’ve been using VMWare for a long time and agree that the recommended Virtual Disk Type should be SCSI. I don’t know why, but I’ve had much better success with the SCSI virtual disks than the IDE ones. So in this step we want to select “SCSI (Recommended)” and the “Next >” button.
Step 7: Set disk size and options
Now we want to set the size of the disk we are creating. One of the nice features of VMWare is that you don’t have to allocate all of the disk when you create it. So if you create a 40 GB disk it doesn’t have to take it all right away, the disk will grow as your virtual machine needs it. I will say this is a big performance hit you take when the disk has to extend, but for most applications its OK. Also, I will warn that if the virtual disk grows and there is no physical disk left on the host operating system you will see a catastrophic failure and in most cases both the host and guest operating systems lock up and become unusable. (Don’t say I didn’t warn you) Lastly, you can split the files into 2GB sizes, while this isn’t necessary, it just makes all the disks much easier to manage and move around. For this step we want to set our disk size (12 GB in this case), I chose not to allocate the disk space right now (the machine has a 300 GB drive and has only 20 GB on it) and Split disk into 2 GB files.
Step 8: Name the disk file
This is actually pretty simple in that you decide what you want to physically call the disk and where to put it. .vmdk is the extension for VMWare virtual disks. After we name the disk we can select the “Finish” button which adds the disk to the virtual machine.
Step 9: Ensure new disk exists
So now we can see that the new disk has been added to the “Virtual Machine Settings” within the selected virtual machine. From here the disk acts just like it would if you added a new disk to a standalone server. So we select the “OK” button to continue.
Step 10: Boot the virtual machine
From here we just start the virtual machine like we would normally, either by selecting the button on the toolbar or selecting the “Start this virtual machine” link.
Step 11: Virtual machine start up
The machine boots normally as it would any other time.
Step 12: Create the Partition
After we’ve logged in and accessed a terminal window as root (or another user with root/sudo privs) we first want to run fdisk on the newly created drive. In Linux the first SCSI drive is sda, the second sdb, the third sdc, etc. since this was the second SCSI drive we added to the system, the device is known as /dev/sdb
The first command we want to run is fdisk /dev/sdb (NOTE: Thanks to everyone that caught my typo here) this utility works very much like the DOS utility of the old days and allows you to create and manage partitions. To create a new partition we enter the command n to create a new partition. This is going to be a primary partition p, and the first partition number 1. Because I want this disk to consume the full 12 GB I specified earlier we start at the first cylinder and end it at the last cylinder. We then want to write the partition table with the new partition we have just created so we enter the command w which writes the new table and exits fdisk.
Step 13: Format the partition
Now that we’ve create the partition, we now want to format the first with the new file system. I’ve decided to use ext3 filesystem for this disk, ext3 provides all the features of the classic ext2 file system plus journaling which helps to prevent disk corruption in the event of an improper shutdown and speeds up the recovery process. For a good overview of Linux standard file systems check out this article: http://linux.org.mt/article/filesystems So, to format the new partition we enter the command mkfs -t ext3 /dev/sdb1. This command makes a new files system with the type t ext3 on the /dev/sdb1 partition, this is the first partition on the sdb disk.
Step 14: Create the mount point
Determine where you want to add the new virtual disk you’ve created. I like to create a partition specifically for all the software I install after the basic Linux install called /software to do that we run mkdir /software, just a simple make directory command. Once that is complete we then want to mount the newly created partition. Because we haven’t added the partition to the /etc/fstab yet we have to mount it manually. To do that we run mount -t ext3 /dev/sdb1 /software. To break down this command we run mount with the ext3 filesystem type, the partition /dev/sdb1 to the directory /software. Pretty simple and straight forward. To check that the partition is properly mounted we run df -k which shows us the mounted partitions and the amount of available space.
Step 15: Open the fstab file
The fstab file holds all of the used disks and partitions, and determines how they are supposed to be used by the operating system. So we edit the file to add the newly created partition
http://www.matttopper.com/images/blog/adding_disk_to_vmware/15.jpg
Step 16: Modify the fstab for the new partition
After we open the fstab file in the previous step we add the following line:
/dev/sdb1 /software ext3 defaults 1 1
The first column is the partition name, the second is the default mount point, the third is the filesystem type. The fourth is the mount options, in this case I used default which mounts the drive rw, suid, dev, exec, auto, nouser and asynchronous. The 5th and 6th options are for the dump and fsck options. If dump is set to 1 the filesystem is marked to be backed up, if you are going to have sensitive material on the drive its a good idea to set it to 1. If fsck is set to greater than 1, then the operating system uses the number to determine in what order fsck should be run during start up. If it is set to 0 it will be ignored such as in the case of a cdrom drive since its a solid state disk. For more information on the fstab file check out this article: http://www.tuxfiles.org/linuxhelp/fstab.html
Lastly, we write and quit the file with the :wq command.
So now that the fstab has been written the drive will be mounted and unmounted when the machine is either started or shutdown. So there you have it, the quick and dirty process for adding a brand new disk to a virtual machine. Until next time…
ShareThis
Trackback ·
Close
Forgot password?
Please put in your email: Send me my password! Close message
This blog postAll blog postsSubscribe to this blog post's comments through...
RSS Feed
Subscribe to this blog's comments through...
RSS Feed
Follow the discussion Login CommentsSort by: Date Rating Last Activity
Close
Login to an existing account
Email: Password: Use OpenID! Forgot login? Login Close
Login with your OpenID
OpenID URL: Back Login Dashboard | Edit profile | Logout Logged in as 0Vote upVote down RishiD Hey,
Just wanted to say thanks for the tutorial.
Worked great. Post reply » 9 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Stan Raichlen I agree: Nice complete and very useful tutorial. I have found several sites previously, but none of them met my needs prior to this site. Thanks! Post reply » 8 weeks ago
This comment has 0 hidden replies. Show them! +1Vote upVote down Rick Karcher • 1p Thanks Matt !! Great Tutorial , could It be possible to replace for example the /var partition and to add a new /var with more space and copy all the content to the new /var partition ?
Thanks ,
Regards . Post reply » 8 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Eric Thanks Matt. I kinda knew what I had to do but couldn't see the /dev/sdb that I added. I rebooted the server and it showed up. It's always nice to find a howto for EXACTLY what you are doing. :) Post reply » 7 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Albin Thanks Matt. It's exactly what I need. Post reply » 7 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Geoffrey useful tutorial, thanks ! Post reply » 7 weeks ago
This comment has 0 hidden replies. Show them! Thread active 4 weeks agoCollapse thread Expand thread 0Vote upVote down Josef Thanks for this Matt. It is very helpful.
God bless! Post reply » 5 weeks ago
0Vote upVote down Gregg Rask These directions are great. I ran into an issue. A new disc was created pointing to /opt/software and when installing into the directory that relates to the newly created disc the / directory is consumed instead of the /opt/software directory structure.
What are your thoughts? Post reply » 4 weeks ago
This comment has 1 hidden reply. Show it! 0Vote upVote down JoseT Thanks Matt! This is what I was looking for to jog my memory, been awhile since I had to add disks to my VM's! Post reply » 3 weeks ago
This comment has 0 hidden replies. Show them! 0Vote upVote down satyanarayana Thank you it helped. Post reply » 3 weeks ago
This comment has 0 hidden replies. Show them! Thread active 3 weeks agoCollapse thread Expand thread 0Vote upVote down Abdul Mateen you are great Matt!!.. this tutorial really helped me.. Post reply » 3 weeks ago
0Vote upVote down Erez thanks a lot! great tutorial and great help Post reply » 3 weeks ago
This comment has 1 hidden reply. Show it! 0Vote upVote down Meng Thans very very much... Your tutorial very very helpful Post reply » 1 week ago
0Vote upVote down Jack THANKS! Post reply » 6 days ago
This comment has 0 hidden replies. Show them! 0Vote upVote down Ntseh Sweet! Easy to read and follow. Post reply » 5 days ago
This comment has 0 hidden replies. Show them! Post a new comment
(Logout)Enter text right here! Name * Email (track replies) Blog URL Claim my comments! Why? | Login Your OpenID * Claim my comments! Why? | Login Submit Comment Or post using OpenID Go back Get better comments for your blog Go to Intense Debate Posting AnonymouslyEnter text right here! Name * Email (track replies) Blog URL Claim my comments! Why? | Login OpenID URL * Claim my comments! Why? | Login Cancel | Submit Comment Or post using OpenID Go back
About Me
Matt Topper
Email: matt@matttopper.com
Phone: 586.855.4595
Disclaimer
The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.
Calendar
April 2008 S M T W T F S
« Jan
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Categories
Auto Industry
BI Server
BIEE
Business Intelligence
Data Integrator
Discoverer
General
Identity Management
MapViewer / GIS
Music
ora-click
Oracle
Oracle Access Manager
Oracle Adaptive Access Manger (OAAM)
Oracle Identity Manager
Oracle Virtual Directory
Personal
Portal
Technology
VMWare
Archives:
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
June 2007
May 2007
April 2007
March 2007
January 2007
October 2006
September 2006
July 2006
June 2006
May 2006
April 2006
November 2005
October 2005
September 2005
August 2005
June 2005
January 2005
December 2004
Links
Meta:
Login
RSS
Comments RSS
Valid XHTML
WP
Copyright © 2004 - 2006 Matt Topper 22 queries. 0.923 seconds.
ERP導入の一般的な流れ
http://www.thinkit.co.jp/cert/article/0607/9/1/3.htm
№ 導入作業 内容 アウトプット
1 社内プロジェクト発足 業務改善プロジェクトなどの名称でチーム編成(必要に応じコンサルタント依頼) プロジェクト計画書
社内ヒアリング 目標設定・問題点分析・課題洗い出し・解決案策定などによりあるべき姿を定義する 業務分析報告書
概要計画書など
RFP作成 概要計画書に基づき提案依頼書(RFP:Request for Proposal)を作成 RFP
ベンダ選択 各ベンダの提案説明を受け、もっとも適切と思われる提案ベンダを選定 評価シート
比較表など
2 要件定義 業務フロー作成、Fit&Gap分析などにより新しい業務想定とカスタマイズ作業の把握を行う 新業務フロー
Fit&Gap分析シート
要件定義書
見積(再見積) 要件定義の結果をもとに費用を再見積 見積書
3 基本(外部)設計 ユーザが新システム概要を確認できるように修正・追加機能の基本設計 基本設計書
4 詳細(内部)設計 基本設計書に基づき、プログラマが製造できるような情報を付加 詳細設計書
5 製造 修正・追加機能のプログラミングおよび単体テスト、各種パラメータ設定など プログラム
単体テスト仕様書
テスト結果報告書
6 結合テスト 基本設計書に書かれた機能要件を満たすことを確認 結合テスト仕様書
テスト結果報告書
7 総合(運用)テスト 本番環境を使って、新システムが実運用に支障がないことを確認 総合テスト仕様書
テスト結果報告書
8 本番稼動 新システムの本番稼動
№ 導入作業 内容 アウトプット
1 社内プロジェクト発足 業務改善プロジェクトなどの名称でチーム編成(必要に応じコンサルタント依頼) プロジェクト計画書
社内ヒアリング 目標設定・問題点分析・課題洗い出し・解決案策定などによりあるべき姿を定義する 業務分析報告書
概要計画書など
RFP作成 概要計画書に基づき提案依頼書(RFP:Request for Proposal)を作成 RFP
ベンダ選択 各ベンダの提案説明を受け、もっとも適切と思われる提案ベンダを選定 評価シート
比較表など
2 要件定義 業務フロー作成、Fit&Gap分析などにより新しい業務想定とカスタマイズ作業の把握を行う 新業務フロー
Fit&Gap分析シート
要件定義書
見積(再見積) 要件定義の結果をもとに費用を再見積 見積書
3 基本(外部)設計 ユーザが新システム概要を確認できるように修正・追加機能の基本設計 基本設計書
4 詳細(内部)設計 基本設計書に基づき、プログラマが製造できるような情報を付加 詳細設計書
5 製造 修正・追加機能のプログラミングおよび単体テスト、各種パラメータ設定など プログラム
単体テスト仕様書
テスト結果報告書
6 結合テスト 基本設計書に書かれた機能要件を満たすことを確認 結合テスト仕様書
テスト結果報告書
7 総合(運用)テスト 本番環境を使って、新システムが実運用に支障がないことを確認 総合テスト仕様書
テスト結果報告書
8 本番稼動 新システムの本番稼動
2008年4月23日水曜日
hibernateを利用してはいけない5つのシチュエーション
hibernateを利用してはいけない5つのシチュエーション
世の中はhibernate礼賛のサイトが沢山あります。
O/Rの中ではバラ色の世界が広がっているように錯覚してしまいます。
しかし実際にマジに使用すると、ひどい目に遭う局面が沢山あります。
-- 2007/01/16 追記
ここに情報を探しにきているようなひとは、悪いこと言いませんのでhibernateの採用を中止しなさい。
利用しだしていても、今引き返した方が工数が減ります。間違いない。1年以上経った今でも、hibernateのオニモツ加減には慣れません。
-- 2007/01/16 追記ここまで
-- ここから追記
下記(特にシチュエーション4)について、再検証を行う必要がありそうです。
必ず、koichikさんのブログを併読してください。
http://d.hatena.ne.jp/koichik/20051002#1128268814
http://d.hatena.ne.jp/koichik/20051003#1128358837
http://d.hatena.ne.jp/koichik/20051004#1128448836
http://d.hatena.ne.jp/koichik/20051005#1128535243
http://d.hatena.ne.jp/koichik/20051006#1128621631
http://d.hatena.ne.jp/koichik/20051007#1128711612
再検証はもうしばらくお待ちください。
-- ここまで追記
2005/10/22 追記ここから
こちらもご覧ください。シチュエーション4はhibernateの使用方法が誤っていたために発生していたものです。
2005/10/22 追記ここまで
2005/12/22 追記ここから
シチュエーション4はhibernateの使用法が間違っていたために発生していた物ですが、
結局1つのプロジェクトコードにはhibernateバッドノウハウが満載になってしまいました。
単純な登録・変更・削除・検索を行うような物以外で使用する際には事前調査に相当の時間をかけた方がよいです。
SQL実行のタイミングがシビアなプロジェクトではつらいかも・・・
2005/12/22 追記ここまで
hibernateについての基礎知識
hibernateはJavaの世界で用いられているO/Rマッピングツールです。
マッピングファイル無しのannotationによる設定も可能で、EJB3の先取りとも言われています。
データベースとのやりとりには、SQLに似せたHQLという言語を用います。HQLはSQLのデータベース毎の方言による違いを吸収するためのものです。
また、HQLのほかにCriteriaというオブジェクト指向的な手法で条件を組み立てることも、部分的に直SQLを用いることも出来ます。
実際のデータベースのやりとり部分にはPreparedStatementを使用しますが、部分的に文字列の連結を行っています(いるように見えます)。
テーブル同士が関連を持つように、マッピングされるオブジェクトについても関連を定義することが出来ます。
関連を定義することによって、各オブジェクトから関連するオブジェクトを取り出すことが出来ます。
関連の取得(Select)は、必要時(メソッド呼び出し時)に行われます(これをLazyローディングといいます)。
シチュエーション1 表示層(ビュー)がHTMLでない場合
表示層に当たる部分がWebサービスであったり、Flash(Flex)と連携をする場合には、使用をしない方がよいでしょう。
基礎知識でふれたLazyローディングが悪さをします。
Lazyローディング自体は悪くないのですが、hibernateはデータベースを扱うコンポーネントであるが故の問題を抱えています。
それはある接続セッションで取得したオブジェクトに関連するオブジェクトの取得は、同一接続セッションを通して行わなければいけないという物です(違反をすると例外が発生します)。
接続セッションが違えばデータベースの状態が違うため思想としては間違っていないのですが、Webアプリケーションの設計的には、接続セッションを表示層まで閉じずに持って行くことは無いでしょう。
この制限を回避するためにとる方法としてとることの出来る手法が四つあります(四つとも全然いけていませんが)。
Lazyローディングをしない設定にする。
表示層で利用する関連については、制御層(コントローラ)で先に呼び出しておく
マッピングオブジェクトを本当のPOJOにコピーして表示層に渡す
関連の設定を削除する
HTMLを表示層に利用する場合は、おそらくもっとも現実的な2(この選択をした場合でも表示層の変更のために制御層を修正する必要がある)を選択することになるとおもいますが、
WebサービスやFlash(Flex)との連携では表示層に渡されるオブジェクトのパブリックなアクセサが全て呼び出されるため、2の選択肢は利用できません。
残る選択肢に関しても、1はある程度の規模のデータベースではあり得ませんし、3もリストを毎回POJOに(しかも必要な関連のオブジェクトも含め)コピーするのは考えたくもありません。
で、結局4にするのですが、hibenateでは関連のないテーブルとはJOINできなかったりします(つまり他の関連テーブルの情報を用いてレコードを抽出することが出来ません)。
これで残る選択肢は無くなりました。
2005/10/22 追記
3を選ぶべきでした。こちらもご覧ください。
追記ここまで
シチュエーション2 Torque等のCriteria系になれている場合
hibernateのCriteriaはおまけ程度です(公式ドキュメントにもそう書いてある)。
ちょっと複雑になると対処できません(Join一つとってもver2のころはaddJoinという直感的な物があったようですが、ver3のJoinは何?ま、関連を削除した時点で利用できませんが)。
Torqueでは非常に簡単にできたのに・・・と泣くことになりますので、hibernateの使用は避けましょう。
シチュエーション3 データベースの複数対応が必要ない場合
シチュエーション2から考えても、hibernateはHQLを使う物のようです。
HQLはSQLの方言を吸収するためのものですが、データベースの複数対応が必要ない場合には、大抵のSQLの方言よりひどい方言を学ぶことになります。
hibernateの使用は避けましょう。
シチュエーション4 データベース側にロジックが存在する場合
hibernateでTransactionを使用すると、同一Transaction内でセレクトした全てのオブジェクトをTransactionコミット時に勝手に更新します。
2005/10/22 追記
特定の条件でのみ同一Transaction内でセレクトした一部のオブジェクトをTransactionコミット時に更新します。もし同様の症状にはまっている場合はこちらもご覧ください。
追記ここまで
は?と思われる方は少数だと思います。上記の文章が何を意味しているのかが理解できない方の方が大多数でしょう。
次のような状況を想像してください。
あるデータ(A)の更新系の処理を行うために、トランザクションを開始する。
必要な情報の抽出(X)やFK先(Y)の存在チェック(SQL例外に任せる人はいないでしょ?)をTransaction内で行う。
あるデータ(A)をデータベースに登録(あるいは更新)する。
成功したのでトランザクションをコミットする。
このような処理を行った場合に4のタイミングで(A)の登録(あるいは更新)と共に(X)(Y)の抽出されたレコードに対してもアップデート文が発行されます。
抽出しただけで変更を行っていなければまだマシですが、何かの理由で情報が変更されている場合は意識しないうちに更新が行われます。
#変更を行ったとすれば、保存されるのはhibernateの特徴である「session内で取得したオブジェクトに対する変更は、sessionのクローズ時にデータベースに登録される」という変な仕様通りですが。
#DirtyFlagが見あたらないな、と思った時点で気づくべきでした。ありえねー
ここで恐ろしいのは、データベースのonUpdateに(自動的に更新ログをとるような)トリガーが仕掛けられていた場合です。何かしら値が変更された場合のみUpdateを行うように作り込んでいても、
データをセレクトしてしまうだけで勝手に更新されてしまうのです。
また、この自動更新は(データベースの)VIEWに対してもUpdate文が発行されます。VIEWにファンクションによってデータが生成されるカラムがあった場合には、例外が出ます(1日はまりました)。
シチュエーション5 問題にぶつかった際に自己解決出来ない場合
hibernateは礼賛の記事は多いのですが、問題点に関する記事はあまりありません(実際に使われているとは思えない位の量です)。
上記、Transactionを使用した場合にはセレクトした物が全て更新される等の想像外問題について、自分で原因を調査・回避できる自信が無いようでしたら、hibernateの使用は避けましょう。
おまけ 仕方なく使う羽目になってしまった技術者へのほんの少しの情報
Criteria#listをすると空のリストが返ってくる。?DAO#getInstance#getでMappingExceptionが発生する
→hibernate.cfgを確認してください。設定が必要です。
MiddlegenIDEにVIEWが出てこない
→middlegenのbuild.xmlにVIEWの名前を記述してください。
MiddlegenIDEでテーブルが探せない
→あきらめてgenerateしてから手でhbmを修正しましょう。
Criteria#listをするとListにとびとびにオブジェクトが入っている
→VIEWをリバースしたhbmをそのまま(あるいはPKの無いテーブル!)使用していませんか?PKが無い場合は全てのプロパティをあわせてコンポジットIDとしてhbmが作成されます(Middlegen)。
コンポジットIDはPKとしての扱いなので一部でもNullが存在するとオブジェクト自体がNullになってしまうようです(クソ)。
逆にhibernateを使用するといいなというようなシチュエーションは?
→簡単なCMS等、複雑度を持たない物。ただ、そういった物はDjangoやRailsを使用することで、数倍の速度で作成できるでしょう。
上司がhibernateを使うように言ってくる
→阻止してください
世の中はhibernate礼賛のサイトが沢山あります。
O/Rの中ではバラ色の世界が広がっているように錯覚してしまいます。
しかし実際にマジに使用すると、ひどい目に遭う局面が沢山あります。
-- 2007/01/16 追記
ここに情報を探しにきているようなひとは、悪いこと言いませんのでhibernateの採用を中止しなさい。
利用しだしていても、今引き返した方が工数が減ります。間違いない。1年以上経った今でも、hibernateのオニモツ加減には慣れません。
-- 2007/01/16 追記ここまで
-- ここから追記
下記(特にシチュエーション4)について、再検証を行う必要がありそうです。
必ず、koichikさんのブログを併読してください。
http://d.hatena.ne.jp/koichik/20051002#1128268814
http://d.hatena.ne.jp/koichik/20051003#1128358837
http://d.hatena.ne.jp/koichik/20051004#1128448836
http://d.hatena.ne.jp/koichik/20051005#1128535243
http://d.hatena.ne.jp/koichik/20051006#1128621631
http://d.hatena.ne.jp/koichik/20051007#1128711612
再検証はもうしばらくお待ちください。
-- ここまで追記
2005/10/22 追記ここから
こちらもご覧ください。シチュエーション4はhibernateの使用方法が誤っていたために発生していたものです。
2005/10/22 追記ここまで
2005/12/22 追記ここから
シチュエーション4はhibernateの使用法が間違っていたために発生していた物ですが、
結局1つのプロジェクトコードにはhibernateバッドノウハウが満載になってしまいました。
単純な登録・変更・削除・検索を行うような物以外で使用する際には事前調査に相当の時間をかけた方がよいです。
SQL実行のタイミングがシビアなプロジェクトではつらいかも・・・
2005/12/22 追記ここまで
hibernateについての基礎知識
hibernateはJavaの世界で用いられているO/Rマッピングツールです。
マッピングファイル無しのannotationによる設定も可能で、EJB3の先取りとも言われています。
データベースとのやりとりには、SQLに似せたHQLという言語を用います。HQLはSQLのデータベース毎の方言による違いを吸収するためのものです。
また、HQLのほかにCriteriaというオブジェクト指向的な手法で条件を組み立てることも、部分的に直SQLを用いることも出来ます。
実際のデータベースのやりとり部分にはPreparedStatementを使用しますが、部分的に文字列の連結を行っています(いるように見えます)。
テーブル同士が関連を持つように、マッピングされるオブジェクトについても関連を定義することが出来ます。
関連を定義することによって、各オブジェクトから関連するオブジェクトを取り出すことが出来ます。
関連の取得(Select)は、必要時(メソッド呼び出し時)に行われます(これをLazyローディングといいます)。
シチュエーション1 表示層(ビュー)がHTMLでない場合
表示層に当たる部分がWebサービスであったり、Flash(Flex)と連携をする場合には、使用をしない方がよいでしょう。
基礎知識でふれたLazyローディングが悪さをします。
Lazyローディング自体は悪くないのですが、hibernateはデータベースを扱うコンポーネントであるが故の問題を抱えています。
それはある接続セッションで取得したオブジェクトに関連するオブジェクトの取得は、同一接続セッションを通して行わなければいけないという物です(違反をすると例外が発生します)。
接続セッションが違えばデータベースの状態が違うため思想としては間違っていないのですが、Webアプリケーションの設計的には、接続セッションを表示層まで閉じずに持って行くことは無いでしょう。
この制限を回避するためにとる方法としてとることの出来る手法が四つあります(四つとも全然いけていませんが)。
Lazyローディングをしない設定にする。
表示層で利用する関連については、制御層(コントローラ)で先に呼び出しておく
マッピングオブジェクトを本当のPOJOにコピーして表示層に渡す
関連の設定を削除する
HTMLを表示層に利用する場合は、おそらくもっとも現実的な2(この選択をした場合でも表示層の変更のために制御層を修正する必要がある)を選択することになるとおもいますが、
WebサービスやFlash(Flex)との連携では表示層に渡されるオブジェクトのパブリックなアクセサが全て呼び出されるため、2の選択肢は利用できません。
残る選択肢に関しても、1はある程度の規模のデータベースではあり得ませんし、3もリストを毎回POJOに(しかも必要な関連のオブジェクトも含め)コピーするのは考えたくもありません。
で、結局4にするのですが、hibenateでは関連のないテーブルとはJOINできなかったりします(つまり他の関連テーブルの情報を用いてレコードを抽出することが出来ません)。
これで残る選択肢は無くなりました。
2005/10/22 追記
3を選ぶべきでした。こちらもご覧ください。
追記ここまで
シチュエーション2 Torque等のCriteria系になれている場合
hibernateのCriteriaはおまけ程度です(公式ドキュメントにもそう書いてある)。
ちょっと複雑になると対処できません(Join一つとってもver2のころはaddJoinという直感的な物があったようですが、ver3のJoinは何?ま、関連を削除した時点で利用できませんが)。
Torqueでは非常に簡単にできたのに・・・と泣くことになりますので、hibernateの使用は避けましょう。
シチュエーション3 データベースの複数対応が必要ない場合
シチュエーション2から考えても、hibernateはHQLを使う物のようです。
HQLはSQLの方言を吸収するためのものですが、データベースの複数対応が必要ない場合には、大抵のSQLの方言よりひどい方言を学ぶことになります。
hibernateの使用は避けましょう。
シチュエーション4 データベース側にロジックが存在する場合
hibernateでTransactionを使用すると、同一Transaction内でセレクトした全てのオブジェクトをTransactionコミット時に勝手に更新します。
2005/10/22 追記
特定の条件でのみ同一Transaction内でセレクトした一部のオブジェクトをTransactionコミット時に更新します。もし同様の症状にはまっている場合はこちらもご覧ください。
追記ここまで
は?と思われる方は少数だと思います。上記の文章が何を意味しているのかが理解できない方の方が大多数でしょう。
次のような状況を想像してください。
あるデータ(A)の更新系の処理を行うために、トランザクションを開始する。
必要な情報の抽出(X)やFK先(Y)の存在チェック(SQL例外に任せる人はいないでしょ?)をTransaction内で行う。
あるデータ(A)をデータベースに登録(あるいは更新)する。
成功したのでトランザクションをコミットする。
このような処理を行った場合に4のタイミングで(A)の登録(あるいは更新)と共に(X)(Y)の抽出されたレコードに対してもアップデート文が発行されます。
抽出しただけで変更を行っていなければまだマシですが、何かの理由で情報が変更されている場合は意識しないうちに更新が行われます。
#変更を行ったとすれば、保存されるのはhibernateの特徴である「session内で取得したオブジェクトに対する変更は、sessionのクローズ時にデータベースに登録される」という変な仕様通りですが。
#DirtyFlagが見あたらないな、と思った時点で気づくべきでした。ありえねー
ここで恐ろしいのは、データベースのonUpdateに(自動的に更新ログをとるような)トリガーが仕掛けられていた場合です。何かしら値が変更された場合のみUpdateを行うように作り込んでいても、
データをセレクトしてしまうだけで勝手に更新されてしまうのです。
また、この自動更新は(データベースの)VIEWに対してもUpdate文が発行されます。VIEWにファンクションによってデータが生成されるカラムがあった場合には、例外が出ます(1日はまりました)。
シチュエーション5 問題にぶつかった際に自己解決出来ない場合
hibernateは礼賛の記事は多いのですが、問題点に関する記事はあまりありません(実際に使われているとは思えない位の量です)。
上記、Transactionを使用した場合にはセレクトした物が全て更新される等の想像外問題について、自分で原因を調査・回避できる自信が無いようでしたら、hibernateの使用は避けましょう。
おまけ 仕方なく使う羽目になってしまった技術者へのほんの少しの情報
Criteria#listをすると空のリストが返ってくる。?DAO#getInstance#getでMappingExceptionが発生する
→hibernate.cfgを確認してください。設定が必要です。
MiddlegenIDEにVIEWが出てこない
→middlegenのbuild.xmlにVIEWの名前を記述してください。
MiddlegenIDEでテーブルが探せない
→あきらめてgenerateしてから手でhbmを修正しましょう。
Criteria#listをするとListにとびとびにオブジェクトが入っている
→VIEWをリバースしたhbmをそのまま(あるいはPKの無いテーブル!)使用していませんか?PKが無い場合は全てのプロパティをあわせてコンポジットIDとしてhbmが作成されます(Middlegen)。
コンポジットIDはPKとしての扱いなので一部でもNullが存在するとオブジェクト自体がNullになってしまうようです(クソ)。
逆にhibernateを使用するといいなというようなシチュエーションは?
→簡単なCMS等、複雑度を持たない物。ただ、そういった物はDjangoやRailsを使用することで、数倍の速度で作成できるでしょう。
上司がhibernateを使うように言ってくる
→阻止してください
/projects/workspace/java
>ls
ant apache-tomcat-6.0.16 eclipse jprofiler5 workspace
apache db-derby-10.3.1.4 jboss struts2
>
(1)ant
(2)apache-tomcat:it can run only on console,it cant integrate into eclipse
(3)eclipse
plugin:jadEclipse
jboss-tools(hibernate,seam,jpdl desinger,pageflow desinger)
(4)jprofiler5:evaluate version,you can aquire serial number from maker for evaluate use
(5)jboss:jboss AS4 ,seam2.0.1
(6)workspace:java puff include seam ,hibernate,jsf....
above all,other puff is mysql ministrator tools at tools diretory
>ls
ant apache-tomcat-6.0.16 eclipse jprofiler5 workspace
apache db-derby-10.3.1.4 jboss struts2
>
(1)ant
(2)apache-tomcat:it can run only on console,it cant integrate into eclipse
(3)eclipse
plugin:jadEclipse
jboss-tools(hibernate,seam,jpdl desinger,pageflow desinger)
(4)jprofiler5:evaluate version,you can aquire serial number from maker for evaluate use
(5)jboss:jboss AS4 ,seam2.0.1
(6)workspace:java puff include seam ,hibernate,jsf....
above all,other puff is mysql ministrator tools at tools diretory
mysql(lampp) at ubuntu7.10
you can conf mysql by modifying /opt/lampp/etc/my.cnf
>ls
extra magic old pool.conf
freetds.conf mime.types openldap proftpd.conf
httpd.conf my.cnf openssl.cnf ssl.crt
httpd.conf.bak my.cnf.maold original ssl.key
lampp my.cnf.maold1 pear.conf webalizer.conf
locales.conf my.conf.org php.ini webalizer.conf.sample
>
you can download mysql manager tools from sun homepage and throgh tool,you can modify it too
>ls
extra magic old pool.conf
freetds.conf mime.types openldap proftpd.conf
httpd.conf my.cnf openssl.cnf ssl.crt
httpd.conf.bak my.cnf.maold original ssl.key
lampp my.cnf.maold1 pear.conf webalizer.conf
locales.conf my.conf.org php.ini webalizer.conf.sample
>
you can download mysql manager tools from sun homepage and throgh tool,you can modify it too
登録:
投稿 (Atom)