[mysql-cluster] 五台電腦安裝步驟

我用的是五台虛擬機器模擬

作業系統用的是debian

Mysql 版本 5.1.26

1. 電腦配置

  • ndb_mgmd     192.168.116.201

  • mysqld 1         192.168.116.202

  • mysqld 2         192.168.116.203

  • ndbd   1           192.168.116.204

  • ndbd   2           192.168.116.205




please install build-essential libncurses5-dev libstdc++5 filst

下載 mysql 5.1.26 的source code

放置於 /usr/src 目錄下 並解壓縮

cd  切換進解壓縮完的目錄

2.編譯設定管理節點

  1. 產生Makefile

    • ./configure --prefix=/usr/local/mysql --enable-community-features --with-mysqld-user=mysql --with-mysqlmanager --with-plugins=ndbcluster



  2. make

    • make



    • make install



  3. 設定執行路徑

    • echo "PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/libexec" >>/root/.bash_profile

    • echo "export PATH">>/root/.bash_profile



  4. 編輯設定檔

    • mkdir /usr/local/mysql/var

    • mkdir /usr/local/mysql/var/mysql-cluster

    • vim /usr/local/mysql/var/mysql-cluster/config.ini

    • 設定檔如下
      ######################################
      [NDBD DEFAULT]
      NoOfReplicas=2
      DataMemory=80M # How much memory to allocate for data storage
      IndexMemory=18M # How much memory to allocate for index storage
      # For DataMemory and IndexMemory, we have used the
      # default values. Since the "world" database takes up
      # only about 500KB, this should be more than enough for
      # this example Cluster setup.
      [MYSQLD DEFAULT]
      [NDB_MGMD DEFAULT]
      [TCP DEFAULT]
      # Section for the cluster management node
      [NDB_MGMD]
      # IP address of the management node (this system)
      HostName=192.168.116.201 # Section for the storage nodes
      [NDBD]
      # IP address of the first storage node
      HostName=192.168.116.204
      DataDir=/usr/local/mysql/var/mysql-cluster
      BackupDataDir=/usr/local/mysql/var/mysql-cluster/backup
      DataMemory=2048M
      [NDBD]
      # IP address of the second storage node
      HostName=192.168.116.205
      DataDir=/usr/local/mysql/var/mysql-cluster
      BackupDataDir=/usr/local/mysql/var/mysql-cluster/backup
      DataMemory=2048M# one [MYSQLD] per storage node
      [MYSQLD]
      HostName=192.168.116.202
      [MYSQLD]
      HostName=192.168.116.203
      ######################################



  5. 啟動管理節點

    • ndb_mgmd -f /usr/local/mysql/var/mysql-cluster/config.ini



  6. 加入開機程序

    • echo '/usr/local/mysql/libexec/ndb_mgmd -f /usr/local/mysql/var/mysql-cluster/config.ini' > /etc/init.d/ndb_mgmd

    • chmod 755 /etc/init.d/ndb_mgmd

    • update-rc.d ndb_mgmd defaults




3.編譯安裝SQL and NDB節點

  1. 產生Makefile

    • ./configure --prefix=/usr/local/mysql --enable-community-features --with-mysqld-user=mysql  --with-plugins=ndbcluster



  2. make

    • make



    • make install



  3. 安裝到目錄

    • /usr/src/mysql-5.1.24-rc/scripts/mysql_install_db --user=mysql (--no-defaults)



  4. 切換使用者權限

    • cd /usr/local/mysql

    • chown -R root:mysql .

    • chown -R mysql.mysql /usr/local/mysql/var



  5. sql加入開機程序

    • cd /usr/src/mysql-5.1.24-rc

    • cp support-files/mysql.server /etc/init.d/

    • chmod 755 /etc/init.d/mysql.server

    • cd /etc/init.d

    • update-rc.d mysql.server defaults



  6. 編輯設定檔

    • vim /etc/my.cnf

    • 設定檔如下
      ######################################
      [client]
      port=3306
      socket=/tmp/mysql.sock
      [mysqld]
      ndbcluster
      # IP address of the cluster management node
      ndb-connectstring=192.168.119.201
      default-storage-engine=NDBCLUSTER#Those are for future tuning
      #max_connections=341
      #query_cache_size=16M
      #thread_concurrency = 4
      [mysql_cluster]
      # IP address of the cluster management node
      ndb-connectstring=192.168.116.201
      ######################################



  7. 設定執行路徑

    • echo "PATH=$PATH:/usr/local/mysql/bin:/usr/local/mysql/libexec" >>/root/.bash_profile

    • export PATH" >>/root/.bash_profile



  8. 啟動

    • mkdir /usr/local/mysql/var/mysql-cluster

    • mkdir /usr/local/mysql/var/mysql-cluster/backup

    • cd /var/lib/mysql-cluster nshowshow

    • (啟動NDB節點)ndbd --initial

    • (啟動SQL節點)/etc/init.d/mysql.server start

    • **ndb要比SQL先啟動 **



  9. 設定密碼

    • mysqladmin -u root password yourrootsqlpassword



  10. ndbd加入開機程序

    • echo '/usr/local/mysql/libexec/ndbd' > /etc/init.d/ndbd

    • chmod 755 /etc/init.d/ndbd

    • update-rc.d ndbd defaults



留言

這個網誌中的熱門文章

電腦網路project