| 1 |
.. -*- rst -*- |
| 2 |
|
| 3 |
``grndb`` |
| 4 |
========= |
| 5 |
|
| 6 |
Summary |
| 7 |
------- |
| 8 |
|
| 9 |
.. versionadded:: 4.0.9 |
| 10 |
|
| 11 |
``grndb`` manages a Groonga database. |
| 12 |
|
| 13 |
Here are features: |
| 14 |
|
| 15 |
* Checks whether database is broken or not. |
| 16 |
* Recovers broken database automatically if the database is |
| 17 |
recoverable. |
| 18 |
|
| 19 |
Syntax |
| 20 |
------ |
| 21 |
|
| 22 |
``grndb`` requires command and database path:: |
| 23 |
|
| 24 |
grndb COMMAND [OPTIONS] DATABASE_PATH |
| 25 |
|
| 26 |
Here are available commands: |
| 27 |
|
| 28 |
* ``check`` - Checks whether database is broken or not. |
| 29 |
* ``recover`` - Recovers database. |
| 30 |
|
| 31 |
Usage |
| 32 |
----- |
| 33 |
|
| 34 |
Here is an example to check the database at ``/var/lib/groonga/db/db``:: |
| 35 |
|
| 36 |
% grndb check /var/lib/groonga/db/db |
| 37 |
|
| 38 |
Here is an example to recover the database at ``/var/lib/groonga/db/db``:: |
| 39 |
|
| 40 |
% grndb recover /var/lib/groonga/db/db |
| 41 |
|
| 42 |
Commands |
| 43 |
-------- |
| 44 |
|
| 45 |
This section describes available commands. |
| 46 |
|
| 47 |
``check`` |
| 48 |
^^^^^^^^^ |
| 49 |
|
| 50 |
It checks an existing Groonga database. If the database is broken, |
| 51 |
``grndb`` reports reasons and exits with non-``0`` exit status. |
| 52 |
|
| 53 |
.. note:: |
| 54 |
|
| 55 |
You must not use this command for opened database. If the database |
| 56 |
is opened, this command may report wrong result. |
| 57 |
|
| 58 |
``check`` has some options. |
| 59 |
|
| 60 |
``--target`` |
| 61 |
"""""""""""" |
| 62 |
|
| 63 |
.. versionadded:: 5.1.2 |
| 64 |
|
| 65 |
It specifies a check target object. |
| 66 |
|
| 67 |
If your database is large and you know an unreliable object, this |
| 68 |
option will help you. ``check`` need more time for large database. You |
| 69 |
can reduce check time by ``--target`` option to reduce check target. |
| 70 |
|
| 71 |
The check target is checked recursive. Because related objects of |
| 72 |
unreliable object will be unreliable. |
| 73 |
|
| 74 |
If the check target is a table, all columns of the table are also |
| 75 |
checked recursive. |
| 76 |
|
| 77 |
If the check target is a table and its key type is another table, the |
| 78 |
another table is also checked recursive. |
| 79 |
|
| 80 |
If the check target is a column and its value type is a table, the |
| 81 |
table is also checked recursive. |
| 82 |
|
| 83 |
If the check target is an index column, the table specified as value |
| 84 |
type and all sources are also checked recursive. |
| 85 |
|
| 86 |
Here is an example that checks only ``Entries`` table and its |
| 87 |
columns:: |
| 88 |
|
| 89 |
% grndb check --target Entries /var/lib/groonga/db/db |
| 90 |
|
| 91 |
Here is an example that checks only ``Entries.name`` column:: |
| 92 |
|
| 93 |
% grndb check --target Entries.name /var/lib/groonga/db/db |
| 94 |
|
| 95 |
``--log-level`` |
| 96 |
""""""""""""""" |
| 97 |
|
| 98 |
.. versionadded:: 7.0.4 |
| 99 |
|
| 100 |
It specifies a log level of ``grndb`` log. |
| 101 |
|
| 102 |
Here is an example that specifies ``--log-level`` option:: |
| 103 |
|
| 104 |
% grndb check --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db |
| 105 |
|
| 106 |
See :doc:`/reference/commands/log_level` to know about supported log level. |
| 107 |
|
| 108 |
``--log-path`` |
| 109 |
"""""""""""""" |
| 110 |
|
| 111 |
.. versionadded:: 7.0.4 |
| 112 |
|
| 113 |
It specifies a path of ``grndb`` log. |
| 114 |
|
| 115 |
Here is an example that specifies ``--log-path`` option:: |
| 116 |
|
| 117 |
% grndb check --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db |
| 118 |
|
| 119 |
``--log-flags`` |
| 120 |
""""""""""""""" |
| 121 |
|
| 122 |
.. versionadded:: 9.0.3 |
| 123 |
|
| 124 |
It specifies a logged content in ``grndb`` log by flags. |
| 125 |
The default value of ``--log-flags`` is ``time|message``. It means that timestamp and log messages are logged into ``grndb`` log. |
| 126 |
|
| 127 |
Here is an example that specifies ``--log-flags`` option:: |
| 128 |
|
| 129 |
% grndb check --log-path /var/log/groonga/grndb.log --log-flags "time|pid|message" /var/lib/groonga/db/db |
| 130 |
|
| 131 |
See :doc:`groonga` to know about supported log flags. |
| 132 |
|
| 133 |
``--since`` |
| 134 |
""""""""""" |
| 135 |
|
| 136 |
.. versionadded:: 9.0.4 |
| 137 |
|
| 138 |
It specifies the object's modified time which should be checked. If object's modified time is newer than the specified time, these objects are checked by ``grndb``. |
| 139 |
You can specify the modified time as ISO 8601 format or ``-NUNIT`` format such as -3days or -2.5weeks format. |
| 140 |
|
| 141 |
Here is an example that specifies ``--since`` option in ISO 8601 format:: |
| 142 |
|
| 143 |
% grmdb check --since=2019-06-24T18:16:22 /var/lib/groonga/db/db |
| 144 |
|
| 145 |
In above example, the objects which are modified after ``2019-06-24T18:16:22`` are checked. |
| 146 |
|
| 147 |
Here is an example that specifies ``--since`` option in ``-NUNIT`` format:: |
| 148 |
|
| 149 |
% grmdb check --since=-7d /var/lib/groonga/db/db |
| 150 |
|
| 151 |
In above example, the objects which are modified in recent 7 days are checked. |
| 152 |
|
| 153 |
``-NUNIT`` accepts the following suffix as a unit. |
| 154 |
|
| 155 |
.. list-table:: |
| 156 |
:header-rows: 1 |
| 157 |
|
| 158 |
* - Supported suffix |
| 159 |
- Description |
| 160 |
* - ``s``, ``sec``, ``secs``, ``second``, ``seconds`` |
| 161 |
- Specify recent N seconds. For example, ``--since=-100s`` means within recent 100 seconds should be checked. |
| 162 |
* - ``m``, ``min``, ``mins``, ``minute``, ``minutes`` |
| 163 |
- Specify recent N minutes. For example, ``--since=-10m`` means within recent 10 minutes should be checked. |
| 164 |
* - ``h``, ``hour``, ``hours`` |
| 165 |
- Specify recent N hours. For example, ``--since=-10h`` means within recent 10 hours should be checked. |
| 166 |
* - ``d``, ``day``, ``days`` |
| 167 |
- Specify recent N days. For example, ``--since=-10d`` means within recent 10 days should be checked. |
| 168 |
* - ``w``, ``week``, ``weeks`` |
| 169 |
- Specify recent N weeks. For example, ``--since=-10w`` means within recent 10 weeks should be checked. |
| 170 |
* - ``month``, ``months`` |
| 171 |
- Specify recent N months. For example, ``--since=-10month`` means within recent 10 months should be checked. |
| 172 |
* - ``year``, ``years`` |
| 173 |
- Specify recent N years. For example, ``--since=-1year`` means within recent 1 year should be checked. |
| 174 |
|
| 175 |
``recover`` |
| 176 |
^^^^^^^^^^^ |
| 177 |
|
| 178 |
It recovers an existing broken Groonga database. |
| 179 |
|
| 180 |
If the database is not broken, ``grndb`` does nothing and exits with |
| 181 |
``0`` exit status. |
| 182 |
|
| 183 |
If the database is broken and one or more index columns are only |
| 184 |
broken, ``grndb`` recovers these index columns and exists with ``0`` |
| 185 |
exit status. It may take a long time for large indexed data. |
| 186 |
|
| 187 |
If the database is broken and tables or data columns are broken, |
| 188 |
``grndb`` reports broken reasons and exits with non-``0`` exit |
| 189 |
status. You can know whether the database is recoverable or not by |
| 190 |
``check`` command. |
| 191 |
|
| 192 |
.. note:: |
| 193 |
|
| 194 |
You must not use this command for opened database. If the database |
| 195 |
is opened, this command may break the database. |
| 196 |
|
| 197 |
``recover`` has some options. |
| 198 |
|
| 199 |
.. _grndb-force-truncate: |
| 200 |
|
| 201 |
``--force-truncate`` |
| 202 |
"""""""""""""""""""" |
| 203 |
|
| 204 |
.. versionadded:: 7.0.4 |
| 205 |
|
| 206 |
It forces to truncate a corrupted database object. |
| 207 |
|
| 208 |
Here is an example that specifies ``--force-truncate`` option:: |
| 209 |
|
| 210 |
% grndb recover --force-truncate --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db |
| 211 |
|
| 212 |
When this option is specified, ``grndb`` does the followings: |
| 213 |
|
| 214 |
* check whether there is a corrupted database object (table, column, indexes) |
| 215 |
* truncate a corrupted database object (table, column, indexes) |
| 216 |
* remove incremental files with .00N suffix which is created when large amount of data is loaded |
| 217 |
|
| 218 |
``--force-truncate`` option is destructive one. Even though lock is still remained, ``grndb`` truncates a targeted corrupted database object. |
| 219 |
|
| 220 |
After ``grndb recover`` command has finished, you need to load data |
| 221 |
against truncated tables or columns to recreate database. |
| 222 |
|
| 223 |
.. note:: |
| 224 |
|
| 225 |
You must use this option only when necessary. It means that you use it when there is a mismatch between database meta information and database object files which exists actually. This options should be used when there is no other way to recover database. |
| 226 |
|
| 227 |
.. _grndb-force-lock-clear: |
| 228 |
|
| 229 |
``--force-lock-clear`` |
| 230 |
"""""""""""""""""""""" |
| 231 |
|
| 232 |
.. versionadded:: 7.1.1 |
| 233 |
|
| 234 |
It forces to clear lock of database, table and data column. It doesn't |
| 235 |
clear lock of index column. If index column has lock, the index column |
| 236 |
is recreated instead of clearing lock. |
| 237 |
|
| 238 |
Normally, you should truncate and load data again instead of just |
| 239 |
clearing lock. Because objects that have lock may be broken. This |
| 240 |
option is provided only for users who know the risk that "the database |
| 241 |
may be broken but I want to keep using it". |
| 242 |
|
| 243 |
Here is an example that specifies ``--force-lock-clear`` option:: |
| 244 |
|
| 245 |
% grndb recover --force-lock-clear --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db |
| 246 |
|
| 247 |
When this option is specified, ``grndb`` does the followings: |
| 248 |
|
| 249 |
* check whether there are database, table or data column that have lock |
| 250 |
* clear lock of these objects |
| 251 |
|
| 252 |
.. note:: |
| 253 |
|
| 254 |
You must use this option only when necessary. Because your database |
| 255 |
may not be recovered. The database that has objects that have lock |
| 256 |
may be broken or not be broken. You can keep using the database but |
| 257 |
Groonga may crash if the database is broken. |
| 258 |
|
| 259 |
``--log-level`` |
| 260 |
""""""""""""""" |
| 261 |
|
| 262 |
.. versionadded:: 7.0.4 |
| 263 |
|
| 264 |
It specifies a log level of ``grndb`` log. |
| 265 |
|
| 266 |
Here is an example that specifies ``--log-level`` option:: |
| 267 |
|
| 268 |
% grndb recover --log-level info --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db |
| 269 |
|
| 270 |
See :doc:`/reference/commands/log_level` to know about supported log level. |
| 271 |
|
| 272 |
``--log-path`` |
| 273 |
"""""""""""""" |
| 274 |
|
| 275 |
.. versionadded:: 7.0.4 |
| 276 |
|
| 277 |
It specifies a path of ``grndb`` log. |
| 278 |
|
| 279 |
Here is an example that specifies ``--log-path`` option:: |
| 280 |
|
| 281 |
% grndb recover --log-path /var/log/groonga/grndb.log /var/lib/groonga/db/db |
| 282 |
|
| 283 |
``--log-flags`` |
| 284 |
""""""""""""""" |
| 285 |
|
| 286 |
.. versionadded:: 9.0.2 |
| 287 |
|
| 288 |
It specifies a logged content in ``grndb`` log by flags. |
| 289 |
The default value of ``--log-flags`` is ``time|message``. It means that timestamp and log messages are logged into ``grndb`` log. |
| 290 |
|
| 291 |
Here is an example that specifies ``--log-flags`` option:: |
| 292 |
|
| 293 |
% grndb check --log-path /var/log/groonga/grndb.log --log-flags "time|pid|message" /var/lib/groonga/db/db |
| 294 |
|
| 295 |
See :doc:`groonga` to know about supported log flags. |