1、cdh的部署形式有三种
bin在线部署
rpm包部署 要访问外网或者私服
tar包部署 这是真正意义上的离线部署
由于公司网路无法访问外网,所以一般我们就是使用第三种模式进行部署
2、CDH离线部署的三个部分
MySQL离线部署
建议MySQL5.7.11(疑问:mysql的版本以及安装方式对于cdh的部署是否有影响???)
CM的离线部署
分为server主节点和agent从节点,负责管理大数据的组件。
Parcel离线部署
即大数据组件的包裹文件。
3、环境
centos 7.2 磁盘可用至少40G
cdh001 server+agent
cdh002 agent
cdh003 agent
4、软件
MySQL:
mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
mysql-connector-java-5.1.47.jar
CM:
cloudera-manager-agent-6.2.0-968826.el7.x86_64.rpm
cloudera-manager-daemons-6.2.0-968826.el7.x86_64.rpm
cloudera-manager-server-6.2.0-968826.el7.x86_64.rpm
Parcel:
其他:
jdk-8u221-linux-x64.gz
以下步骤,如果未特别注明则是指在server主节点所在机器执行命令。
1、hosts配置(所有机器)
echo "192.168.11.141 cdh001" >> /etc/hosts && echo "192.168.11.142 cdh002" >> /etc/hosts && echo "192.168.11.143 cdh003" >> /etc/hosts
2、防火墙关闭(所有机器)
centos6:
关闭防火墙:service iptables stop
关闭防火墙自启动:chkconfig iptables off
centos7:
关闭防火墙:systemctl stop firewalld
禁用防火墙:systemctl disable firewalld
清空防火墙规则:iptables -F (为何需要清空?什么是防火墙规则)
3、SELINUX关闭(所有机器)
关闭selinux:setenforce 0
禁用selinux: vi /etc/selinux/config (SELINUX=disabled)
4、时间同步与设置时区
时间同步的方式:
主从(A负责和互联网同步时间,其他与A同步。优先选择主从)
主主(所有节点都与互联网同步时间)
有些公司有时间同步服务器,所有机器与该机器同步时间。
一般使用主从,因为所有机器从互联网同步时间,遇到关机重启之类的情况,
有的机器同步了时间,而有点机器没有,则可能导致时间不一致。
centos7
设置时区:timedatectl set-timezone Asia/Shanghai (所有机器)
时间同步:
yum -y install ntpd(所有机器)
如果是内网,则没有d。但此时公司必须有仓库中心,不然软件在哪里下载啊。
cdh001节点:
vi /etc/ntp.conf 添加如下内容
server 127.127.1.0 iburst local host
#这句意思是:当互联网时间无法同步时,使用本地硬件时间
restrict 192.168.3.0 mask 255.255.255.0 nomodify notrap
#这句话的意思:允许什么网段的机器来本机同步时间
#网段及ip前三位,最后一位补0
systemctl start ntpd
systemctl status ntpd
ntpq -p
##进行网络验证
cdh002和cdh003
systemctl stop ntpd && systemctl disable ntpd
##关闭并禁用除server节点的其他节点的ntpd
ntpdate cdh001
##其他节点同步server节点的时间
crontab -e 添加如下内容
*/1 * * * * /usr/sbin/ntpdate cdh001
#每隔一分钟到cdh001上同步时间
5、安装JDK配置环境变量(所有机器)
tar -zxvf jdk-8u181-linux-x64.gz -C /usr/java
chown -R root:root /usr/java/jdk1.8.0_181
vi /etc/profile #添加如下内容
export JAVA_HOME=/usr/java/jdk1.8.0_181
export PATH=${JAVA_HOME}/bin:$PATH
source /etc/profile
1、解压
tar -zxvf mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz -C /usr/local
2、重命名
cd /usr/local && mv mysql-5.7.11-linux-glibc2.5-x86_64 mysql
3、建目录
mkdir mysql/arch mysql/data mysql/tmp
4、改配置文件
vi /etc/my.cnf 替换成以下内容
[client]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
default-character-set=utf8mb4
[mysqld]
port = 3306
socket = /usr/local/mysql/data/mysql.sock
skip-slave-start
skip-external-locking
key_buffer_size = 256M
sort_buffer_size = 2M
read_buffer_size = 2M
read_rnd_buffer_size = 4M
query_cache_size= 32M
max_allowed_packet = 16M
myisam_sort_buffer_size=128M
tmp_table_size=32M
table_open_cache = 512
thread_cache_size = 8
wait_timeout = 86400
interactive_timeout = 86400
max_connections = 600
# Try number of CPU's*2 for thread_concurrency
#thread_concurrency = 32
#isolation level and default engine
default-storage-engine = INNODB
transaction-isolation = READ-COMMITTED
server-id = 1739
basedir = /usr/local/mysql
datadir = /usr/local/mysql/data
pid-file = /usr/local/mysql/data/hostname.pid
#open performance schema
log-warnings
sysdate-is-now
binlog_format = ROW
log_bin_trust_function_creators=1
log-error = /usr/local/mysql/data/hostname.err
log-bin = /usr/local/mysql/arch/mysql-bin
expire_logs_days = 7
innodb_write_io_threads=16
relay-log = /usr/local/mysql/relay_log/relay-log
relay-log-index = /usr/local/mysql/relay_log/relay-log.index
relay_log_info_file= /usr/local/mysql/relay_log/relay-log.info
log_slave_updates=1
gtid_mode=OFF
enforce_gtid_consistency=OFF
# slave
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=4
master_info_repository=TABLE
relay_log_info_repository=TABLE
relay_log_recovery=ON
#other logs
#general_log =1
#general_log_file = /usr/local/mysql/data/general_log.err
#slow_query_log=1
#slow_query_log_file=/usr/local/mysql/data/slow_log.err
#for replication slave
sync_binlog = 500
#for innodb options
innodb_data_home_dir = /usr/local/mysql/data/
innodb_data_file_path = ibdata1:1G;ibdata2:1G:autoextend
innodb_log_group_home_dir = /usr/local/mysql/arch
innodb_log_files_in_group = 4
innodb_log_file_size = 1G
innodb_log_buffer_size = 200M
#根据生产需要,调整pool size
innodb_buffer_pool_size = 2G
#innodb_additional_mem_pool_size = 50M #deprecated in 5.6
tmpdir = /usr/local/mysql/tmp
innodb_lock_wait_timeout = 1000
#innodb_thread_concurrency = 0
innodb_flush_log_at_trx_commit = 2
innodb_locks_unsafe_for_binlog=1
#innodb io features: add for mysql5.5.8
performance_schema
innodb_read_io_threads=4
innodb-write-io-threads=4
innodb-io-capacity=200
#purge threads change default(0) to 1 for purge
innodb_purge_threads=1
innodb_use_native_aio=on
#case-sensitive file names and separate tablespace
innodb_file_per_table = 1
lower_case_table_names=1
[mysqldump]
quick
max_allowed_packet = 128M
[mysql]
no-auto-rehash
default-character-set=utf8mb4
[mysqlhotcopy]
interactive-timeout
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 256M
read_buffer = 2M
write_buffer = 2M
3.创建用户组及用户
groupadd -g 101 dba && useradd -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
补充:
## if user mysqladmin is existing,please execute the following command of usermod.
#[root@hadoop39 local]# usermod -u 514 -g dba -G root -d /usr/local/mysql mysqladmin
4.拷贝配置文件
cp /etc/skel/.* /usr/local/mysql ###important
注意:
拷贝的实际上是.bash_profile和.bashrc两个文件
5.配置环境变量
vi mysql/.bashrc #添加如下内容
# User specific environment and startup programs
export MYSQL_BASE=/usr/local/mysql
export PATH=${MYSQL_BASE}/bin:$PATH
6、赋权限和用户组
chown mysqladmin:dba /etc/my.cnf && chmod 640 /etc/my.cnf
chown -R mysqladmin:dba /usr/local/mysql && chmod -R 755 /usr/local/mysql
7、配置服务及开机自启动
cd /usr/local/mysql && cp support-files/mysql.server /etc/rc.d/init.d/mysql
chmod +x /etc/rc.d/init.d/mysql #赋予可执行权限
chkconfig --del mysql #删除服务
chkconfig --add mysql #添加服务
chkconfig mysql on #开机自启
8.安装libaio及初始化mysql
yum -y install libaio
初始化mysql(需要近一分钟时间)
bin/mysqld \
--defaults-file=/etc/my.cnf \
--user=mysqladmin \
--basedir=/usr/local/mysql/ \
--datadir=/usr/local/mysql/data/ \
--initialize
注意:
在初始化时如果加上 –initial-insecure,则会创建空密码的 root@localhost 账号,否则会创建带密
码的 root@localhost 账号,密码直接写在 log-error 日志文件中
(在5.6版本中是放在 ~/.mysql_secret 文件里,更加隐蔽,不熟悉的话可能会无所适从)
9、登录及修改密码
cat hostname.err |grep password ##查看临时密码
su - mysqladmin && service mysql start
mysql -umysqladmin -p密码
mysql> alter user root@localhost identified by '123456';
mysql> grant all privileges on *.* TO 'root'@'%' identified by '123456' ;
mysql> flush privileges;
mysql> exit;
10.重启
service mysql restart && mysql -uroot -p123456
1、创建cdh元数据库的用户和amon的服务的库的用户
mysql>create database cmf default character set utf8;
mysql>create database amon default character set utf8;
mysql>grant all privileges on cmf.* to 'cmf'@'%' identified by '123456' ;
mysql>grant all privileges on amon.* to 'amon'@'%' identified by '123456' ;
mysql>flush privileges;
2、amon进程需要用到msyql驱动包
mkdir -p /usr/share/java
cp mysql-connector-java-5.1.47.jar /usr/share/java/mysql-connector-java.jar
##为什么去掉版本号?
3、安装cm的server和agent
安装server需要:*server*.rpm和*daemons*.rpm
安装agent需要:*agent*.rpm和*daemons*.rpm
注意:
首先应该安装daemons包才行
cdh001(安装server和agent):
rpm -ivh cloudera-manager-daemons-6.2.0-968826.el7.x86_64.rpm --nodeps --force
rpm -ivh cloudera-manager-server-6.2.0-968826.el7.x86_64.rpm --nodeps --force
cd /etc/cloudera-scm-server && vi db.properties 添加
com.cloudera.cmf.db.host=cdh001:3306
com.cloudera.cmf.db.name=cmf
com.cloudera.cmf.db.user=cmf
com.cloudera.cmf.db.password=123456
com.cloudera.cmf.db.setupType=EXTERNAL
#其实这些键值对的键都在配置文件中有,直接改也行
service cloudera-scm-server start
Sever首次启动会自动创建表以及数据,不要立即关闭或重启,需要等待1-2分钟
查看日志:
tail -F /var/log/cloudera-scm-server/cloudera-scm-server.log
rpm -ivh cloudera-manager-agent-6.2.0-968826.el7.x86_64.rpm --nodeps --force
vi /etc/cloudera-scm-agent/config.ini 修改
server_host=cdh001
cdh002和cdh003(安装agent):
rpm -ivh cloudera-manager-daemons-6.2.0-968826.el7.x86_64.rpm --nodeps --force
rpm -ivh cloudera-manager-agent-6.2.0-968826.el7.x86_64.rpm --nodeps --force
vi /etc/cloudera-scm-agent/config.ini 修改
server_host=cdh001
启动agent(所有机器):
service cloudera-scm-agent start