Trex-Group / trex-bigdata

11 stars 6 forks source link

[本地開発環境]从宿主机不能远程访问Container #32

Closed chinndou closed 7 years ago

chinndou commented 7 years ago

「[word count]Mac+IDEA+Gradle搭建MapReduce本地开发环境」参照着设置了一下。

从Mac还是不能连上Docker上的Master。另外进入container的master/slave里面可以访问主页。 Log如下。

chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46b0546a221d trex/hbase-slave:latest "/bin/sh -c ''/roo..." 3 hours ago Exited (137) 2 hours ago slave2.trex.com 757dd8818b3a trex/hbase-slave:latest "/bin/sh -c ''/roo..." 3 hours ago Exited (137) 2 hours ago slave1.trex.com 00dafa4806ea trex/hbase-master:latest "/bin/sh -c ''/roo..." 3 hours ago Exited (137) 2 hours ago master.trex.com 5da57a60841f trex/hadoop-slave:latest "/bin/sh -c ''/roo..." 3 hours ago Up 2 hours 0.0.0.0:32947->22/tcp, 0.0.0.0:32946->7373/tcp, 0.0.0.0:32945->7946/tcp, 0.0.0.0:32944->8030/tcp, 0.0.0.0:32943->8031/tcp, 0.0.0.0:32942->8032/tcp, 0.0.0.0:32941->8033/tcp, 0.0.0.0:32940->8040/tcp, 0.0.0.0:32939->8042/tcp, 0.0.0.0:32938->8060/tcp, 0.0.0.0:32937->8088/tcp, 0.0.0.0:32936->9000/tcp, 0.0.0.0:32935->50010/tcp, 0.0.0.0:32934->50020/tcp, 0.0.0.0:32933->50060/tcp, 0.0.0.0:32932->50070/tcp, 0.0.0.0:32931->50075/tcp, 0.0.0.0:32930->50090/tcp, 0.0.0.0:32929->50475/tcp slave2 ce6212e48f93 trex/hadoop-slave:latest "/bin/sh -c ''/roo..." 3 hours ago Up 2 hours 0.0.0.0:32928->22/tcp, 0.0.0.0:32927->7373/tcp, 0.0.0.0:32926->7946/tcp, 0.0.0.0:32925->8030/tcp, 0.0.0.0:32924->8031/tcp, 0.0.0.0:32923->8032/tcp, 0.0.0.0:32922->8033/tcp, 0.0.0.0:32921->8040/tcp, 0.0.0.0:32920->8042/tcp, 0.0.0.0:32919->8060/tcp, 0.0.0.0:32918->8088/tcp, 0.0.0.0:32917->9000/tcp, 0.0.0.0:32916->50010/tcp, 0.0.0.0:32915->50020/tcp, 0.0.0.0:32914->50060/tcp, 0.0.0.0:32913->50070/tcp, 0.0.0.0:32912->50075/tcp, 0.0.0.0:32911->50090/tcp, 0.0.0.0:32910->50475/tcp slave1 3d2435f53a85 trex/hadoop-master:latest "/bin/sh -c ''/roo..." 3 hours ago Up 20 minutes 0.0.0.0:32966->22/tcp, 0.0.0.0:32965->7373/tcp, 0.0.0.0:32964->7946/tcp, 0.0.0.0:32963->8030/tcp, 0.0.0.0:32962->8031/tcp, 0.0.0.0:32961->8032/tcp, 0.0.0.0:32960->8033/tcp, 0.0.0.0:32959->8040/tcp, 0.0.0.0:32958->8042/tcp, 0.0.0.0:32957->8060/tcp, 0.0.0.0:32956->8088/tcp, 0.0.0.0:32955->9000/tcp, 0.0.0.0:32954->50010/tcp, 0.0.0.0:32953->50020/tcp, 0.0.0.0:32952->50060/tcp, 0.0.0.0:32951->50070/tcp, 0.0.0.0:32950->50075/tcp, 0.0.0.0:32949->50090/tcp, 0.0.0.0:32948->50475/tcp master chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default * virtualbox Running tcp://192.168.99.101:2376 v17.03.0-ce chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ ssh -p 32966 root@192.168.99.101 root@192.168.99.101's password: Permission denied, please try again. root@192.168.99.101's password: Permission denied, please try again. root@192.168.99.101's password: Permission denied (publickey,password). chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ docker exec -it 3d2435f53a85 /bin/bash root@master:~# root@master:~# root@master:~# cat /etc/ssh/sshd_config | grep Permit PermitRootLogin without-password PermitRootLogin yes PermitEmptyPasswords yes

