Pre-Configuration Requirements
##################################
Assign hostname node01 to primary node with IP address 192.168.10.50
Assign hostname node02 to slave node with IP address 192.168.10.51
Assume 192.168.10.52 is the virtual IP address that will be used for our Apache webserver.
Install Heartbeat
yum install heartbeat-devel
######################################
Now we have to configure heartbeat on node01 and node02
Main files
1, authkeys
2, ha.cf
3, haresources
Just copy all the files from
cp /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d/
cp /usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d/
Configure heartbeat
vi /etc/ha.d/authkeys
Then add the following lines
auth 2
2 sha1 test-ha
change the permission
chmo 600 /etc/ha.d/authkeys
vi /etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth0
udpport 694
auto_failback on
node node01
node node02
:wq!
#######################
vi /etc/ha.d/haresources
Then add the following
node01 192.168.10.52 httpd
:wq!
Copy the /etc/ha.d/ directory from node01 to node02 with scp
scp -r /etc/ha.d/* node02:/etc/ha.d/
#################################
Now edit httpd.conf
vi /etc/httpd/conf/httpd.conf
add this line
Listen 192.168.10.52:80
:wq!
scp httpd.conf node02:/etc/httpd/conf/
now create some test html file on both slave and master
start heartbeat on both system
/etc/init.d/heartbeat start
and then open browser and type http://192.168.10.52/
will b able to see node01 test page
and stop heartbeat on node01 and refresh the browser you will be able to see node02 test page
############################################################################
Tuesday, July 27, 2010
Monday, June 28, 2010
Apache Tomcat On Linux
Download tomcat from http://tomcat.apache.org/
Before we begin, we will need to have a Java installed
[nikhil@bom ~]$ which java
/usr/java/jdk1.5.0_11/bin/java
[nikhil@bom ~]$ cat .bashrc
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=/usr/java/jdk1.5.0_11/bin/:$PATH;export PATH
export JAVA_HOME=/usr/java/jdk1.5.0_11
[nikhil@bom ~]$ mkdir /tomcat
[nikhil@bom ~]$ mkdir /Dowmloads
[nikhil@bom ~]$ mv /Downlods/jakarta-tomcat-Xxxx.tar.gx /opt/tomcat
[nikhil@bom ~]$ tar -xvzf jakarta-tomcat-Xxxxtar.rg
[nikhil@bom ~]$ rm -rf jakarta-tomcat-Xxxxtar.rg
[nikhil@bom ~]$ mv jakarta-tomcat/* .
[nikhil@bom ~]$ rm -rf jakarta-tomcat
Now login to root user and create a user called "tomcat"
[nikhil@bom ~]$ sudo su -
Password:
[nikhil@bom ~]$ sudo su -
Password:
[root@bom ~]# groupadd tomcat
[root@bom ~]# useradd -g tomcat -d /opt/tomcat tomcat
[root@bom ~]# passwd tomcat
[root@bom ~]# chown -R tomcat:tomcat /opt/tomcat
Switch to tomcat user
[root@bom ~]# su - tomcat
Now try to start tomcat with tomcat user
Make sure Java path is correct
[tomcat@bom ~]$ cat .bashrc
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=/usr/java/jdk1.5.0_11/bin/:$PATH;export PATH
export JAVA_HOME=/usr/java/jdk1.5.0_1
xport CATALINA_HOME=/opt/tomcat
[tomcat@bom ~]#sh /opt/tomcat/bin/startup.sh
[tomcat@bom ~]#sh /opt/tomcat/bin/shutdown.sh
###################################################################################
Administering Tomcat
* Server Status application
* Tomcat Administration Tool
* Tomcat Manager
Tomcat Administrator Role admin This is a built-in role.
Tomcat Manager Role manager This is a built-in role.
Tomcat Administrator Username TomcatAdmin
Tomcat Administrator Password passwd
Open with vi $CATALINA_HOME/conf/tomcat-users.xml
tomcat-users>
role rolename="tomcat"/>
role rolename="role1"/>
role rolename="manager"/>
role rolename="admin"/>
user username="tomcat" password="tomcat" roles="tomcat"/>
user username="both" password="tomcat" roles="tomcat,role1"/>
user username="role1" password="tomcat" roles="role1"/>
user username="TomcatAdmin" password="passwd" roles="admin,manager"/>
tomcat-users>
Save the file, start Tomcat and open a browserYou should be able to access the Administartion Tool web application by clicking on the "Tomcat Administration" link on the left sidebar, make sure u have extracted admin tool also to ur $CATALINA_HOME
Before we begin, we will need to have a Java installed
[nikhil@bom ~]$ which java
/usr/java/jdk1.5.0_11/bin/java
[nikhil@bom ~]$ cat .bashrc
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=/usr/java/jdk1.5.0_11/bin/:$PATH;export PATH
export JAVA_HOME=/usr/java/jdk1.5.0_11
[nikhil@bom ~]$ mkdir /tomcat
[nikhil@bom ~]$ mkdir /Dowmloads
[nikhil@bom ~]$ mv /Downlods/jakarta-tomcat-Xxxx.tar.gx /opt/tomcat
[nikhil@bom ~]$ tar -xvzf jakarta-tomcat-Xxxxtar.rg
[nikhil@bom ~]$ rm -rf jakarta-tomcat-Xxxxtar.rg
[nikhil@bom ~]$ mv jakarta-tomcat/* .
[nikhil@bom ~]$ rm -rf jakarta-tomcat
Now login to root user and create a user called "tomcat"
[nikhil@bom ~]$ sudo su -
Password:
[nikhil@bom ~]$ sudo su -
Password:
[root@bom ~]# groupadd tomcat
[root@bom ~]# useradd -g tomcat -d /opt/tomcat tomcat
[root@bom ~]# passwd tomcat
[root@bom ~]# chown -R tomcat:tomcat /opt/tomcat
Switch to tomcat user
[root@bom ~]# su - tomcat
Now try to start tomcat with tomcat user
Make sure Java path is correct
[tomcat@bom ~]$ cat .bashrc
# .bashrc
# User specific aliases and functions
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=/usr/java/jdk1.5.0_11/bin/:$PATH;export PATH
export JAVA_HOME=/usr/java/jdk1.5.0_1
xport CATALINA_HOME=/opt/tomcat
[tomcat@bom ~]#sh /opt/tomcat/bin/startup.sh
[tomcat@bom ~]#sh /opt/tomcat/bin/shutdown.sh
###################################################################################
Administering Tomcat
* Server Status application
* Tomcat Administration Tool
* Tomcat Manager
Tomcat Administrator Role admin This is a built-in role.
Tomcat Manager Role manager This is a built-in role.
Tomcat Administrator Username TomcatAdmin
Tomcat Administrator Password passwd
Open with vi $CATALINA_HOME/conf/tomcat-users.xml
tomcat-users>
role rolename="tomcat"/>
role rolename="role1"/>
role rolename="manager"/>
role rolename="admin"/>
user username="tomcat" password="tomcat" roles="tomcat"/>
user username="both" password="tomcat" roles="tomcat,role1"/>
user username="role1" password="tomcat" roles="role1"/>
user username="TomcatAdmin" password="passwd" roles="admin,manager"/>
tomcat-users>
Save the file, start Tomcat and open a browserYou should be able to access the Administartion Tool web application by clicking on the "Tomcat Administration" link on the left sidebar, make sure u have extracted admin tool also to ur $CATALINA_HOME
Tuesday, May 18, 2010
kills all pids matching the search word of "PROCESS".
ps -ef | awk '/PROCESS/ && !/awk/ {print $2}' | xargs -r kill -9
Wednesday, April 7, 2010
desktop Icons to have no text
No Text Icons
If you would like your desktop Icons to have no text underneath then try this tweak:
Right click the icon and select "Rename"
Now hold the "Alt" key and type "255" and hit Enter
NOTE : It may only work with the keypad numbers and not the number keys on top of the keyboard.
If you would like your desktop Icons to have no text underneath then try this tweak:
Right click the icon and select "Rename"
Now hold the "Alt" key and type "255" and hit Enter
NOTE : It may only work with the keypad numbers and not the number keys on top of the keyboard.
Wednesday, March 10, 2010
How to Limit Linux CPU Usage Per Process
We can use cpulimit program that attempts to limit the cpu usage of a process. Limits are expressed in percentage and not in cpu time. cpulimit does not act on the nice value or other scheduling priority stuff, but on the real cpu usage. Also, it is able to adapt itself to the overall system load, dynamically and quickly.
########################################################################################
TO INSTALL CPULIMIT
#mkdir /cpulimit
#cd /cpulimit
# wget 'http://downloads.sourceforge.net/cpulimit/cpulimit-1.1.tar.gz'
# tar -zxvf cpulimit-1.1.tar.gz
# cd cpulimit-1.1
# make
# cp cpulimit /usr/local/sbin/
# rm -rf cpulimit*
"gcc" need to be installed
To limit CPU usage of the process called thunderbird to 20%, enter:
# cpulimit -e thunderbird -l 20
# cpulimit -p 1818 -l 20
You can also use absolute path name of the executable, enter:
cpulimit -P /pathto/executablefile -l 20
########################################################################################
TO INSTALL CPULIMIT
#mkdir /cpulimit
#cd /cpulimit
# wget 'http://downloads.sourceforge.net/cpulimit/cpulimit-1.1.tar.gz'
# tar -zxvf cpulimit-1.1.tar.gz
# cd cpulimit-1.1
# make
# cp cpulimit /usr/local/sbin/
# rm -rf cpulimit*
"gcc" need to be installed
To limit CPU usage of the process called thunderbird to 20%, enter:
# cpulimit -e thunderbird -l 20
# cpulimit -p 1818 -l 20
You can also use absolute path name of the executable, enter:
cpulimit -P /pathto/executablefile -l 20
Tuesday, February 16, 2010
This server's clock is not synchronized with the primary domain controller's clock
to set time from primary domain controller
net time /domain:(domain_name) /set
net time /domain:(domain_name) /set
How to backup email acconuts in Microsoft Outlook 2003
locate the following key in registry (start – run – regedit)
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook
Then right click on the key outlook and then go for next option export and save it an backup folder and run in while restoring outlook .
It will restore your old outlook profile with all email accounts and rules but it does not store the user passwords.
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook
Then right click on the key outlook and then go for next option export and save it an backup folder and run in while restoring outlook .
It will restore your old outlook profile with all email accounts and rules but it does not store the user passwords.
Monday, February 15, 2010
SVN COMMANDS
svn checkout/co
svn checkout or svn co. This command is used to pull an SVN tree such as svn://10.0.0.100/trunk/Test from the server. You should only need to do this once. If the directory structure is changed (as is sometimes necessary), you may occasionally need to delete your local sand box and re-check it out.
svn add
svn add. When you are creating a new file or directory, you need to tell the SVN server about it. This command does that. Note that the file won't appear in the repository until you do an svn commit (see below).
svn propset
svn propset. When you are creating a new file or directory, you generally need to tell the SVN to apply properties to the file in places that have keywords in a special format such as $Date: 2007-04-03 14:28:17 -0500 (Tue, 03 Apr 2007) $. Note that the keyword value won't appear in the file until you do an svn commit (see below).
svn delete
svn delete. This does what it says! When you do an svn commit the file will be deleted from your local sand box immediately as well as from the repository after committing.
svn status
svn status. This command prints the status of working directories and files. If you have made local changes, it'll show your locally modified items. If you use the --verbose switch, it will show revision information on every item. With the --show-updates (-u) switch, it will show any server out-of-date information.
You should always do a manual svn status --show-updates before trying to commit changes in order to check that everything is OK and ready to go.
svn update/up
svn update or svn up. This command syncs your local sand box with the server. If you have made local changes, it will try and merge any changes on the server with your changes on your machine.
svn commit/ci
svn commit or svn ci. This command recursively sends your changes to the SVN server. It will commit changed files, added files, and deleted files. Note that you can commit a change to an individual file or changes to files in a specific directory path by adding the name of the file/directory to the end of the command. The -m option should always be used to pass a log message to the command. Please don't use empty log messages (see later in this document the policy which governs the log messages).
svn diff
svn diff. This is useful for two different purposes. First, those without write access to the BLFS SVN server can use it to generate patches to send to the BLFS-Dev mailing list. To do this, simply edit the files in your local sand box then run svn diff > FILE.patch from the root of your BLFS directory. You can then attach this file to a message to the BLFS-Dev mailing list where someone with editing rights can pick it up and apply it to the book. The second use is to find out what has changed between two revisions using: svn diff -r revision1:revision2 FILENAME. For example: svn diff -r 168:169 index.xml will output a diff showing the changes between revisions 168 and 169 of index.xml.
svn move
svn move SRC DEST or svn mv SRC DEST or svn rename SRC DEST or svn ren SRC DEST. This command moves a file from one directory to another or renames a file. The file will be moved on your local sand box immediately as well as on the repository after committing.
svn checkout or svn co. This command is used to pull an SVN tree such as svn://10.0.0.100/trunk/Test from the server. You should only need to do this once. If the directory structure is changed (as is sometimes necessary), you may occasionally need to delete your local sand box and re-check it out.
svn add
svn add. When you are creating a new file or directory, you need to tell the SVN server about it. This command does that. Note that the file won't appear in the repository until you do an svn commit (see below).
svn propset
svn propset. When you are creating a new file or directory, you generally need to tell the SVN to apply properties to the file in places that have keywords in a special format such as $Date: 2007-04-03 14:28:17 -0500 (Tue, 03 Apr 2007) $. Note that the keyword value won't appear in the file until you do an svn commit (see below).
svn delete
svn delete. This does what it says! When you do an svn commit the file will be deleted from your local sand box immediately as well as from the repository after committing.
svn status
svn status. This command prints the status of working directories and files. If you have made local changes, it'll show your locally modified items. If you use the --verbose switch, it will show revision information on every item. With the --show-updates (-u) switch, it will show any server out-of-date information.
You should always do a manual svn status --show-updates before trying to commit changes in order to check that everything is OK and ready to go.
svn update/up
svn update or svn up. This command syncs your local sand box with the server. If you have made local changes, it will try and merge any changes on the server with your changes on your machine.
svn commit/ci
svn commit or svn ci. This command recursively sends your changes to the SVN server. It will commit changed files, added files, and deleted files. Note that you can commit a change to an individual file or changes to files in a specific directory path by adding the name of the file/directory to the end of the command. The -m option should always be used to pass a log message to the command. Please don't use empty log messages (see later in this document the policy which governs the log messages).
svn diff
svn diff. This is useful for two different purposes. First, those without write access to the BLFS SVN server can use it to generate patches to send to the BLFS-Dev mailing list. To do this, simply edit the files in your local sand box then run svn diff > FILE.patch from the root of your BLFS directory. You can then attach this file to a message to the BLFS-Dev mailing list where someone with editing rights can pick it up and apply it to the book. The second use is to find out what has changed between two revisions using: svn diff -r revision1:revision2 FILENAME. For example: svn diff -r 168:169 index.xml will output a diff showing the changes between revisions 168 and 169 of index.xml.
svn move
svn move SRC DEST or svn mv SRC DEST or svn rename SRC DEST or svn ren SRC DEST. This command moves a file from one directory to another or renames a file. The file will be moved on your local sand box immediately as well as on the repository after committing.
Thursday, January 28, 2010
Mount windows Shares with CIFS
Just create a Empty folder, cifs
# mkdir /cifs
mount -t cifs //serverip/sharename /cifs -o
username=shareuser,password=password,domain=somedomain.com
now go to cifs folder and see u can see all content of windows shared folder !
# mkdir /cifs
mount -t cifs //serverip/sharename /cifs -o
username=shareuser,password=password,domain=somedomain.com
now go to cifs folder and see u can see all content of windows shared folder !
Tuesday, November 3, 2009
IIS for WinXP Home
Windows XP Home Edition is not come with IIS service. So for those who need IIS to run on some application, there need go for Windows XP Pro Edition. It’s that great that windows xp home edition is come with IIS service? We still can install the IIS service on Windows XP Home edition as the step below.
1. We need the installation CD of Windows 2000 Professional or Server
2. Copy the directory i386 from the WinXP Home to your hard disk (If you don’t have 2 CD-ROM)
3. In this directory (i386) there is a file called IMS.CAB with WinRar (or something similar) unpack the content to a temporary folder (you will need them at the end of the installation)
4. Search for and find the file: c:\WINDOWS\INF\SYSOC.INF
5. In the section [COMPONENTS] you will find this line: iis=iis.dll,OcEntry,iis.inf,hide,7
6. Change it to this: iis=iis2.dll,OcEntry,iis2.inf,,7 (remember to change the name in iis2.dll and iis2.inf and to eliminate the word hide. In this way you bypass the protection of XP home)
7. From the Win2000 cd (Pro or Server) take the files: iis.dl_ and iis.in_ that are in the i386 folder and copy them on your desktop, open a dos windows and with the prompt pointing at your desktop edit the following commands:
EXPAND IIS.DL_ IIS2.DLL
EXPAND IIS.IN_ IIS2.INF
this will generate two new files named iis2.dll and iis2.inf
copy and paste IIS2:DLL to c:\WINDOWS\SYSTEM32\SETUP\
and IIS.INF to c:\WINDOWS\INF\
8. Go to control panel/application/windows components (I don’t have an English version of Windows so I don’t know exactly the name) and start windows installer. You will see “Internet Information server” is now available as a checkable option.
9. Select it (I suggest that if you are looking only for PWS to select only that because the more components you install the more files you have to search for)
10. It will need about 10/15 minutes and during that time the system is going to ask you for a lot of files: some are in XP Home CD other in Win2000 CD. At a certain point the system will ask you for the EXCH_adsiisex.dll file: it is the file you have extracted at the point 3 of this guide, select it and you should go on without trouble.
11. At the end restart you computer.
12. Test if it is working: open Internet Explorer and type in the address line: http://localhost
13. If it will not work, try the following:
open a DOS window and type: iisreset /RESTART
go to web proprieties in “directory protection” (I don’t know if this is the exact name on an English version) click on “modify” (or edit, as said before I don’t have an English version …) “browse” and finally”find”. You will see all user in your PC. Select the one you are working with and click OK. In the text-box you will see PcName\UserName. Click OK to close the window. Remember to uncheck “password Control) and click OK three times. Close and restart the web server and retry point 12. If all is correct you will see the default presentation page of IIS 5 and the online help
1. We need the installation CD of Windows 2000 Professional or Server
2. Copy the directory i386 from the WinXP Home to your hard disk (If you don’t have 2 CD-ROM)
3. In this directory (i386) there is a file called IMS.CAB with WinRar (or something similar) unpack the content to a temporary folder (you will need them at the end of the installation)
4. Search for and find the file: c:\WINDOWS\INF\SYSOC.INF
5. In the section [COMPONENTS] you will find this line: iis=iis.dll,OcEntry,iis.inf,hide,7
6. Change it to this: iis=iis2.dll,OcEntry,iis2.inf,,7 (remember to change the name in iis2.dll and iis2.inf and to eliminate the word hide. In this way you bypass the protection of XP home)
7. From the Win2000 cd (Pro or Server) take the files: iis.dl_ and iis.in_ that are in the i386 folder and copy them on your desktop, open a dos windows and with the prompt pointing at your desktop edit the following commands:
EXPAND IIS.DL_ IIS2.DLL
EXPAND IIS.IN_ IIS2.INF
this will generate two new files named iis2.dll and iis2.inf
copy and paste IIS2:DLL to c:\WINDOWS\SYSTEM32\SETUP\
and IIS.INF to c:\WINDOWS\INF\
8. Go to control panel/application/windows components (I don’t have an English version of Windows so I don’t know exactly the name) and start windows installer. You will see “Internet Information server” is now available as a checkable option.
9. Select it (I suggest that if you are looking only for PWS to select only that because the more components you install the more files you have to search for)
10. It will need about 10/15 minutes and during that time the system is going to ask you for a lot of files: some are in XP Home CD other in Win2000 CD. At a certain point the system will ask you for the EXCH_adsiisex.dll file: it is the file you have extracted at the point 3 of this guide, select it and you should go on without trouble.
11. At the end restart you computer.
12. Test if it is working: open Internet Explorer and type in the address line: http://localhost
13. If it will not work, try the following:
open a DOS window and type: iisreset /RESTART
go to web proprieties in “directory protection” (I don’t know if this is the exact name on an English version) click on “modify” (or edit, as said before I don’t have an English version …) “browse” and finally”find”. You will see all user in your PC. Select the one you are working with and click OK. In the text-box you will see PcName\UserName. Click OK to close the window. Remember to uncheck “password Control) and click OK three times. Close and restart the web server and retry point 12. If all is correct you will see the default presentation page of IIS 5 and the online help
Tuesday, October 6, 2009
Disable USB Removable Mass Storage Device Drive Access in Windows
- Run Registry Editor (regedit).
- Navigate to the following registery key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UsbStor
- In the right pane, double click on the Start value name.
- Change the value data to 4 to disable the removable USB mass storage device drive access.
- To revert and re-enable the drive access for removable USB mass storage device driver, change back the value data for Start to its original default of 3.
How to Hide and Loch Hardisk Drive In windows
- Click on the "Start" button. Go to "Run", type "gpedit.msc" and press enter.
- Wait for the "Group Policy" window to appear. Click on the "+" button behind "Administrative Templates". Then click the "+" button behind "Windows Components" and then "Windows Explorer".
- Search for "Hide these specified drives in My Computer" in the options that appear in the right column of the window. Double click it, enable it and choose the drive(s) you want to hide.
- Search for "Prevent access to drives from My Computer". Double click it and repeat the previous step if you want to stop accessing any drive by "command" (e.g, by typing "C:" in the address bar or "Run").
- Close the group policy window.
- Restart your computer for changes to take effect.
To Remove Drive Open with option
first go to run then write " regedit" that is registry
then find " ctrl+f"
in this box write "mountpoints2" and delete it ......
then again press "ctrl+f" again find mountpoints2 until all these files are not deleted
then u will see ur problems is solved................
then find " ctrl+f"
in this box write "mountpoints2" and delete it ......
then again press "ctrl+f" again find mountpoints2 until all these files are not deleted
then u will see ur problems is solved................
Saturday, October 3, 2009
How to install + Yum in Red Hat Enterprise Linux 4
Setting up the yum package manager is not required by everyone who downloads and installs Red Hat Enterprise Linux 4. If you will be using your Linux system on the U of S wireless network or other services that use the yum package manager, you need to complete this step. Red Hat Enterprise Linux 5 will use the yum package manager as the standard package manager.
############################################################
Search the packages available from RHN.
yum search wine
Install packages
yum install wine
############################################################
- Download the following rpms from http://dag.wieers.com/packages/
- Install the rpms as root from the command line.
- Add the ATrpms repository to your /etc/yum.conf by adding the following lines
[atrpms]
name=Red Hat Enterprise Linux $releasever - $basearch - ATrpms
baseurl=http://dl.atrpms.net/el4-$basearch/atrpms/stable
gpgkey=http://ATrpms.net/RPM-GPG-KEY.atrpms
gpgcheck=1 - Update the yum database.
# rpm -Uvh python* sqlite* yum* rpmforge-release*
Search the packages available from RHN.
yum search wine
Install packages
yum install wine
What does myisamchk do?
- How do you start and stop MySQL on Windows? - net start MySQL, net stop MySQL
- How do you start MySQL on Linux? - /etc/init.d/mysql start
- Explain the difference between mysql and mysqli interfaces in PHP? - mysqli is the object-oriented version of mysql library functions.
- What’s the default port for MySQL Server? - 3306
- What does tee command do in MySQL? - tee followed by a filename turns on MySQL logging to a specified file. It can be stopped by command notee.
- Can you save your connection settings to a conf file? - Yes, and name it ~/.my.conf. You might want to change the permissions on the file to 600, so that it’s not readable by others.
- How do you change a password for an existing user via mysqladmin? - mysqladmin -u root -p password "newpassword"
- Use mysqldump to create a copy of the database? - mysqldump -h mysqlhost -u username -p mydatabasename > dbdump.sql
- Have you ever used MySQL Administrator and MySQL Query Browser? Describe the tasks you accomplished with these tools.
- What are some good ideas regarding user security in MySQL? - There is no user without a password. There is no user without a user name. There is no user whose Host column contains % (which here indicates that the user can log in from anywhere in the network or the Internet). There are as few users as possible (in the ideal case only root) who have unrestricted access.
- Explain the difference between MyISAM Static and MyISAM Dynamic. - In MyISAM static all the fields have fixed width. The Dynamic MyISAM table would include fields such as TEXT, BLOB, etc. to accommodate the data types with various lengths. MyISAM Static would be easier to restore in case of corruption, since even though you might lose some data, you know exactly where to look for the beginning of the next record.
- What does myisamchk do? - It compressed the MyISAM tables, which reduces their disk usage.
- Explain advantages of InnoDB over MyISAM? - Row-level locking, transactions, foreign key constraints and crash recovery.
- Explain advantages of MyISAM over InnoDB? - Much more conservative approach to disk space management - each MyISAM table is stored in a separate file, which could be compressed then with myisamchk if needed. With InnoDB the tables are stored in tablespace, and not much further optimization is possible. All data except for TEXT and BLOB can occupy 8,000 bytes at most. No full text indexing is available for InnoDB. TRhe COUNT(*)s execute slower than in MyISAM due to tablespace complexity.
- What are HEAP tables in MySQL? - HEAP tables are in-memory. They are usually used for high-speed temporary storage. No TEXT or BLOB fields are allowed within HEAP tables. You can only use the comparison operators = and <=>. HEAP tables do not support AUTO_INCREMENT. Indexes must be NOT NULL.
- How do you control the max size of a HEAP table? - MySQL config variable max_heap_table_size.
- What are CSV tables? - Those are the special tables, data for which is saved into comma-separated values files. They cannot be indexed.
- Explain federated tables. - Introduced in MySQL 5.0, federated tables allow access to the tables located on other databases on other servers.
- What is SERIAL data type in MySQL? - BIGINT NOT NULL PRIMARY KEY AUTO_INCREMENT
- What happens when the column is set to AUTO INCREMENT and you reach the maximum value for that table? - It stops incrementing. It does not overflow to 0 to prevent data losses, but further inserts are going to produce an error, since the key has been used already.
- Explain the difference between BOOL, TINYINT and BIT. - Prior to MySQL 5.0.3: those are all synonyms. After MySQL 5.0.3: BIT data type can store 8 bytes of data and should be used for binary data.
- Explain the difference between FLOAT, DOUBLE and REAL. - FLOATs store floating point numbers with 8 place accuracy and take up 4 bytes. DOUBLEs store floating point numbers with 16 place accuracy and take up 8 bytes. REAL is a synonym of FLOAT for now.
- If you specify the data type as DECIMAL (5,2), what’s the range of values that can go in this table? - 999.99 to -99.99. Note that with the negative number the minus sign is considered one of the digits.
- What happens if a table has one column defined as TIMESTAMP? - That field gets the current timestamp whenever the row gets altered.
- But what if you really want to store the timestamp data, such as the publication date of the article? - Create two columns of type TIMESTAMP and use the second one for your real data.
- Explain data type TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP - The column exhibits the same behavior as a single timestamp column in a table with no other timestamp columns.
- What does TIMESTAMP ON UPDATE CURRENT_TIMESTAMP data type do? - On initialization places a zero in that column, on future updates puts the current value of the timestamp in.
- Explain TIMESTAMP DEFAULT ‘2006:09:02 17:38:44′ ON UPDATE CURRENT_TIMESTAMP. - A default value is used on initialization, a current timestamp is inserted on update of the row.
- If I created a column with data type VARCHAR(3), what would I expect to see in MySQL table? - CHAR(3), since MySQL automatically adjusted the data type.
Subscribe to:
Posts (Atom)