CDH6.2.1部署操作手册
目录
说明
本文档旨在描述相关CDH6.2.1的安装配置操作,便于相关使用人员后参考。
相关配置信息
软件版本
软件 | 信息 |
CDH | CDH6.2.1 |
OS | CentOS 7.5 |
MySQL | MySQL 5.7.27 |
访问地址信息
代理访问地址 | 备注 |
http://10.128.21.41:7180 | 安装完成后,CM管理界面 |
服务器信息
IP | 主机名 | 角色 |
10.128.21.41 | cdh01 | Cm、nn |
10.128.21.42 | cdh02 | datanode |
10.128.21.43 | cdh03 | datanode |
目录参数信息
程序基本目录参数信息:
配置参数 | 备注 |
/opt/cloudera/parcels | CDH程序目录 |
系统环境准备
Hosts配置(所有主机)
[root@cdh01 ~]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.128.21.41 cdh01.paraview.cn cdh01 10.128.21.42 cdh02.paraview.cn cdh02 10.128.21.43 cdh03.paraview.cn cdh03 |
配置免密(所有主机)
[root@cdh01 ~]# ssh-keygen -t rsa (连按三次回车) [root@cdh01 .ssh]# ssh-copy-id cdh01.paraview.cn [root@cdh01 .ssh]# ssh-copy-id cdh02.paraview.cn [root@cdh01 .ssh]# ssh-copy-id cdh03.paraview.cn |
修改yum源
cd /etc/yum.repos.d/ yum install -y wget mv CentOS-Base.repo CentOS-Base.repo.bak wget http://mirrors.aliyun.com/repo/Centos-7.repo mv Centos-7.repo CentOS-Base.repo yum clean all yum makecache |
关闭SELINUX(所有节点)
[root@cdh01 ~]# vi /etc/selinux/config 将这一行修改为 SELINUX=disabled |
配置集群时间同步
安装ntp(所有节点)
[root@cdh01 ~]# yum install ntp -y |
在主节点配置时间同步
[root@cdh01 ~]# vi /etc/ntp.conf |
#server 0.centos.pool.ntp.org iburst #server 1.centos.pool.ntp.org iburst #server 2.centos.pool.ntp.org iburst #server 3.centos.pool.ntp.org iburst server 127.127.1.0 |
修改系统时间与硬件时间同步
vi /etc/sysconfig/ntpd # Command line options for ntpd OPTIONS="-g" SYNC_HWCLOCK=yes |
配置其他节点时间同步
server 10.128.21.41 |
开启自启(所有节点)
systemctl start ntpd systemctl enable ntpd |
优化虚拟内存(所有节点)
[root@cdh01 ~]# echo 'vm.swappiness = 0' > /etc/sysctl.d/swappiness.conf [root@cdh01 ~]# sysctl -p |
禁用大页内存(所有节点)
[root@cdh01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/defrag [root@cdh01 ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled [root@cdh01 ~]# echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local [root@cdh01 ~]# echo "echo never > /sys/kernel/mm/transparent_hugepage/defrag" >> /etc/rc.local [root@cdh01 ~]# chmod u+x /etc/rc.local |
所有节点(所有节点关闭防火墙)
[root@cdh01 ~]# systemctl stop firewalld.service [root@cdh01 ~]# systemctl disable firewalld.service |
重启所有节点
reboot |
安装mysql
准备
先卸载系统自带mariadb-lib
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64 |
安装MySQL
上传mysql包,解压
rpm -ivh mysql-community-common-5.7.27-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-5.7.27-1.el7.x86_64.rpm rpm -ivh mysql-community-libs-compat-5.7.26-1.el7.x86_64.rpm rpm -ivh mysql-community-client-5.7.27-1.el7.x86_64.rpm rpm -ivh mysql-community-server-5.7.27-1.el7.x86_64.rpm |
启动MySQL
systemctl start mysqld.service systemctl status mysqld.service |
修改密码
grep "password" /var/log/mysqld.log mysql -uroot -p 然后输入我们之前获取到的密码 ALTER USER 'root'@'localhost' IDENTIFIED BY '[Root123]'; |
初始化数据库:
/usr/bin/mysql_secure_installation Securing the MySQL server deployment. Enter password for user root: (输入前面修改的root密码:[Root123]) The 'validate_password' plugin is installed on the server. The subsequent steps will run with the existing configuration of the plugin. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : ... skipping. By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? (Press y|Y for Yes, any other key for No) : y Success. Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? (Press y|Y for Yes, any other key for No) : ... skipping. By default, MySQL comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y - Dropping test database... Success. - Removing privileges on test database... Success. Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y Success. All done! |
配置root用户远程访问
mysql -uroot -p[Root123] grant all privileges on *.* to 'root' @'%' identified by '[Root123]'; flush privileges; |
创建数据及日志目录
更新mysql配置,以root用户执行如下命令,创建目录:
export MySQLDataDir=/data/mysql_data 指定mysql data根目录 export MySQLLogDIR=/data/mysql_log 指定mysql log的根目录 mkdir -p $MySQLDataDir/data; mkdir $MySQLDataDir/run; touch $MySQLDataDir/run/health_3430.sock; touch $MySQLDataDir/run/health_3430.pid touch $MySQLDataDir/run/health.pid; mkdir $MySQLDataDir/tmp; mkdir -p $MySQLLogDIR/log/error_log; touch $MySQLLogDIR/log/error_log/error.log; mkdir -p $MySQLLogDIR/log/binary_log/; touch $MySQLLogDIR/log/binary_log/health-5049-bin; touch $MySQLLogDIR/log/binary_log/health-5049-bin.index; mkdir -p $MySQLLogDIR/log/slow_log; touch $MySQLLogDIR/log/slow_log/slow.log; mkdir -p $MySQLLogDIR/log/general_log; touch $MySQLLogDIR/log/general_log/general.log; mkdir -p $MySQLLogDIR/log/relay_log; touch $MySQLLogDIR/log/relay_log/mysql-relay-bin; touch $MySQLLogDIR/log/relay_log/relay-bin.index; mkdir -p $MySQLLogDIR/log/audit_log/; touch $MySQLLogDIR/log/audit_log/audit.log; mkdir -p $MySQLLogDIR/log/ibdata_log/; mkdir -p $MySQLLogDIR/log/redo_log/; mkdir -p $MySQLLogDIR/log/undo_log/; |
迁移数据库目录
停止mysql
systemctl stop mysqld |
#迁移目录并修改目录权限:
export MySQLDataDir=/data/mysql_data export MySQLLogDIR=/data/mysql_log cp -a /var/lib/mysql/* $MySQLDataDir/data chown -R mysql:mysql $MySQLDataDir mv /var/lib/mysql /var/lib/mysql.bak ln -s $MySQLDataDir/data /var/lib/mysql chown -R mysql:mysql /var/lib/mysql chown -R mysql:mysql $MySQLDataDir chown -R mysql:mysql $MySQLLogDIR |
更新my.cnf配置
备份原有配置:
mv /etc/my.cnf /etc/my.cnf.bak |
执行更新配置命令:
#设置目录环境变量 export MySQLDataDir=/data/mysql_data export MySQLLogDIR=/data/mysql_log export id=65 #为每个mysql server-id设置一个唯一ID #执行更新: cat >> /etc/my.cnf <<EOF [client] port = 3306 socket = /var/lib/mysql/mysql.sock user=root password=[Root123] [mysql-dump] port = 3306 socket = /var/lib/mysql/mysql.sock user=root password=[Root123] [mysql] port = 3306 no-auto-rehash default_character_set = utf8mb4 prompt = '\u@\h [\d]> ' socket = /var/lib/mysql/mysql.sock [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock pid-file=/var/run/mysqld/mysqld.pid port = 3306 user = mysql server-id = $id tmpdir = $MySQLDataDir/tmp character-set-server = utf8mb4 skip-external-locking = 1 skip-name-resolve = 1 skip_networking = 0 symbolic-links = 0 max_connections = 3000 max_user_connections = 0 max_connect_errors = 100000 max_allowed_packet = 128M lower_case_table_names = 1 sql-mode="STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION" query_cache_type=0 query_cache_size=0 log-error = $MySQLLogDIR/log/error_log/error.log log-bin = $MySQLLogDIR/log/binary_log/health-bin log-bin-index = $MySQLLogDIR/log/binary_log/health-bin.index binlog-format = ROW sync-binlog = 1 expire-logs-days = 15 binlog_cache_size = 2M max_binlog_size = 512M binlog_stmt_cache_size = 512K binlog_rows_query_log_events = 1 slow_query_log = 1 long_query_time = 0.1 general_log = 0 general_log_file = $MySQLLogDIR/log/general_log/general.log log_slave_updates = 1 relay_log_recovery = 1 relay_log_purge = 1 relay_log = $MySQLLogDIR/log/relay_log/mysql-relay-bin relay_log_index = $MySQLLogDIR/log/relay_log/relay-bin.index relay_log_info_repository = TABLE master_info_repository = TABLE transaction-isolation = REPEATABLE-READ innodb_data_home_dir = /var/lib/mysql innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = $MySQLLogDIR/log/redo_log/ innodb_log_file_size = 200M innodb_log_files_in_group = 4 innodb_log_buffer_size = 16M innodb_file_per_table=1 innodb_undo_directory = $MySQLLogDIR/log/undo_log/ innodb_undo_logs = 128 innodb_buffer_pool_size = 4G innodb_buffer_pool_instances = 48 innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 30 innodb_sync_spin_loops = 40 innodb_max_dirty_pages_pct = 75 innodb_support_xa = 1 innodb_thread_concurrency = 0 innodb_thread_sleep_delay = 500 innodb_concurrency_tickets = 1000 innodb_flush_method = O_DIRECT innodb_read_io_threads = 16 innodb_write_io_threads = 16 innodb_numa_interleave = 1 key_buffer_size = 8M table_open_cache = 1024 table_definition_cache = 1024 max_tmp_tables = 256 tmp_table_size = 32M max_heap_table_size = 32M table_open_cache_instances = 8 open_files_limit = 204800 join_buffer_size = 1M sort_buffer_size = 1M read_buffer_size = 1M read_rnd_buffer_size = 1M bulk_insert_buffer_size = 0 EOF |
启动
systemctl start mysqld |
创建CDH需要用到的库
在mysql中创建数据库:mysql -uroot -p[Root123]
create database amon DEFAULT CHARACTER SET utf8; create database rman DEFAULT CHARACTER SET utf8; create database metastore DEFAULT CHARACTER SET utf8; create database ranger DEFAULT CHARACTER SET utf8; create database hue DEFAULT CHARACTER SET utf8; create database oozie DEFAULT CHARACTER SET utf8; create database scm DEFAULT CHARACTER SET utf8; create database das DEFAULT CHARACTER SET utf8; create database schemaregistry DEFAULT CHARACTER SET utf8; create database smm DEFAULT CHARACTER SET utf8; create database nav DEFAULT CHARACTER SET utf8; create database navms DEFAULT CHARACTER SET utf8; create database hive DEFAULT CHARACTER SET utf8; |
创建账户:
grant all privileges on amon.* to 'amon'@'%' identified by '[Root123]'; grant all privileges on rman.* to 'rman'@'%' identified by '[Root123]'; grant all privileges on metastore.* to 'hive'@'%' identified by '[Root123]'; grant all privileges on ranger.* to 'ranger'@'%' identified by '[Root123]'; grant all privileges on nav.* to 'nav'@'%' identified by '[Root123]'; grant all privileges on navms.* to 'navms'@'%' identified by '[Root123]'; grant all privileges on hue.* to 'hue'@'%' identified by '[Root123]'; grant all privileges on oozie.* to 'oozie'@'%' identified by '[Root123]'; grant all privileges on smm.* to 'smm'@'%' identified by '[Root123]'; grant all privileges on das.* to 'das'@'%' identified by '[Root123]'; grant all privileges on schemaregistry.* to 'schemaregistry'@'%' identified by '[Root123]'; grant all privileges on scm.* to 'scm'@'%' identified by '[Root123]'; grant all privileges on hive.* to 'hive'@'%' identified by '[Root123]'; GRANT ALL PRIVILEGES ON *.* TO 'scm'@'%' IDENTIFIED BY '[Root123]' WITH GRANT OPTION; |
必须执行以下命令,不然初始化ranger会报错 SET GLOBAL innodb_file_per_table = ON, innodb_file_format = Barracuda, innodb_large_prefix = ON; |
拷贝Mysql驱动
mkdir -p /usr/share/java cp mysql-connector-java.jar /usr/share/java/ |
CM&CDH安装
准备
cm准备
unzip cm6.2.1.zip |
安装createrepo:
yum -y install createrepo 进去cm目录,执行如下语句 createrepo . 看到repodata目录生成,目录里并且有repomd.xml说明成功 |
将cm6.2.1移动到/var/www/html下面。访问http://IP/cm6.2.1
parcels准备
unzip cdh6.2.1.zip
解压后软链接到/var/www/html供后续使用
在主节点/etc/yum.repos.d/下创建cm.repo源文件:
vi /etc/yum.repos.d/cm.repo [local_cloudera_source] name=local_cloudera baseurl=http://10.128.21.41/cm6.2.1/ enabled=1 gpgcheck=0 验证: yum clean all yum repolist
|
JDK安装
mkdir -p /usr/java/ yum -y install oracle-j2sdk1.8-1.8.0+update181-1.x86_64.rpm vi /etc/profile #JAVA_HOME export JAVA_HOME=/usr/java/jdk1.8.0_181-cloudera export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar |
分发jdk到其他节点:
scp -r /usr/java root@10.128.21.42:/usr/ scp -r /usr/java root@10.128.21.43:/usr/ scp /etc/profile root@10.128.21.42:/etc/ scp /etc/profile root@10.128.21.43:/etc/ |
所有节点刷新一下 source /etc/profile java -version |
CM安装
主节点安装CM
yum install -y cloudera-manager-server.x86_64 |
初始化CM数据库
/opt/cloudera/cm/schema/scm_prepare_database.sh mysql scm root [Root123] |
看到Successfully connected to database即为成功
启动CM
systemctl start cloudera-scm-server |
(启动时间大约需要两分钟)
组件安装
浏览器输入http://10.128.21.41:7180
账号:admin
密码:admin