共享权限问题导致Greenplum初始化失败

今天在测试过程中发现了该问题,经过调查发现该问题在VMWare、Parallels Desktop和Docker中均会现过,记录一下,方便他人。

注:目前并未找到该问题的解决方案,如果有网友有解决办法,请留言交流~

背景介绍

我在虚拟机测试环境进行Greenplum数据库安装,由于本身CentOS7虚拟机分配的空间有限,故想采用PD(Parallels Desktop)与Mac主机的共享文件夹作为共享目录。从下面可以看到该目录比较大:

[gpadmin1@centos-7 master]$ df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/cl-root   41G  6.6G   35G  17% /
devtmpfs             3.9G     0  3.9G   0% /dev
tmpfs                3.9G   24K  3.9G   1% /dev/shm
tmpfs                3.9G  9.6M  3.9G   1% /run
tmpfs                3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1           1014M  169M  846M  17% /boot
/dev/mapper/cl-home   20G  279M   20G   2% /home
Home                 1.9T  145G  1.7T   8% /media/psf/Home
iCloud               1.9T  145G  1.7T   8% /media/psf/iCloud
tmpfs                782M   12K  782M   1% /run/user/42
tmpfs                782M     0  782M   0% /run/user/1000
tmpfs                782M     0  782M   0% /run/user/1001

重现步骤

首先我在/media/psf/Home目录下创建了数据目录GPData,作为PGDATA目录,用于初始化数据库。

[gpadmin1@centos-7 Home]$ ls -al
total 0
drwxr-xr-x  1 gpadmin1 gpadmin  1152 Feb  3 10:55 .
dr-xr-xr-x. 4 root     root       32 Feb  3 08:01 ..
-rw-r--r--  1 gpadmin1 gpadmin     0 Feb  2 15:40 .gitconfig
drwxr-xr-x  1 gpadmin1 gpadmin    96 Feb  3 07:36 GPData

从该目录的权限看,与本地文件夹的权限并没有什么区别。以下是发现出错原因后,在虚拟机本地创建的数据路径。

[gpadmin1@centos-7 ~]$ ls -al
drwxr-xr-x  2 gpadmin1 gpadmin  184 Feb  3 11:05 gpAdminLogs
drwxr-xr-x  4 gpadmin1 gpadmin   35 Feb  3 10:10 GPData
-rw-r--r--  1 gpadmin1 gpadmin   18 Feb  3 10:11 .gphostcache

然后编辑好初始化文件及主机文件,执行初始化命令。

[gpadmin1@centos-7 ~]$ gpinitsystem -c gpinitsystem_singlenode -h hostfile_singlenode -D

报错日志如下:

20200203:10:02:34:018332 gpinitsystem:centos-7:gpadmin1-[INFO]:-Building the Master instance database, please wait...
20200203:10:02:34:018332 gpinitsystem:centos-7:gpadmin1-[INFO]:-Initializing Master Postgres instance /media/psf/Home/GPData/singlenode/master/gpsne-1
20200203:10:02:34:018332 gpinitsystem:centos-7:gpadmin1-[INFO]:-Commencing local /usr/local/greenplum-db/./bin/initdb -E UNICODE -D /media/psf/Home/GPData/singlenode/master/gpsne-1 --locale=en_US.utf8        --max_connections=25 --shared_buffers=128000kB --data-checksums --backend_output=/media/psf/Home/GPData/singlenode/master/gpsne-1.initdb
The files belonging to this database system will be owned by user "gpadmin1".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default text search configuration will be set to "english".

Data page checksums are enabled.

creating directory /media/psf/Home/GPData/singlenode/master/gpsne-1 ... ok
creating subdirectories ... ok
selecting default max_connections ... 25
selecting default shared_buffers ... 125MB
selecting default timezone ... PRC
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
creating template1 database in /media/psf/Home/GPData/singlenode/master/gpsne-1/base/1 ... 2020-02-03 10:02:34.418437 CST,,,p19473,th-1304082304,,,,0,,,seg-10000,,,,,"LOG","42501","could not link file ""pg_xlog/xlogtemp.19473"" to ""pg_xlog/000000010000000000000001"": Operation not permitted",,,,,,,,"durable_link_or_rename","fd.c",579,
2020-02-03 10:02:34.420507 CST,,,p19473,th-1304082304,,,,0,,,seg-10000,,,,,"FATAL","58P01","could not open file ""pg_xlog/000000010000000000000001"": No such file or directory",,,,,,,,"XLogFileInit","xlog.c",3363,1    0x9f392c postgres errstart (elog.c:558)
2    0x550de2 postgres XLogFileInit (xlog.c:3255)
3    0x55261f postgres BootStrapXLOG (xlog.c:5151)
4    0x5959c3 postgres AuxiliaryProcessMain (bootstrap.c:492)
5    0x4ceb70 postgres main (main.c:243)
6    0x7f33addce445 libc.so.6 __libc_start_main + 0xf5
7    0x4cf10c postgres <symbol not found> + 0x4cf10c

