1.环境:Ubuntu16.04 desktop x 3 台
2.需下载安装的软件:
root@master:~# vim /etc/hostname
~~~~~~~内容~~~~~~~
master
~~~~~~~内容~~~~~~~
root@slave1:~# vim /etc/hostname
~~~~~~~内容~~~~~~~
slave1
~~~~~~~内容~~~~~~~
1 root@master:~# vim /etc/hosts
2 ~~~~~~~~~~~内容~~~~~~~~~~~
3 127.0.0.1 localhost
4 10.132.226.121 master
5 10.132.226.122 slave1
6 10.132.226.123 slave2
7
8 # The following lines are desirable for IPv6 capable hosts
9 ::1 ip6-localhost ip6-loopback
10 fe00::0 ip6-localnet
11 ff00::0 ip6-mcastprefix
12 ff02::1 ip6-allnodes
13 ff02::2 ip6-allrouters
14 ~~~~~~~~~~~内容~~~~~~~~~~~
注意:部分主机含有127.0.1.1 的地址 用#注释或删除
root@master:~# apt update
注意:如果有涉及内核的更新需要重启一下系统
root@slave1:~# ufw disable
Firewall stopped and disabled on system startup
ssh服务配置:
如果未安装ssh服务则先进行安装(所有节点):
root@master:~# apt install openssh-server openssh-client
1 root@master:~# vim /etc/ssh/sshd_config
2 ~~~~~~~~查找并修改~~~~~~~~
3 PermitRootLogin yes
4 PasswordAuthentication yes
5 ~~~~~~~~查找并修改~~~~~~~~
6 root@master:~# /etc/init.d/ssh restart
若有#号注释的删除#号并更改即可
1 root@master:~# ssh-keygen -t rsa
2 //生成密钥 一路回车,如果之前已有生成,提示是否重新生成时填y即可
3 root@master:~# cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
4 root@master:~# chmod 600 ~/.ssh/authorized_keys
5 root@master:~# scp -r /root/.ssh root@slave1:/root/
6 root@master:~# scp -r /root/.ssh root@slave2:/root/
注意:如果出现无法连接的 WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED 错误时 清楚~/.ssh 文件下know_hosts文件找到与登录错误的IP的公钥删除即可
1 root@master:~# apt-get install ntp
1 root@master:~# vim /etc/ntp.conf
2 //用#注释掉所有的pool和server
3 ~~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~~~
4 restrict 10.132.226.0 mask 255.255.255.0
5 server 202.120.2.101
6 server cn.pool.ntp.org
7 server 127.0.0.1
8 ~~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~~~
1 root@slave1:~# vim /etc/ntp.conf
2 //用#注释掉所有pool与server添加一下内容
3 ~~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~~
4 server master
5 ~~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~~
1 root@master:~t# service ntp restart
1 root@master:~# add-apt-repository ppa:webupd8team/java
2 //因为cm需要安装oracle的java,二ubuntu的源中默认只有openjdk所以需要添加源
3 root@master:~# apt-get update
4 root@master:~# apt-get install oracle-java8-installer
1 root@master:~# vim /etc/profile
2 ~~~~~~~~~~~~~~~~~~~~~~文末添加~~~~~~~~~~~~~~~~~~~~~~
3 export JAVA_HOME=/usr/lib/jvm/java-8-oracle
4 export JRE_HOME=${JAVA_HOME}/jre
5 export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
6 export PATH=$PATH:${JAVA_HOME}/bin:{JRE_HOME}/bin:$PATH
7 ~~~~~~~~~~~~~~~~~~~~~~文末添加~~~~~~~~~~~~~~~~~~~~~~
若不知道java的位置可通过update-alternatives --config java 来查看java信息
1 root@master:~# update-alternatives --config java
2 有 4 个候选项可用于替换 java (提供 /usr/bin/java)。
3
4 选择 路径 优先级 状态
5 ------------------------------------------------------------
6 0 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 自动模式
7 1 /usr/java/jdk1.8.0_121/bin/java 300 手动模式
8 2 /usr/lib/jvm/j2sdk1.6-oracle/jre/bin/java 315 手动模式
9 3 /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java 1081 手动模式
10 * 4 /usr/lib/jvm/java-8-oracle/jre/bin/java 1081 手动模式
11
12 要维持当前值[*]请按<回车键>,或者键入选择的编号:
root@master:/home/jy# apt-get install mariadb-server
1 root@master:~# vim /etc/mysql/mariadb.conf.d/50-server.cnf
2
3 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 [mysqld]
5
6 #
7 # * Basic Settings
8 #
9 user = mysql
10 pid-file = /var/run/mysqld/mysqld.pid
11 socket = /var/run/mysqld/mysqld.sock
12 port = 3306
13 basedir = /usr
14 datadir = /var/lib/mysql
15 tmpdir = /tmp
16 lc-messages-dir = /usr/share/mysql
17 skip-external-locking
18
19 # Instead of skip-networking the default is now to listen only on
20 # localhost which is more compatible and is not less secure.
21 bind-address = 0.0.0.0 #修改此项,可用#注释,或改成本实例内容
22 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 root@master:~# mysql_secure_installation
2 ~~~~省略部分内容~~~~
3 Enter current password for root (enter for none): //此处直接回车,默认root密码为空
4 OK, successfully used password, moving on...
5
6 Setting the root password ensures that nobody can log into the MariaDB
7 root user without the proper authorisation.
8
9 Set root password? [Y/n] y //选择y更改root密码
10 New password:
11 Re-enter new password:
12 Password updated successfully!
13 Reloading privilege tables..
14 ... Success!
15 ~~~~省略部分内容~~~~
16 Remove anonymous users? [Y/n] n
17 ... skipping.
18 ~~~~省略部分内容~~~~
19 Disallow root login remotely? [Y/n] n //选 n 为允许root用户远程登录
20 ... skipping.
21 ~~~~省略部分内容~~~~
22 Remove test database and access to it? [Y/n] y
23 ~~~~省略部分内容~~~~
24 Reload privilege tables now? [Y/n] y
25 ... Success!
26
27 Cleaning up...
28
29 All done! If you've completed all of the above steps, your MariaDB
30 installation should now be secure.
31
32 Thanks for using MariaDB!
1 root@master:~# mysql -u root -p
2 Enter password:
3 MariaDB [(none)]> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root123' WITH GRANT OPTION;
4 Query OK, 0 rows affected (0.00 sec
5 MariaDB [(none)]> flush privileges;
1 MariaDB [(none)]> create database hive DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
2 MariaDB [(none)]> create database amon DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
3 MariaDB [(none)]> create database hue DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
4 MariaDB [(none)]> create database manager DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
5 MariaDB [(none)]> create database oozie DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
6 //后续其他选中的服务需要数据库可以自己再次创建
root@master:~# apt install libmysql-java
1.配置本地源:
1 root@master:~# mkdir /opt/cloudera-manager //所有节点创建
2 root@master:~# tar -xzvf cloudera-manager-xenial-cm5.14.2_amd64.tar.gz -C /opt/cloudera-manager
1 root@master:~# vim /opt/cloudera-manager/cm-5.14.2/etc/cloudera-scm-agent/config.ini
2 ~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~
3 [General]
4 # Hostname of the CM server.
5 server_host=master
6
7 # Port that the CM server is listening on.
8 server_port=7182
9 ~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~
10 //server_host 更改为主节点的ip或者host名
11 //server_port 默认为7182 若端口被占,则改成其他
1 root@master:~# scp -r /opt/cloudera-manager root@slave1:/opt/cloudera-manager/
2 root@master:~# scp -r /opt/cloudera-manager root@slave2:/opt/cloudera-manager/
1 root@master:~# mkdir -p /opt/cloudera/parcel-repo //在所有节点创建
2 //将sha1更名为sha否则无法识别,并将资源包拷贝到/opt/cloudera/parcel-repo
3 root@master:~# mv CDH-5.14.0-1.cdh5.14.0.p0.24-xenial.parcel.sha1 CDH-5.14.0-1.cdh5.14.0.p0.24-xenial.parcel.sha
4 root@master:~# cp CDH-5.14.0-1.cdh5.14.0.p0.24-xenial.parcel CDH-5.14.0-1.cdh5.14.0.p0.24-xenial.parcel.sha manifest.json /opt/cloudera/parcel-repo
1 root@master:~# mkdir -p /opt/cloudera/parcels
root@master:~# useradd --system --home=/opt/cloudera-manager/cm-5.14.2/run/cloudera-scm-server --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm
1 root@master:~# chown cloudera-scm:cloudera-scm /opt/cloudera/parcels
2 root@master:~# chown -R cloudera-scm:cloudera-scm /opt/cloudera/parcel-repo
3 root@master:~# chown -R cloudera-scm:cloudera-scm /opt/cloudera-manager
2.安装cloudera manager*
1 root@master:/etc/apt/sources.list.d# vim /etc/apt/sources.list.d/cloudera-manager.list
2 ~~~~~~~~~~~~~~~~~~~~添加内容~~~~~~~~~~~~~~~~~~~~
3 # Packages for Cloudera Manager, Version 5, on Ubuntu 16.04 amd64
4 deb [arch=amd64] http://archive.cloudera.com/cm5/ubuntu/xenial/amd64/cm xenial-cm5 contrib
5 deb-src http://archive.cloudera.com/cm5/ubuntu/xenial/amd64/cm xenial-cm5 contrib
6 ~~~~~~~~~~~~~~~~~~~~添加内容~~~~~~~~~~~~~~~~~~~~
安装cloudera-manager-daemons(主节点) cloudera-manager-server(主节点) coudera-manager-agent(主节点和从节点):
1 root@master:~# apt-get install cloudera-manager-daemons cloudera-manager-server
2 root@master:~# apt-get install cloudera-manager-agent
1 root@master:~# vim /etc/cloudera-scm-agent/config.ini
2 ~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~
3 [General]
4 # Hostname of the CM server.
5 server_host=master
6
7 # Port that the CM server is listening on.
8 server_port=7182
9 ~~~~~~~~~~~~~~内容~~~~~~~~~~~~~~
10 //server_host 更改为主节点的ip或者host名
11 //server_port 默认为7182 若端口被占,则改成其他
3.配置cm数据库账户:
1 root@master:~# mysql -uroot -p
2 Enter password:
3 MariaDB [(none)]> grant all on *.* to 'scm'@'%' identified by 'scm' with grant option;
4 MariaDB [(none)]> flush privileges;
1 root@master:~# /usr/share/cmf/schema/scm_prepare_database.sh mysql -hmaster -uroot -p --scm-host master scm scm scm
2 JAVA_HOME=/usr/lib/jvm/java-8-oracle
3 Verifying that we can write to /etc/cloudera-scm-server
4 log4j:ERROR Could not find value for key log4j.appender.A
5 log4j:ERROR Could not instantiate appender named "A".
6 Creating SCM configuration file in /etc/cloudera-scm-server
7 Executing: /usr/lib/jvm/java-8-oracle/bin/java -cp /usr/share/java/mysql-connector-java.jar:/usr/share/java/oracle-connector-java.jar:/usr/share/cmf/schema/../lib/* com.cloudera.enterprise.dbutil.DbCommandExecutor /etc/cloudera-scm-server/db.properties com.cloudera.cmf.db.
8 log4j:ERROR Could not find value for key log4j.appender.A
9 log4j:ERROR Could not instantiate appender named "A".
10 [2018-05-20 02:19:36,840] INFO 0[main] - com.cloudera.enterprise.dbutil.DbCommandExecutor.testDbConnection(DbCommandExecutor.java) - Successfully connected to database.
11 All done, your SCM database is configured correctly!
12 //这里出现的ERROR暂时没发现影响后面的操作,可以忽略
说明:
脚本用来创建和配置CMS需要的数据库。各参数是指:
mysql:数据库用的是mysql,如果安装过程中用的oracle,那么该参数就应该改为oracle。
-uroot:root身份运行mysql。-proot:mysql的root密码是root。
--scm-host localhost :CMS的主机,一般是和mysql安装的主机是在同一个主机上。
最后三个参数是:数据库名,数据库用户名,数据库密码。
4.启动cloudera manager服务:
1 root@master:~# service cloudera-scm-server start
这步启动时间有点长,可以查看日志来看服务是否启动完成:
root@master:/# tail -f /var/log/cloudera-scm-server/cloudera-scm-server.log
1 root@master:~# service cloudera-scm-agent start
注意:Cloudera 建议将 /proc/sys/vm/swappiness 设置为 10。当前设置为 60。使用 sysctl 命令在运行时更改该设置并编辑 /etc/sysctl.conf 以在重启后保存该设置。
解决方法 在出现问题的节点上运行:echo 10 > /proc/sys/vm/swappiness
echo后面的10 为需要的设置的值。
数据库名为之前创建的数据库名,若没有创建你需要的服务所需的数据库,可自行再进行创建,用户名这里使用root。也可自己创建新的用户