0. 配置hostname
一定要在一开始就配置hostname,本人忽略了这一点,在集群安装好之后才进行配置hostname,多了很多不必要的操作,详见第11点
1. 修改网卡配置 vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.10.11.38 #本机地址
NETMASK=255.255.255.0 #子网掩码
2. DNS设置 vi /etc/resolv.conf
nameserver 114.114.114.114 #主
nameserver 8.8.8.8 #备
3. host映射配置 vim /etc/hosts
168.20.11.11 dev-cdh-db1
168.20.11.12 dev-cdh-db2
168.20.11.13 dev-cdh-db3
4. 配置ssh免密
//1.在主节点生成公钥文件
ssh-keygen -t rsa
//2.把公钥添加到认证文件中
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
//3.设置认证文件权限
chmod 600 ~/.ssh/authorized_keys
//4.拷贝认证文件到所有datanode节点
scp ~/.ssh/authorized_keys root@db1.cdh:~/.ssh/
5. 依赖包安装
- vi dependency.sh #追加以下内容
yum -y install bind-utils
yum -y install chkconfig
yum -y install cyrus-sasl-gssapi
yum -y install cyrus-sasl-plain
yum -y install fuse
yum -y install fuse-libs
yum -y install gcc
yum -y install httpd
yum -y install init-functions
yum -y install libxslt
yum -y install mod_ssl
yum -y install MySQL-python
yum -y install openssl
yum -y install openssl-devel
yum -y install openssl-devel
yum -y install perl
yum -y install portmap
yum -y install postgresql-server
yum -y install psmisc
yum -y install python-devel
yum -y install python-psycopg2
yum -y install python-setuptools
yum -y install sed
yum -y install service
yum -y install sqlite
yum -y install swig
yum -y install useradd
yum -y install zlib
- sh dependency.sh #每台机器执行
6. MYSQL安装配置
- Install the MySQL database
//卸载
//1.快速删除
yum remove mysql mysql-server mysql-libs mysql-server
//2.查找残留文件
rpm -qa | grep -i mysql
//3.将查询出来的文件逐个删除,如:
yum remove mysql-community-common-5.7.20-1.el6.x86_64
//4.查找残留目录
whereis mysql
//5.逐条删除目录,如:
rm –rf /usr/lib64/mysql
//安装
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
sudo yum install mysql-server
//该步骤报错,如下图,解决方法如下:
//1.sudo vim /etc/yum.repos.d/mysql-community.repo
//2.找到mysql-56-community
//3.将enable置为0 enable=0
//4.sudo yum install mysql-server
sudo systemctl start mysqld
- Ensure the MySQL server starts at boot.
sudo /sbin/chkconfig mysqld on
sudo /sbin/chkconfig --list mysqld
- Start the MySQL serverStart the MySQL server
sudo service mysqld start
- Set the MySQL root password
sudo /usr/bin/mysql_secure_installation
[...]
Enter current password for root (enter for none):
OK, successfully used password, moving on...
[...]
Set root password? [Y/n] y
New password:
Re-enter new password:
Remove anonymous users? [Y/n] Y
[...]
Disallow root login remotely? [Y/n] N
[...]
Remove test database and access to it [Y/n] Y
[...]
Reload privilege tables now? [Y/n] Y
All done!
- Installing the MySQL JDBC Driver
> Download the MySQL JDBC driver from http://www.mysql.com/downloads/connector/j/5.1.html
sudo mkdir -p /usr/share/java/
scp mysql-connector-java-5.1.47.tar.gz root@168.20.11.13:/usr/share/java
tar zxvf mysql-connector-java-5.1.31.tar.gz
//版本号要去掉
mv /usr/share/java/mysql-connector-java-8.0.11.jar /usr/share/java/mysql-connector-java.jar
// Creating Databases need
create database amon DEFAULT CHARACTER SET utf8;
create database rman DEFAULT CHARACTER SET utf8;
create database metastore DEFAULT CHARACTER SET utf8;
create database sentry DEFAULT CHARACTER SET utf8;
create database nav DEFAULT CHARACTER SET utf8;
create database navms DEFAULT CHARACTER SET utf8;
create database cms DEFAULT CHARACTER SET utf8;
create database oozie default character set utf8;
create database hue default character set utf8 default collate utf8_general_ci;
grant all on amon.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on rman.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on metastore.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on sentry.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on nav.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on navms.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all on hue.* TO 'cdh'@'%' IDENTIFIED BY ‘cdhroot’;
grant all on cms.* TO 'cdh'@'%' IDENTIFIED BY 'cdhroot';
grant all privileges on oozie.* to 'cdh'@'localhost' identified by 'cdhroot';
grant all privileges on oozie.* to 'cdh'@'%' identified by 'cdhroot';
7. 安装JDK
java安装目录最好在/usr/java/下面,下面是具体范围
local JAVA8_HOME_CANDIDATES=(
'/usr/java/jdk1.8'
'/usr/java/jre1.8'
'/usr/lib/jvm/j2sdk1.8-oracle'
'/usr/lib/jvm/j2sdk1.8-oracle/jre'
'/usr/lib/jvm/java-8-oracle'
)
- Download the JDK
- mkdir -p /usr/java
- 直接把解压的安装包放在/usr/java下面
- scp jdk-8u191-linux-x64.tar.gz root@168.20.11.13:/usr/java
- tar zxvf jdk-8u191-linux-x64.tar.gz
- 配置环境变量
vi /etc/profile //末尾追加下面内容:
export JAVA_HOME=/usr/java/jdk1.8.0_191
export PATH=PATH
- source /etc/profile
8. 安装CDH
- Download and Extract Tarballs
- Download tarballs from the locations listed in Cloudera Manager Version and Download Information(https://www.cloudera.com/documentation/enterprise/release-notes/topics/cm_vd.html#cmvd_topic_1)
- sudo mkdir /opt/cloudera-manager
- scp cloudera-manager-centos7-cm5.15.1_x86_64.tar.gz root@168.20.11.12:/opt/cloudera-manager
- sudo tar xzf cloudera-manager*.tar.gz -C /opt/cloudera-manager
- Create user on all host
sudo useradd --system --home=/opt/cloudera-manager/cm-5.15.1/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
- Create the Cloudera Manager Server Local Data Storage Directory
sudo mkdir /var/lib/cloudera-scm-server
sudo chown cloudera-scm:cloudera-scm /var/lib/cloudera-scm-server
- Configure Cloudera Manager Agents
vi /opt/cloudera-manager/cm-5.15.1/etc/cloudera-scm-agent/config.ini
server_host //Name of the host where Cloudera Manager Server is running.
server_port //Port on the host where Cloudera Manager Server is running.
- 设置agent数据目录
vim /opt/cloudera-manager/cm-5.15.1/etc/default/cloudera-scm-agent
export CMF_VAR=/cluster/cdh/cdhdata export CMF_AGENT_ROOT=$CMF_ROOT/lib64/cmf
export CMF_SERVER_ROOT=$CMF_ROOT/share/cmf
export CMF_SBINDIR=$CMF_ROOT/sbin
export CMF_ETC=$CMF_ROOT/etc
export CMF_VAR=/cluster/cdh/cdhdata #只改了这一行
export CMF_SUDO_CMD=" "
mkdir -p /cluster/cdh/cdhdata/log/cloudera-scm-agent/
mkdir -p /cluster/cdh/cdhdata/lib/cloudera-scm-agent/
- Create Parcel Directories
//On the Cloudera Manager Server host, create a parcel repository directory:
sudo mkdir -p /opt/cloudera/parcel-repo
sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
//On each cluster host, create a parcels directory:
sudo mkdir -p /opt/cloudera/parcels
sudo chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
//同步Agent到其他节点
//同步主节点的agent到从节点时候一定要在主节点启动agent之前同步过去,不然会导致uuid不一致问题
scp -r /opt/cloudera-manager/cm-5.15.1 root@otherip:/opt/cloudera-manager
- 下载parcels并放在server在的机器
//ps: http://archive.cloudera.com/cdh5/parcels/ #下载以下三个文件
CDH-5.15.2-1.cdh5.14.2.p0.3-el7.parcel
CDH-5.14.2-1.cdh5.14.2.p0.3-el7.parcel.sha
manifest.json manifest.json
//将这三个文件放到/opt/cloudera/parcel-repo/ #只需在server的那台机器操作
9. 初始化数据库
在server那台机器操作
/opt/cloudera-manager/cm-5.15.1/share/cmf/schema/scm_prepare_database.sh mysql cm -h 168.20.11.14 -u root -p --scm-host 168.20.11.14scm scm scm
10. 运行agent 和 server
sh /opt/cloudera-manager/cm-5.15.1/etc/init.d/cloudera-scm-server start
sh /opt/cloudera-manager/cm-5.15.1/etc/init.d/cloudera-scm-agent start
11. 未配置hostname,建好集群之后配置hostname相关操作
切记:在一开始就应该配置好hostname
1.停止集群
2.vi /etc/hosts
3.vi /etc/sysconfig/network
4.vi /etc/hostname
5.在cdh机器上面进入mysql,mysql -uroot -p000000
6.mysql>use cm;
7.mysql>select host_id, host_identifier, name, ip_address from HOSTS;
8.mysql> update HOSTS set name = 'cdh1.dev' where host_id=4;
9.mysql> select config_id,attr,value from CONFIGS where value like '%dev-statis%';
10.mysql>update CONFIGS set value = 'cdh2.dev' where config_id=162;
11.重启网卡:service network restart
12.输入hostname 看出现的主机名是否是期待的主机名
13.如果修改后没有更新,reboot 重启机器即可
12. 单独安装spark2.1
停止CDH集群
下载CSD包:http://archive.cloudera.com/spark2/csd/http://archive.cloudera.com/spark2/csd/
下载parcel包:http://archive.cloudera.com/spark2/parcels/2.1.0.cloudera1/http://archive.cloudera.com/spark2/parcels/2.1.0.cloudera1/
上传csd包,在每台机器执行
1.创建目录:mkdir -p /opt/cloudera/csd
2.修改该权限及组:chown cloudera-scm:cloudera-scm /opt/cloudera/csd
3.scp /Users/slash/Downloads/SPARK2_ON_YARN-2.1.0.cloudera1.jar root@168.20.11.14:/opt/cloudera/csd
4.修改组用户权限:
chown cloudera-scm:cloudera-scm SPARK2_ON_YARN-2.1.0.cloudera2.jar
- 上传parcel包,在每台机器执行
SPARK2-2.1.0.cloudera1-1.cdh5.7.0.p0.120904-el6.parcel
SPARK2-2.1.0.cloudera1-1.cdh5.7.0.p0.120904-el6.parcel.sha
manifest.json
- 启动CDH集群
- 然后点击主机->Parcel页面,看是否多了个spark2的选项。如下图,你这里此时应该是分配按钮,点击,等待操作完成后,点击激活按钮
- 激活后,点击你的群集->添加服务,添加spark2服务。注意,如果你这里看不到spark2服务,就请检查你的CSD包和parcel包是否对应,上面的步骤是否有漏掉。正常情况下,应该是能用了。