One place for hosting & domains

      March 2019

      Tags and Groups


      Updated by Linode

      Contributed by

      Linode

      Linode’s Cloud Manager and API allow you to create tags to help organize and group your Linode resources. Tags can be applied to Linodes, Block Storage Volumes, NodeBalancers, and Domains.

      This guide will show you how to perform the following actions with the Cloud Manager:

      • Create and apply tags to your Linode resources
      • Search and group your Linode resources by tag
      • Import tags from the Classic Manager

      Tagging a Linode

      Tag a Linode at Creation

      To tag a Linode at the time of its creation:

      1. In the Create New Linode form, click the dropdown menu labeled Add Tags located below the Linode Label field.

      2. Select one or more tags from the menu. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears:

        Add Tags field in the Linode creation form

      3. Your tag will be applied when you finish creating the Linode.

      Tag an Existing Linode

      To tag an existing Linode:

      1. Navigate to the Linode’s detail page.

      2. Click on the Summary tab.

      3. Locate the Tags pane and click on the Add New Tag option.

      4. Select one or more tags from the dropdown menu that appears. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears:

        Location of Tags box for a Linode

      Remove a Tag from a Linode

      To remove a tag from a Linode:

      1. Navigate to the Linode’s detail page.

      2. Click on the Summary tab.

      3. Locate the Tags box. A list of your tags for the Linode will be displayed.

      4. Click on the X icon attached to the tag you would like to remove from your Linode.

      Tagging a Volume

      Tag a Volume at Creation

      To tag a Volume at the time of its creation:

      1. In the Create a Volume form, select the dropdown menu labeled Tags.

      2. Select one or more tags from the menu. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears.

        Tags field in the Volume creation form

      3. Once you are done configuring the Volume, click Submit.

      Tag an Existing Volume

      To tag an existing Volume:

      1. Navigate to the Volumes page of the Cloud Manager.

      2. Select the more options ellipsis (…) corresponding to the Volume you would like to tag.

      3. Select Edit Volume from the menu that appears.

      4. The Edit volume form will appear. Click on the dropdown menu labeled Tags.

      5. Select one or more tags from the form. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears.

      6. When you are done, click Submit:

        Tags field in the Edit volume form

      Remove a Tag from a Volume

      To remove a tag from a Volume:

      1. Navigate to the Volumes page of the Cloud Manager.

      2. Select the more options ellipsis (…) corresponding to the Volume whose tags you would like to edit.

      3. Select Edit Volume from the menu that appears.

      4. The Edit volume form will appear. A list of your tags for the Volume will be displayed in the Tags field.

      5. Click on the x icon attached to the tag you would like to remove from your Volume.

      Tagging a NodeBalancer

      Tag a NodeBalancer at Creation

      To tag a NodeBalancer at the time of its creation:

      1. In the Create a NodeBalancer form, click the dropdown menu labeled Add Tags under the NodeBalancer Label field.

      2. Select one or more tags from the menu. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears.

        Add Tags field in the NodeBalancer creation form

      3. Once you are done configuring the NodeBalancer, click Create.

      Tag an Existing NodeBalancer

      To tag an existing NodeBalancer:

      1. Navigate to the NodeBalancer’s detail page.

      2. Click on the Summary tab.

      3. Locate the Tags pane and click on the Add New Tag option.

      4. Select one or more tags from the dropdown menu that appears. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears:

        Location of Tags box for a NodeBalancer

      Remove a Tag from a NodeBalancer

      To remove a tag from a NodeBalancer:

      1. Navigate to the NodeBalancer’s detail page.

      2. Click on the Summary tab.

      3. Locate the Tags pane. A list of your tags for the NodeBalancer will be displayed.

      4. Click on the x icon attached to the tag you would like to remove from your NodeBalancer.

      Tagging a Domain

      Tag a Domain at Creation

      To tag a domain at the time of its creation:

      1. In the Add a new Domain form, click the dropdown menu labeled Add Tags.

      2. Select one or more tags from the menu. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears:

        Tags field in the domain creation form

      Tag an Existing Domain

      To tag an existing domain:

      1. Navigate to the domain’s detail page.

      2. Click on the DNS Records tab.

      3. Locate the pane labeled Tags and click on the Add New Tag option.

      4. Select one or more tags from the dropdown menu that appears. To create a new tag, type in the desired tag name and click the Create “new-tag” option that appears:

        Location of Tags box for a domain

      Remove a Tag from a Domain

      To remove a tag from a domain:

      1. Navigate to the domain’s detail page.

      2. Click on the DNS Records tab.

      3. Locate the Tags pane. A list of your tags for the Domain will be displayed.

      4. Click on the x icon attached to the tag you would like to remove from your domain.

      Grouping by Tag

      You can group the following resources by tag: Linodes, Volumes, NodeBalancers, and Domains.

      1. To group by tag, navigate to the resource’s page and toggle the Group by Tag switch at the top of the page:

        Cloud Manager Group by Tag switch

      2. You will now be able to view your resources grouped by tag:

        Group your Linodes by tag

      Searching by Tag

      You can search your Linode resources by a tag’s name:

      1. Type the tag name into the search bar at the top of the Cloud Manager and the results will be populated in a dropdown list that appears:

        Cloud Manager tag search

      2. To see a more organized view of your tagged resources, click on the blue View search results page banner inside the dropdown list, or hit the Enter key on your keyboard. You will be taken to the search results page:

        Cloud Manager search results page

      3. A second way to search by tag is to click on a tag wherever it appears in the Cloud Manager. For example, if you previously applied a tag named tag-example to one of your Linodes, clicking on that tag where it is displayed in the Linode’s detail page will take you to the search results page for tag-example.

      If you have used the Display Groups feature in the Classic Manager, you can import your Display Groups to the Cloud Manager as tags:

      1. Navigate to the Account page in the sidebar links menu, then click on the Settings tab.

      2. Expand the panel labeled Import Display Groups as Tags and then click Import Display Groups:

        Cloud Manager import display groups as tags

      3. A form will appear that lists your Display Groups and asks you to confirm the import action. To proceed, click the Import Display Groups Now button in this form.

        Note

        Importing your Display Groups is a one-time operation. If you don’t have any Display Groups configured in the Classic Manager this feature will not appear in the Cloud Manager.

      Find answers, ask questions, and help others.

      This guide is published under a CC BY-ND 4.0 license.



      Source link

      How To Fix Corrupted Tables in MySQL



      Part of the Series:
      How To Troubleshoot Issues in MySQL

      This guide is intended to serve as a troubleshooting resource and starting point as you diagnose your MySQL setup. We’ll go over some of the issues that many MySQL users encounter and provide guidance for troubleshooting specific problems. We will also include links to DigitalOcean tutorials and the official MySQL documentation that may be useful in certain cases.

      Occasionally, MySQL tables can become corrupted, meaning that an error has occurred and the data held within them is unreadable. Attempts to read from a corrupted table will usually lead to the server crashing.

      Some common causes of corrupted tables are:

      • The MySQL server stops in middle of a write.
      • An external program modifies a table that’s simultaneously being modified by the server.
      • The machine is shut down unexpectedly.
      • The computer hardware fails.
      • There’s a software bug somewhere in the MySQL code.

      If you suspect that one of your tables has been corrupted, you should make a backup of your data directory before troubleshooting or attempting to fix the table. This will help to minimize the risk of data loss.

      First, stop the MySQL service:

      • sudo systemctl stop mysql

      Then copy all of your data into a new backup directory. On Ubuntu systems, the default data directory is /var/lib/mysql/:

      • cp -r /var/lib/mysql /var/lib/mysql_bkp

      After making the backup, you’re ready to begin investigating whther the table is in fact corrupted. If the table uses the MyISAM storage engine, you can check whether it’s corrupted by running a CHECK TABLE statement from the MySQL prompt:

      A message will appear in this statement's output letting you know whether or not it's corrupted. If the MyISAM table is indeed corrupted, it can usually be repaired by issuing a REPAIR TABLE statement:

      Assuming the repair was successful, you will see a message like the following in your output:

      Output

      +--------------------------+--------+----------+----------+ | Table | Op | Msg_type | Msg_text | +--------------------------+--------+----------+----------+ | database_name.table_name | repair | status | OK | +--------------------------+--------+----------+----------+

      If the table is still corrupted, though, the MySQL documentation suggests a few alternative methods for repairing corrupted tables.

      On the other hand, if the corrupted table uses the InnoDB storage engine, then the process for repairing it will be different. InnoDB is the default storage engine in MySQL as of version 5.5, and it features automated corruption checking and repair operations. InnoDB checks for corrupted pages by performing checksums on every page it reads, and if it finds a checksum discrepancy it will automatically stop the MySQL server.

      There is rarely a need to repair InnoDB tables, as InnoDB features a crash recovery mechanism that can resolve most issues when the server is restarted. However, if you do encounter a situation where you need to rebuild a corrupted InnoDB table, the MySQL documentation recommends using the "Dump and Reload" method. This involves regaining access to the corrupted table, using the mysqldump utility to create a logical backup of the table, which will retain the table structure and the data within it, and then reloading the table back into the database.

      With that in mind, try restarting the MySQL service to see if doing so will allow you access to the server:

      • sudo systemctl restart mysql

      If the server remains crashed or otherwise inaccessible, then it may be helpful to enable InnoDB's force_recovery option. You can do this by editing the mysqld.cnf file:

      • sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf

      In the [mysqld] section, add the following line:

      /etc/mysql/mysql.conf.d/mysqld.cnf

      . . .
      [mysqld]
      . . .
      innodb_force_recovery=1
      

      Save and close the file, and then try restarting the MySQL service again. If you can successfully access the corrupted table, use the mysqldump utility to dump your table data to a new file. You can name this file whatever you like, but here we'll name it out.sql:

      • mysqldump database_name table_name > out.sql

      Then drop the table from the database. To avoid having to reopen the MySQL prompt, you can use the following syntax:

      • mysql -u user -p --execute="DROP TABLE database_name.table_name"

      Following this, restore the table with the dump file you just created:

      • mysql -u user -p < out.sql

      Note that the InnoDB storage engine is generally more fault-tolerant than the older MyISAM engine. Tables using InnoDB can still be corrupted, but because of its auto-recovery features the risk of table corruption and crashes is decidedly lower.



      Source link

      How To Troubleshoot Socket Errors in MySQL


      MySQL manages connections to the database server through the use of a socket file, a special kind of file that facilitates communications between different processes. The MySQL server’s socket file is named mysqld.sock and on Ubuntu systems it’s usually stored in the /var/run/mysqld/ directory. This file is created by the MySQL service automatically.

      Sometimes, changes to your system or your MySQL configuration can result in MySQL being unable to read the socket file, preventing you from gaining access to your databases. The most common socket error looks like this:

      Output

      ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

      There are a few reasons why this error may occur, and a few potential ways to resolve it.

      One common cause of this error is that the MySQL service is stopped or did not start to begin with, meaning that it was unable to create the socket file in the first place. To find out if this is the reason you’re seeing this error, try starting the service with systemctl:

      • sudo systemctl start mysql

      Then try accessing the MySQL prompt again. If you still receive the socket error, double check the location where your MySQL installation is looking for the socket file. This information can be found in the mysqld.cnf file:

      • sudo nano /etc/mysql/mysql.conf.d/mysql.cnf

      Look for the socket parameter in the [mysqld] section of this file. It will look like this:

      /etc/mysql/mysql.conf.d/mysqld.cnf

      . . .
      [mysqld]
      user            = mysql
      pid-file        = /var/run/mysqld/mysqld.pid
      socket          = /var/run/mysqld/mysqld.sock
      port            = 3306
      . . .
      

      Close this file, then ensure that the mysqld.sock file exists by running an ls command on the directory where MySQL expects to find it:

      If the socket file exists, you will see it in this command's output:

      Output

      . .. mysqld.pid mysqld.sock mysqld.sock.lock

      If the file does not exist, the reason may be that MySQL is trying to create it, but does not have adequate permissions to do so. You can ensure that the correct permissions are in place by changing the directory's ownership to the mysql user and group:

      • sudo chown mysql:mysql /var/run/mysqld/

      Then ensure that the mysql user has the appropriate permissions over the directory. Setting these to 775 will work in most cases:

      • sudo chmod -R 755 /var/run/mysqld/

      Finally, restart the MySQL service so it can attempt to create the socket file again:

      • sudo systemctl restart mysql

      Then try accessing the MySQL prompt once again. If you still encounter the socket error, there's likely a deeper issue with your MySQL instance, in which case you should review the error log to see if it can provide any clues.



      Source link