使用您的软件架构师特权,创建 MySQL Software组件以将 MySQL 安装到 vSphere CentOS 计算机上。为 CentOS 虚拟机设计 MySQL Software组件时,您需配置 Linux 操作系统的安装、配置、启动参数和脚本。

过程

  1. 选择设计 > 软件组件
  2. 单击新建图标 (添加)。
  3. 名称文本框中,输入 MySQL for Linux Virtual Machines
  4. 确认系统已根据提供的名称填充标识符。

    例如,Software.MySQLforLinuxVirtualMachines

  5. 描述文本框中,输入 MySQL installation and configuration
  6. 容器下拉菜单中选择计算机

    由于您仅希望直接将 MySQL 安装在计算机上,因此您阻止架构师将 MySQL Software组件放到其他Software组件顶部。

  7. 单击下一步
  8. 单击新建,然后为安装脚本添加并配置以下每个属性。

    单击确定保存每个属性。

    架构师可以将Software属性配置为在请求表单中显示给用户。架构师可以使用“在请求中显示”选项,要求或请求用户填写您标记为“可覆盖”的属性的值。

    名称

    描述

    类型

    已加密

    允许替代

    必需

    计算

    db_root_username

    数据库 root 用户名

    字符串

    root

    JAVA_HOME

    安装 JRE 1.8 或更高版本的目录

    字符串

    /opt/vmware-jre

    global_ftp_proxy

    FTP 代理 URL(如有)。不需要。

    字符串

    db_port

    MySQL 数据库端口

    字符串

    db_root_password

    数据库 root 用户密码

    字符串

    密码

    global_http_proxy

    HTTP 代理 URL(如有)。不需要。

    字符串

    global_https_proxy

    HTTPS 代理 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 Software组件,但您只有在将Software组件与计算机进行组合之后才可对其进行使用。

下一步做什么

使用您的软件架构师、应用程序架构师或 IaaS 架构师特权,将 MySQL 组件与 CentOS for Software 计算机蓝图进行组合。