- 安装centos并修改配置
- 下载linux系统centos7
- 创建虚拟机centos7 一主一从
- 新建用户user,选择语言修改配置
- 下载http://mirrors.163.com/centos/7/os/x86_64/Packages/wget-1.14-15.el7_4.1.x86_64.rpm
安装 rpm -ivh wget-1.14-15.el7_4.1.x86_64.rpm
- 安装 vim
yum -y install vim-enhanced
- 安装:
dos2unix.x86_64 0:6.0.3-7.el7 yum install dos2unix
dos2unix xxxx.sh 转化dos 为linux系统sh
- 设置网络连接
ip addr查看ip
修改配置信息vi /ect/sysconfig/network-scripts
/ ifcfg-ens33
重启网络service network restart
Xshell
远程连接
查看网络ifconfig
安装 net-tools sudo yum install net-tools
- 更改yum源:
Yum原本的源都在国外,更新特别浪费时间,我们改为阿里源:
首先我们将原来的源进行备份:
[root@localhost download]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
接下来我们用阿里源进行替换:
[root@localhost download]# wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost download]# yum makecache
[root@localhost download]# yum update
关闭防火墙 并禁止重启启动
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
时间同步
[root@master ~]# yum install -y ntp ntpdate
yum -y install ntp
systemctl enable ntpd
systemctl start ntpd
ntpdate -u cn.pool.ntp.org
3. 配置SSH
· root用户创建密匙(所有机器):
[root@master ssh]
Autossh.Sh
#!/bin/sh
########################################################
#
# 该脚本用来生成服务器之间的免密
# DEST_USER :系统用户
# PASSWORD : 系统密码
# HOSTS_FILE : 服务器名称的配置文件
# 使用方法: sh xxx.sh remoteUser remotePassword hostsFile
#
########################################################
DEST_USER=root
PASSWORD=root
HOSTS_FILE=ip.list
#判断输入参数是否满足
if [ $# -ne 3 ]; then
echo "ex: sh $0 remoteUser remotePassword hostsFile"
exit 1
fi
SSH_DIR=~/.ssh
SCRIPT_PREFIX=./tmp
echo ===========================
# 先删除.ssh目录下的所有文件
rm -rf $SSH_DIR
mkdir $SSH_DIR
chmod 700 $SSH_DIR
# 2. generat ssh key
TMP_SCRIPT=$SCRIPT_PREFIX.sh
echo "#!/usr/bin/expect">$TMP_SCRIPT
echo "spawn ssh-keygen -b 1024 -t rsa">>$TMP_SCRIPT
echo "expect *key*">>$TMP_SCRIPT
echo "send \r">>$TMP_SCRIPT
if [ -f $SSH_DIR/id_rsa ]; then
echo "expect *verwrite*">>$TMP_SCRIPT
echo "send y\r">>$TMP_SCRIPT
fi
echo "expect *passphrase*">>$TMP_SCRIPT
echo "send \r">>$TMP_SCRIPT
echo "expect *again:">>$TMP_SCRIPT
echo "send \r">>$TMP_SCRIPT
echo "interact">>$TMP_SCRIPT
chmod +x $TMP_SCRIPT
/usr/bin/expect $TMP_SCRIPT
rm $TMP_SCRIPT
# 3. generat file authorized_keys
cat $SSH_DIR/id_rsa.pub>>$SSH_DIR/authorized_keys
# 4. chmod 600 for file authorized_keys
chmod 600 $SSH_DIR/authorized_keys
echo ===========================
# 5. copy all files to other hosts
for ip in $(cat $HOSTS_FILE)
do
if [ "x$ip" != "x" ]; then
echo -------------------------
TMP_SCRIPT=${SCRIPT_PREFIX}.$ip.sh
# check known_hosts
val=`ssh-keygen -F $ip`
if [ "x$val" == "x" ]; then
echo "$ip not in $SSH_DIR/known_hosts, need to add"
val=`ssh-keyscan $ip 2>/dev/null`
if [ "x$val" == "x" ]; then
echo "ssh-keyscan $ip failed!"
else
echo $val>>$SSH_DIR/known_hosts
fi
fi
echo "copy $SSH_DIR to $ip"
echo "#!/usr/bin/expect">$TMP_SCRIPT
echo "spawn scp -r $SSH_DIR $DEST_USER@$ip:~/">>$TMP_SCRIPT
echo "expect *assword*">>$TMP_SCRIPT
echo "send $PASSWORD\r">>$TMP_SCRIPT
echo "interact">>$TMP_SCRIPT
chmod +x $TMP_SCRIPT
#echo "/usr/bin/expect $TMP_SCRIPT" >$TMP_SCRIPT.do
#sh $TMP_SCRIPT.do&
/usr/bin/expect $TMP_SCRIPT
rm $TMP_SCRIPT
echo "copy done."
fi
done
echo done
Ip.list
192.168.1.184
Linux格式化sh文件:dos2unix auto.sh
执行脚本
[root@master ssh]# bash autossh.sh root root ip.list
脚本名字 用户名 密码 host文件地址
测试相互连接
修改文件ssh_config 添加访问配置
[root@master ssh]# vim /etc/ssh/ssh_config
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
连接成功(从机同时修改ssh_config文件)
二、 安装jdk
下载 jdk
安装
rpm -ivh jdk-8u191-linux-x64.rpm
三. 安装mysql
下载mysql
解压
安装mysql
Yum install perl
安装如下:
rpm -ivh mysql-community-common-5.7.24-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.24-1-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.24-1-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.24-1-1.el7.x86_64.rpm
安装完成 启动 mysql service mysqld restart
修改配置文件/etc/my.cnf
skip-grant-tables
登录数据库
进入mysql数据库
use mysql;
设置远程连接
update mysql.user set authentication_string=password(‘root’) where user='root';
因为数据库对密码的设置有要求需要重新配置
mysql> set global validate_password_policy=0;
mysql> set global validate_password_mixed_case_count=0;
mysql> set global validate_password_number_count=3;
mysql> set global validate_password_special_char_count=0;
mysql> set global validate_password_length=3;
mysql> SHOW VARIABLES LIKE 'validate_password%';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
mysql> FLUSH PRIVILEGES;
修改my.cnf配置文件删除添加信息skip-grant-tables ,并修改bind-address= 0.0.0.0 重启mysql
设置mysql 开机启动
systemctl enable mysqld.service
创建数据库
create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database monitor DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
- 搭建hadoop集群-使用Cloudera部署
- cloudera简介
Cloudera作为一个强大的商业版数据中心管理工具,提供了各种能够快速稳定运行的数据计算框架,如Apache Spark;使用Apache Impala做为对HDFS,HBase的高性能SQL查询引擎;也带了Hive数据仓库工具帮助用户分析数据; 用户也能用Cloudera管理安装HBase分布式列式NoSQL数据库;Cloudera还包含了原生的Hadoop搜索引擎以及Cloudera Navigator Optimizer去对Hadoop上的计算任务进行一个可视化的协调优化,提高运行效率;同时Cloudera中提供的各种组件能让用户在一个可视化的UI界面中方便地管理,配置和监控Hadoop以及其它所有相关组件,并有一定的容错容灾处理;Cloudera作为一个广泛使用的商业版数据中心管理工具更是对数据的安全决不妥
- 下载Cloudera Manager
下载
wget http://archive.cloudera.com/cm5/cm/5/cloudera-manager-centos7-cm5.14.0_x86_64.tar.gz
下载 cdh http://archive.cloudera.com/cdh5/parcels/5.7.0/
wget http://archive.cloudera.com/cdh5/parcels/5.7.0/CDH-5.7.0-1.cdh5.7.0.p0.45-el7.parcel
wget http://archive.cloudera.com/cdh5/parcels/5.7.0/CDH-5.7.0-1.cdh5.7.0.p0.45-el7.parcel.sha1
- //解压cm tar包到指定目录所有服务器都要(或者在主节点解压好,然后通过scp到各个节点同一目录下)
[root@master download]#mkdir /opt/cloudera-manager
[root@master download]# tar -axvf cloudera-manager-centos7-cm5.14.0_x86_64.tar.gz -C /opt/cloudera-manager
- //创建cloudera-scm用户(所有节点)
[root@master download]# useradd --system --home=/opt/cloudera-manager/cm-5.14.0/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
- //在主节点创建cloudera-manager-server的本地元数据保存目录
[root@master download]# mkdir /var/cloudera-scm-server
[root@master download]# chown cloudera-scm:cloudera-scm /var/cloudera-scm-server
[root@master download]# chown cloudera-scm:cloudera-scm /opt/cloudera-manager
- //配置从节点cloudera-manger-agent指向主节点服务器
[root@slave download]# vi /opt/cloudera-manager/cm-5.14.0/etc/cloudera-scm-agent/config.ini
将server_host改为CMS所在的主机名即cdh1
- //主节点中创建parcel-repo仓库目录
[root@master download]# mkdir -p /opt/cloudera/parcel-repo
[root@master download]# chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
[root@master download]# cp CDH-5.14.0-1.cdh5.14.0.p0.18-el7.parcel CDH-5.14.0-1.cdh5.14.0.p0.18-el7.parcel.sha manifest.json /opt/cloudera/parcel-repo
注意:其中CDH-5.14.0-1.cdh5.14.0.p0.18-el5.parcel.sha1 后缀要把1去掉
- //所有节点创建parcels目录
[root@master download]# mkdir -p /opt/cloudera/parcels
[root@master download]# chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
解释:Clouder-Manager将CDHs从主节点的/opt/cloudera/parcel-repo目录中抽取出来,分发解压激活到各个节点的/opt/cloudera/parcels目录中
- //初始脚本配置数据库scm_prepare_database.sh(在主节点上)
[root@master download]# /opt/cloudera-manager/cm-5.14.0/share/cmf/schema/scm_prepare_database.sh mysql -hmaster -uroot -proot --scm-host master scmdbn scmdbu scmdbp
说明:这个脚本就是用来创建和配置CMS需要的数据库的脚本。各参数是指:
mysql:数据库用的是mysql,如果安装过程中用的oracle,那么该参数就应该改为oracle。
- hmaster:数据库建立在cdh1主机上面,也就是主节点上面。
- uroot:root身份运行mysql。-root:mysql的root密码是root。
--scm-host master:CMS的主机,一般是和mysql安装的主机是在同一个主机上,最后三个参数是:数据库名,数据库用户名,数据库密码
- //启动主节点
[root@master download]# cp /opt/cloudera-manager/cm-5.14.0/etc/init.d/cloudera-scm-server /etc/init.d/cloudera-scm-server
[root@master download]# chkconfig cloudera-scm-server on
[root@master download]# vi /etc/init.d/cloudera-scm-server
CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}改为=/opt/cloudera-manager/cm-5.14.0/etc/default
[root@master download]# service cloudera-scm-server start
- //同时为了保证在每次服务器重启的时候都能启动cloudera-scm-server,应该在开机启动脚本/etc/rc.local中加入命令:service cloudera-scm-server restart
- //启动cloudera-scm-agent所有节点
[root@cdhX ~]# mkdir /opt/cloudera-manager/cm-5.14.0/run/cloudera-scm-agent
[root@cdhX ~]# cp /opt/cloudera-manager/cm-5.14.0/etc/init.d/cloudera-scm-agent /etc/init.d/cloudera-scm-agent
[root@cdhX ~]# chkconfig cloudera-scm-agent on
[root@cdhX ~]# vi /etc/init.d/cloudera-scm-agent
CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}改为=/opt/cloudera-manager/cm-5.14.0/etc/default
[root@cdhX ~]# service cloudera-scm-agent start
- //同时为了保证在每次服务器重启的时候都能启动cloudera-scm-agent,应该在开机启动脚本/etc/rc.local中加入命令:service cloudera-scm-agent restart
- 安装完成mannager在浏览器中打开
输入;192.168.1.152::7180 主机地址 cloudera 端口号 用户名admin 密码admin