Raw devices or files? What is better? we can create raw devices and regular files functioning as devices.
Let's start with an example showing how to create a device basing on a file. All what is required to start with the device creation is a folder on file system having enough free space. First decide where to locate the devices. It is not a bad idea to have a dedicated folder for file devices. Because data files and log files are used differently you should probably think about locating files on separate filesystem anyway. Here let's put all the files in the same folder.
[sap@localhost ~]$ pwd /opt/sap [sap@localhost ~]$ mkdir databases [sap@localhost ~]$ cd databases [sap@localhost databases]$ mkdir alfa
Having folder, enough space and read and write permissions there, we can switch to SQL:
Let's interpret meaning of the command:
disk init name ='AlfaDataDev', physname = '/opt/sap/databases/alfa/alfadatadev.dat', size=10240 GO disk init name ='AlfaLogDev', physname = '/opt/sap/databases/alfa/alfalogdev.dat', size=2560, skip_alloc = true GO
Let's interpret meaning of the command:
- disk init is a command used to create devices
- name defines the name of the device. Having that name it will e possible to manipulate an existing device, for example it could be added to the database or it's properties could be changed.Name must be unique on the server. Try to use meaningful names, that point to name of database that will be built on that device.
- physname points to device, in this case this will be a file name. Remember to define this path that way, that user running ASE has full permissions to the folder. However, this is allowed, but rater avoid using relative path here. Try to always put full path here (full path starts always with '/' or disk letter on Windows). On Unix you could also use symbolic links that point to the real file location, what makes your administration more flexible.
- size is the desired size of the device. Here only integer value may be used that defines number of 2KB pages that buid the device. As mentioned earlier if you want to easy recalculate X MB to number of 2KB pages just multiply X * 512. To create a 20MB device you will have 10*512 = 10240 pages. When talking here about pages we mean virtual pages (not logical pages), what means their size is always 2KB. See also Pages in SAP ASE: Virtual and Logical pages Remember also to verify first if the file system is able to accommodate the desired device. If a raw device will be created - use all available space on the device. No other device will be able to use the remaining space, it would be lost!
- skip_alloc - parameter working only on Windows system. If it is false (the default value), space allocated to file will be filled with zeros. If it is set to true, we are skipping that part of file initialization. Setting the value to false (or using default value) may be considered as more secure but also takes more time to create a device, what can be important for very big files.
Additional parameters not used in mentioned command could be:
- vdevno - number assigned to each device. It must be unique and less then value of parameter "number of devices". Parameter value can be changed using procedure sp_configure. In earlier versions of Sybase parameter was required. In newer versions this is calculated by ASE automatically.
- directio - set to true causes data saved on the device bypass OS buffering, what was the biggest disadvantage of file-based device (see Raw devices or files? What is better?).
- There is also another option called dsync. It works very similar as directio because guarantees, that writes made to the OS buffer will be saved on disk before continuing next operations. The difference is that directio bypasses buffers at all and writes directly to the disk (however does not guarantee that write will not be lost), while dsync causes writing to the buffer and forcing OS to synchronize buffer with disk. When synchronization is completed ASE continues next operations. Whenever possible directio should be used. The only difference is master database that has always dsync enabled. Dsync and directio cannot be used simultaneously. You need to decide which parameter you decide to use. Change of that parameters causes ASE needs to be restarted. If you wish to be 100% sure the writes will not be lost use DSYNC, or just raw devices.
Additional info:
No comments:
Post a Comment