您的位置:首页 > 运维架构 > Linux

生产环境实战spark (4)Linux CentOS 系统安装 防火墙检查 ssh免密码登录

2017-04-11 09:36 1036 查看
 生产环境实战spark (4)Linux CentOS 系统安装 防火墙检查 ssh免密码登录

保障hadoop集群、spark集群、kafka集群、zookeeper集群的分布式通信畅通,分布式节点之间关闭防火墙。
保障hadoop集群、spark集群、kafka集群、zookeeper集群的系统登录畅通,配置节点间ssh免密码登录。

1.关闭防火墙

[root@master ~]# service iptables status
Redirecting to /bin/systemctl status  iptables.service
iptables.service - IPv4 firewall with iptables
   Loaded: loaded (/usr/lib/systemd/system/iptables.service; disabled)
   Active: inactive (dead)

[root@master ~]# ping master
PING master (127.0.0.1) 56(84) bytes of data.
64 bytes from master (127.0.0.1): icmp_seq=1 ttl=64 time=0.060 ms
64 bytes from master (127.0.0.1): icmp_seq=2 ttl=64 time=0.085 ms
64 bytes from master (127.0.0.1): icmp_seq=3 ttl=64 time=0.084 ms

配置hosts文件中的主机名[root@master ~]# cat /etc/hosts
127.0.0.1   master
10.100.100.237 master
::1         master


2.配置ssh免密码登录。

[root@master ~]# ls -a
.  ..  anaconda-ks.cfg  .bash_history  .bash_logout  .bash_profile  .bashrc  .cache  .config  .cshrc  .dbus  .oracle_jre_usage  .tcshrc
[root@master ~]# ll -a
total 52
dr-xr-x---.  6 root root 4096 Apr 10 12:07 .
drwxr-xr-x. 18 root root 4096 Apr 10 06:00 ..
-rw-------.  1 root root 1655 Apr  6 08:59 anaconda-ks.cfg
-rw-------.  1 root root 1354 Apr 10 14:24 .bash_history
-rw-r--r--.  1 root root   18 Dec 29  2013 .bash_logout
-rw-r--r--.  1 root root  176 Dec 29  2013 .bash_profile
-rw-r--r--.  1 root root  176 Dec 29  2013 .bashrc
drwx------.  4 root root 4096 Apr  6 13:06 .cache
drwx------.  4 root root 4096 Apr  6 13:06 .config
-rw-r--r--.  1 root root  100 Dec 29  2013 .cshrc
drwx------.  3 root root 4096 Apr  6 13:01 .dbus
drwxr-xr-x.  2 root root 4096 Apr 10 12:07 .oracle_jre_usage
-rw-r--r--.  1 root root  129 Dec 29  2013 .tcshrc

执行ssh-keygen -t rsa命令,自动生成.ssh目录,目录中存放密钥文件。
[root@master ~]# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): 
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
e3:54:d0:0c:3a:29:54:a0:e3:b4:95:dd:da:b3:ef:e8 root@master
The key's randomart image is:
+--[ RSA 2048]----+
|    oo. o+       |
|   o o + .o      |
|  + + = . .      |
| o + . + .       |
|  o   . S        |
|       o +       |
|        o        |
|         o       |
|       .E.o      |
+-----------------+
[root@master ~]# ls -a
.  ..  anaconda-ks.cfg  .bash_history  .bash_logout  .bash_profile  .bashrc  .cache  .config  .cshrc  .dbus  .oracle_jre_usage  .ssh  .tcshrc
[root@master ~]# cd .ssh
[root@master .ssh]# ls -a
.  ..  id_rsa  id_rsa.pub
复制一份密码文件
[root@master .ssh]# cp id_rsa.pub authorized_keys
[root@master .ssh]# ls -l
total 12
-rw-r--r--. 1 root root  393 Apr 11 08:53 authorized_keys
-rw-------. 1 root root 1675 Apr 11 08:51 id_rsa
-rw-r--r--. 1 root root  393 Apr 11 08:51 id_rsa.pub
 
配置完成,ssh免密码登陆验证
[root@master .ssh]# ssh master
The authenticity of host 'master (::1)' can't be established.
ECDSA key fingerprint is 05:5b:98:b2:90:46:86:26:7f:9a:fa:0c:80:1d:27:df.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added 'master' (ECDSA) to the list of known hosts.
Last login: Tue Apr 11 08:41:46 2017 from 132.150.75.19
[root@master ~]# ssh master
Last login: Tue Apr 11 08:56:49 2017 from master
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: