# 查看IPv6当前状态,有值则为打开,空则为关闭 ansible all -a "lsmod | grep ipv6"
IPv6打开的情况下如何关闭:
1 2 3 4 5 6 7 8
# 第六行添加 vim /etc/default/grub GRUB_CMDLINE_LUNUX="ipv6.disable=1 ...." ansible all -m copy -a "src=/etc/default/grub dest=/etc/default/grub" # 重启 ansible all -a "reboot" # 验证 ansible all -a "lsmod | grep ipv6"
# 调整时区 ansible all -a "ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime" # 安装ntp ansible all -a "yum install ntp -y" # 手动同步时间(ntpd服务关闭的情况下),避免时间差距过大导致同步失败 ansible all -a "ntpdate -u 0.cn.pool.ntp.org"
# 配置ntp服务器地址 vim /etc/ntp.conf # 有外网的情况下可直接配置外部ntp服务器 echo "server ntp1.aliyun.com" >> /etc/ntp.conf # 其他备用ntp服务器 # server 0.pool.ntp.org # server 1.pool.ntp.org # server 2.pool.ntp.org # server 0.pool.ntp.org # 有域名负载均衡 # server 0.cn.pool.ntp.org # 有域名负载均衡 # server ntp.tuna.tsinghua.edu.cn # 清华大学
# 启动ntp ansible all -a "systemctl start ntpd" # 开机启动 ansible all -a "systemctl enable ntpd"
# 备份 ansible all -a "mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup" # 下载 ansible all -a "wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo" # 更新 ansible all -m shell -a "yum clean all && yum makecache" ansible all -a "yum -y update"
系统软件安装
安装后续需要用到的系统软件,以备日后服务器无外网无法下载的情况。
1 2
# 包括不限于 ansible all -a "yum install -y expect bc net-tools iotop zip unzip telnet wget iperf3 fio ntfs-3g lzo iftop vim"
# 以2.11.8示例 ansible all -m shell -a "rm -rf /usr/scala && mkdir -p /usr/scala" cp /tmp/scala-2.11.8.tgz /usr/scala ansible all -m copy -a "src=/usr/scala/scala-2.11.8.tgz dest=/usr/scala/scala-2.11.8.tgz" ansible all -m shell -a "cd /usr/scala && tar -zxvf scala-2.11.8.tgz && rm -rf scala-2.11.8.tgz"
配置环境变量
1 2 3 4 5
ansible all -a "echo JAVA_HOME=/usr/java/jdk1.8.0_141-cloudera >> /etc/profile" ansible all -a "echo SCALA_HOME=/usr/scala/scala-2.11.8 >> /etc/profile" ansible all -a "echo CLASSPATH=$JAVA_HOME/bin:$SCALA_HOME/bin >> /etc/profile" ansible all -a "echo export PATH=$JAVA_HOME:$SCALA_HOME:$CLASSPATH:$PATH >> /etc/profile" ansible all -a "source /etc/profile"
Python与Python包
Centos7自带python2.7,Centos6自带python2.6需要升级。
1 2
python -V # Python 2.7.5
安装python3.6
1 2 3 4 5 6 7 8 9 10 11 12 13 14
# 依赖包安装 ansible all -a "yum install -y openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel gcc-c++ python36-devel cyrus-sasl-lib.x86_64 cyrus-sasl-devel.x86_64 libgsasl-devel.x86_64 epel-release" # yum源下载 ansible all -a "yum install https://centos7.iuscommunity.org/ius-release.rpm -y" # 安装python3.6 ansible all -a "yum install python36 -y" # 安装setuptools ansible all -a "wget -P /tmp --no-check-certificate https://pypi.python.org/packages/source/s/setuptools/setuptools-19.6.tar.gz#md5=c607dd118eae682c44ed146367a17e26" ansible all -a "tar -zxvf /tmp/setuptools-19.6.tar.gz" ansible all -m shell -a "cd /tmp/setuptools-19.6 && python3.6 setup.py build && python3.6 setup.py install" # 安装pip3.6 ansible all -a "wget -P /tmp --no-check-certificate https://pypi.python.org/packages/source/p/pip/pip-8.0.2.tar.gz#md5=3a73c4188f8dbad6a1e6f6d44d117eeb" ansible all -a "tar -zxvf /tmp/pip-8.0.2.tar.gz" ansible all -m shell -a "cd /tmp/pip-8.0.2 && python3.6 setup.py build && python3.6 setup.py install"
# 更新 ansible all -m copy -a "src=/etc/locale.conf dest=/etc/locale.conf" ansible all -a "source /etc/locale.conf"
tuned
1 2 3 4 5 6 7 8
ansible all -a "systemctl start tuned" ansible all -a "systemctl status tuned" # 显示No current active profile ansible all -a "tuned-adm off" ansible all -a "tuned-adm list" # 关闭tuned服务 ansible all -a "systemctl stop tuned" ansible all -a "systemctl disable tuned"
大页面关闭
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
# 输出[always] never意味着THP已启用,always [never]意味着THP未启用 ansible all -a "cat /sys/kernel/mm/transparent_hugepage/enabled" ansible all -a "cat /sys/kernel/mm/transparent_hugepage/defrag"
# 关闭 ansible all -m shell -a "echo never > /sys/kernel/mm/transparent_hugepage/enabled" ansible all -m shell -a "echo never > /sys/kernel/mm/transparent_hugepage/defrag" # 设置开机关闭 echo "echo never > /sys/kernel/mm/transparent_hugepage/defrag" >> /etc/rc.local echo "echo never > /sys/kernel/mm/transparent_hugepage/enabled" >> /etc/rc.local chmod +x /etc/rc.d/rc.local
# 在GRUB_CMDLINE_LINUX项目后面添加一个参数:transparent_hugepage=never vim /etc/default/grub ansile all -m copy -a "src=/etc/default/grub dest=/etc/default/grub" # 重新生成gurb.cfg文件 ansible all -a "grub2-mkconfig -o /boot/grub2/grub.cfg"
swappiness
1 2 3 4
ansible all -a "cat /proc/sys/vm/swappiness" ansible all -a "sysctl -w vm.swappiness=1" echo "vm.swappiness=1" >> /etc/sysctl.conf ansible all -m copy -a "src=/etc/sysctl.conf dest=/etc/sysctl.conf"
# max_connections - Allow 100 maximum connections for each database and then add 50 extra connections. max_connections = 550 #expire_logs_days = 10 #max_binlog_size = 100M
#log_bin should be on a disk with enough free space. #Replace '/var/lib/mysql/mysql_binary_log' with an appropriate path for your #system and chown the specified folder to the mysql user. # 修改binlog存储路径 log_bin=/opt/mysql/binlog/mysql_binary_log
#In later versions of MySQL, if you enable the binary log and do not set #a server_id, MySQL will not start. The server_id must be unique within #the replicating group. server_id=1
# 官网下载mysql驱动并上传至服务器 # Installing the MySQL JDBC Driver tar zxvf /tmp/mysql-connector-java-5.1.46.tar.gz
ansible all -a "mkdir -p /usr/share/java/" # 注意去掉版本号,否则cm无法使用 ansible all -m copy -a "src=/tmp/mysql-connector-java-5.1.46/mysql-connector-java-5.1.46-bin.jar /usr/share/java/usr/share/java/mysql-connector-java.jar" rm -rf /tmp/mysql-connector-java-5.1.46*
启动mysql服务
1 2 3
systemctl start mysqld systemctl status mysqld systemctl enable mysqld
# Configure the Cloudera Manager Server, Activity Monitor, Reports Manager, Cloudera Navigator Audit Server, and Cloudera Navigator Metadata Server databases to support the utf8mb4 character set encoding. # Configure all other databases to use the utf8 character set. CREATE DATABASE scm DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON scm.* TO 'scm'@'%' IDENTIFIED BY 'scm@DW'; CREATE DATABASE amon DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON amon.* TO 'amon'@'%' IDENTIFIED BY 'amon@DW'; CREATE DATABASE rman DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON rman.* TO 'rman'@'%' IDENTIFIED BY 'rman@DW'; CREATE DATABASE hue DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON hue.* TO 'hue'@'%' IDENTIFIED BY 'hue@DW'; CREATE DATABASE metastore DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON metastore.* TO 'hive'@'%' IDENTIFIED BY 'hive@DW'; CREATE DATABASE sentry DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON sentry.* TO 'sentry'@'%' IDENTIFIED BY 'sentry@DW'; CREATE DATABASE nav DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON nav.* TO 'nav'@'%' IDENTIFIED BY 'nav@DW'; CREATE DATABASE navms DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON navms.* TO 'navms'@'%' IDENTIFIED BY 'navms@DW'; CREATE DATABASE oozie DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci; GRANT ALL ON oozie.* TO 'oozie'@'%' IDENTIFIED BY 'oozie@DW'; SHOW DATABASES;
注意事项:
在大型集群中Activity Monitor 与 Service Monitor 使用的数据库应该分配不同的磁盘卷来进行读写。
For MySQL 5.6 and 5.7, you must install the MySQL-shared-compat or MySQL-shared package. This is required for the Cloudera Manager Agent package installation.
3.6 安装Cloudera Manager服务
本次过程不启用auto-ssl。
安装CM软件包
创建免密root权限用户
1 2 3 4 5
vim /etc/sudoers cloudera-scm ALL=(ALL) NOPASSWD:ALL
# 同步 ansible except1 -m copy -a "src=/etc/sudoers dest=/etc/sudoers"
# 各个节点上启动agent ansible all -a "systemctl start cloudera-scm-agent"
3.7 附:卸载Cloudera Manager服务
删除mysql数据库
1 2 3 4 5 6 7 8 9
drop database scm; drop database amon; drop database rman; drop database hue; drop database metastore; drop database sentry; drop database nav; drop database navms; drop database oozie;
卸载软件
1 2 3 4
ansible all -a "yum -y remove cloudera-manager-*" ansible all -a "umount /var/run/cloudera-scm-agent/process" # 删除数据目录 ansible all -a "rm -Rf /var/lib/cloudera* /var/log/cloudera* /var/run/cloudera* /etc/cloudera* /tmp/.scm_prepare_node.lock"
# Service Monitor 客户端配置替代 <property><name>mapreduce.output.fileoutputformat.compress</name><value>true</value></property><property><name>mapreduce.output.fileoutputformat.compress.codec</name><value>org.apache.hadoop.io.compress.SnappyCodec</value></property><property><name>io.compression.codecs</name><value>org.apache.hadoop.io.compress.DefaultCodec,org.apache.hadoop.io.compress.GzipCodec,org.apache.hadoop.io.compress.BZip2Codec,org.apache.hadoop.io.compress.DeflateCodec,org.apache.hadoop.io.compress.SnappyCodec,org.apache.hadoop.io.compress.Lz4Codec</value></property>