the setting of "PermitRootLogin without-password".

root@master:~# root@master:~# curel http://localhost:50070/ bash: curel: command not found root@master:~# curl http://localhost:50070/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Hadoop Administration

root@master:~# root@master:~# curl http://master.trex.com:50070/

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Hadoop Administration

root@master:~# root@master:~# ssh root@slave1 Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.52-boot2docker x86_64)

LiuMing5489 commented 7 years ago

docker苦战中,一起研究一下。

允许root登陆好像是↓吧? PermitRootLogin yes 别用root登陆,建个普通用户登陆trytry。

chinndou commented 7 years ago

等会建一个普通用户试试吧。 已经设置过那个配置项了。而且ssh也重新启动了。 LOG如下。


root@master:~# ls -tlr /etc/ssh/sshd_config* -rw-r--r-- 1 root root 2541 Mar 19 13:28 /etc/ssh/sshd_config_org -rw-r--r-- 1 root root 2563 Mar 20 03:22 /etc/ssh/sshd_config root@master:~# root@master:~# diff /etc/ssh/sshd_config_org /etc/ssh/sshd_config 28a29

PermitRootLogin yes 45c46 < PermitEmptyPasswords no

PermitEmptyPasswords yes root@master:~# root@master:~# pwd /root root@master:~# root@master:~# sudo /etc/init.d/ssh restart

  • Restarting OpenBSD Secure Shell server sshd [ OK ] root@master:~# root@master:~# sudo /etc/init.d/ssh status
  • sshd is running root@master:~# root@master:~# root@master:~# exit exit chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$ ssh -p 32966 root@192.168.99.101 root@192.168.99.101's password: Permission denied, please try again. root@192.168.99.101's password: Permission denied, please try again. root@192.168.99.101's password: Permission denied (publickey,password). chindoutekiMacBook-Pro:Hadoop_Ubuntu_Bin chinndou$
chinndou commented 7 years ago

建个一般用户就进去了。我肯定哪里设置的不对。求助中!!!


