准备工作
1. 安装JDK,集群内各成员主机安装JDK的路径和版本必须统一。 2. 在集群内主机安装一台MySQL Server (MySQL为选装,Ambari默认的数据库为 PostgreSQL) 1. MySQL 配置 创建 ambari-server 的数据库以及连接用户,且授权 # mysql -u root -p CREATE DATABASE ambari DEFAULT CHARSET=utf8; CREATE USER '<AMBARIUSER>'@'%' IDENTIFIED BY '<AMBARIPASSWORD>'; GRANT ALL PRIVILEGES ON ambari.* TO '<AMBARIUSER>'@'%'; # 删除MySQL默认的匿名账户,此处省略。 FLUSH PRIVILEGES; 2. 连接测试 MySQL 且创建结构表 # mysql -u ambari -p SHOW DATABASES; SHOW GRANTS; # 导入结构表 SOURCE /var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql; 3.配置 mysql-jdbc 连接器 wget ****/mysql-connector-java-5.1.40.tar.gz tar xf mysql-connector-java-5.1.40.tar.gz cd mysql-connector-java-5.1.40 mkdir /usr/share/java cp mysql-connector-java-5.1.40-bin.jar /usr/share/java/ cd /usr/share/java ln -s mysql-connector-java-5.1.40-bin.jar mysql-connector-java.jar或者直接 yum 安装 mysql-connector-java 即可。
1. 配置ambari repo本地源 #VERSION_NUMBER=2.4.2.0-136 [Updates-ambari-2.4.2.0] name=ambari-2.4.2.0 - Updates baseurl=http://172.17.20.21/ambari/ gpgcheck=1 gpgkey=http://172.17.20.21/ambari/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 2. 配置HDP本地源 [HDP-2.5.3.0] name=HDP Version - HDP-2.5.3.0 baseurl=http://172.17.20.21/HDP/CentOS6/ gpgcheck=1 gpgkey=http://172.17.20.21/HDP/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 [HDP-UTILS-2.5.3.0] name=HDP-UTILS Version - HDP-UTILS-2.5.3.0 baseurl=http://172.17.20.21/HDP-UTILS-1.1.0.21/repos/centos6/ gpgcheck=1 gpgkey=http://172.17.20.21/HDP-UTILS-1.1.0.21/repos/centos6/RPM-GPG-KEY/RPM-GPG-KEY-Jenkins enabled=1 priority=1 3.安装ambari-server yum install ambari-serveryum安装ambari-server 需要依赖安装 postgresql,ambari-server 是需要数据库支持的,默认为PostgreSQL,也可以选择 MySQL (这里因为依赖关系,先安装PostgreSQL,后续不用,改用安装MySQL即可)。
yum install ambari-agent在集群内所有的成员主机上手动安装 ambari-agent
4. 初始化ambari使用命令:
ambari-server setup Using python /usr/bin/python Setup ambari-server Checking SELinux... SELinux status is 'disabled' Customize user account for ambari-server daemon [y/n] (n)? # ambari-server以root身份运行 Adjusting ambari-server permissions and ownership... Checking firewall status... Checking JDK... [1] Oracle jdk 1.8 + java cryptography extension (jce) policy files 8 [2] oracle jdk 1.7 + java cryptography extension (jce) policy files 7 [3] custom jdk # 如果本地已经安装有jdk,那么选择这一项,否则ambari初始化的时候会通过yum源安装jdk ============================================================================== Enter choice (1): 3 WARNING: JDK must be installed on all hosts and JAVA_HOME must be valid on all hosts. WARNING: JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos,please makesure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts. Path to JAVA_HOME: /opt/java/jdk # 指定本地已经安装好的jdk路径,也就是环境变量 JAVA_HOME 的值。 Validating JDK on Ambari Server...done. Completing setup... Configuring database... Enter advanced database configuration [y/n] (n)? y # 是否需要自定义数据库配置 Configuring database... ============================================================================== Choose one of the following options: [1] - PostgreSQL (Embedded) # 默认使用PostgreSQL [2] - Oracle [3] - MySQL / MariaDB # 我们这里选择本地安装的MySQL [4] - PostgreSQL [5] - Microsoft SQL Server (Tech Preview) [6] - SQL Anywhere [7] - BDB ============================================================================== Enter choice (1): 3 Hostname (localhost): Port (3306): # 是否需要指定数据库端口,默认3306 Database name (ambari): # 是否需要指定ambari 的数据库,默认ambari库 Username (ambari): # 是否需要指定ambari-server的数据库用户,默认ambari Enter Database Password (bigdata): # 是否需要使用默认的数据库连接密码,默认为bigdata Re-enter password: Configuring ambari database... Copying JDBC drivers to server resources... Configuring remote database connection properties... WARNING: Before starting Ambari Server, you must run the following DDL against the database to create the schema:/var/lib/ambari-server/resources/Ambari-DDL-MySQL-CREATE.sql Proceed with configuring remote database connection properties [y/n] (y)? y # 初始化数据库连接数据 Extracting system views... ............. Adjusting ambari-server permissions and ownership... Ambari Server 'setup' completed successfully. # successfully 配置完成