shell脚本在容器云中搭建hadoop集群(四)

总结一下今天的学习过程

1,上午继续观看学习Python的数据库编程视屏,测试Django项目使用MariaDB数据库,由列表实现数据库表的映射,总结了区别

sqlite: 不需要继承models.Model
class student01():
    id = models.IntegerField(primary_key=True)
    name = models.CharField(max_length=50)
    adress = models.CharField(max_length=50)
    class Meta:
        db_table='student01'

MariaDB:
class User(models.Model):
    id = models.AutoField(max_length=11,db_column='UID',primary_key=True)
    userName = models.CharField(max_length=255,db_column='username',blank = False)
    passWord = models.CharField(max_length=255,db_column='password',blank = False)
    cid = models.IntegerField(max_length=11,db_column='CID',blank = False)
    class Meta:
        db_table = 'user'
testDB.User.cid: (fields.W122) 'max_length' is ignored when used with IntegerField
设置为整形integer,长度不生效

2,中午以及下午还有晚上陆陆续续的师弟师妹来到实验室,感觉队伍又壮大了

3,今天师兄返校,倍感激动,请教了我之前做的使用shell脚本在docker中搭建hadoop的问题:关于sshd服务开启、hadoop容器之间相互免密登录的问题,实现了从节点的sshd以及其的ssh免密登录,感觉看到了曙光,期待明天能有更多的进展。

# !/bin/bash
# start sshd
/usr/sbin/sshd

hadoopsum=
hadoopPwd=

echo $hadoopsum
echo $hadoopPwd

function setupHadoopSalve(){

	allhadoopip=''
	for ((i=0;i<$hadoopsum;i++));
	do
	    allhadoopip+="\n192.168.2.1$i hadoop$i";
	done
	allhadoopip+="\n"
	
	echo $allhadoopip
	echo "/etc/hosts......."
	cat /etc/hosts
	
	cp /etc/hosts /root/hosts.new
	echo "/root/hosts.new........"
	cat /root/hosts.new
	
	for ss in `cat /root/hosts.new | grep hadoop | awk '{print $1}'`;
	do sed -i '/'$ss'.*/d' /root/hosts.new;
	done
	echo -e "$(cat /root/hosts.new)" > /etc/hosts
	
	cat /etc/hosts
	echo -e $allhadoopip >> /etc/hosts
	
	cd ~
	rm -rf /root/.ssh
	mkdir /root/.ssh
	
	expect -c "set timeout -1;
        spawn ssh-keygen -t rsa;
        expect {
		    *(y/n)* {send -- y\r;exp_continue;}
            *Enter* {send -- \r;exp_continue;}
        }";
		
	expect -c "set timeout -1;
			spawn ssh-copy-id localhost;
			expect {
				*(yes/no)* {send -- yes\r;exp_continue;}
				*assword:* {send -- $hadoopPwd\r;exp_continue;}
				eof        {exit 0;}
			}";
	
	for hostname in `hostname`;
	do
	    echo $hostname
		expect -c "set timeout -1;
			spawn ssh-copy-id $hostname;
			expect {
				*(yes/no)* {send -- yes\r;exp_continue;}
				*assword:* {send -- $hadoopPwd\r;exp_continue;}
				eof        {exit 0;}
			}";
	done 
}
setupHadoopSalve

for ss in `ps -e | grep sshd | awk '{print $1}'`;
do
kill $ss;
done
/usr/sbin/sshd -D


激动的一天,明天加油!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值