使用軟體架構設計人員權限建立 MySQL 軟體元件,以便將 MySQL 安裝在 vSphere CentOS 機器上。當您為 CentOS 虛擬機器設計 MySQL 軟體元件時,需要設定 Linux 作業系統的安裝、設定、啟動參數和指令碼。

開始之前

程序

  1. 選取設計 > 軟體元件
  2. 按一下新增圖示 (新增)。
  3. 名稱文字方塊中輸入 MySQL for Linux Virtual Machines
  4. 確認識別碼根據提供的名稱填入。

    例如 Software.MySQLforLinuxVirtualMachines

  5. 說明文字方塊中輸入 MySQL installation and configuration
  6. 容器下拉式功能表中選取機器

    由於您只想要 MySQL 直接安裝在機器上,因此您會限制架構設計人員,使其不會將您的 MySQL 軟體 元件放置在其他軟體元件之上。

  7. 下一步
  8. 按一下新增,然後新增和設定安裝指令碼的下列各項內容。

    按一下確定儲存各項內容。

    架構設計人員可以將您的軟體內容設定為在申請表單中對使用者顯示。架構設計人員可以使用 [在申請中顯示] 選項來要求或請求使用者填寫您標記為可覆寫的內容值。

    名稱

    說明

    類型

    已加密

    允許覆寫

    必要

    計算值

    db_root_username

    資料庫根使用者名稱

    字串

    root

    JAVA_HOME

    安裝 JRE 1.8 或更新版本的目錄

    字串

    /opt/vmware-jre

    global_ftp_proxy

    FTP Proxy URL (如有)。非必填項。

    字串

    db_port

    MySQL 資料庫連接埠

    字串

    db_root_password

    資料庫根使用者密碼

    字串

    密碼

    global_http_proxy

    HTTP Proxy URL (如有)。非必填項。

    字串

    global_https_proxy

    HTTPS Proxy URL (如有)。非必填項。

    字串

    max_allowed_packet_size

    伺服器允許封包大小上限

    整數

    1024

  9. 下一步
  10. 設定 [安裝] 動作。
    1. 指令碼類型下拉式功能表中選取 Bash
    2. 按一下按一下這裡編輯
    3. 貼上下列指令碼。
      #!/bin/bash
      
      #Setting proxies
      export ftp_proxy=${ftp_proxy:-$global_ftp_proxy}
      echo "Setting ftp_proxy to $ftp_proxy"
      
      export http_proxy=${http_proxy:-$global_http_proxy}
      echo "Setting http_proxy to $http_proxy"
      
      export https_proxy=${https_proxy:-$global_https_proxy}
      echo "Setting https_proxy to $https_proxy"
      
      #
      # Determine operating system and version 
      #
      export OS=
      export OS_VERSION=
      
      if [ -f /etc/redhat-release ]; then
          # For CentOS the result will be 'CentOS'
          # For RHEL the result will be 'Red'
          OS=$(cat /etc/redhat-release | awk {'print $1'})
      
          if [ -n $OS ] && [ $OS = 'CentOS' ]; then
              OS_VERSION=$(cat /etc/redhat-release | awk '{print $3}')
          else
              # RHEL
              OS_VERSION=$(cat /etc/redhat-release | awk '{print $7}')
          fi
      
      elif [ -f /etc/SuSE-release ]; then
          OS=SuSE
      
          MAJOR_VERSION=$(cat /etc/SuSE-release | grep VERSION | awk '{print $3}')
          PATCHLEVEL=$(cat /etc/SuSE-release | grep PATCHLEVEL | awk '{print $3}')
      
          OS_VERSION="$MAJOR_VERSION.$PATCHLEVEL"
      
      elif [ -f /usr/bin/lsb_release ]; then
          # For Ubuntu the result is 'Ubuntu'
          OS=$(lsb_release -a 2> /dev/null | grep Distributor | awk '{print $3}')
          OS_VERSION=$(lsb_release -a 2> /dev/null | grep Release | awk '{print $2}')
      
      fi
      
      echo "Using operating system '$OS' and version '$OS_VERSION'"
      
      if [ "x${global_http_proxy}" == "x" ] || [ "x${global_https_proxy}" == "x" ] ||
         [ "x${global_ftp_proxy}" == "x" ]; then
         echo ""
         echo "###############################################################"
         echo "#  One or more PROXY(s) not set. Network downloads may fail   #"
         echo "###############################################################"
         echo ""
      fi
      
      export PATH=$PATH:$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      set -e
      
      # Tested on CentOS
      if [ -x /usr/sbin/selinuxenabled ] && /usr/sbin/selinuxenabled; then
          # SELinux can be disabled by setting "/usr/sbin/setenforce Permissive"
          echo 'SELinux in enabled on this VM template.  This service requires SELinux to be disabled to install successfully'
          exit 1
      fi
      
      if [ "x$OS" != "x" ] && [ "$OS" = 'Ubuntu' ]; then
          # Fix the linux-firmware package 
          export DEBIAN_FRONTEND=noninteractive
          apt-get install -y linux-firmware < /dev/console > /dev/console 
          # Install MySQL package 
          apt-get install -y mysql-server
      else 
          yum --nogpgcheck --noplugins -y install -x MySQL-server-community mysql-server
      fi
      
      # Set Install Path to the default install path (For monitoring)
      Install_Path=/usr
      echo Install_Path is set to $Install_Path, please modify this script if the install path is not correct.
    4. 按一下確定
  11. 設定 [設定] 動作。
    1. 指令碼類型下拉式功能表中選取 Bash
    2. 按一下按一下這裡編輯
    3. 貼上下列指令碼。
      #!/bin/bash
      
      #Setting proxies
      export ftp_proxy=${ftp_proxy:-$global_ftp_proxy}
      echo "Setting ftp_proxy to $ftp_proxy"
      
      export http_proxy=${http_proxy:-$global_http_proxy}
      echo "Setting http_proxy to $http_proxy"
      
      export https_proxy=${https_proxy:-$global_https_proxy}
      echo "Setting https_proxy to $https_proxy"
      
      #
      # Determine operating system and version 
      #
      export OS=
      export OS_VERSION=
      
      if [ -f /etc/redhat-release ]; then
          # For CentOS the result will be 'CentOS'
          # For RHEL the result will be 'Red'
          OS=$(cat /etc/redhat-release | awk {'print $1'})
      
          if [ -n $OS ] && [ $OS = 'CentOS' ]; then
              OS_VERSION=$(cat /etc/redhat-release | awk '{print $3}')
          else
              # RHEL
              OS_VERSION=$(cat /etc/redhat-release | awk '{print $7}')
          fi
      
      elif [ -f /etc/SuSE-release ]; then
          OS=SuSE
      
          MAJOR_VERSION=$(cat /etc/SuSE-release | grep VERSION | awk '{print $3}')
          PATCHLEVEL=$(cat /etc/SuSE-release | grep PATCHLEVEL | awk '{print $3}')
      
          OS_VERSION="$MAJOR_VERSION.$PATCHLEVEL"
      
      elif [ -f /usr/bin/lsb_release ]; then
          # For Ubuntu the result is 'Ubuntu'
          OS=$(lsb_release -a 2> /dev/null | grep Distributor | awk '{print $3}')
          OS_VERSION=$(lsb_release -a 2> /dev/null | grep Release | awk '{print $2}')
      
      fi
      
      echo "Using operating system '$OS' and version '$OS_VERSION'"
      
      if [ "x${global_http_proxy}" == "x" ] || [ "x${global_https_proxy}" == "x" ] ||
         [ "x${global_ftp_proxy}" == "x" ]; then
         echo ""
         echo "###############################################################"
         echo "#  One or more PROXY(s) not set. Network downloads may fail   #"
         echo "###############################################################"
         echo ""
      fi
      
      export PATH=$PATH:$JAVA_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
      set -e
      
      # Locate the my.cnf file 
      my_cnf_file=
      if [ -f /etc/my.cnf ]; then 
          my_cnf_file=/etc/my.cnf
      elif [ -f /etc/mysql/my.cnf ]; then 
          my_cnf_file=/etc/mysql/my.cnf
      fi
      
      if [ "x$my_cnf_file" = "x" ]; then 
          echo "Neither /etc/my.cnf nor /etc/mysql/my.cnf can be found, stopping configuration"
          exit 1
      fi
      
      # update mysql configuration to handle big packets
      sed -ie "s/\[mysqld\]/\[mysqld\]\n\
      max_allowed_packet=$max_allowed_packet/g" $my_cnf_file
      # update listening port
      sed -ie "s/\[mysqld\]/\[mysqld\]\n\
      port=$db_port/g" $my_cnf_file
      
      sed -i "s/port.*=.*[0-9]*/port=$db_port/g" $my_cnf_file
      
      if [ "x$OS" != "x" ] && [ "$OS" = 'Ubuntu' ]; then
          # Make sure that MySQL is started 
          service mysql restart
      else 
          # set up auto-start on booting
          chkconfig mysqld on
          # restart mysqld service
          service mysqld start
      fi
      
      # this will assign a password for mysql admin user 'root'
      mysqladmin -u $db_root_username password $db_root_password
       
    4. 按一下確定
  12. 設定 [啟動] 動作。
    1. 指令碼類型下拉式功能表中選取 Bash
    2. 按一下按一下這裡編輯
    3. 貼上下列指令碼。
      #!/bin/sh
      
      echo "The maximum allowed packet size is: "
      
       
    4. 將游標置於冒號和問號之間。
    5. 選取要插入的內容下拉式功能表中選取 max_allowed_packet_size

      指令碼現在會包含該內容。

      #!/bin/sh
      
      echo "The maximum allowed packet size is: $max_allowed_packet_size" 
      
       
    6. 按一下確定
  13. 下一步
  14. 按一下完成
  15. 選取包含 MySQL for Linux Virtual Machines 的一列,然後按一下發佈

結果

您的 MySQL 軟體元件便可提供給藍圖設計頁面上的其他架構設計人員使用,但是在將軟體元件與機器合併之前,您無法提供這些元件。

下一步

使用軟體架構設計人員、應用程式架構設計人員或 IaaS 架構設計人員權限,將您的 MySQL 元件與 CentOS for Software 機器藍圖合併。請參閱案例:組合並測試藍圖以在 Rainpole 連結複製機器上提供 MySQL