MySQL on linux box? I think it might be possible

Frage MySQL on linux box? I think it might be possible

  • Donnerstag, 26. Mai 2011 16:35
     
      Enthält Code

    Hello,

    I would like to start discussion of having MySQL server runned on linux box. I think it might be possible because only thing which needs having MySQL on Windows system is diskspace calculation task (if I'm wrong then please correct me) and this can be achieved by MySQL query described in this topic:

    http://social.msdn.microsoft.com/Forums/en-US/wspdiscuss/thread/e8d77678-bb10-4b5e-9ebc-cd2f08a71758

    After updating private long CalculateDatabaseSize(string database) function from:

        private long CalculateDatabaseSize(string database)
        {
          // read mySQL INI file
          string dataPath = null;
          string iniPath = Path.Combine(InstallFolder, "my.ini");
          if (File.Exists(iniPath))
          {
            string[] lines = File.ReadAllLines(iniPath);
            Regex re = new Regex(@"^datadir\s?=\s?\""?(?<path>[^\""\n]*)", RegexOptions.IgnoreCase);
            foreach (string line in lines)
            {
              Match m = re.Match(line);
              if (m.Success)
              {
                dataPath = m.Groups["path"].Value.Trim();
                break;
              }
            }
          }
    
          if (String.IsNullOrEmpty(dataPath))
            dataPath = Path.Combine(InstallFolder, "data");
    
          string dbFolder = Path.Combine(dataPath, database);
    
          Log.WriteStart("Database path: " + dbFolder);
    
          if (Directory.Exists(dbFolder))
          {
            Log.WriteStart("Data folder exists");
            return FileUtils.CalculateFolderSize(dbFolder);
          }
          return 0;
        }
    
    to:

        private long CalculateDatabaseSize(string database)
        {
          DataTable dbSize = ExecuteQuery(String.Format("Select SUM(data_length + index_length) as DBSize from information_schema.tables where table_schema = '{0}'", database));
          if (dbSize.Rows.Count == 1)
          {
            return long.Parse(dbSize.Rows[0]["DBSize"].ToString());
          }
          return 0;
        }
    

    we don't need to have MySQL on the same system where WSP Server is. Only thing left is to configure WSP Server on some system (it could be WSP Enterprise box) where number of additional WSP Server instalces would be equal to number of MySQL servers running on linux systems (in provider configuration we only must provide the same external and internal MySQL). This is just an idea but I thought someone would be interested and that's why I've started this topic.

    Regards

Alle Antworten

  • Montag, 4. Juli 2011 08:15
     
     

    I have done this since January, and it is working fine.

    Didn't care about the database size calculation part though.