Bug #41005 running upgrade installer remove wrong 1.3 init.d/mysql-service-agent
Submitted: 25 Nov 2008 11:12 Modified: 17 Mar 2010 10:51
Reporter: Simon Mudd (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Enterprise Monitor: Installing Severity:S3 (Non-critical)
Version:2.0.0.7102 OS:Any
Assigned to: BitRock Merlin CPU Architecture:Any
Tags: windmill

[25 Nov 2008 11:12] Simon Mudd
Description:
When running the upgrade installer on the merlin agent from 2.0.0.7088 to 2.0.0.7102 on a box with 2 agents:

1.3.2.X installed in /opt/mysql/enterprise/agent
2.0.0.X installed in /opt/mysql/enterprise/agent3

the 2.0.0 installer remove the /etc/init.d/mysql-service-agent file. This file however is for a different agent instance which can be seen by examining the MERLIN_AGENT_BIN which refers to a different "BASE" path than the /opt/mysql/enterprise/agent3 for the 2.0. instance.

On boxes with more than 1 1.3 agent we are concerned that the upgrade may interfere with the wrong agent installation

Observation: it wasn't very clear to me in the 1.3 documentation exactly what happens when multiple instances are installed what happens in the /etc/init.d directory and how the start files are arranged.

How to repeat:
Install multiple 1.3 agents in different locations
Run the 2.0 upgrade on one of them.
Notice that the /etc/init.d/mysql-service-agent file is removed!

Suggested fix:
Ensure that upgrades only affect the installed agent being upgraded. Double check the "base path".
[26 Nov 2008 22:15] Marcos Palacios
I have followed the information in the description to try to reproduce it without success: 

I have a 1.3 agent and a 2.0.0.7088 agent, I upgraded the 2.0 agent to 2.0.0.7102 and saw if the 1.3's /etc/init.d/mysql-service-agent file was removed but it was not.

Also, I have tried with two 1.3 agents and upgraded one of them, then checked the other agent's /etc/init.d/mysql-service-agent file and it was not removed (this was to do like what the 'How to repeat:' says).
[27 Nov 2008 7:58] Simon Mudd
Hi. OK. I'll try and repeat this again to see if I can show the behaviour. Perhaps I did something wrong.
I'll report back with more information.
[27 Nov 2008 8:32] Simon Mudd
Backup and clean out the 2.0 instance

[root@dc01ppcmdb-01 ~]# /opt/mysql/enterprise/agent3/etc/init.d/mysql-monitor-agent stop
Shutting down MySQL Enterprise agent service...            [  OK  ]
[root@dc01ppcmdb-01 ~]# cd /opt/mysql/enterprise/agent3
[root@dc01ppcmdb-01 agent3]# tar cvzf ~/agent-config.tgz etc/instances etc/mysql-monitor-agent.ini 
etc/instances/
etc/instances/mysql/
etc/instances/mysql/agent-instance.ini
etc/mysql-monitor-agent.ini
[root@dc01ppcmdb-01 agent3]# rm -rf /opt/mysql/enterprise/agent3/
[root@dc01ppcmdb-01 agent3]# rm /etc/init.d/mysql-monitor-agent 
rm: remove regular file `/etc/init.d/mysql-monitor-agent'? y
[root@dc01ppcmdb-01 agent3]# ls -l /etc/init.d/*my*
-rwxr-xr-x  1 root root 11948 Aug 13 17:12 /etc/init.d/mysql
-rwxr-xr-x  1 root root  6676 Aug 26 11:00 /etc/init.d/mysql-service-agent

Now we just have a running 1.3 instance.

Run our custom installer to install 2.0.0.7088

[root@dc01ppcmdb-01 merlin2_agent]# sh merlin2_agent_install_http /opt/mysql/enterprise/agent3 2.0.0.7088
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Arch: x86_64, Binary: mysqlmonitoragent-2.0.0.7088-linux-glibc2.3-x86-64bit-installer.bin
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Checking if we are doing an upgrade or installation
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: - no installation directory /opt/mysql/enterprise/agent3, so this is a new install
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Starting agent install to install_dir /opt/mysql/enterprise/agent3 (version 2.0.0.7088)
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Found mysql binary at /usr/bin/mysql
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: We can reach the local MySQL server, so setting grants
Nov 27 09:17:50 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Running install script
Nov 27 09:17:56 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Starting agent
Starting MySQL Enterprise agent service...                 [  OK  ]
Nov 27 09:17:57 dc01ppcmdb-01 merlin2_agent_install_http[25544]: Install completed successfully
[root@dc01ppcmdb-01 merlin2_agent]# ls -l /etc/init.d/*my*
-rwxr-xr-x  1 root root 11948 Aug 13 17:12 /etc/init.d/mysql
-rwxr-xr-x  1 root root  6941 Nov 27 09:17 /etc/init.d/mysql-monitor-agent
-rwxr-xr-x  1 root root  6676 Aug 26 11:00 /etc/init.d/mysql-service-agent

Now run the 7102 upgrade script.

[root@dc01ppcmdb-01 merlin2_agent]# DISPLAY= ./mysqlmonitoragent-2.0.0.7102-linux-glibc2.3-x86-64bit-update-installer.bin 
Language Selection

Please select the installation language
[1] English
[2] Japanese
Please choose an option [1] : 1
----------------------------------------------------------------------------
Welcome to the setup wizard for the MySQL Enterprise Monitor Agent Update

----------------------------------------------------------------------------
Please specify the directory that contains the previous installation of the MySQL Enterprise Monitor Agent

Installation directory [/opt/mysql/enterprise/agent]: /opt/mysql/enterprise/agent3

----------------------------------------------------------------------------
Current installation backup

Do you want to create a backup during the update process?

Backup the current installation [Y/n]: y

Backup directory [/opt/mysql/enterprise/agent3/patchbackup]: 

----------------------------------------------------------------------------
Setup is now ready to begin installing MySQL Enterprise Monitor Agent Update on your computer.

Do you want to continue? [Y/n]: 

----------------------------------------------------------------------------
Please wait while Setup installs MySQL Enterprise Monitor Agent Update on your computer.

 Installing
 0% ______________ 50% ______________ 100%
 #########################################

----------------------------------------------------------------------------
Setup has finished installing MySQL Enterprise Monitor Agent Update on your computer.

Restart MySQL Enterprise Monitor Agent now [Y/n]: n

View Readme File [Y/n]: n

[root@dc01ppcmdb-01 merlin2_agent]# ls -l /etc/init.d/*my*
-rwxr-xr-x  1 root root 11948 Aug 13 17:12 /etc/init.d/mysql
-rwxr-xr-x  1 root root  6941 Nov 27 09:24 /etc/init.d/mysql-monitor-agent
[root@dc01ppcmdb-01 merlin2_agent]# 

So this seems to show to me that the agent script has been removed.

I hope I've provided enough information now for you to repeat this.
[29 Nov 2008 16:45] Marcos Palacios
Notice that the customer is referring to the mysql-service-agent file at /etc/init.d/ and not the one at /opt/mysql/enterprise/agent3/etc/init.d/
This is running the installer as the root user.
[1 Dec 2008 7:33] Simon Mudd
We're running the install scripts as the root user. Does MySQL recommend doing this differently? If so can you provide a pointer? (I'd prefer not to run as the root user.)
[2 Dec 2008 15:53] Marcos Palacios
One advantage of running the install scripts as the root user is that you get auto-start set up for the agent and/or monitor. However, the installs can be run as another (non-root) user, too.

For the privileges required for the agent (as a user in the monitored DB), see the following section in the online Help: 2.4.1. Creating a MySQL User Account for the Service Agent.
[2 Dec 2008 16:24] Simon Mudd
I see no such section in https://enterprise.mysql.com/docs/monitor/2.0/en/.

I see:

This manual documents the MySQL Enterprise Monitor version 2.0.

Document generated on: 2008-11-04 (revision: 1373)

Table of Contents

1. Introduction
1.1. Conventions Used in This Document
2. An Overview of the Service
2.1. The Service Architecture
2.1.1. Service Agent
2.1.2. Service Manager
2.1.3. The Repository
2.1.4. The Web Client
2.2. Service Features
2.3. Security
3. Installation and Upgrades
3.1. User Roles
3.1.1. Existing Users
3.1.2. User Created During Installation
3.1.3. Users Created on First Log-in
3.2. Service Manager Installation
3.2.1. Service Manager Installation Common Parameters
...

So it's hard to say if I'm doing the right thing. In any case the point seems to be that (IMO) running the agent as a non-root user is a good thing, and perhaps this should be the default configuration.

If so the installer needs to ask the appropriate questions about possibly creating the required unix users if they don't already exist.
[3 Dec 2008 17:03] Marcos Palacios
Sorry about the outdated doc version on that site. The current Help can be accessed locally from the 'Help' link on the Monitor UI (Enterprise Dashboard).
[16 Nov 2009 16:09] BitRock Merlin
This is our suggested approach to fix this issue. We have followed a similar behavior described for Windows platforms in #27332.

1) Currently, the help option shows the following on Windows platforms:

--servicename <servicename>                                   Default: MySQL Enterprise Monitor Agent

We propose to show the following on Unix like platforms (Linux, OS X, Solaris, etc):

--servicename <servicename>                                   Default: mysql-monitor-agent

The default service name script is "mysql-monitor-agent".

2) On Windows, if the installer detects the presence of the service name you were going to use, it gives the following error:

The name "MySQL Enterprise Monitor Agent" is already in use.
Each installation of the agent must have a unique name.
Please either uninstall the existing instance, or start
the installer with the --servicename flag to specify a
new name for this instance. For example:

mysqlmonitoragent-<version>-windows-installer.exe --servicename="MySQL Enterprise Monitor Agent 2"

The installer for Unix platforms  will check if the service scripts already exists and will give the same error. In this case, the installer only creates the service if it is running as root user, so this error will only be thrown when the installer is running as root user and the service script exists.

3) The user can specify the new service script name using the "servicename" option:

# ./mysqlmonitoragent-<version>-linux-installer.bin --servicename=mysql-monitor-agent-2

This name will be saved in <install-dir>/etc/mysql-monitor-agent script so the upgrade installer knows the service name associated.

Please let us know any question or suggestion.

Beltran
[16 Nov 2009 16:49] Simon Mudd
Is there any recommendation for installing the agent as a non-root user?
My understanding was that several things that the agent collects have to be done as root. While it's also possible to split this into different processes and drop privileges I don't remember seeing anywhere a comment that the agent should be installed as a non-root user.

So this last comment has left me somewhat confused.
[2 Dec 2009 22:20] Enterprise Tools JIRA Robot
Keith Russell writes: 
Patch installed in versions => 2.2.0.1563.
[6 Jan 2010 18:45] Enterprise Tools JIRA Robot
Marcos Palacios writes: 
Verified fixed in agent installer build 2.2.0.1570 and agent update installer build 2.2.0.1595.
[17 Mar 2010 10:51] MC Brown
An entry has been added to the 2.2.0 changelog. 

        When running an update installation on a machine where you                                                                                          
        have multiple instnaces of &merlin_agent; already installed,                                                                                        
        the installer could identify and upgrade the wrong                                                                                                  
        version. You can now specify the installed version (as                                                                                              
        identified by the startup script                                                                                                                    
        in <filename>/etc/init.d</filename>) by using                                                                                                       
        the <literal>--servicename=<replaceable>mysql-monitor-agent</replaceable></literal>                                                                 
        option to the command line installer.
                                                                                                                                                            
      For new installations where a instance of the                                                                                                   
        &merlin_agent; is already installed, the installer could                                                                                            
        identify an existing version and refuse to perform the                                                                                              
        installation process. During the installation, you are now                                                                                          
        prompted with the installation name to use for the startup                                                                                          
        script if, and only if, an existing instance has been                                                                                               
        identified.

The installation notes/guides on upgrades have also been updated.