One place for hosting & domains

      How to Deploy TOBS on LKE


      Updated
      , by Rajakavitha Kodhandapani

      Traducciones al Español

      Estamos traduciendo nuestros guías y tutoriales al Español. Es
      posible que usted esté viendo una traducción generada
      automáticamente. Estamos trabajando con traductores profesionales
      para verificar las traducciones de nuestro sitio web. Este proyecto
      es un trabajo en curso.

      Create a Linode account
      to try this guide with a $100 credit.

      This credit will be applied to any valid services used during your first 60 days.

      In this guide, deploy
      TOBS to your Linode Kubernetes Engine (LKE) cluster using
      Helm. And use kubectl port-forward for local access to your monitoring interfaces.

      The Prometheus Operator Monitoring Stack

      TOBS, short for The Observability Stack, is a pre-packaged distribution of monitoring tools and dashboard interfaces which can be installed on any existing Kubernetes cluster. It includes many of the most popular open-source observability tools such as Prometheus, Grafana, Promlens, TimescaleDB, and others. Together, these provide a maintainable solution to analyze the traffic on the server and identify any potential problems with a deployment. You can use Helm charts to configure and update TOBS deployments.

      TOBS includes the following components:

      • OpenTelemetry collector is deployed to collect traces.
      • Alertmanager, is deployed alongside Prometheus, forms the alerting layer of the stack, and handles alerts generated by Prometheus.
      • Grafana is a data visualization and analytics tool that allows you to build dashboards and graphs for your metrics data.
      • PromLens helps users build PromQL queries with ease. PromLens is a PromQL query builder that helps you build, understand, and fix your queries much more effectively.
      • TimescaleDB is for long-term storage of metric data. Long-term storage provides the ability to perform post-hoc analysis on metric data over long periods of time. Such data analysis can be used for capacity planning, identifying slow-moving regressions, trend analysis, auditing, and more. For information about connecting to the database from the cluster, see
        TimescaleDB Documentation
      • Promscale provides the translation layer between Prometheus and the database. It allows the Prometheus server to store and retrieve metrics from TimescaleDB, and allows users to use PromQL on Promscale and Prometheus.
      • Prometheus is an open-source systems monitoring and altering stack. It has become the de-facto standard in metric monitoring and is the basis of standards such as OpenMetrics. It allows you to monitor and understand how your infrastructure and applications are performing. Service discovery allows Prometheus to automagically discover components within your Kubernetes cluster that are already emitting metrics.
      • kube-state-metrics exports the metrics related to Kubernetes resources such as the status and count of Kubernetes resources, with visibility of the desired resources and the current resources, as well as the trends in your cluster.
      • Node-Exporter is deployed to export node related metrics such as CPU, memory usage, and others from the Kubernetes cluster.

      Before You Begin

      Note

      This guide was written using
      Kubernetes version 1.23.
      1. Deploy an LKE Cluster. This guide was written using an example node pool with three
        2 GB Linodes. Depending on the workloads you plan to deploy on your cluster, you may consider using Linodes with more available resources.

      2. Install
        Helm 3 to your local environment.

      3. Install
        kubectl to your local environment and
        connect to your cluster.

      4. Create the monitoring namespace on your LKE cluster:

        kubectl create namespace monitoring
        
      5. Add the stable Helm charts repository to your Helm repos:

        helm repo add stable https://charts.helm.sh/stable
        
      6. Update your Helm repositories:

        helm repo update
        

      TOBS Minimal Deployment

      In this section, learn to deploy TOBS for individual/local access with kubectl
      Port-Forward.

      Deploy The Observability Stack

      1. Install a certificate manager for your LKE cluster:

         kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.8.0/cert-manager.yaml
        
      2. Using Helm, deploy the TOBS release labeled lke-monitor in the monitoring namespace on your LKE cluster:

        helm repo add timescale https://charts.timescale.com/
        helm repo update
        helm install --wait lke-monitor timescale/tobs --namespace monitoring
        
      3. Verify that the Prometheus Operator has been deployed to your LKE cluster and its components are running and ready by checking the pods in the monitoring namespace:

        kubectl -n monitoring get pods
        

        You should see a similar output to the following:

        NAME                                                        READY   STATUS      RESTARTS      AGE
        alertmanager-tobs-kube-prometheus-alertmanager-0            2/2     Running     0             2m13s
        lke-monitor-connection-secret-j4sdh                         0/1     Completed   0             2m35s
        lke-monitor-grafana-54d979dcf5-tkkgj                        3/3     Running     2 (65s ago)   2m32s
        lke-monitor-grafana-db-swm8g                                0/1     Completed   3             2m35s
        lke-monitor-kube-state-metrics-6bc5c44b9-g8r5g              1/1     Running     0             2m27s
        lke-monitor-prometheus-node-exporter-b4vvg                  1/1     Running     0             2m33s
        lke-monitor-prometheus-node-exporter-bbcnd                  1/1     Running     0             2m34s
        lke-monitor-prometheus-node-exporter-frrfp                  1/1     Running     0             2m26s
        lke-monitor-promlens-569cfbd586-bkhrr                       1/1     Running     0             2m34s
        lke-monitor-promscale-86d574986c-9wj2z                      1/1     Running     4 (64s ago)   2m27s
        lke-monitor-timescaledb-0                                   1/1     Running     0             2m30s
        opentelemetry-operator-controller-manager-8cf5c85c8-krdj5   2/2     Running     0             2m27s
        prometheus-tobs-kube-prometheus-prometheus-0                2/2     Running     0             2m13s
        tobs-kube-prometheus-operator-5b4f674986-55r4k              1/1     Running     0             2m34s

      Access Monitoring Interfaces with Port-Forward

      1. List the services running in the monitoring namespace and review their respective ports:

        kubectl -n monitoring get svc
        

        You should see an output similar to the following:

        NAME                                                        TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                                           AGE
        alertmanager-operated                                       ClusterIP   None             <none>        9093/TCP,9094/TCP,9094/UDP   3m41s
        lke-monitor                                                 ClusterIP   10.128.40.142    <none>        5432/TCP                     4m3s
        lke-monitor-config                                          ClusterIP   None             <none>        8008/TCP                     4m3s
        lke-monitor-grafana                                         ClusterIP   10.128.102.243   <none>        80/TCP                       4m3s
        lke-monitor-kube-state-metrics                              ClusterIP   10.128.208.39    <none>        8080/TCP                     4m3s
        lke-monitor-prometheus-node-exporter                        ClusterIP   10.128.170.88    <none>        9100/TCP                     4m3s
        lke-monitor-promlens                                        ClusterIP   10.128.45.92     <none>        80/TCP                       4m3s
        lke-monitor-promscale-connector                             ClusterIP   10.128.198.88    <none>        9201/TCP,9202/TCP            4m3s
        lke-monitor-replica                                         ClusterIP   10.128.137.189   <none>        5432/TCP                     4m3s
        opentelemetry-operator-controller-manager-metrics-service   ClusterIP   10.128.45.42     <none>        8443/TCP                     4m3s
        opentelemetry-operator-webhook-service                      ClusterIP   10.128.12.89     <none>        443/TCP                      4m3s
        prometheus-operated                                         ClusterIP   None             <none>        9090/TCP                     3m41s
        tobs-kube-prometheus-alertmanager                           ClusterIP   10.128.33.44     <none>        9093/TCP                     4m3s
        tobs-kube-prometheus-operator                               ClusterIP   10.128.175.39    <none>        443/TCP                      4m3s
        tobs-kube-prometheus-prometheus                             ClusterIP   10.128.106.173   <none>        9090/TCP                     4m3s

        From the above output, the resource services you will access have the corresponding ports:

        ResourceService NamePort
        Prometheustobs-kube-prometheus-prometheus9090
        Alertmanagertobs-kube-prometheus-alertmanager9093
        Grafanalke-monitor-grafana80
      2. Use kubectl
        port-forward to open a connection to a service, then access the service’s interface by entering the corresponding address in your web browser:

        Note

        Press control+C on your keyboard to terminate a port-forward process after entering any of the following commands.

        • To provide access to the Prometheus interface at the address 127.0.0.1:9090 in your web browser, enter:

          kubectl -n monitoring \
          port-forward \
          svc/tobs-kube-prometheus-prometheus \
          9090
          
        • To provide access to the Alertmanager interface at the address 127.0.0.1:9093 in your web browser, enter:

          kubectl -n monitoring \
          port-forward \
          svc/tobs-kube-prometheus-alertmanager  \
          9093
          
        • To provide access to the Grafana interface at the address 127.0.0.1:8081 in your web browser, enter:

          kubectl -n monitoring \
          port-forward \
          svc/lke-monitor-grafana  \
          8081:80
          

          When accessing the Grafana interface, log in as admin. You can get the password using:

          kubectl get secret --namespace monitoring lke-monitor-grafana -o jsonpath="{.data.admin-password}" | base64 --decode ; echo
          

          The Grafana dashboards are accessible at Dashboards > Manage from the left navigation bar.

      TOBS eliminates the need to maintain configuration details for each of the applications, while providing standardized monitoring for the applications running on your cluster.

      More Information

      You may wish to consult the following resources for additional information
      on this topic. While these are provided in the hope that they will be
      useful, please note that we cannot vouch for the accuracy or timeliness of
      externally hosted materials.

      This page was originally published on



      Join the conversation.
      Read other comments or post your own below. Comments must be respectful,
      constructive, and relevant to the topic of the guide. Do not post external
      links or advertisements. Before posting, consider if your comment would be
      better addressed by contacting our
      Support team or asking on
      our
      Community Site.



      Source link

      Connect to a MySQL Database Using the mysql Command


      Updated
      , by Linode

      Traducciones al Español

      Estamos traduciendo nuestros guías y tutoriales al Español. Es
      posible que usted esté viendo una traducción generada
      automáticamente. Estamos trabajando con traductores profesionales
      para verificar las traducciones de nuestro sitio web. Este proyecto
      es un trabajo en curso.

      Create a Linode account
      to try this guide with a $100 credit.

      This credit will be applied to any valid services used during your first 60 days.

      This guide shows you how to connect to a MySQL database using
      mysql, the MySQL command-line client. This opens up a simple SQL shell environment, allowing you to perform
      SQL queries and commands on your database. If you require more advanced capabilities, consider using the
      MySQL Shell.

      Note

      If you wish to connect to a Linode MySQL Managed Database, review the
      Connect to a MySQL Managed Database guide instead.

      Before You Begin

      • Obtain the connection details for the MySQL instance you wish to use. If you do not have a MySQL instance yet, you can
        create a Managed Database,
        deploy the MySQL Marketplace App, or
        install MySQL server (or MariaDB) on a Compute Instance. This instance must allow remote connections or you must run the mysql command from within same system.

      • Ensure mysql is installed and is compatible with the MySQL version on your database server. Run the following command on the system you intend on using to verify that mysql is installed.

        mysql --version
        

        This should inform you which version you are using. If the command is not found or you are not on a compatible version, see the
        Installing MySQL guide.

      Note

      The steps in this guide are written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, see the
      Linux Users and Groups guide.

      General mysql Syntax

      The main purpose of the mysql utility is to connect to a MySQL database server and open a simple SQL shell environment. The mysql command can be used to connect to either a local or remote database server. In the commands provided below, see the
      Common Command Options for information on each of the available options.

      • Local database server: Use this command when connecting to a MySQL Server instance running on the same machine you are using.

        mysql -u [username] -p
        
      • Remote database server: In many cases, the database server is not on the same system you are using. In these cases, you can SSH in to the remote system (if permitted) and run the command above to connect to a local MySQL instance. Alternatively, you can use the mysql command to remotely connect to the database. If your MySQL server does not allow remote connections or your user cannot connect remotely, see
        Configure the Database Server to Allow Remote Connections.

        mysql -h [host] -p [port] -u [username] -p
        

        Note

        If you wish to connect to a Linode MySQL Managed Database, review the
        Connect to a MySQL Managed Database guide instead.

      Common Command Options

      The following list is a collection of common options used with the mysqldump command. At minimum, the username and password is required. When connecting to a remote database server, the host (and perhaps the port) should be provided. For a full list of available options, reference the
      Command Options for Connecting to the Server documentation.

      • Username (--user=[] or -u []): The username of your MySQL user. This user must have proper grants to access the database.

      • Password (--password=[] or -p[]): Specifies that the user’s password is required for the connection. The password can be entered directly in the command itself (though that is not recommended due to security concerns) or the password can be omitted (by just using the --password option with no value). In the password is omitted, mysql prompts you for the password before connecting to the database. For more details about password security, see MySQL’s
        End-User Guidelines for Password Security.

      • Host (--host=[] or -h []): The IP address or FQDN (fully qualified domain name) of the remote database server. You can omit this option from the command if you are connecting to a local MySQL instance on your same system.

      • Port (--port=[] or -P []): The port number of that the MySQL database instance uses. This can be omitted if your MySQL instance uses the default port of 3306.

      • SSL Settings (--ssl-mode): This controls if the connection should be encrypted. This can be set to DISABLED (unencrypted – not recommended), PREFERRED (tries an encrypted connection first before falling back to unencrypted), or REQUIRED (fails if an encrypted connection can’t be established. If omitted, this option is automatically set to PREFERRED. You can also set this to VERIFY_CA or VERIFY_IDENTITY to require an encrypted connection and either verify the CA certificate or both verify the CA certificate and the host name identity.

      If you are frequently connecting to the same database, you can securely store many of these options (including the password). See the
      Securely Storing Credentials guide. Other options can be stored in an
      option file.

      Configure the Database Server to Allow Remote Connections

      If you have installed the MySQL server yourself (not through a managed service) and wish to connect to a database remotely without first logging in to the database server through SSH, you may need to modify a few settings. This can be useful if you want to limit SSH access but still permit database access.

      Refer to our
      Create an SSH Tunnel for MySQL Remote Access to learn how to connect to your database using an SSH tunnel.

      1. Make sure your database has a user set up to allow connections from your local machine’s IP address.

        The example below displays a series of commands to create a new MySQL/MariaDB user named example_user. The user accepts connections from 192.0.2.0 and has SELECT, INSERT, UPDATE, and DELETE permissions on the example_db database:

        CREATE user 'example_user'@'192.0.2.0' IDENTIFIED BY 'password';
        GRANT SELECT,INSERT,UPDATE,DELETE ON example-db.* TO 'example_user' IDENTIFIED BY 'password';
        
      2. Locate you database’s configuration files using the command below. The following command lists the files’ default locations. The locations returned by the command may be different than those in the example shown below:

        sudo mysql --help
        
        ...
        Default options are read from the following files in the given order:
        /etc/my.cnf /etc/mysql/my.cnf ~/.my.cnf
        ...
      3. Using your preferred text editor, locate the [mysqld] section and a bind-address parameter.

        If you see any !includedir parameters in the files, you may also need to check the files in the locations those parameters designate.

      4. Once you locate the bind-address parameter, change it from the default 127.0.0.1 to 0.0.0.0. This enables external connections on the database.

        Also, if the file contains a skip-networking parameter, comment it out with a #.

        File: /etc/mysql/mysql.conf.d/mysqld.conf
        1
        2
        3
        4
        5
        6
        7
        8
        
        ...
        [mysqld]
        
        ...
        # skip-networking
        
        bind-address = 0.0.0.0
        ...
      5. Restart the MySQL service.

        sudo systemctl restart mysqld
        

      Follow our
      Install MySQL Workbench for Database Administration guide for steps to install the MySQL Workbench tool on your local machine. This guide also shows you how to connect to a remote database via MySQL Workbench. These steps work whether your target database server is MySQL or MariaDB.

      For more information, take a look at the
      official MySQL Workbench manual. You may also refer to MariaDB’s documentation on
      using the MySQL Workbench with MariaDB.

      Conclusion

      Now that you have your remote database connection, you may want to learn more about using MySQL/MariaDB and working with more advanced database operations. You can refer to our extensive
      list of MySQL guides and specific
      MariaDB guides to build your database management skills.

      More Information

      You may wish to consult the following resources for additional information
      on this topic. While these are provided in the hope that they will be
      useful, please note that we cannot vouch for the accuracy or timeliness of
      externally hosted materials.

      This page was originally published on



      Join the conversation.
      Read other comments or post your own below. Comments must be respectful,
      constructive, and relevant to the topic of the guide. Do not post external
      links or advertisements. Before posting, consider if your comment would be
      better addressed by contacting our
      Support team or asking on
      our
      Community Site.



      Source link

      Installing MySQL: A Definitive Guide


      MySQL is one of the most popular SQL-based relational databases. The Community Edition is available at no charge and is widely used across the industry. This guide walks you through installing and updating MySQL Community on Windows, macOS, and Linux (either through the native repositories or MySQL’s own repositories).

      When installing MySQL, you can either install MySQL Server or MySQL client utilities. Installing the entire MySQL Server software is the most common option. This allows you to run a full database server on your system. It also installs all of the client utilities that you might need when working with any MySQL instances (a locally installed one or one on a remote system). If you want to reduce disk usage or know you only need the client utilities, you can install the MySQL client package. Alternatively, consider installing and using the
      MySQL Shell.

      Currently, there are two primary MySQL releases to consider: MySQL 5.7 and MySQL 8.0. Both are still receiving support and updates (until October 2023 and April 2026 respectively). You should likely install MySQL 8.0 unless your application does not yet support it.

      Note

      For additional instructions on installing MySQL on any supported operating system, see the
      Installing and Upgrading MySQL guide in the official documentation.

      Before You Begin

      • Consider other deployment options, such as fully managed solutions or automated installations.

      • Check to see if MySQL is already installed on your system. To determine if MySQL is already installed, run the following command:

        mysql --version
        

        The above command should inform you which version you are using. If this command is not found, continue with the installation steps below. If the installed version differs from the release you want to use, consider first uninstalling it and then continuing with the instructions below.

      Note

      The steps in this guide are written for a non-root user. Commands that require elevated privileges are prefixed with sudo. If you’re not familiar with the sudo command, see the
      Linux Users and Groups guide.

      Installing MySQL on Windows

      1. Open a web browser and navigate to the
        MySQL Installer Downloads page. By default, the latest version of MySQL is displayed. You can also view the installer files for
        8.0 or
        5.7 directly. Alternatively, you can navigate to the Archives tab and select any MySQL release and version you wish.

      2. Select your operating system version, click the Download link corresponding with the package you’d like to install, and then click the No thanks, just start my download link. The file should now start downloading.

      3. Open the downloaded file and follow the prompts to install MySQL on your system.

      Installing MySQL on macOS

      1. Open a web browser and navigate to the
        MySQL Community Server Downloads page. By default, the latest version of MySQL is displayed. You can also view the installer files for
        8.0 or
        5.7 directly. Alternatively, you can navigate to the Archives tab and select any MySQL release and version you wish.

      2. Select your operating system version, click the Download link corresponding with the package you’d like to install, and then click the No thanks, just start my download link. The file should now start downloading.

      3. Open the downloaded file and follow the prompts to install MySQL on your system.

      Installing MySQL on Linux: Native Repositories

      One of the fastest ways to quickly install MySQL on most common Linux distributions is to use the distribution’s default/native repositories. For greater control over the release and version that’s installed, and to get the latest versions faster, you may want to consider using
      MySQL’s own YUM or APT repositories.

      CentOS Stream 8 (and 9), CentOS/RHEL 8 (and 9)

      sudo dnf upgrade && sudo dnf install mysql-server
      

      CentOS/RHEL 7

      MySQL is not available through CentOS 7’s native repositories (see
      CentOS 7 Packages list). Installing the mysql package actually installs the mariadb package. While MariaDB can be used as a drop-in replacement in some cases, it may be preferable to install MySQL through the
      MySQL YUM repository.

      sudo yum update && sudo yum install mariadb-server
      

      Debian

      MySQL is not available through Debian’s native repositories. Instead, Debian includes MariaDB. While MariaDB can be used as a drop-in replacement in some cases, it may be preferable to install MySQL through the
      MySQL APT repository.

      sudo apt update && sudo apt install mariadb-server
      

      Fedora

      sudo dnf update && sudo dnf install mysql-community-server
      

      Ubuntu

      sudo apt update && sudo apt install mysql-server
      

      Replace mysql-server with one of the available packages below. If no version is specified in the package name, the default version is installed.

      • MySQL Server packages: mysql-server

        Target a specific version with mysql-server-5.7 or mysql-server-8.0. See
        Ubuntu Package Search for more.

      • MySQL Client packages: mysql-client

        Target a specific version with mysql-client-5.7 or mysql-client-8.0. See
        Ubuntu Package Search for more.

      Installing MySQL on Linux: MySQL’s Repositories

      Using MySQL’s own repositories provides the latest MySQL versions faster than most native repositories. It also allows you more control over the version that is installed.

      Ubuntu and Debian (APT Repository)

      1. Download the release package for your distribution. Currently, all compatible distributions are combined into a single release package.

        wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
        

        If you’d like to download the latest version of this file or to select a different distribution, visit the
        MySQL APT Repository Downloads page. To obtain the URL for the file, click the Downloads button next to the package you wish to download, right click on the No thanks, just start my download link, and select Copy Link Address (or similar).

      2. Install the downloaded release package. If you downloaded a different file than featured in the previous step, adjust the filename as needed.

        sudo dpkg -i ./mysql-apt-config_0.8.22-1_all.deb
        
      3. The repository configuration tool should automatically start. If not, you can run it using the following command:

        sudo dpkg-reconfigure mysql-apt-config
        
      4. Within the configuration tool, you can select from the options below to adjust how the repository is configured in your system:

        • MySQL Server & Cluster: Select mysql to add MySQL Server packages, mysql-cluster to add the
          MySQL NDB Cluster, or None to forgo adding either option.

        • MySQL Tools & Connectors: When enabled, this option adds all of the additional tools and utilities included with the MySQL software.

        • MySQL Preview Packages: Leave this option as disabled in production, though non-production environments can enable this to test unreleased features and products.

      5. Run the update command to obtain updated package version and dependency information:

        sudo apt update
        
      6. Install MySQL Server or just the MySQL client tools:

        Additional information about the packages available within MySQL’s APT repository can be found by exploring the repository for your distribution:
        Ubuntu or
        Debian.

      CentOS/RHEL and Fedora (YUM Repository)

      1. Download the release package for your distribution.

        curl -OL [file-url]
        
        • CentOS/RHEL 8: https://dev.mysql.com/get/mysql80-community-release-el8-4.noarch.rpm
        • CentOS/RHEL 7: https://dev.mysql.com/get/mysql80-community-release-el7-6.noarch.rpm
        • Fedora 35: https://dev.mysql.com/get/mysql80-community-release-fc35-3.noarch.rpm
        • Fedora 34: https://dev.mysql.com/get/mysql80-community-release-fc34-4.noarch.rpm

        If you’d like to download the latest file or to select a different distribution, visit the
        MySQL YUM Repository Downloads page. To obtain the URL for the desired file, click the Downloads button next to the package you wish to download, right click on the No thanks, just start my download link, and select Copy Link Address (or similar).

      2. Install the downloaded release package, replacing [filename] with the file you just downloaded.

        sudo yum install [filename]
        

        Once installed, you can view all available packages and all enabled packages by running the commands below:

        yum repolist all | grep mysql
        yum repolist enabled | grep mysql
        
      3. By default, the MySQL 8.0 release will be installed. To switch this to MySQL 5.7 or any other available release, run the following commands:

        • CentOS Stream 8 (and 9), CentOS/RHEL 8 (and 9)

          sudo dnf config-manager --disable mysql80-community
          sudo dnf config-manager --enable mysql57-community
          
        • CentOS/RHEL 7:

          sudo yum-config-manager --disable mysql80-community
          sudo yum-config-manager --enable mysql57-community
          
      4. Within CentOS/RHEL 8 distributions, disable the default MySQL module.

        sudo dnf module disable mysql
        
      5. Install MySQL Server or just the MySQL client tools:

        Additional information about the packages available within MySQL’s YUM repository can be found by
        exploring the repository.

      More Information

      You may wish to consult the following resources for additional information
      on this topic. While these are provided in the hope that they will be
      useful, please note that we cannot vouch for the accuracy or timeliness of
      externally hosted materials.



      Source link