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

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

主站蜘蛛池模板: 余江县| 博野县| 荆门市| 阿瓦提县| 白河县| 酒泉市| 井研县| 武定县| 区。| 左权县| 龙泉市| 西畴县| 扎鲁特旗| 靖宇县| 明溪县| 日照市| 屯门区| 霍州市| 喀什市| 青铜峡市| 泾川县| 石家庄市| 进贤县| 遂溪县| 汕尾市| 澎湖县| 新巴尔虎右旗| 甘孜| 临高县| 吉木乃县| 丹巴县| 宜阳县| 遂平县| 甘德县| 都安| 安陆市| 康平县| 神池县| 安国市| 曲麻莱县| 龙江县|