Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import TabItem from '@theme/TabItem';

# How to Apply Configuration Using Agent

To apply the recommended configuration, run the command for your operating system:
Use this method for self-managed MySQL, MariaDB, or Percona servers where Releem Agent is installed directly on the database host.

To apply the latest recommended configuration and allow MySQL restart when required, run:


<Tabs>
<TabItem value="linux" label="Linux" default>
Expand All @@ -24,3 +27,8 @@ To apply the recommended configuration, run the command for your operating syste
</Tabs>

Releem Agent is equipped with an automatic rollback function. This means if any issues arise while applying a new configuration, Releem will smartly revert to the previous configuration.


## Cloud-Managed Databases

For AWS RDS, GCP Cloud SQL, and Azure Database for MySQL, apply recommended configuration from the Releem Portal. The agent receives the task from the portal and uses the cloud provider API to update database parameters.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ To apply the recommended configuration using the Releem Portal, follow these ste

By following these steps, you can efficiently apply and manage your database configuration using the Releem Portal.

For self-managed servers, Releem Agent updates MySQL configuration files or dynamic variables depending on the selected action. For cloud-managed databases, Releem Agent uses the provider API:

- AWS RDS: updates the DB Parameter Group. Dynamic parameters are applied immediately; static parameters remain pending until reboot.
- GCP Cloud SQL: updates database flags through the Cloud SQL Admin API.
- Azure Database for MySQL: updates Flexible Server configurations through Azure Resource Manager. **Apply Without Restart** leaves restart-required parameters pending; **Apply and Restart** restarts the server after applying them.

## Troubleshooting applying configuration

### **FOR SELF-MANAGED SERVERS**
Expand Down Expand Up @@ -154,3 +160,40 @@ Enable Full Api Access to Cloud SQL and Stackdriver Monitoring API for the Compu
Agent stopped unexpectedly during applying configuration and unable to send information about task to Releem Platform.

**User Action**: send us please the [Releem Agent logs](https://docs.releem.com/releem-agent/how-to-check-logs) to hello@releem.com


### **FOR AZURE DATABASE FOR MYSQL INSTANCES**

#### 1. Azure identity lacks permissions to read the server
This issue occurs when the identity used by Releem Agent does not have permission to call `Microsoft.DBforMySQL/flexibleServers/read`.

Grant `Reader` on the Azure MySQL server or its resource group:

```bash
az role assignment create \
--assignee-object-id "[OBJECT_ID]" \
--assignee-principal-type ServicePrincipal \
--role Reader \
--scope "/subscriptions/[SUBSCRIPTION_ID]/resourceGroups/[RESOURCE_GROUP]/providers/Microsoft.DBforMySQL/flexibleServers/[MYSQL_SERVER]"
```

Restart Releem Agent after granting access.

#### 2. Azure identity lacks permissions to apply configuration
This issue occurs when the identity can read the server but cannot update Flexible Server configurations or restart the server.

Grant `Contributor` on the Azure MySQL server or use a custom role that allows configuration update and restart actions:

```bash
az role assignment create \
--assignee-object-id "[OBJECT_ID]" \
--assignee-principal-type ServicePrincipal \
--role Contributor \
--scope "/subscriptions/[SUBSCRIPTION_ID]/resourceGroups/[RESOURCE_GROUP]/providers/Microsoft.DBforMySQL/flexibleServers/[MYSQL_SERVER]"
```

#### 3. The latest recommended configuration is partially applied
Some Azure MySQL parameters require a restart. Click **Apply** and then **Apply and Restart** in the Releem Portal to finish applying the configuration.

#### 4. Azure MySQL server is not Ready
Check the Azure MySQL Flexible Server status in the Azure Portal. Wait until the server state is `Ready`, then apply the configuration again.
79 changes: 67 additions & 12 deletions docs/query-optimization/disable-sql-query-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,75 @@ To disable the SQL Query Optimization feature, please select your installation t
<Tabs>
<TabItem value="linux" label="Linux" default>

1. Edit the configuration file:
```bash
nano /opt/releem/releem.conf
```
2. Change the `query_optimization` setting to `false`.
3. Restart the Releem Agent:
```bash
service releem-agent restart
```
1. Edit the agent configuration file:

```bash
nano /opt/releem/releem.conf
```

2. Set:

```ini
query_optimization=false
```

3. Restart the agent:

```bash
systemctl restart releem-agent
```

</TabItem>
<TabItem value="docker" label="Docker">

Recreate the container with query optimization disabled:

```bash
docker rm -f releem-agent
docker run -d --name releem-agent \
-e RELEEM_QUERY_OPTIMIZATION=false \
... \
releem/releem-agent:[version]
```

For Docker Compose, set:

```yaml
environment:
RELEEM_QUERY_OPTIMIZATION: false
```

Then recreate the service:

```bash
docker compose up -d
```

</TabItem>
<TabItem value="aws-rds" label="AWS RDS">

If the agent is managed by CloudFormation, update the `releem-agent` stack and set `QueryOptimization` to `false`.

If the agent runs on EC2, set `query_optimization=false` in `/opt/releem/releem.conf` and restart the agent:

```bash
systemctl restart releem-agent
```

</TabItem>
<TabItem value="gcp-cloudsql" label="GCP Cloud SQL">

Set `query_optimization=false` in the agent configuration or recreate the Docker container with `RELEEM_QUERY_OPTIMIZATION=false`, then restart the agent.

</TabItem>
<TabItem value="azure-mysql" label="Azure MySQL">

Set `query_optimization=false` in the agent configuration or recreate the Docker container with `RELEEM_QUERY_OPTIMIZATION=false`, then restart the agent.

</TabItem>
<TabItem value="aws" label="AWS RDS">
<TabItem value="windows" label="Windows">

To disable the SQL Query Optimization feature for AWS RDS, you need to reinstall the Releem Agent and disable the feature in the CloudFormation template.
Set `query_optimization=false` in `C:\ProgramData\ReleemAgent\releem.conf`, then restart the Releem Agent Windows service.

</TabItem>
</Tabs>
</Tabs>
154 changes: 106 additions & 48 deletions docs/query-optimization/enable-sql-query-optimization.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@ import TabItem from '@theme/TabItem';

# Enable SQL Query Optimization

To enable the SQL Query Optimization feature, please select your installation type and follow the instructions below. Once enabled, you'll see the first automatic SQL Query Recommendation in one week.
To enable the SQL Query Optimization feature, please select your installation type and follow the instructions below. SQL Query Optimization lets Releem collect query execution plans and generate query-level recommendations. After enabling it, the first recommendations can take up to one week because Releem needs enough workload data.

<Tabs>
<TabItem value="linux" label="Linux" default>

## Existing Linux Installation

### Automatic Installation


Note: If your server is already installed, you can use automatic installation, as it won't add a new server if it has the same hostname.

1. Click "Add Server" link at Releem Customer Portal.
2. Select the installation type.
3. Modify the one-step installation command and the following environment variable:
```bash
RELEEM_QUERY_OPTIMIZATION=true
```
4. Run the modified installation command on your server.
Run the helper mode from the installer:

If the server is already added, you can copy the following command, change the MySQL root password, and run it:
```bash
RELEEM_MYSQL_ROOT_PASSWORD='password' /bin/bash -c "$(curl -L https://releem.s3.amazonaws.com/v2/install.sh)" enable_query_optimization
```
```bash
RELEEM_MYSQL_ROOT_PASSWORD='[MySQL root password]' \
bash -c "$(curl -L https://releem.s3.amazonaws.com/v2/install.sh)" enable_query_optimization
```

This command updates `/opt/releem/releem.conf`, enables query optimization, and prepares the required MySQL settings.

### Manual Installation

If your server is already installed, please do the following steps:

If you prefer to update the agent manually:

1. Grant additional permissions to the releem user. The SQL Query Optimization feature requires [Additional Permissions](/releem-agent/mysql-permissions) for the Releem Agent user.
2. Add `query_optimization=true` setting to the `/opt/releem/releem.conf`.
Expand All @@ -45,76 +45,134 @@ To enable the SQL Query Optimization feature, please select your installation ty
/opt/releem/mysqlconfigurer.sh -p
```

## New Linux Installation

Add this environment variable to the installation command:

```bash
RELEEM_QUERY_OPTIMIZATION=true
```

1. Click "Add Server" link at Releem Customer Portal.
2. Select the installation type.
3. Modify the one-step installation command and the following environment variable:
```bash
RELEEM_QUERY_OPTIMIZATION=true
```
4. Run the modified installation command on your server.

</TabItem>
<TabItem value="aws-rds" label="AWS RDS">

1. Grant additional permissions to the releem user. The SQL Query Optimization feature requires [Additional Permissions](/releem-agent/mysql-permissions) for the Releem Agent user.
2. Set the following MySQL variables in the Parameter Group to allow Releem to collect more queries for optimization:
```ini
performance_schema = 1
```
3. Update the already installed Releem Agent:
2. Enable Performance Schema in the RDS Parameter Group to allow Releem to collect more queries for :

```ini
performance_schema = 1
```

3. Reboot the RDS instance if AWS marks the change as pending reboot.
4. Enable query optimization in the agent:

If the agent is managed by CloudFormation, update the `releem-agent` stack and set `QueryOptimization` to `true`.
1. Select CloudFormation Stack - releem-agent, click the **Update** button.
2. Select "Replace existing template".
3. Paste in "Amazon S3 URL" the URL `https://releem.s3.amazonaws.com/test/releem-agent-cloudformation.yml` and click **Next**.
4. Change the option "QueryOptimization" to true and click **Next**.
5. Click **Next** and **Submit**.

</TabItem>
<TabItem value="gcp-cloudsql" label="GCP Cloud SQL" default>
If the agent runs in Docker, recreate the Docker container with `RELEEM_QUERY_OPTIMIZATION=true` environment variable enabled.
Ensure that the `RELEEM_HOSTNAME` variable should be the same as the currently added server.

If the agent runs on EC2, set `query_optimization=true` in `/opt/releem/releem.conf` and restart the service:

### Docker Installation
```bash
systemctl restart releem-agent
```

</TabItem>
<TabItem value="gcp-cloudsql" label="GCP Cloud SQL">

1. Grant additional permissions to the releem user. The SQL Query Optimization feature requires [Additional Permissions](/releem-agent/mysql-permissions) for the Releem Agent user.
2. Re-install Releem Agent with `RELEEM_QUERY_OPTIMIZATION=true` environment variable enabled.
2. Enable Performance Schema in Cloud SQL database flags:

```ini
performance_schema = 1
```

3. Restart the Cloud SQL instance if required.
4. Enable query optimization in the agent:

If the agent runs in Docker, recreate the Docker container with `RELEEM_QUERY_OPTIMIZATION=true` environment variable enabled.
Ensure that the `RELEEM_HOSTNAME` variable should be the same as the currently added server.


If the agent runs on VM, set `query_optimization=true` in `/opt/releem/releem.conf` and restart the service:

### Manual Installation
```bash
systemctl restart releem-agent
```

If your server is already installed, please do the following steps:
</TabItem>
<TabItem value="azure-mysql" label="Azure MySQL">

1. Grant additional permissions to the releem user. The SQL Query Optimization feature requires [Additional Permissions](/releem-agent/mysql-permissions) for the Releem Agent user.
2. Add `query_optimization=true` setting to the `/opt/releem/releem.conf`.
3. Restart Releem Agent using the following command:
```bash
systemctl restart releem-agent
```
4. Run the following command:
```bash
/opt/releem/mysqlconfigurer.sh -p
```
2. Enable Performance Schema on Azure Database for MySQL Flexible Server if it is disabled.
3. Enable query optimization in the agent:

</TabItem>
If the agent runs in Docker, recreate the Docker container with `RELEEM_QUERY_OPTIMIZATION=true` environment variable enabled.
Ensure that the `RELEEM_HOSTNAME` variable should be the same as the currently added server.


If the agent runs on VM, set `query_optimization=true` in `/opt/releem/releem.conf` and restart the service:

```bash
systemctl restart releem-agent
```

</TabItem>
<TabItem value="docker" label="Docker">

1. Grant additional permissions to the releem user. The SQL Query Optimization feature requires [Additional Permissions](/releem-agent/mysql-permissions) for the Releem Agent user.
2. Re-install Releem Agent with `RELEEM_QUERY_OPTIMIZATION=true` environment variable enabled.

Ensure that the `RELEEM_HOSTNAME` variable should be the same as the currently added server. If you don't configure automatic applying of configuration, then please add the following MySQL variables to the configuration:
2. Recreate the agent container with query optimization enabled:

```ini
performance-schema-consumer-events-statements-history = ON
performance-schema-consumer-events-statements-current = ON
```
```bash
docker rm -f releem-agent
docker run -d --name releem-agent \
-e RELEEM_QUERY_OPTIMIZATION=true \
... \
releem/releem-agent:[version]
```

For Docker Compose, set:

```yaml
environment:
RELEEM_QUERY_OPTIMIZATION: true
```

Ensure that the `RELEEM_HOSTNAME` variable should be the same as the currently added server.
If the agent cannot automatically apply MySQL settings, add these settings to MySQL configuration and restart MySQL:

```ini
performance-schema-consumer-events-statements-history = ON
performance-schema-consumer-events-statements-current = ON
```

</TabItem>
<TabItem value="windows" label="Windows" default>
<TabItem value="windows" label="Windows">

1. Grant additional permissions to the releem user. The SQL Query Optimization feature requires [Additional Permissions](/releem-agent/mysql-permissions) for the Releem Agent user.
2. Add `query_optimization=true` setting to the `C:\ProgramData\ReleemAgent\releem.conf`.
3. Add the following MySQL variables to the configuration and restart DB service:
2. Set `query_optimization=true` in `C:\ProgramData\ReleemAgent\releem.conf`.
3. Add these settings to MySQL configuration and restart MySQL:

```ini
performance-schema-consumer-events-statements-history = ON
performance-schema-consumer-events-statements-current = ON
```
4. Restart Releem Agent using the following command:

```bash
systemctl restart releem-agent
```

4. Restart the Releem Agent Windows service.

</TabItem>
</Tabs>
Expand Down
Loading