环境介绍
node1:192.168.168.201
node2:192.168.168.202
1.配置主机名
[[email protected] ~]# vim /etc/sysconfig/network #编辑节点1主机名配置文件 #编辑 HOSTNAME=node1.linuxpanda.com [[email protected] ~]# hostname node1.linuxpanda.com #主机名立即生效 [[email protected] ~]# vim /etc/sysconfig/network #编辑节点2主机名配置文件 #编辑 HOSTNAME=node2.linuxpanda.com [[email protected] ~]# hostname node2.linuxpanda.com #主机名立即生效
2.主机互信
具体可以参见我的上一篇博客:http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_023_sshgenkey.html
[[email protected] ~]# ssh-keygen -t rsa -P ‘‘ -f ~/.ssh/id_rsa #生成rsa [[email protected] ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]192.168.168.202 #复制公钥 [[email protected] ~]# ssh-keygen -t rsa -P ‘‘ -f ~/.ssh/id_rsa #生成rsa [[email protected] ~]# ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]192.168.168.201 #复制公钥
[[email protected] ~]# ssh 192.168.168.202 ‘ip addr show dev eth0 ‘ #测试node1 ssh node2
[[email protected] ~]# ssh 192.168.168.201 ‘ip addr show dev eth0 ‘ #测试node2 ssh node1
3.host文件配置
host配置文件配置主要用于名称解析, 我们不建议使用dns解析,否则dns无法解析就会导致集群服务的崩溃。
[[email protected] ~]# vim /etc/hosts #添加如下2行 192.168.168.201 node1.linuxpanda.com node1 192.168.168.202 node2.linuxpanda.com node2[[email protected] ~]# scp /etc/hosts [email protected]:/etc/hosts #host文件复制一份到node2中去[[email protected] ~]# ping node2 -c 1 #node1 ping node2[[email protected] ~]# ping node1 -c 1 #node2 ping node1
4.防火墙和selinux设置
[[email protected] ~]# service iptables stop #关闭node防火墙 iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ] [[email protected] ~]# ssh node2 ‘service iptables stop‘ #关闭node2防火墙 iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules: [ OK ]
[[email protected] ~]# sed -i ‘/SELINUX/s/enforcing/disabled/‘ /etc/selinux/config #修改node1selinux设置 [[email protected] ~]# setenforce 0 #立马生效 [[email protected] ~]# ssh node2 "sed -i ‘/SELINUX/s/enforcing/disabled/‘ #修改node1selinux设置 [[email protected] ~]# ssh node2 " setenforce 0‘ #立马生效
5.时间同步
具体参见我的另一篇博客:http://www.cnblogs.com/zhaojiedi1992/p/zhaojiedi_linux_022_ntp.html
6.
时间: 2024-10-12 09:12:41