child process exited with exit code 1
initdb: removing data directory "/media/psf/Home/GPData/singlenode/master/gpsne-1"
2020-02-03 02:02:34.059482 GMT,,,p19472,th314574976,,,,0,,,seg-10000,,,,,"LOG","00000","skipping missing configuration file ""/media/psf/Home/GPData/singlenode/master/gpsne-1/postgresql.auto.conf""",,,,,,,,"ParseConfigFile","guc-file.l",563,
20200203:10:02:34:018332 gpinitsystem:centos-7:gpadmin1-[INFO]:-Start Function ERROR_EXIT
20200203:10:02:34:018332 gpinitsystem:centos-7:gpadmin1-[FATAL]:- Command /usr/local/greenplum-db/./bin/initdb -E UNICODE -D /media/psf/Home/GPData/singlenode/master/gpsne-1 --locale=en_US.utf8        --max_connections=25 --shared_buffers=128000kB --data-checksums --backend_output=/media/psf/Home/GPData/singlenode/master/gpsne-1.initdb failed with error status 1, see log file /home/gpadmin1/gpAdminLogs/gpinitsystem_20200203.log for more detail Script Exiting!

错误分析

通过以上错误信息分析,第一次出现错误的位置为日志

creating template1 database in /media/psf/Home/GPData/singlenode/master/gpsne-1/base/1 ... 2020-02-03 10:02:34.418437 CST,,,p19473,th-1304082304,,,,0,,,seg-10000,,,,,"LOG","42501","could not link file ""pg_xlog/xlogtemp.19473"" to ""pg_xlog/000000010000000000000001"": Operation not permitted",,,,,,,,"durable_link_or_rename","fd.c",579,

该日志提示不能链接xlogtemp.19473和000000010000000000000001,该操作在创建template1数据库时报错(postgres数据库在初始化时会先创建template1数据库,然后在用copy template1形成template0和postgres数据库)。不能创建链接???这除了权限问题还能是啥问题呢?可是从虚拟机内部来看,本身是不存在问题的呀?

尝试从Mac本机查看权限,如下:

# chris @ ChrisdeMacBook-Pro in ~ [10:55:17]
$ ls -al GPData
total 0
drwxr-xr-x   3 chris  staff    96  2  3 07:36 .
drwxr-xr-x+ 36 chris  staff  1152  2  3 11:44 ..
drwxr-xr-x   4 chris  staff   128  2  3 07:43 singlenode

# chris @ ChrisdeMacBook-Pro in ~ [11:44:08]
$ ls -al GPData/singlenode
total 0
drwxr-xr-x  4 chris  staff  128  2  3 07:43 .
drwxr-xr-x  3 chris  staff   96  2  3 07:36 ..
drwxr-xr-x  3 chris  staff   96  2  3 10:06 master
drwxr-xr-x  2 chris  staff   64  2  3 10:02 primary

# chris @ ChrisdeMacBook-Pro in ~ [11:44:16]

可以看出从虚拟机内外查看权限是不一样的,这是因为该目录是采用虚拟机工具共享给虚拟机的,虚拟机外部不认识gpadmin1用户很正常。那么问题就定位到共享工具上了(vmware-tools等工具)。

为了验证该问题是由于共享文件夹导致的,我特意修改了数据存储路径,采用了虚拟机本地的文件夹初始化,成功了。

暂时结论

尝试了好多办法去解决这个初始化问题都报错,目前为止没有找到解决方案。

并且在搜索过程中,发现了vmware和docker也存在同样的问题,也只能通过别的方式来实现,并没有直接解决问题的方案。

相关参考链接如下:

vmwre问题:https://communities.vmware.com/thread/489541

docker问题:http://www.512kbps.com/tag/docker-compose/

发表评论

电子邮件地址不会被公开。 必填项已用*标注