# web server **Repository Path**: pythonista/web-server ## Basic Information - **Project Name**: web server - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-07-20 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README **语言依赖** ``` python3.6+ ``` **安装** ``` # 离线安装python、ansible、tox cdinstall/ && sh install.sh ``` **数据库** ``` # 执行以下pg sql指令,创建相关数据库与用户 CREATE USER ansible WITH PASSWORD 'ansible'; create database ansible owner ansible; grant all privileges on database ansible to ansible; # 导入databases文件夹中的sql文件,生成必要的数据库结构与数据 psql -h hostname -U ansible -d ansible < databases/public.sql ``` **启动** ``` # centos/redhat # 用户必须有sudo权限 # 启动 cd webserver2 sudo ./server -s start # 关闭 sudo ./server -s stop ``` **自带模板及完成度** |服务|服务名称|完成度| |--|--|--| |免密钥|nopasswd|完成| |初始化环境|setup-env|完成| |安装ZK|zokeeper|完成| |安装hadoop|hadoop|完成| |安装spark|spark|完成| |安装pg|postgres|完成| |安装hive|hive|完成| |安装alluxio|alluxio|完成| **操作指南** **`1. 获取服务列表`** ``` curl -X POST "http://localhost:8000/api/ansible_db/services/list" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"\"}" ``` **`2. 获取服务相应的分组`** ``` curl -X GET "http://localhost:8000/api/ansible_db/inventory/group/list/" -H "accept: application/json" ``` **`3. 为相应的服务group添加host`** ``` curl -X POST "http://localhost:8000/api/ansible_db/inventory/host/add" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"string\", \"service_id\": int, \"group_id\": int, \"vars\": \"string\"}" ``` **`4. 为相应的服务group修改host内容`** ``` curl -X PATCH "http://localhost:8000/api/ansible_db/inventory/host/set" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"id\": 0, \"name\": \"string\", \"service_id\": 0, \"group_id\": 0, \"vars\": \"string\"}" ``` **`5. 为相应的服务group删除host`** ``` curl -X DELETE "http://localhost:8000/api/ansible_db/inventory/host/remove/" -H "accept: application/json" ``` **`6. 为相应的服务group指定master`** ``` # 不需要设置master的分组可跳过 curl -X PATCH "http://localhost:8000/api/ansible_db/inventory/group/set" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"id\": 0, \"name\": \"string\", \"service_id\": 0, \"vars\": \"string\", \"master\": \"string\", \"master_need\": \"string\"}" ``` **`7. 生成服务的任务列表与jid`** ``` curl -X POST "http://localhost:8000/api/ansible_db/execute/deploy/info" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": int}" ``` **`8. 根据生成的jid执行相应的任务`** ``` curl -X POST "http://localhost:8000/api/ansible_db/execute/playbook/deploy" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 0, \"jid\": \"string\", \"check\": \"string\"}" ``` **`9. 查询相应jid的执行状态`** ``` curl -X GET "http://localhost:8000/api/ansible_db/task/status/list/string" -H "accept: application/json" ``` **`10. 根据jid执行状态(jid与tid)可选中断任务`** ``` curl -X POST "http://localhost:8000/api/ansible_db/task/interrupt" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"jid\": \"string\", \"tid\": \"string\"}" ``` **自定义模板指南** **`1. 结构推荐`** - playbooks对应于上文提到的服务; - playbooks目录必须按照如下格式组织,缺一不可; - roles名称推荐与服务名称相同; - roles目录没有强制约束,但是推荐统一使用如下结构,减少开发、维护复杂度。 ``` . ├── playbooks # 存放不同服务的顶层playbook等信息 │ ├── service # 服务名称 │ │ ├── service.md # 服务描述 │ │ ├── service.yml # 顶层playbook文件 │ │ ├── inventory # 存放主机信息 │ │ └── vars.yml # 存放变量信息 └── roles # 存放不同角色 └── service # 以服务名称命名的角色 ├── files # 文件存放 ├── tasks # 任务组织 └── templates # 配置文件等模板 ``` **`2. playbooks`** > 目前playbooks结构中service.yml以及vars.yml文件属于我们必填的文件。 `service.yml文件格式` > service.yml文件的格式固定,如下: ``` # service.yml --- - hosts: '{{ remote_host }}' # 固定参数,无须修改 roles: - roles_name # 对应角色名称 ``` `vars.yml` > 目前版本下,vars.yml不能为空,如果确实没有变量,自定义一个变量写入文件; vars.yml文件中的变量必须是固定值或者嵌套变量,因为通过接口可直接修改的参数存储于数据库。 **`3. roles`** > roles的编写最好按照推荐结构,但是不强制限定,也可以按照官方给出的完整roles结构编写。 唯一需要注意的是roles中所有涉及的变量,均来自于vars.yml。 **待处理** **`FXIME`**:vars.yml文件不能为空 **`FXIME`**:services表中inventory_vars字段中分组all自动更新显示为空列表 **`TODO`**:服务清理 **其他可用接口请查看swagger文档** ``` http://ip:port/swagger ``` **案例** > 1. 安装zookeeper;2. 安装hadoop;3. 安装alluxio; 4. 安装spark; 5. 安装hive **`1. 获取服务列表`** ``` curl -X POST "http://192.168.3.191:8000/api/ansible_db/services/list" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"\"}" ``` 结果如下: ``` # 内容包含各服务的id、名称、描述、变量 { "data": [ { "id": 1, "name": "hadoop", "instruction": "Hadoop", "createdate": 1545906809, "updatedate": 1551276627, "vars": "{\"dfs_namenode_httpport\":9001,\"dfs_namenode_nameservices\":\"nameservice\",\"group\":\"hadoop\",\"hadoop_conf_copy\":\"/etc/hadoop/conf\",\"hadoop_dfs\":\"/opt/alluxio/hadoop/dfs\",\"hadoop_path\":\"/opt/alluxio/hadoop\",\"hadoop_tmp\":\"/opt/alluxio/hadoop/tmp\",\"hadoop_version\":\"2.9.0\",\"hdfs_host\":\"192.168.3.191\",\"hdfs_port\":9000,\"user\":\"hadoop\",\"yarn_resourcemanager_admin_port\":8141,\"yarn_resourcemanager_port\":8040,\"yarn_resourcemanager_scheduler_port\":8030,\"yarn_resourcemanager_tracker_port\":8025,\"yarn_resourcemanager_webapp_port\":8088,\"io_file_buffer_size\":131072,\"fs_trash_interval\":10080,\"io_bytes_per_checksum\":4096,\"dfs_replication\":3,\"dfs_ha_fencing_ssh_connect_timeout\":30000,\"ha_failover_controller_cli_check_rpc_timeout_ms\":60000,\"ha_failover_controller_active_standby_elector_zk_op_retries\":120,\"hadoop_http_authentication_simple_anonymous_allowed\":\"true\",\"hadoop_security_authentication\":\"simple\",\"hadoop_security_authorization\":\"false\",\"ipc_client_connect_max_retries\":50,\"ipc_client_connection_maxidletime\":30000,\"ipc_client_idlethreshold\":8000,\"ipc_server_tcpnodelay\":\"true\",\"mapreduce_jobtracker_webinterface_trusted\":\"false\",\"dfs_block_access_token_enable\":\"true\",\"dfs_blockreport_initialDelay\":120,\"dfs_blocksize\":134217728,\"dfs_client_read_shortcircuit_streams_cache_size\":4096,\"dfs_client_retry_policy_enabled\":\"false\",\"dfs_cluster_administrators\":\"hadoop\",\"dfs_content_summary_limit\":5000,\"dfs_datanode_address\":\"0.0.0.0:50010\",\"dfs_datanode_balance_bandwidthPerSec\":\"6250000\",\"dfs_datanode_http_address\":\"0.0.0.0:50075\",\"dfs_datanode_https_address\":\"0.0.0.0:50475\",\"dfs_datanode_ipc_address\":\"0.0.0.0:8010\",\"dfs_domain_socket_path\":\"/var/lib/hadoop-hdfs/dn_socket\",\"dfs_encrypt_data_transfer_cipher_suites\":\"AES/CTR/NoPadding\",\"dfs_heartbeat_interval\":3,\"dfs_hosts_exclude\":\"/etc/hadoop/conf/dfs.exclude\",\"dfs_http_policy\":\"HTTP_ONLY\",\"dfs_https_port\":\"50470\",\"dfs_journalnode_http_address\":\"0.0.0.0:8480\",\"dfs_journalnode_https_address\":\"0.0.0.0:8481\",\"dfs_namenode_audit_log_async\":\"true\",\"dfs_namenode_avoid_read_stale_datanode\":\"true\",\"dfs_namenode_avoid_write_stale_datanode\":\"true\",\"dfs_namenode_checkpoint_edits_dir\":\"${dfs.namenode.checkpoint.dir}\",\"dfs_namenode_checkpoint_txns\":1000000,\"dfs_namenode_fslock_fair\":\"false\",\"dfs_namenode_name_dir_restore\":\"true\",\"dfs_namenode_stale_datanode_interval\":30000,\"dfs_namenode_startup_delay_block_deletion_sec\":3600,\"dfs_namenode_write_stale_datanode_ratio\":\"1.0f\",\"dfs_permissions_enabled\":\"true\",\"dfs_permissions_superusergroup\":\"hadoop\",\"dfs_replication_max\":50,\"dfs_support_append\":\"true\",\"fs_permissions_umask_mode\":\"022\",\"hadoop_caller_context_enabled\":\"true\",\"manage_include_files\":\"false\",\"hadoop_registry_rm_enabled\":\"true\",\"yarn_client_failover_proxy_provider\":\"org.apache.hadoop.yarn.client.RequestHedgingRMFailoverProxyProvider\",\"yarn_client_nodemanager_connect_max_wait_ms\":60000,\"yarn_client_nodemanager_connect_retry_interval_ms\":\"10000\",\"yarn_http_policy\":\"HTTP_ONLY\",\"yarn_log_aggregation_retain_seconds\":2592000,\"yarn_node_labels_fs_store_retry_policy_spec\":\"2000,500\",\"yarn_node_labels_fs_store_root_dir\":\"/system/yarn/node-labels\",\"yarn_nodemanager_address\":\"0.0.0.0:45454\",\"yarn_nodemanager_admin_env\":\"MALLOC_ARENA_MAX=$MALLOC_ARENA_MAX\",\"yarn_nodemanager_aux_services_mapreduce_shuffle_class\":\"org.apache.hadoop.mapred.ShuffleHandler\",\"yarn_nodemanager_aux_services_spark2_shuffle_class\":\"org.apache.spark.network.yarn.YarnShuffleService\",\"yarn_nodemanager_aux_services_spark_shuffle_class\":\"org.apache.spark.network.yarn.YarnShuffleService\",\"yarn_nodemanager_bind_host\":\"0.0.0.0\",\"yarn_nodemanager_container_metrics_unregister_delay_ms\":60000,\"yarn_nodemanager_container_monitor_interval_ms\":3000,\"yarn_nodemanager_delete_debug_delay_sec\":0,\"yarn_nodemanager_disk_health_checker_max_disk_utilization_per_disk_percentage\":90,\"yarn_nodemanager_disk_health_checker_min_free_space_per_disk_mb\":1000,\"yarn_nodemanager_disk_health_checker_min_healthy_disks\":0.25,\"yarn_nodemanager_health_checker_interval_ms\":135000,\"yarn_nodemanager_health_checker_script_timeout_ms\":60000,\"yarn_nodemanager_kill_escape_launch_command_line\":\"slider-agent,LLAP\",\"yarn_nodemanager_kill_escape_user\":\"hadoop\",\"yarn_nodemanager_log_aggregation_compression_type\":\"gz\",\"yarn_nodemanager_log_aggregation_debug_enabled\":\"false\",\"yarn_nodemanager_log_aggregation_num_log_files_per_app\":\"336\",\"yarn_nodemanager_log_aggregation_roll_monitoring_interval_seconds\":3600,\"yarn_nodemanager_log_retain_seconds\":604800,\"yarn_nodemanager_vmem_check_enabled\":\"false\",\"yarn_resourcemanager_am_max_attempts\":2,\"yarn_resourcemanager_bind_host\":\"0.0.0.0\",\"yarn_resourcemanager_fs_state_store_retry_policy_spec\":\"2000,500\",\"yarn_resourcemanager_monitor_capacity_preemption_natural_termination_factor\":1,\"yarn_resourcemanager_monitor_capacity_preemption_total_preemption_per_round\":0.2,\"yarn_resourcemanager_nodes_exclude_path\":\"/etc/hadoop/conf/yarn.exclude\",\"yarn_resourcemanager_state_store_max_completed_applications\":\"${yarn.resourcemanager.max-completed-applications}\",\"yarn_resourcemanager_store_class\":\"org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore\",\"yarn_resourcemanager_system_metrics_publisher_dispatcher_pool_size\":10,\"yarn_resourcemanager_system_metrics_publisher_enabled\":\"true\",\"yarn_resourcemanager_webapp_delegation_token_auth_filter_enabled\":\"false\",\"yarn_resourcemanager_work_preserving_recovery_scheduling_wait_ms\":10000,\"yarn_resourcemanager_zk_acl\":\"world:anyone:rwcda\",\"yarn_resourcemanager_zk_num_retries\":1000,\"yarn_resourcemanager_zk_retry_interval_ms\":1000,\"yarn_resourcemanager_zk_state_store_parent_path\":\"/rmstore\",\"yarn_resourcemanager_zk_timeout_ms\":10000,\"yarn_scheduler_capacity_ordering_policy_priority_utilization_underutilized_preemption_enabled\":\"false\",\"yarn_timeline_service_bind_host\":\"false\",\"yarn_timeline_service_client_fd_flush_interval_secs\":5,\"yarn_timeline_service_client_max_retries\":30,\"yarn_timeline_service_client_retry_interval_ms\":1000,\"yarn_timeline_service_entity_group_fs_store_active_dir\":\"/ats/active/\",\"yarn_timeline_service_entity_group_fs_store_app_cache_size\":10,\"yarn_timeline_service_entity_group_fs_store_cleaner_interval_seconds\":3600,\"yarn_timeline_service_entity_group_fs_store_done_dir\":\"/ats/done/\",\"yarn_timeline-service_entity_group-fs_store_group_id_plugin_classes\":\"org.apache.tez.dag.history.logging.ats.TimelineCachePluginImpl,org.apache.spark.deploy.history.yarn.plugin.SparkATSPlugin\",\"yarn_timeline_service_entity_group_fs_store_retain_seconds\":604800,\"yarn_timeline_service_entity_group_fs_store_scan_interval_seconds\":15,\"yarn_timeline_service_entity_group_fs_store_summary_store\":\"org.apache.hadoop.yarn.server.timeline.RollingLevelDBTimelineStore\",\"yarn_timeline_service_http_authentication_simple_anonymous_allowed\":\"true\",\"yarn_timeline_service_http_authentication_type\":\"simple\",\"yarn_timeline_service_leveldb_timeline_store_read_cache_size\":104857600,\"yarn_timeline_service_leveldb_timeline_store_start_time_read_cache_size\":10000,\"yarn_timeline_service_leveldb_timeline_store_start_time_write_cache_size\":10000,\"yarn_timeline_service_recovery_enabled\":\"true\",\"yarn_timeline_service_version\":1.5, \"java_home\": \"/opt/jdk1.8.0_131\", \"fs_alluxio_impl\": \"alluxio.hadoop.FileSystem\", \"alluxio_zookeeper_enabled\": \"true\", \"alluxio_zookeeper_address\": \"192.168.3.191:2181,192.168.3.192:2181,192.168.3.193:2181\" }", "inventory_vars": "{\"group\": {\"all\": [], \"hadoop\": [\"192.168.3.191\", \"192.168.3.193\", \"192.168.3.192\"], \"namenode\": [\"192.168.3.191\", \"192.168.3.192\"], \"zookeeper\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"], \"journalnode\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"], \"jobhistory\": [\"192.168.3.191\"], \"resourcemanager\": [\"192.168.3.191\", \"192.168.3.192\"]}}" }, { "id": 2, "name": "zookeeper", "instruction": "Zookeeper", "createdate": 1550055207, "updatedate": 1551264574, "vars": "{\"zookeeper_path\": \"/opt\", \"version\": \"3.4.13\"}", "inventory_vars": "{\"group\": {\"all\": [], \"zookeeper\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"]}}" }, { "id": 3, "name": "spark", "instruction": "Spark", "createdate": 1550068087, "updatedate": 1551278870, "vars": "{\"user\": \"hadoop\",\"group\": \"hadoop\",\"spark_version\": \"2.4.0\",\"spark_path\": \"/opt/alluxio\",\"hdfs_host\": \"192.168.6.12\",\"hdfs_port\": \"9000\",\"scala_version\": \"2.12.0\",\"spark_master_port\": 17077,\"spark_history_ui_port\": 17777, \"spark_web_port\": 18080,\"spark_eventLog_compress\": \"true\",\"spark_history_updateInterval\": \"5\",\"fs_defaultFS\": \"hdfs://192.168.3.192:9000\",\r\n\"hadoop_tmp_dir\": \"file:///data/hadoop/tmp\",\"io_file_buffer_size\": 131072,\"ha_zookeeper_quorum\": \"192.168.3.191:2181,192.168.3.192:2181,192.168.3.193:2181\",\"fs_trash_interval\": 10080,\"io_bytes_per_checksum\": 4096,\"io_compression_codecs\": \"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\", \"alluxio_zookeeper_enabled\": \"true\", \"alluxio_zookeeper_address\": \"192.168.3.191:2181,192.168.3.192:2181,192.168.3.193:2181\"}", "inventory_vars": "{\"group\": {\"spark\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"], \"all\": []}}" }, { "id": 4, "name": "hive", "instruction": "Hive", "createdate": 1550072312, "updatedate": 1551279112, "vars": "{\"user\": \"hadoop\",\"group\": \"hadoop\",\"hive_version\": \"1.2.2\",\"hive_path\": \"/opt/alluxio\",\"db_type\": \"postgres\",\"hive_connection_driver_name\": \"org.postgresql.Driver\",\"hive_connection_host\": \"192.168.3.193\",\"hive_connection_port\": \"5432\",\"hive_connection_dbname\": \"hive\",\"hive_connection_user_name\": \"hive\",\"hive_connection_password\": \"hive\",\"hdfs_host\": \"192.168.6.12\",\"hdfs_port\": \"9000\",\"hive_metastore_schema_verification\": \"false\",\"hive_server_port\": 10000,\"hive_hwi_port\": 9999,\"hive_metastore_port\": 9083, \"fs_alluxio_impl\": \"alluxio.hadoop.FileSystem\",\"alluxio_zookeeper_enabled\": \"true\", \"alluxio_zookeeper_address\": \"192.168.3.191:2181,192.168.3.192:2181,192.168.3.193:2181\"}", "inventory_vars": "{\"group\": {\"all\": [], \"hive\": [\"192.168.3.191\"]}}" }, { "id": 5, "name": "alluxio", "instruction": "Alluxio", "createdate": 1550074401, "updatedate": 1551276944, "vars": "{\"masters\": [\"192.168.3.191\"],\"workers\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"]}", "inventory_vars": "{\"group\": {\"all\": [], \"masters\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"], \"nn\": [\"192.168.3.191\"], \"zookeeper\": [\"192.168.3.191\", \"192.168.3.192\", \"192.168.3.193\"], \"workers\": [\"192.168.3.191\", \"192.168.3.192\"]}}" }, { "id": 6, "name": "jdk", "instruction": "JDK", "createdate": 1550483006, "updatedate": 1550485193, "vars": "{}", "inventory_vars": "{\"group\": {\"all\": [], \"jdk\": [\"114.115.217.222\"]}}" }, { "id": 7, "name": "postgres", "instruction": "Postgres", "createdate": 1550500323, "updatedate": 1550592974, "vars": "{\"pg_create_path\": \"/opt/pg_req/\", \"pg_data_path\": \"/opt/pg_data/\"}", "inventory_vars": "{\"group\": {\"all\": [], \"postgres\": [\"114.115.217.222\"]}}" }, { "id": 8, "name": "nopasswd", "instruction": "Nopasswd", "createdate": 1550570760, "updatedate": 1550759260, "vars": "{}", "inventory_vars": "{\"group\": {\"all\": [], \"nopasswd\": [\"114.115.217.222\"]}}" }, { "id": 9, "name": "setup-env", "instruction": "SetupEnv", "createdate": 1551259399, "updatedate": 1551365368, "vars": "{}", "inventory_vars": "{\"group\": {\"env\": [\"132.232.166.134\"], \"all\": []}}" } ], "detail": "success" } ``` **`2. 安装zookeeper`** `2.1 获取zk服务对应的分组信息` ``` curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/list/2" -H "accept: application/json" ``` 结果如下: ``` # all分组为 每个分组必备,无须修改 { "data": [ { "id": 9, "name": "all", "vars": null, "createdate": 1550055484, "updatedate": 1550055487, "services_id": 2, "master": null, "master_need": "false" }, { "id": 10, "name": "zookeeper", "vars": null, "createdate": 1550055507, "updatedate": 1550055510, "services_id": 2, "master": null, "master_need": "false" } ], "detail": "success" } ``` `2.2 相应分组添加主机` ``` # 其他主机同样的方式添加,我们以3.191-193为例 curl -X POST "http://192.168.3.191:8000/api/ansible_db/inventory/host/add" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"name\": \"192.168.3.191\", \"service_id\": 2, \"group_id\": 10, \"vars\": \"\"}" ``` 不需要的主机可以删除: ``` curl -X DELETE "http://192.168.3.191:8000/api/ansible_db/inventory/host/remove/39" -H "accept: application/json" ``` 最终我们给zookeeper分组添加的主机如下: ``` # 注意:相对应的主机系统信息为程序自动刷新 { "data": { "id": 10, "name": "zookeeper", "vars": null, "createdate": 1550055507, "updatedate": 1550055510, "services_id": 2, "master": null, "master_need": "false", "hosts": [ { "id": 19, "group_id": 10, "name": "192.168.3.191", "vars": null, "createdate": 1550055636, "updatedate": 1551712795, "services_id": 2, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1761, \"free\": 5866}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1023, \"free\": 6604}}", "ansible_mounts": "[{\"block_used\": 10774196, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 753485, \"size_available\": 3086274560, \"fstype\": \"xfs\", \"inode_total\": 12654864, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585178, \"block_size\": 4096, \"inode_available\": 12069686}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 21, "group_id": 10, "name": "192.168.3.193", "vars": null, "createdate": 1550055682, "updatedate": 1551712796, "services_id": 2, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.193\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-03", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 473, \"free\": 7154}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 257, \"free\": 7370}}", "ansible_mounts": "[{\"block_used\": 7700915, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3826766, \"size_available\": 15674433536, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 213493, \"block_size\": 4096, \"inode_available\": 45919755}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 20, "group_id": 10, "name": "192.168.3.192", "vars": null, "createdate": 1550055666, "updatedate": 1551712796, "services_id": 2, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1012, \"free\": 6615}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 766, \"free\": 6861}}", "ansible_mounts": "[{\"block_used\": 7950993, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3576688, \"size_available\": 14650114048, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 252203, \"block_size\": 4096, \"inode_available\": 45881045}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } ``` `2.3 为相应分组指定master` > 当前分组无需指定master `2.4. 生成任务列表与jid` ``` curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/deploy/info" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 2}" ``` 结果如下: ``` { "data": { "jid": "0f92ef00-3e4f-11e9-8353-001a4a16015c" }, "detail": "success" } ``` 可根据接口查询job状态 ``` curl -X GET "http://192.168.3.191:8000/api/ansible_db/execute/status/f5f441e2-3e4f-11e9-8353-001a4a16015c" -H "accept: application/json" ``` 结果如下: ``` # 按照顺序生成job执行过程记录,undo表示服务未开始 { "data": [ { "id": 4184, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : unarchive zookeeper", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4185, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : unarchive zookeeper", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4186, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : unarchive zookeeper", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4187, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : add zookeeper env to profile", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4188, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : add zookeeper env to profile", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4189, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : add zookeeper env to profile", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4190, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : config zookeeper", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4191, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : config zookeeper", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4192, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : config zookeeper", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4193, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : mkdir zookeeper directory", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4194, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : mkdir zookeeper directory", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4195, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : mkdir zookeeper directory", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4196, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : create myid on node1", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4197, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : create myid on node1", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4198, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : create myid on node1", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4199, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : create myid on node2", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4200, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : create myid on node2", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4201, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : create myid on node2", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4202, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : create myid on node3", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4203, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : create myid on node3", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4204, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : create myid on node3", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4205, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "zookeeper : start zookeeper server", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4206, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "zookeeper : start zookeeper server", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 }, { "id": 4207, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "zookeeper : start zookeeper server", "status": "undo", "msg": null, "created": 1551713676, "updated": 1551713676, "is_check": "false", "tag": "common", "service_id": 2 } ], "detail": "success" } ``` `2.5. 根据jid执行任务部署` ``` # 执行部署 # check: false为跳过ansible检查 curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/playbook/deploy" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 2, \"jid\": \"f5f441e2-3e4f-11e9-8353-001a4a16015c\", \"check\": \"false\"}" ``` 可以根据jid查看服务的完成状态 ``` curl -X GET "http://192.168.3.191:8000/api/ansible_db/task/status/list/f5f441e2-3e4f-11e9-8353-001a4a16015c" -H "accept: application/json" ``` 结果如下: ``` # status值为completed为正常完成,running为正在运行,interrupt为异常中断。 { "data": [ { "id": 250, "jid": "f5f441e2-3e4f-11e9-8353-001a4a16015c", "thread_id": "139904488515328", "status": "completed", "is_check": "False", "createdate": 1551714122, "updatedate": 1551714122 } ], "detail": "success" } ``` **`3. 安装hadoop`** `3.1 获取hadoop相应分组` ``` curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/list/1" -H "accept: application/json" ``` 结果如下: ``` { "data": [ { "id": 1, "name": "all", "vars": "", "createdate": 1545915941, "updatedate": 1545922048, "services_id": 1, "master": null, "master_need": "false" }, { "id": 2, "name": "hadoop", "vars": null, "createdate": 1546854141, "updatedate": 1546854146, "services_id": 1, "master": null, "master_need": "false" }, { "id": 3, "name": "namenode", "vars": null, "createdate": 1546883907, "updatedate": 1546883910, "services_id": 1, "master": "192.168.3.191", "master_need": "true" }, { "id": 4, "name": "zookeeper", "vars": null, "createdate": 1547025964, "updatedate": 1547025961, "services_id": 1, "master": null, "master_need": "false" }, { "id": 6, "name": "journalnode", "vars": "", "createdate": 1547047394, "updatedate": 1547047394, "services_id": 1, "master": null, "master_need": "false" }, { "id": 7, "name": "jobhistory", "vars": "", "createdate": 1547048952, "updatedate": 1547048952, "services_id": 1, "master": null, "master_need": "false" }, { "id": 8, "name": "resourcemanager", "vars": null, "createdate": 1547222943, "updatedate": 1547222945, "services_id": 1, "master": null, "master_need": "false" } ], "detail": "success" } ``` `3.2 为分组添加主机` 为除all分组外其他分组添加主机(方法见zk安装示例) 最终我们得到的分组信息如下: ``` # hadoop分组我们添加191-193 三台主机 # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/info/2" -H "accept: application/json" { "data": { "id": 2, "name": "hadoop", "vars": null, "createdate": 1546854141, "updatedate": 1546854146, "services_id": 1, "master": null, "master_need": "false", "hosts": [ { "id": 9, "group_id": 2, "name": "192.168.3.192", "vars": "", "createdate": 1547047322, "updatedate": 1551715255, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1188, \"free\": 6439}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 833, \"free\": 6794}}", "ansible_mounts": "[{\"block_used\": 7952245, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3575436, \"size_available\": 14644985856, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 252206, \"block_size\": 4096, \"inode_available\": 45881042}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 7, "group_id": 2, "name": "192.168.3.193", "vars": "", "createdate": 1547040081, "updatedate": 1551715255, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.193\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-03", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 630, \"free\": 6997}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 323, \"free\": 7304}}", "ansible_mounts": "[{\"block_used\": 7701533, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3826148, \"size_available\": 15671902208, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 213498, \"block_size\": 4096, \"inode_available\": 45919750}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 4, "group_id": 2, "name": "192.168.3.191", "vars": "", "createdate": 1547039297, "updatedate": 1551715255, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1963, \"free\": 5664}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1097, \"free\": 6530}}", "ansible_mounts": "[{\"block_used\": 10777600, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 750081, \"size_available\": 3072331776, \"fstype\": \"xfs\", \"inode_total\": 12600400, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585180, \"block_size\": 4096, \"inode_available\": 12015220}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } # namenode我们添加191与191两台主机 # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/info/3" -H "accept: application/json" { "data": { "id": 3, "name": "namenode", "vars": null, "createdate": 1546883907, "updatedate": 1546883910, "services_id": 1, "master": "192.168.3.191", "master_need": "true", "hosts": [ { "id": 5, "group_id": 3, "name": "192.168.3.191", "vars": "", "createdate": 1547039640, "updatedate": 1551715375, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1963, \"free\": 5664}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1097, \"free\": 6530}}", "ansible_mounts": "[{\"block_used\": 10777633, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 750048, \"size_available\": 3072196608, \"fstype\": \"xfs\", \"inode_total\": 12599872, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585181, \"block_size\": 4096, \"inode_available\": 12014691}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 6, "group_id": 3, "name": "192.168.3.192", "vars": "", "createdate": 1547039908, "updatedate": 1551715374, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1188, \"free\": 6439}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 832, \"free\": 6795}}", "ansible_mounts": "[{\"block_used\": 7952241, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3575440, \"size_available\": 14645002240, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 252206, \"block_size\": 4096, \"inode_available\": 45881042}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } # hadoop服务中的zookeeper分组我们指定191-193三台主机 # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/info/4" -H "accept: application/json" { "data": { "id": 4, "name": "zookeeper", "vars": null, "createdate": 1547025964, "updatedate": 1547025961, "services_id": 1, "master": null, "master_need": "false", "hosts": [ { "id": 11, "group_id": 4, "name": "192.168.3.192", "vars": "", "createdate": 1547047350, "updatedate": 1551715494, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1189, \"free\": 6438}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 833, \"free\": 6794}}", "ansible_mounts": "[{\"block_used\": 7952240, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3575441, \"size_available\": 14645006336, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 252206, \"block_size\": 4096, \"inode_available\": 45881042}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 10, "group_id": 4, "name": "192.168.3.191", "vars": "", "createdate": 1547047345, "updatedate": 1551715495, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1895, \"free\": 5732}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1028, \"free\": 6599}}", "ansible_mounts": "[{\"block_used\": 10777665, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 750016, \"size_available\": 3072065536, \"fstype\": \"xfs\", \"inode_total\": 12599360, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585183, \"block_size\": 4096, \"inode_available\": 12014177}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 12, "group_id": 4, "name": "192.168.3.193", "vars": "", "createdate": 1547047354, "updatedate": 1551715494, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.193\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-03", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 629, \"free\": 6998}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 322, \"free\": 7305}}", "ansible_mounts": "[{\"block_used\": 7701566, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3826115, \"size_available\": 15671767040, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 213498, \"block_size\": 4096, \"inode_available\": 45919750}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } # 我们为分组journalnode添加191-193三台主机 # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/info/6" -H "accept: application/json" { "data": { "id": 6, "name": "journalnode", "vars": "", "createdate": 1547047394, "updatedate": 1547047394, "services_id": 1, "master": null, "master_need": "false", "hosts": [ { "id": 14, "group_id": 6, "name": "192.168.3.192", "vars": "", "createdate": 1547047416, "updatedate": 1551715736, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1200, \"free\": 6427}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 844, \"free\": 6783}}", "ansible_mounts": "[{\"block_used\": 7952393, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3575288, \"size_available\": 14644379648, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 252212, \"block_size\": 4096, \"inode_available\": 45881036}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 15, "group_id": 6, "name": "192.168.3.193", "vars": "", "createdate": 1547047422, "updatedate": 1551715736, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.193\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-03", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 640, \"free\": 6987}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 332, \"free\": 7295}}", "ansible_mounts": "[{\"block_used\": 7701667, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3826014, \"size_available\": 15671353344, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 213504, \"block_size\": 4096, \"inode_available\": 45919744}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 13, "group_id": 6, "name": "192.168.3.191", "vars": "", "createdate": 1547047410, "updatedate": 1551715736, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1980, \"free\": 5647}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1112, \"free\": 6515}}", "ansible_mounts": "[{\"block_used\": 10777841, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 749840, \"size_available\": 3071344640, \"fstype\": \"xfs\", \"inode_total\": 12596544, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585186, \"block_size\": 4096, \"inode_available\": 12011358}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } # 指定191为jobhistory # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/info/7" -H "accept: application/json" { "data": { "id": 7, "name": "jobhistory", "vars": "", "createdate": 1547048952, "updatedate": 1547048952, "services_id": 1, "master": null, "master_need": "false", "hosts": [ { "id": 16, "group_id": 7, "name": "192.168.3.191", "vars": "", "createdate": 1547048992, "updatedate": 1551715856, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1972, \"free\": 5655}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1104, \"free\": 6523}}", "ansible_mounts": "[{\"block_used\": 10777791, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 749890, \"size_available\": 3071549440, \"fstype\": \"xfs\", \"inode_total\": 12597344, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585187, \"block_size\": 4096, \"inode_available\": 12012157}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } # 指定192-193为resourcemanager # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/info/8" -H "accept: application/json" { "data": { "id": 8, "name": "resourcemanager", "vars": null, "createdate": 1547222943, "updatedate": 1547222945, "services_id": 1, "master": null, "master_need": "false", "hosts": [ { "id": 18, "group_id": 8, "name": "192.168.3.192", "vars": null, "createdate": 1547223006, "updatedate": 1551715916, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 1191, \"free\": 6436}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 835, \"free\": 6792}}", "ansible_mounts": "[{\"block_used\": 7952399, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3575282, \"size_available\": 14644355072, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 252212, \"block_size\": 4096, \"inode_available\": 45881036}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 17, "group_id": 8, "name": "192.168.3.191", "vars": null, "createdate": 1547222979, "updatedate": 1551715915, "services_id": 1, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 2027, \"free\": 5600}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1159, \"free\": 6468}}", "ansible_mounts": "[{\"block_used\": 10777809, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 749872, \"size_available\": 3071475712, \"fstype\": \"xfs\", \"inode_total\": 12597056, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 585189, \"block_size\": 4096, \"inode_available\": 12011867}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } ``` `3.3 为需要的分组指定master` hadoop服务中namenode可以指定master主机 ``` curl -X PATCH "http://192.168.3.191:8000/api/ansible_db/inventory/group/set" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"id\": 3, \"name\": \"namenode\", \"service_id\": 1, \"vars\": \"\", \"master\": \"192.168.3.191\", \"master_need\": \"true\"}" ``` `3.4 生成任务列表与jid` ``` # curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/deploy/info" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 1}" { "data": { "jid": "ede9db68-3e56-11e9-8353-001a4a16015c" }, "detail": "success" } ``` `3.5 工具jid执行部署任务` ``` curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/playbook/deploy" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 1, \"jid\": \"ede9db68-3e56-11e9-8353-001a4a16015c\", \"check\": \"false\"}" ``` 执行过程我们同样可以查看服务部署进度: ``` # status为undo即未执行,success为执行完毕,faild为失败,msg可以反映状态信息信息。 { "data": [ { "id": 4210, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Create basic Path", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717285, "is_check": "false", "tag": "common", "service_id": 1 }, { "id": 4209, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Create basic Path", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717285, "is_check": "false", "tag": "common", "service_id": 1 }, { "id": 4212, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717325, "is_check": "false", "tag": "beforeInstall", "service_id": 1 }, { "id": 4211, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717329, "is_check": "false", "tag": "beforeInstall", "service_id": 1 }, { "id": 4214, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Unzip Hadoop", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717346, "is_check": "false", "tag": "install", "service_id": 1 }, { "id": 4216, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Unzip Hadoop", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717349, "is_check": "false", "tag": "install", "service_id": 1 }, { "id": 4215, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Unzip Hadoop", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717350, "is_check": "false", "tag": "install", "service_id": 1 }, { "id": 4218, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop Env Script", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717367, "is_check": "false", "tag": "env_copy", "service_id": 1 }, { "id": 4222, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Set Hadoop Env", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717394, "is_check": "false", "tag": "env_set", "service_id": 1 }, { "id": 4223, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop core-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717396, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4225, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop core-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717397, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4224, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop core-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717398, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4226, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop hdfs-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717402, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4228, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop hdfs-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717403, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4227, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop hdfs-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717406, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4231, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop mapred-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717407, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4229, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop mapred-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717407, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4230, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop mapred-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717408, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4232, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop yarn-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717409, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4234, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop yarn-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717410, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4233, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop yarn-site.xml", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717410, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4235, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop workers", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717411, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4236, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Copy Hadoop workers", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717412, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4237, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop workers", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717412, "is_check": "false", "tag": "config", "service_id": 1 }, { "id": 4240, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : start journalnode", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717419, "is_check": "false", "tag": "journalnode_start", "service_id": 1 }, { "id": 4239, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : start journalnode", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717419, "is_check": "false", "tag": "journalnode_start", "service_id": 1 }, { "id": 4238, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : start journalnode", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717419, "is_check": "false", "tag": "journalnode_start", "service_id": 1 }, { "id": 4241, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : hadoop namenode format", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717424, "is_check": "false", "tag": "namenode_format", "service_id": 1 }, { "id": 4243, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : start hdfs", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "hdfs_start", "service_id": 1 }, { "id": 4244, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : start yarn", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "yarn_start", "service_id": 1 }, { "id": 4245, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : start historyserver", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "historyserver_start", "service_id": 1 }, { "id": 4246, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : ln -s config file core-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4247, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : ln -s config file core-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4248, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : ln -s config file core-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4249, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : ln -s config file yarn-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4250, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : ln -s config file yarn-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4251, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : ln -s config file yarn-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4252, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : ln -s config file hdfs-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4253, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : ln -s config file hdfs-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4254, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : ln -s config file hdfs-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4255, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : ln -s config file mapred-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4256, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : ln -s config file mapred-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4257, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : ln -s config file mapred-site.xml", "status": "undo", "msg": null, "created": 1551716669, "updated": 1551716669, "is_check": "false", "tag": "config_ln", "service_id": 1 }, { "id": 4208, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Create basic Path", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717284, "is_check": "false", "tag": "common", "service_id": 1 }, { "id": 4213, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717331, "is_check": "false", "tag": "beforeInstall", "service_id": 1 }, { "id": 4217, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Copy Hadoop Env Script", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717368, "is_check": "false", "tag": "env_copy", "service_id": 1 }, { "id": 4219, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.193", "task": "hadoop : Copy Hadoop Env Script", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717369, "is_check": "false", "tag": "env_copy", "service_id": 1 }, { "id": 4220, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : Set Hadoop Env", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717376, "is_check": "false", "tag": "env_set", "service_id": 1 }, { "id": 4221, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.192", "task": "hadoop : Set Hadoop Env", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717380, "is_check": "false", "tag": "env_set", "service_id": 1 }, { "id": 4242, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "host": "192.168.3.191", "task": "hadoop : copy hadoop namenode data to another host", "status": "success", "msg": "success", "created": 1551716669, "updated": 1551717425, "is_check": "false", "tag": "namenode_copy", "service_id": 1 } ], "detail": "success" } ``` 同zk安装示例可获取hadoop服务最终执行结果: ``` # 从结果来看,hadoop服务正常部署完毕 # curl -X GET "http://192.168.3.191:8000/api/ansible_db/task/status/list/ede9db68-3e56-11e9-8353-001a4a16015c" -H "accept: application/json" { "data": [ { "id": 251, "jid": "ede9db68-3e56-11e9-8353-001a4a16015c", "thread_id": "139904488515328", "status": "completed", "is_check": "False", "createdate": 1551717278, "updatedate": 1551717278 } ], "detail": "success" } ``` **`4. 安装alluxio`** `4.1 获取alluxio服务对应分组` ``` # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/list/5" -H "accept: application/json" { "data": [ { "id": 11, "name": "spark", "vars": null, "createdate": 1550068628, "updatedate": 1550068632, "services_id": 3, "master": null, "master_need": "false" }, { "id": 12, "name": "all", "vars": null, "createdate": 1550069416, "updatedate": 1550069419, "services_id": 3, "master": null, "master_need": "false" } ], "detail": "success" } ``` `4.2 为相应分组添加主机` ``` # spark分组我们指定191-193三个节点,设置方法同上 ``` `4.3 生成jid与任务列表` ``` # curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/deploy/info" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 3}" { "data": { "jid": "5b7c3a7e-3e64-11e9-8353-001a4a16015c" }, "detail": "success" } ``` `4.4 执行部署任务` ``` # curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/playbook/deploy" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 3, \"jid\": \"5b7c3a7e-3e64-11e9-8353-001a4a16015c\", \"check\": \"false\"}" ``` **`5. 安装spark`** `5.1 获取spark服务对应分组` ``` # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/list/3" -H "accept: application/json" { "data": { "id": 16, "name": "masters", "vars": null, "createdate": 1550074787, "updatedate": 1550074792, "services_id": 5, "master": "192.168.3.191", "master_need": "true", "hosts": [ { "id": 31, "group_id": 16, "name": "192.168.3.192", "vars": null, "createdate": 1550164301, "updatedate": 1551719995, "services_id": 5, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.192\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-02", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 3094, \"free\": 4533}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 1509, \"free\": 6118}}", "ansible_mounts": "[{\"block_used\": 8260648, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3267033, \"size_available\": 13381767168, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 278106, \"block_size\": 4096, \"inode_available\": 45855142}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 24, "group_id": 16, "name": "192.168.3.191", "vars": null, "createdate": 1550074923, "updatedate": 1551719995, "services_id": 5, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.191\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-01", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 5905, \"free\": 1722}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 2531, \"free\": 5096}}", "ansible_mounts": "[{\"block_used\": 11140729, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 386952, \"size_available\": 1584955392, \"fstype\": \"xfs\", \"inode_total\": 6802496, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 611094, \"block_size\": 4096, \"inode_available\": 6191402}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" }, { "id": 32, "group_id": 16, "name": "192.168.3.193", "vars": null, "createdate": 1550164366, "updatedate": 1551719995, "services_id": 5, "ansible_os_family": "RedHat", "ansible_all_ipv4_addresses": "[\"192.168.3.193\"]", "ansible_distribution": "OracleLinux", "ansible_distribution_version": "7.3", "ansible_machine": "x86_64", "ansible_hostname": "airflow-03", "ansible_kernel": "4.1.12-61.1.18.el7uek.x86_64", "ansible_memory_mb": "{\"real\": {\"total\": 7627, \"used\": 2524, \"free\": 5103}, \"swap\": {\"cached\": 0, \"total\": 0, \"free\": 0, \"used\": 0}, \"nocache\": {\"used\": 994, \"free\": 6633}}", "ansible_mounts": "[{\"block_used\": 8012324, \"uuid\": \"e82c84ca-83c4-4ee0-bf2b-2e62c93ccd4f\", \"size_total\": 47217381376, \"block_total\": 11527681, \"mount\": \"/\", \"block_available\": 3515357, \"size_available\": 14398902272, \"fstype\": \"xfs\", \"inode_total\": 46133248, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/mapper/ol-root\", \"inode_used\": 239387, \"block_size\": 4096, \"inode_available\": 45893861}, {\"block_used\": 44342, \"uuid\": \"a01a1e0e-d124-4146-b39f-1f3e35034e0c\", \"size_total\": 1063256064, \"block_total\": 259584, \"mount\": \"/boot\", \"block_available\": 215242, \"size_available\": 881631232, \"fstype\": \"xfs\", \"inode_total\": 1048576, \"options\": \"rw,relatime,attr2,inode64,noquota\", \"device\": \"/dev/sda1\", \"inode_used\": 334, \"block_size\": 4096, \"inode_available\": 1048242}]", "ansible_processor": "[\"0\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\", \"1\", \"GenuineIntel\", \"Intel Celeron_4x0 (Conroe/Merom Class Core 2)\"]", "ansible_processor_vcpus": "2", "is_online": "online", "default_user": "root" } ] }, "detail": "success" } ``` `5.2 为相应分组添加主机` ``` # 我们为masters指定为191节点,191为nn分组节点,191-193均为workers分组,zookeeper分组指定191-193节点,设置方法同上 ``` `5.3 生成jid与任务列表` ``` # curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/deploy/info" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 5}" { "data": { "jid": "e2528bc6-3e5e-11e9-8353-001a4a16015c" }, "detail": "success" } ``` `5.4 执行部署任务` ``` curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/playbook/deploy" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 5, \"jid\": \"e2528bc6-3e5e-11e9-8353-001a4a16015c\", \"check\": \"false\"}" ``` **`6. 安装hive`** `6.1 获取spark服务对应分组` ``` # curl -X GET "http://192.168.3.191:8000/api/ansible_db/inventory/group/list/4" -H "accept: application/json" { "data": [ { "id": 13, "name": "all", "vars": null, "createdate": 1550072366, "updatedate": 1550072368, "services_id": 4, "master": null, "master_need": "false" }, { "id": 14, "name": "hive", "vars": null, "createdate": 1550072385, "updatedate": 1550072388, "services_id": 4, "master": null, "master_need": "false" } ], "detail": "success" } ``` `6.2 为相应分组添加主机` ``` # 我们为hive分组指定191节点,设置方法同上 ``` `6.3 生成jid与任务列表` ``` # curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/deploy/info" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 4}" { "data": { "jid": "ed228620-3e66-11e9-8353-001a4a16015c" }, "detail": "success" } ``` `6.4 执行部署任务` ``` curl -X POST "http://192.168.3.191:8000/api/ansible_db/execute/playbook/deploy" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"service_id\": 4, \"jid\": \"ed228620-3e66-11e9-8353-001a4a16015c\", \"check\": \"false\"}" ``` > 我们查看三个节点的jps ``` # 192.168.3.191 21297 QuorumPeerMain 29665 NameNode 30674 JobHistoryServer 30356 NodeManager 29781 DataNode 15413 Master 15511 Worker 28809 JournalNode 27035 AlluxioProxy 22926 Jps 25630 AlluxioMaster # 192.168.3.192 1024 Worker 6529 QuorumPeerMain 8051 Jps 15411 NodeManager 11827 AlluxioProxy 14810 JournalNode 15261 DataNode # 192.168.3.193 2992 DataNode 9760 AlluxioProxy 2707 JournalNode 27700 Jps 23253 Worker 3111 NodeManager 9327 QuorumPeerMain ```