CDH 5.16.1 离线部署 通过 CDH 部署 Hadoop 服务(2)

部署MySQL

# 采用bin包部署,解压后直接使用 cd /usr/local/src tar -zxvf mysql-5.7.24-el7-x86_64.tar.gz -C /usr/local/ mv /usr/local/mysql-5.7.24-el7-x86_64/ /usr/local/mysql

账号与权限

# 添加账号 groupadd mysql useradd -g mysql -s /sbin/nologin mysql # 创建"data"目录 mkdir /data # 赋权 chown -R mysql:mysql /usr/local/mysql/ chown -R mysql:mysql /data/

初始化MySQL

获取root@localhost账号的初始密码Hqe6x<Re4jhK

cd /usr/local/mysql/ bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data

设置变量

cat << EOF >> /etc/profile # MySQL export PATH=$PATH:/usr/local/mysql/bin EOF # 加载变量 source /etc/profile # 软链接 ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql ln -s /usr/local/mysql/include/mysql /usr/include/mysql

设置开机启动

# 复制开机启动脚本到系统服务 cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld chown mysql:mysql /etc/rc.d/init.d/mysqld # 修改默认的"basedir"与"datadir" vim /etc/rc.d/init.d/mysqld basedir=/usr/local/mysql datadir=/data # 添加开机启动脚本 chkconfig --add mysqld chkconfig --level 35 mysqld on

文件路径:log && pid && socket

# 日志路径 mkdir -p /var/log/mysqld touch /var/log/mysqld/mysqld.log chown -R mysql:mysql /var/log/mysqld/ # pid路径 mkdir -p /var/run/mysqld chown -R mysql:mysql /var/run/mysqld/ # socker路径 mkdir -p /var/lib/mysqld chown -R mysql:mysql /var/lib/mysqld/ ln -s /var/lib/mysqld/mysql.sock /tmp/mysql.sock

设置my.cnf文件

# 注意"log-error","pid-file"与"socket"的路径 mkdir -p /usr/local/mysql/etc cat << EOF >> /usr/local/mysql/etc/my.cnf [mysqld] character-set-server=utf8 max_connections = 3000 log-error=/var/log/mysqld/mysqld.log pid-file=/var/run/mysqld/mysqld.pid socket=/var/lib/mysqld/mysql.sock sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set=utf8 EOF # 软链接 ln -s /usr/local/mysql/etc/my.cnf /etc/my.cnf # 赋权 chown -R mysql:mysql /usr/local/mysql/etc/

启动MySQL服务

# 启动服务 service mysqld start # 验证 service mysqld status

设置MySQL账号密码与登陆权限

# 使用初始化密码登陆 mysql -uroot -p # 修改密码,注意不能使用"$"等特殊符号 set password=password('cdh12#hadoop'); flush privileges; # 远程登陆权限 grant all privileges on *.* to 'root'@'%' identified by 'cdh12#hadoop' with grant option; flush privileges; # 查看账号 select user, host, authentication_string from mysql.user;

三. Cloudera Manager安装 3.1 部署CM Server & Agent

在所有节点创建CM目录/opt/cloudera-manager

mkdir /opt/cloudera-manager

在master节点向其余节点分发cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz

for i in {1..3}; do scp /usr/local/src/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz root@slave0$i:/usr/local/src/ ; done

在所有节点解压cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz到/opt/cloudera-manager/目录

tar -zxvf /usr/local/src/cloudera-manager-centos7-cm5.16.1_x86_64.tar.gz -C /opt/cloudera-manager/

在所有slave节点修改/opt/cloudera-manager/cm-5.16.1/etc/cloudera-scm-agent/config.ini的server_host参数为master节点ip或主机名

sed -i "s/server_host=localhost/server_host=master/g" /opt/cloudera-manager/cm-5.16.1/etc/cloudera-scm-agent/config.ini

3.2 账号 && 权限

在所有节点创建cloudera-scm账号,这是CM相关服务使用的默认账号

# 禁止使用"cloudera-scm"账号登陆 useradd --system --home=/opt/cloudera-manager/cm-5.16.1/run/cloudera-scm-server/ --no-create-home --shell=/bin/false --comment "Cloudera SCM User" cloudera-scm

在所有节点为/opt/cloudera-manager目录赋权

chown -R cloudera-scm:cloudera-scm /opt/cloudera-manager

3.3 设置开机启动

在master节点设置系统服务

# 设置使用"cloudera-scm-server"为系统启动服务 cp /opt/cloudera-manager/cm-5.16.1/etc/init.d/cloudera-scm-server /etc/rc.d/init.d/ chown cloudera-scm:cloudera-scm /etc/rc.d/init.d/cloudera-scm-server # 修改"CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}"的路径 vim /etc/rc.d/init.d/cloudera-scm-server CMF_DEFAULTS=/opt/cloudera-manager/cm-5.16.1/etc/default # 添加系统启动服务 chkconfig --add cloudera-scm-server chkconfig --level 35 cloudera-scm-server on checkconfig --list

在所有slave节点设置系统服务

# 设置使用"cloudera-scm-agent"为系统启动服务 cp /opt/cloudera-manager/cm-5.16.1/etc/init.d/cloudera-scm-agent /etc/rc.d/init.d/ chown cloudera-scm:cloudera-scm /etc/rc.d/init.d/cloudera-scm-agent # 修改"CMF_DEFAULTS=${CMF_DEFAULTS:-/etc/default}"的路径"-/etc/default" vim /etc/rc.d/init.d/cloudera-scm-agent CMF_DEFAULTS=${CMF_DEFAULTS:/opt/cloudera-manager/cm-5.16.1/etc/default} # 添加系统启动服务 chkconfig --add cloudera-scm-agent chkconfig --level 35 cloudera-scm-agent on checkconfig --list

3.4 初始化数据库

在所有节点设置MySQL驱动(JDBC);

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/5a1d2e75088f1e10f7fb76514d2e52c7.html