背景:
前一段时间使用docker构建了hadoop集群,现在在集群中安装hive,当执行sudo systemctl start mysqld这个命令启动mysql服务的时候报错:Failed to get D-Bus connection: Operation not permitted。
修改特权模式(并非最终解决方案):
在网上找了很多,有说是启动容器的时候没有用特权模式,导致权限不够,我就把容器配置文件修改中的Privileged改成了true,操作如下:
1.首先查看容器
记一下这个ID
2.暂停docker服务
systemctl stop docker
3.进入配置文件目录
#进入容器目录
cd /var/lib/docker/containers
#查看所有目录
ls
4.找到对应容器目录
进入目录,通过vim命令编辑 配置文件 :hostconfig.json
将false改成true
5.重启docker服务
systemctl restart docker
最后修改结束后,启动容器,继续执行sudo systemctl start mysqld这个命令,还是报这个错误Failed to get D-Bus connection: Operation not permitted
最终解决方案:
更换systemctl文件
1.首先备份systemctl文件
mv /usr/bin/systemctl /usr/bin/systemctl.old
2.下载systemctl文件
curl https://raw.githubusercontent.com/gdraheim/docker-systemctl-replacement/master/files/docker/systemctl.py > /usr/bin/systemctl
如果下载很慢可以用下面这种方式:
打开网站
将页面的所有内容复制,再使用vim systemctl命令,粘贴进去保存。
3.赋权
最后给systemctl文件赋权限
chmod +x /usr/bin/systemctl
再次执行sudo systemctl start mysqld命令启动mysql服务,就没有报错了