ansible CDH 添加新主机

2 篇文章 0 订阅
环境
  • Centos 6.5
  • CDH 5.15
ansible命令
# 查看系统
ansible newnode -m shell -a "df -h"
# 修改hostname
ansible {{HOSTIP}} -m hostname -a 'name=psjssqsjzxqs92'

# 修改host和iptables,同步集群
ansible cluster -m copy -a 'src=cluster/hosts dest=/etc/hosts'
ansible cluster -m copy -a 'src=cluster/iptables dest=/etc/sysconfig/iptables'
# 重载iptables服务
ansible cluster -m service -a 'name=iptables state=reloaded'

# 上传CDM端的key
ansible newnode -m shell -a 'ssh-keygen -t rsa -N "" -f "/root/.ssh/id_rsa" -C "root@`hostname`"'
ansible newnode -m copy -a 'src=cluster/authorized_keys dest=/root/.ssh/authorized_keys'
ansible newnode -m copy -a 'src=cluster/hosts.allow dest=/etc/hosts.allow'

# 时间同步
ansible newnode -m yum -a 'name=ntp state=present'
ansible newnode -m shell -a 'ntpdate ntp1.aliyun.com'
ansible newnode -m lineinfile -a "path=/var/spool/cron/root line='1 */6 * * * ntpdate ntp1.aliyun.com > /dev/null 2>&1'"
ansible newnode -m service -a "name=ntpd state=stopped enabled=no"

# JAVA安装
ansible newnode -m yum -a 'name=java* state=absent'
ansible newnode -m yum -a 'name=jdk* state=absent'
ansible newnode -m yum -a 'name=http://192.168.0.238/soft/java/jdk-8u162-linux-x64.rpm state=present'
ansible newnode -m copy -a 'content="export JAVA_HOME=/usr/java/jdk1.8.0_162\nexport JRE_HOME=$JAVA_HOME/jre\nexport CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib" dest=/etc/profile.d/java.sh'
ansible newnode -m replace -a 'path="/etc/profile.d/path.sh" regexp="(PATH.+)$" replace="\1:$JAVA_HOME/bin"'
ansible newnode -m shell -a "source /etc/profile"
ansible newnode -m shell -a "java -version"

# jdbc安装
ansible newnode -m get_url -a "url=http://192.168.0.238/soft/mysql/mysql-connector-java-5.1.46-bin.jar dest=/var/tmp"
ansible newnode -m file -a "path=/usr/share/java state=directory"
ansible newnode -m shell -a "cp /var/tmp/mysql-connector-java-5.1.46-bin.jar /usr/share/java/mysql-connector-java.jar"

//系统设置
ansible newnode -m sysctl -a "name=vm.max_map_count value=262144"
ansible newnode -m sysctl -a "name=vm.swappiness value=1"
ansible newnode -m shell -a 'echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled'
ansible newnode -m shell -a 'echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag'
ansible newnode -m lineinfile -a "path=/etc/rc.local line='echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled'"
ansible newnode -m lineinfile -a "path=/etc/rc.local line='echo never > /sys/kernel/mm/redhat_transparent_hugepage/defrag'"
ansible newnode -m shell -a 'swapoff -a'

# entropy设置
ansible newnode -m yum -a 'name=epel-release state=present'
# 清华EPEL镜像
ansible newnode -m copy -a 'src=cluster/epel.repo dest=/etc/yum.repos.d/'
ansible newnode -m yum -a 'name=haveged state=present'
ansible newnode -m file -a "path=/etc/default/haveged state=touch"
ansible newnode -m lineinfile -a "path=/etc/default/haveged line='DAEMON_ARGS=\"-w 1024\"'"
ansible newnode -m service -a "name=haveged state=started enabled=yes"

# 安装agent端
ansible newnode -m get_url -a "url=http://192.168.0.238/soft/cdh/el6/cloudera-manager-daemons-5.15.0-1.cm5150.p0.62.el6.x86_64.rpm  dest=/var/tmp"
ansible newnode -m get_url -a "url=http://192.168.0.238/soft/cdh/el6/cloudera-manager-agent-5.15.0-1.cm5150.p0.62.el6.x86_64.rpm  dest=/var/tmp"
ansible newnode -m yum -a 'name=/var/tmp/cloudera-manager-daemons-5.15.0-1.cm5150.p0.62.el6.x86_64.rpm state=present'
ansible newnode -m yum -a 'name=/var/tmp/cloudera-manager-agent-5.15.0-1.cm5150.p0.62.el6.x86_64.rpm state=present'
iptables
# Generated by iptables-save 2019/4/4
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

# example 
-A INPUT -s 192.168.0.192 -p tcp -m tcp -m multiport --dports 60010,50090,19888,10002,8084,50070,8086,8888,11000,8088,50075,8091,60030,8042,7180 -j ACCEPT
-A INPUT -s 192.168.0.192 -p tcp -m tcp -m multiport --dports 873,25020,25010,18088,64689,80,63751,50075,7183,7072,8889,25000,8084,12321,8081 -j ACCEPT
-A INPUT -s 192.168.0.192 -p tcp -m tcp -m multiport --dports 8050,3181,50977,31079,4181,9010,8051,9095,4040,9868,9864,9870 -j ACCEPT


#drop
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m multiport --dports 60010,50090,19888,10002,8084,50070,8086,8888,11000,8088,50075,8091,60030,8042,7180 -j DROP
-A INPUT -p tcp -m multiport --dports 873,25020,25010,18088,64689,80,63751,50075,7183,7072,8889,25000,8084,12321,8081 -j DROP
-A INPUT -p tcp -m multiport --dports 8050,3181,50977,31079,4181,9010,8051,9095,4040,9868,9864,9870 -j DROP

COMMIT
清华镜像
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever

[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
baseurl=https://mirrors.tuna.tsinghua.edu.cn/epel/$releasever/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1

新增主机模板

到WEB管理界面:
主机-> 主机模板

增加新主机

到WEB管理界面:
主机->所有主机->向群集添加新主机
选择"此 Cloudera Manager Server 的匹配发行版 "
选择"选择WorkerHost主机模板"
去掉"应用主机模板后启动服务"

分配角色

hadf->配置->角色组,设置自定义配置或者使用默认配置

yarn->配置->角色组,设置自定义配置或者使用默认配置

主机->所有主机->新增主机->配置->关闭主机的时钟偏差报警

重启集群

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值