官术网_书友最值得收藏!

Using SHOW STATUS to check if a feature is being used

The SHOW STATUS command shows information about the server. This includes things such as the number of bytes of data received and sent by the server, the number of connections served, the number of rows read, and so on. The command can also be used to check whether a feature has been enabled or is being used.

How to do it...

  1. Launch the mysql command-line client and connect to our MariaDB database server.
  2. Uninstall the Cassandra storage engine with:
    UNINSTALL SONAME 'ha_cassandra.so';
    
  3. MariaDB will either respond with a Query OK message (if the Cassandra storage engine was installed and has now been uninstalled) or it will give the SONAME ha_cassandra.so does not exist error (if the Cassandra storage engine was not installed). Either of the messages is ok.
  4. Issue the following SHOW STATUS command to see if the Cassandra storage engine is installed. The result will be an Empty set, which means that it is not installed:
    SHOW STATUS LIKE 'Cassandra%';
    
  5. Install the Cassandra storage engine with the following command, and the result will be Query OK:
    INSTALL SONAME 'ha_cassandra.so';
    
  6. Issue the SHOW STATUS command from step 3 again. This time, an output similar to the following screenshot will be displayed:
    How to do it...

How it works...

The SHOW STATUS output gives us two different sets of information in this recipe. Firstly, the actual presence of the Cassandra% variables tells us that the Cassandra storage engine is installed. Secondly, it shows us some useful information about our usage of the Cassandra storage engine since it was installed (or the server was last restarted) and if there have been any exceptions. Since we just installed the plugin, all the values will likely be zeroes unless we have an active application that used the plugin between the time when we ran the INSTALL and SHOW STATUS commands.

There's more...

In the recipe, we modified the full SHOW STATUS output to restrict it just to the information on the Cassandra storage engine by adding LIKE 'Cassandra%' to the end of the command. We could also just add the following line of command to get the complete output:

SHOW STATUS;

There is a lot of output, so it is often better to use LIKE and some text with the wildcard character (%) to shorten the output to just what we want to know.

Many plugins and storage engines in MariaDB provide the STATUS variables that are useful when we want to know how the engine or plugin is operating. However, not all do; the preferred method to check whether a given plugin or storage engine is installed is to use the SHOW PLUGINS; command.

See also

主站蜘蛛池模板: 常熟市| 濉溪县| 武平县| 平湖市| 凉城县| 柳河县| 万荣县| 石家庄市| 抚顺县| 民县| 杨浦区| 梨树县| 嵊泗县| 奉化市| 博客| 米林县| 海丰县| 连江县| 肃南| 金坛市| 清水河县| 阿克苏市| 顺昌县| 边坝县| 衡阳县| 柘荣县| 嫩江县| 喀喇| 丹巴县| 寿宁县| 祁连县| 大丰市| 陕西省| 镶黄旗| 凉山| 开封市| 海南省| 洛南县| 望奎县| 肥西县| 霸州市|