如何让 Laravel 7 Homestead 数据库快照正常工作?
How can I get the Laravel 7 Homestead database snapshots working?
多年来我一直很喜欢 Homestead,今天我注意到一个非常吸引人的功能,这是我以前从未使用过的。
https://laravel.com/docs/7.x/homestead#database-snapshots 说:
Homestead supports freezing the state of MySQL and MariaDB databases
and branching between them using Logical MySQL Manager. For example,
imagine working on a site with a multi-gigabyte database. You can
import the database and take a snapshot. After doing some work and
creating some test content locally, you may quickly restore back to
the original state.
...
A common workflow looks like the following:
- Import a database into the default
master
lmm branch.
- Save a snapshot
of the unchanged database using
sudo lmm branch prod-YYYY-MM-DD
.
- Modify the database.
- Run
sudo lmm merge prod-YYYY-MM-DD
to undo all
changes.
- Run
sudo lmm delete <branch>
to delete unneeded branches.
这个工具听起来很有用,但我无法按照这些说明进行操作。这是我尝试过的方法和结果:
sudo lmm status
Active snapshot:
Database snapshots:
master
2.70% used by MySQL databases.
sudo lmm branch beforeImports
df: '': No such file or directory
Logical volume name "" is invalid.
Run `lvcreate --help' for more information.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/prod-YYYY-MM-DD: special device /dev/homestead-vg/mysql-prod-YYYY-MM-DD does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
sudo lmm checkout master
is the currently active database.
Setting /homestead-vg/master as the active database.
rm: cannot remove '/var/lib/mysql': Is a directory
ln: failed to create symbolic link '/var/lib/mysql/master': File exists
我正在使用:Windows10,Vag运行t 2.2.7,Virtualbox 6.1.2,Homestead v10.2.0。
我做错了什么?
P.S。我查看了 https://github.com/Lullabot/lmm/blob/ubuntu-18.04/functions.sh#L5(我认为这是 Homestead 正在使用的),然后我查看了 运行 sudo echo `readlink
/var/lib/mysql`
,它打印了一个空行。但是 sudo ls -lah /var/lib/mysql
显示了很多文件。我显然不知道自己在做什么,希望得到任何帮助。
P.P.S。我也看到了https://github.com/laravel/homestead/issues/1112但是没看懂
存在阻止 LMM 使用 MySQL 8 的错误:https://github.com/laravel/homestead/issues/1383
多年来我一直很喜欢 Homestead,今天我注意到一个非常吸引人的功能,这是我以前从未使用过的。
https://laravel.com/docs/7.x/homestead#database-snapshots 说:
Homestead supports freezing the state of MySQL and MariaDB databases and branching between them using Logical MySQL Manager. For example, imagine working on a site with a multi-gigabyte database. You can import the database and take a snapshot. After doing some work and creating some test content locally, you may quickly restore back to the original state.
...
A common workflow looks like the following:
- Import a database into the default
master
lmm branch.- Save a snapshot of the unchanged database using
sudo lmm branch prod-YYYY-MM-DD
.- Modify the database.
- Run
sudo lmm merge prod-YYYY-MM-DD
to undo all changes.- Run
sudo lmm delete <branch>
to delete unneeded branches.
这个工具听起来很有用,但我无法按照这些说明进行操作。这是我尝试过的方法和结果:
sudo lmm status
Active snapshot:
Database snapshots:
master
2.70% used by MySQL databases.
sudo lmm branch beforeImports
df: '': No such file or directory
Logical volume name "" is invalid.
Run `lvcreate --help' for more information.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
mount: /homestead-vg/prod-YYYY-MM-DD: special device /dev/homestead-vg/mysql-prod-YYYY-MM-DD does not exist.
mount: /homestead-vg/beforeImports: special device /dev/homestead-vg/mysql-beforeImports does not exist.
sudo lmm checkout master
is the currently active database.
Setting /homestead-vg/master as the active database.
rm: cannot remove '/var/lib/mysql': Is a directory
ln: failed to create symbolic link '/var/lib/mysql/master': File exists
我正在使用:Windows10,Vag运行t 2.2.7,Virtualbox 6.1.2,Homestead v10.2.0。
我做错了什么?
P.S。我查看了 https://github.com/Lullabot/lmm/blob/ubuntu-18.04/functions.sh#L5(我认为这是 Homestead 正在使用的),然后我查看了 运行 sudo echo `readlink
/var/lib/mysql`
,它打印了一个空行。但是 sudo ls -lah /var/lib/mysql
显示了很多文件。我显然不知道自己在做什么,希望得到任何帮助。
P.P.S。我也看到了https://github.com/laravel/homestead/issues/1112但是没看懂
存在阻止 LMM 使用 MySQL 8 的错误:https://github.com/laravel/homestead/issues/1383