chindoutekiMacBook-Pro:~ chinndou$ chindoutekiMacBook-Pro:~ chinndou$ chindoutekiMacBook-Pro:~ chinndou$ chindoutekiMacBook-Pro:~ chinndou$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 46b0546a221d trex/hbase-slave:latest "/bin/sh -c ''/roo..." 6 hours ago Exited (137) 5 hours ago slave2.trex.com 757dd8818b3a trex/hbase-slave:latest "/bin/sh -c ''/roo..." 6 hours ago Exited (137) 5 hours ago slave1.trex.com 00dafa4806ea trex/hbase-master:latest "/bin/sh -c ''/roo..." 6 hours ago Exited (137) 5 hours ago master.trex.com 5da57a60841f trex/hadoop-slave:latest "/bin/sh -c ''/roo..." 6 hours ago Up 5 hours 0.0.0.0:32947->22/tcp, 0.0.0.0:32946->7373/tcp, 0.0.0.0:32945->7946/tcp, 0.0.0.0:32944->8030/tcp, 0.0.0.0:32943->8031/tcp, 0.0.0.0:32942->8032/tcp, 0.0.0.0:32941->8033/tcp, 0.0.0.0:32940->8040/tcp, 0.0.0.0:32939->8042/tcp, 0.0.0.0:32938->8060/tcp, 0.0.0.0:32937->8088/tcp, 0.0.0.0:32936->9000/tcp, 0.0.0.0:32935->50010/tcp, 0.0.0.0:32934->50020/tcp, 0.0.0.0:32933->50060/tcp, 0.0.0.0:32932->50070/tcp, 0.0.0.0:32931->50075/tcp, 0.0.0.0:32930->50090/tcp, 0.0.0.0:32929->50475/tcp slave2 ce6212e48f93 trex/hadoop-slave:latest "/bin/sh -c ''/roo..." 6 hours ago Up 5 hours 0.0.0.0:32928->22/tcp, 0.0.0.0:32927->7373/tcp, 0.0.0.0:32926->7946/tcp, 0.0.0.0:32925->8030/tcp, 0.0.0.0:32924->8031/tcp, 0.0.0.0:32923->8032/tcp, 0.0.0.0:32922->8033/tcp, 0.0.0.0:32921->8040/tcp, 0.0.0.0:32920->8042/tcp, 0.0.0.0:32919->8060/tcp, 0.0.0.0:32918->8088/tcp, 0.0.0.0:32917->9000/tcp, 0.0.0.0:32916->50010/tcp, 0.0.0.0:32915->50020/tcp, 0.0.0.0:32914->50060/tcp, 0.0.0.0:32913->50070/tcp, 0.0.0.0:32912->50075/tcp, 0.0.0.0:32911->50090/tcp, 0.0.0.0:32910->50475/tcp slave1 3d2435f53a85 trex/hadoop-master:latest "/bin/sh -c ''/roo..." 6 hours ago Up 3 hours 0.0.0.0:32966->22/tcp, 0.0.0.0:32965->7373/tcp, 0.0.0.0:32964->7946/tcp, 0.0.0.0:32963->8030/tcp, 0.0.0.0:32962->8031/tcp, 0.0.0.0:32961->8032/tcp, 0.0.0.0:32960->8033/tcp, 0.0.0.0:32959->8040/tcp, 0.0.0.0:32958->8042/tcp, 0.0.0.0:32957->8060/tcp, 0.0.0.0:32956->8088/tcp, 0.0.0.0:32955->9000/tcp, 0.0.0.0:32954->50010/tcp, 0.0.0.0:32953->50020/tcp, 0.0.0.0:32952->50060/tcp, 0.0.0.0:32951->50070/tcp, 0.0.0.0:32950->50075/tcp, 0.0.0.0:32949->50090/tcp, 0.0.0.0:32948->50475/tcp master chindoutekiMacBook-Pro:~ chinndou$ chindoutekiMacBook-Pro:~ chinndou$ chindoutekiMacBook-Pro:~ chinndou$ ssh -p 32966 hadoop@192.168.99.101 hadoop@192.168.99.101's password: Welcome to Ubuntu 14.04.5 LTS (GNU/Linux 4.4.52-boot2docker x86_64)

The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.

Ubuntu 14.04.5 LTS Docker Image - philcryer/min-wheezy - 2017/03/19 hadoop@master:~$ hadoop@master:~$

LiuMing5489 commented 7 years ago

在容器里用别的用户ssh root试试。 docker环境的root用户密码好像不是ubuntu,自己改过了吗?

McKey1911 commented 7 years ago

看起来好像是密码的问题。我还没用root用户ssh过Docker里的master。回家试一试。

McKey1911 commented 7 years ago

如果你是用 Hadoop_Ubuntu_Bin 下的脚本来构建Docker image的,那么base是 ubuntu:14.04 ,而ubuntu默认情况下root是没有password的,只能通过sudo来访问,不过详细情况我也不清楚。 我查看了一下image的构建脚本,并没有发现对user的配置。 那么用ssh访问root是不可以了,即便你改了ssh的设置。 你可以运行passwd命令给root设置一个密码然后再ssh到root用户。 参考:http://askubuntu.com/questions/189907/what-is-the-default-root-password

xenron commented 7 years ago

关于docker,网络问题恐怕是最复杂的问题之一。

大概有以下几种使用场景 1,宿主机与其上运行 docker container 之间的访问 2,宿主机与其他宿主机上运行 docker container 之间的访问 3,不同宿主机上运行 docker container 之间的访问 4,docker container 之间网络互通,及网络隔离(类似 vlan ) 可参照下面链接 https://docs.docker.com/engine/userguide/networking/

对于 docker 的应用场景来说,仅是为了提供某些 service,所以是不需要 openssh 服务的。 所以也就不存在用户是否存在的问题

chinndou commented 7 years ago

问题好像 解决了。