Monday, April 30, 2012

Installing MySQL on Linux (centOS)


Following are steps to install MySQL on CenOS 5/6.

  1. Check the OS Versions and download respective installables from Oracle / Mysql Sites.
    1. cat /proc/version
    2. cat /etc/issue
    3. cat /etc/redhat-release
    4. lsb_release -a
  2. For my CentOS system download following to your Linux System:
    Output of $ lsb_release -a
    1. MySQL Cluster 7.3.4 RPM for Oracle Linux / RHEL 6 x86 (64bit) V43767-01 330M
    2. MySQL Cluster Manager 1.3.0+Cluster RPM for Oracle Linux/RHEL 5+6 x86 (64bit) V42979-01 140M
    3. or download: MySQL-Cluster-gpl-7.3.5-1.rhel5.x86_64.rpm-bundle.tar
  3. Important RPM Command for Installing RPM Package.
    1. Install: $ rpm -ivh mcm-1.3.0-cluster-7.3.3-linux-rhel5-x86-64bit.rpm
      1. -i : install a package
      2. -v : verbose for a nicer display
      3. -h : print hash mark as the package archive is unpacked.
    2. Check Signature: $ rpm --checksig mcm-1.3.0-cluster-7.3.3-linux-rhel5-x86-64bit.rpm
    3. Check dependency of rpm package before installing:[rpm -qPR *.rpm]
      1. -q: query a package
      2. -p: list capabilities this package provides
      3. -R: list capabilities on which this package depends
    4. Install a RPM package without dependencies: [rpm -ivh --nodeps *.rpm]
    5. Check an install rpm package: rpm -q mysql
    6. List (query list) all files of an installed rpm package: [ $ rpm -ql mysql]
    7. List recently installed rpm packages: [$ rpm -qa --last]
    8. List all installed rpm packages: [$ rpm -qa]
    9. Upgrade a rpm package: [rpm -Uvh *.rpm]
    10. Remove a package: [$ rpm -evv mysql]
    11. Remove a rpm package without dependencies: [$ rpm -ev --nodeps mysql]
    12. Query a file that belongs which rpm package: [$ rpm -qf /usr/bin/htpasswd]
    13. Query an info for installed rpm package: [ $ rpm -qi mysql]
    14. Get info of rpm package before installing: [ $ rpm -qip *mysql*.rpm] # query info package
    15. Query documentation of installed RPM Package: [ $ rpm -qdf /usr/bin/vmstat] (query document file)
    16. Verify a RPM package: (verify package) $ rpm -vP *mysql*.rpm
    17. Verify all RPM package: rpm -Va
    18. Import RPM GPG Key: $ rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-CENTOS-6
    19. List all imported RPM GPG Key: ( $ rpm -qa gpg-pubkey*)
    20. Rebuild corrupted RPM database: Sometimes rpm database gets corrupted and stops all the functionality of RPM and other applications on the system, so at that time we need to rebuild the RPM Database and restore it with the help of following commands:
      1. cd /var/lib
      2. rm __db*
      3. rpm --rebuilddb
      4. rpmdb_verify Packages
  4. Installation Steps:
    1. Create required users / group on CentOS & unarchive file on all hosts:
      1. $ groupadd mysql
      2. $ useradd –g mysql mysql
      3. Artifacts.
        1. tar –zxvf  /usr/local/ mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64.tar.gz or
        2. tar -zvf /usr/local/ MySQL-Cluster-gpl-7.3.5-1.rhel5.x86_64.rpm-bundle.tar [ wget http://cdn.mysql.com/Downloads/MySQL-Cluster-7.3/MySQL-Cluster-gpl-7.3.5-1.rhel5.x86_64.rpm-bundle.tar to download file]
      4. mv /usr/local/ mysql-cluster-gpl-7.3.2-linux-glibc2.5-x86_64 /opt/mysql_cluster
      5. chown mysql.mysql –R /opt/mysql_cluster
    2. We have list of following Servers:
      1. 10.253.92.154 - ndb(192.168.1.196) & mgm (192.168.1.144)
      2. 10.253.92.155 - ndb(192.168.1.197)
      3. 10.252.168.174 - mysql (192.168.1.152)
      4. 10.252.168.173 - mysql (192.168.1.193)
    3. On Server '10.253.92.154' & '10.253.92.155' create a new folder - Data Node.
      1. mkdir  /opt/mysql_cluster/ndbdata
      2. chown mysql.mysql –R /opt/mysql_cluster
    4.  MGM Node: (10.253.92.154) configuration:
      1.  cd /opt/mysql_cluster/ 
      2. vi config.ini
    5. Install and configure mysql on two mysqld node (10.252.168.173, 10.252.168.174)
      1. cd /opt/mysql_cluster/
      2. scripts/mysql_cluster_install --user=mysql --datadir=/opt/mysql_cluster/data --basedir=/opt/mysql_cluster/
      3. mv /opt/mysql_cluster/my.cnf /etc/my.cnf
      4. vi /etc/my.cnf 
      5. Modify the /opt/mysql_cluster/support-files/mysql.server, replace datadir and basedir
        1. datadir=/opt/mysql_cluster/data
        2. basedir=/opt/mysql_cluster/
    6. Start all cluster and mgm node:
      1. Startup data node(10.253.92.154, 10.253.92.155)
      2. [root@Node1]# /opt/mysql_cluster/bin/ndbd --defaults-file=/opt/mysql_cluster/my.cnf --initial
      3. 2013-10-02 13:17:36 [ndbd] INFO     -- Angel connected to '10.253.92.154:1186'
      4. 2013-10-02 13:17:36 [ndbd] INFO     -- Angel allocated nodeid: 11
      5. Startup mysqld node(10.252.168.173, 10.252.168.174)
      6. Startup the mgm node:
        1. /opt/mysql_cluster/bin/ndb_mgmd -f /opt/mysql_cluster/config.ini --configdir=/opt/mysql_cluster
    7. Check status:

No comments:

Post a Comment