Introduction I am going to talk about three servers, Server 1 192.168.0.1 Server 2 192.168.0.2 Server 3 192.168.0.3 Servers 1 and 2 will be the two that end up "clustered". Each of them will have mysql client and ndb installed on it. (ndb is the storage node). Server 3 will have the management node installed on it. Install MySQL on Server 1 and Server 2
groupadd mysql useradd -g mysql mysql cd /usr/local/ wget http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-max-5.0.15-linux-i686-glibc23.tar.gz /from/http://mirror.trouble-free.net/mysql_mirror/ tar -zxvf mysql-max-5.0.15-linux-i686-glibc23.tar.gz rm mysql-max-5.0.15-linux-i686-glibc23.tar.gz ln -s mysql-max-5.0.15-linux-i686-glibc23 mysql cd mysql scripts/mysql_install_db --user=mysql chown -R root . chown -R mysql data chgrp -R mysql . cp support-files/mysql.server /etc/rc.d/init.d/ chmod +x /etc/rc.d/init.d/mysql.server chkconfig --add mysql.server Install and configure the managment server
cd /tmp http://dev.mysql.com/get/Downloads/MySQL-4.1/mysql-max-5.0.15-pc-linux-gnu-i686.tar.gz/ from/http://www.signal42.com/mirrors/mysql/ tar -zxvf mysql-max-5.0.15-pc-linux-gnu-i686.tar.gz cd mysql-max-5.0.15-pc-linux-gnu-i686 mv bin/ndb_mgm . mv bin/ndb_mgmd . chmod +x ndb_mg* mv ndb_mg* /usr/bin/
mkdir /var/lib/mysql-cluster cd /var/lib/mysql-cluster vi config.ini
[NDBD DEFAULT] NoOfReplicas=2 [MYSQLD DEFAULT] [NDB_MGMD DEFAULT] [TCP DEFAULT] # Managment Server [NDB_MGMD] # the IP of THIS SERVER HostName=192.168.0.3 # Storage Engines [NDBD] # the IP of the FIRST SERVER (STORAGE NODE) HostName=192.168.0.1 DataDir= /var/lib/mysql-cluster [NDBD] # the IP of the SECOND SERVER (STORAGE NODE) HostName=192.168.0.2 DataDir=/var/lib/mysql-cluster # 2 MySQL Clients # I personally leave this blank to allow rapid changes of the mysql clients; # you can enter the hostnames of the above two servers here. I suggest you dont. [MYSQLD] [MYSQLD]
Configure the storage/SQL servers and start MySQL
vi /etc/my.cnf
[mysqld] ndbcluster # the IP of the MANAGMENT (THIRD) SERVER ndb-connectstring=192.168.0.3 [mysql_cluster] # the IP of the MANAGMENT (THIRD) SERVER ndb-connectstring=192.168.0.3
mkdir /var/lib/mysql-cluster cd /var/lib/mysql-cluster /usr/local/mysql/bin/ndbd --initial /etc/rc.d/init.d/mysql.server start If you have done one server now go back to the start of stage 3 and repeat exactly the same procedure on the second server. NOTE that you should ONLY use --initial if you are either starting from scratch or have changed the config.ini file on the managment. Check if its working You can now return to the managment server (Server 3) and enter the managment console: /usr/local/mysql/bin/ndb_mgm Enter the command SHOW to see what is going on. A sample output looks like this: [root@mysql3 mysql-cluster]# /usr/local/mysql/bin/ndb_mgm -- NDB Cluster -- Management Client -- ndb_mgm> show Connected to Management Server at: localhost:1186 Cluster Configuration --------------------- [ndbd(NDB)] 2 node(s) id=2 @192.168.0.1 (Version: 5.0.15, Nodegroup: 0, Master) id=3 @192.168.0.2 (Version: 5.0.15, Nodegroup: 0) [ndb_mgmd(MGM)] 1 node(s) id=1 @192.168.0.3 (Version: 5.0.15) [mysqld(API)] 2 node(s) id=4 (Version: 5.0.15) id=5 (Version: 5.0.15) ndb_mgm> If you see not connected, accepting connect from 192.168.0.[1/2/3] In the first or last two lines they you have a problem. If you are OK to here it is time to test mysql. On either server Server 1 or Server 2 enter the following commands: Note that we have no root password yet. mysql use test; CREATE TABLE ctest (i INT) ENGINE=NDBCLUSTER; INSERT INTO ctest () VALUES (1); SELECT * FROM ctest; You should see 1 row returned (with the value 1). If this works, now go to the other server and run the same SELECT and see what you get. Insert from that host and go back to host 1 and see if it works. If it works then congratulations. The final test is to kill one server to see what happens. If you have physical access to the machine simply unplug its network cable and see if the other server keeps on going fine (try the SELECT query). If you dont have physical access do the following: ps aux | grep ndbd You get an output like this: root 5578 0.0 0.3 6220 1964 ? S 03:14 0:00 ndbd root 5579 0.0 20.4 492072 102828 ? R 03:14 0:04 ndbd root 23532 0.0 0.1 3680 684 pts/1 S 07:59 0:00 grep ndbd In this case ignore the command "grep ndbd" (the last line) but kill the first two processes by issuing the command kill -9 pid pid: kill -9 5578 5579 Then try the select on the other server. While you are at it run a SHOW command on the managment node to see that the server has died. To restart it, just issue ndbd NOTE no --inital! Putting initial will clear the database Issues If a node goes down. Restart that node from the server the node resides in. Steps given below. (http://bugs.mysql.com/bug.php?id=23121)
If any issues arise try killing all the processes used for clustering. That is ndbd, ndb_mgmd, ndb_mdm and mysql.server. Bring the processes of Server 1, Server 2 and Server 3 down. Then start them back up. To locate processes use ps aux | grep ndb Processes ndbd is for the storage node mysql.server is for the mysql server ndb_mgmd is for the management node Sources http://www.davz.net/static/howto/mysqlcluster |
Thursday, September 16, 2010
Wednesday, September 1, 2010
Recover GRUB menu after Ubuntu 9.10 update
A couple the GRUB menu got screwed up after an update. The recover process can be found here. But I had to take a couple additional steps to fix my GRUB.
- Figure what your where your /boot and /root partition is installed in. My /boot was /dev/sdc2 and /root was /dev/sdc3.
- Mount /root to /mnt using sudo mount /dev/sdc3 /mnt
- Mount /boot to /mnt/boot using
mount /dev/sdc2 /mnt/boot.
NOTE: If both /root and /boot are on the same partition then you only have to mount the /root partition. - Check /mnt/boot/grub/device.map for an entry for /dev/sdc.
- If /dev/sdc does not exist, then add it using vi. For example, the entries in mine were
(hd0) /dev/sda
(hd1) /dev/sdb
So I added (hd2) /dev/sdc to list. - If this was not added to the list, the /root partition will not be found and the grub recovery will fail.
- Next re-install the grub by executing
sudo grub-install --root-directory=/mnt /dev/sdc - Reboot
- Refresh the GRUB 2 menu by executing update-grub2
Wednesday, July 14, 2010
CentOS static routes
Temporary Static Route
Use the route command to add a static route. route add -host 192.168.1.2 gw 192.168.50.254 dev eth0:0 (eth0:0 is virtual interface)
Permanent Static Route
echo "192.168.1.2/32 via 192.168.50.254" >> /etc/sysconfig/network-scripts/eth0:0
In both the cases above all requests to 192.168.1.2 will be routed via gateway 192.168.50.254 and device eth0:0
Friday, April 23, 2010
Install/Uninstall GlassFish on Linux
Uninstalling Glassfish V2 and installing Glassfish V3
Glassfish can be installed with the file-based installer or the JAR-based installer.
Uninstall instructions from SUN
Installtion instruction from SUN
Installing Glassfish
File-based
JAR-based
Uninstalling Glassfish
File-based
JAR-based and Zip
Glassfish can be installed with the file-based installer or the JAR-based installer.
Uninstall instructions from SUN
Installtion instruction from SUN
Installing Glassfish
File-based
- Download the file from
- chmod +x sges-glassfish-v3-unix.sh
- Create the installation directory: mkdir /usr/glassfish
- Navigate to where sges-glassfish-v3-unix.sh file exists.
- Run ./sges-glassfish-v3-unix.sh
- Follow the instructions.
- Download the file from
- Create the installation directory: mkdir /usr/glassfish
- Unzip contents to installation directory: unzip sges-v3-unix.zip
JAR-based
Uninstalling Glassfish
File-based
-
Navigate to your Enterprise Server installation directory.
-
Invoke the uninstallation program as follows:
-
To use the uninstallation in GUI mode, type:
./uninstall
-
To use the uninstallation in command-line mode, type:
./uninstall -console
-
JAR-based and Zip
-
Change to the directory containing the glassfish directory.
-
Run the following command: rm —r glassfish.
Installing Apache Tomcat
- Download the latest stable release of tomcat from the tomcat website.
- Extract it to the required root directory. In our case it is /usr/tomcat/
- tar -xzf /apache-tomcat-6.0.20.tar.gz -C /usr/tomcat/
- NOTE: /usr/tomcat directory has to be created.
- Create a symbolic from /usr/tomcat/apache-tomcat-6.0.20 to latest. Commands shown below.
- cd /usr/tomcat
- ln -s apache-tomcat-6.0.20 latest
- Add CATALINA_HOME = /usr/tomcat/latest to /etc/profiles.
- Execute the following command after the changes to /etc/profiles has been made.
- source /etc/profiles
Java changing the default JRE
If you installed a new version of the JDK or JRE you may need to run the following commands to change the default JRE. Use java -version or the command below to determine which JRE the system is currently using.
- Run the following command to determine the default jre being used by the system.
- /usr/sbin/alternatives --config java
- If the JRE used is not the one from the JDK execute the following command so that the default JRE is the one that belongs to the JDK.
- /usr/sbin/alternatives --install /usr/bin/java java /usr/java/jdk1.6.0_16/bin/java 2
Java JDK vs SDK
JDK is a subset of the SDK. The SDK seems to contain Sun application servers (Glassfish, Tutorials, etc) refer here in addition to the contents of the SDK.
Both JRE and JDK come with the JRE (Java RunTime Environment). The JRE is required execute simple "Hello World" programs were as the JDK/SDK is required for Enterprise level development (Servlets, JavaMail etc)
Both JRE and JDK come with the JRE (Java RunTime Environment). The JRE is required execute simple "Hello World" programs were as the JDK/SDK is required for Enterprise level development (Servlets, JavaMail etc)
Thursday, April 22, 2010
Install/Uninstall Java on Linux
These commands were tested on CentOS 5.3
Installing Java
RPM Users
Install
Remove Java
NON-RPM Users
Install
Remove Java
Remember to remove the system or update the system variable JAVA_HOME. (The /etc/profile file for CentOS users).
Overview of JDK and JRE file structure here
Installing Java
- Download the latest stable JDK from here.
- RPM users (CentOS, RedHat, Fedora) should use the RPM builds.
- Non-RPM users (Debian, Ubuntu) should use the self extracting binary file.
- Remove the existing Java version.
- Install new Java version.
RPM Users
Install
- The RPM file I am using is jdk-6u
20-linux-x64-rpm.bin. - chmod +x jdk-6u
20-linux-x64-rpm.bin ./jdk-6u 20-linux-x64-rpm.bin
Remove Java
- In this example I am uninstalling jdk-6u16.
rpm -e sun-javadb-common-10.4.2-1.1 sun-javadb-client-10.4.2-1.1 sun-javadb-demo-10.4.2-1.1 sun-javadb-docs-10.4.2-1.1 jdk-1.6.0_16-fcs - This everything that was installed by the jdk-6u-linux-x64-rpm.bin package.
NON-RPM Users
Install
- chmod +x jdk-6u20
-linux-x64-bin ./jdk-6u 20-linux-x64-.bin
- Find the installation directory. Assume it is installed in /usr/java/jdk1.6.0_16
- Since this was a self extracting install all you have to do is remove the directory and its contents using the command shown below.
- rm -rf /usr/java/jdk1.6.0_16
Remember to remove the system or update the system variable JAVA_HOME. (The /etc/profile file for CentOS users).
Overview of JDK and JRE file structure here
MySQL Clustering on CentOS 5.2
Subscribe to:
Posts (Atom)