diff --git a/dsms_deploy/config/depend_list b/dsms_deploy/config/depend_list index 1778da1a33e4fe9176071de6fe0603c92c052d56..a69f1cefed8b7767084034ef5bae7b7f26de4b34 100644 --- a/dsms_deploy/config/depend_list +++ b/dsms_deploy/config/depend_list @@ -1,80 +1,45 @@ -depend=abseil-cpp-20200923.3-1.el8.x86_64.rpm -depend=gperftools-libs-2.7-9.el8.x86_64.rpm -depend=grpc-data-1.34.1-8.0.1.an8.noarch.rpm -depend=leveldb-1.22-1.el8.x86_64.rpm -depend=leveldb-devel-1.22-1.el8.x86_64.rpm -depend=liboath-2.6.2-3.el8.x86_64.rpm -depend=libunwind-1.3.1-3.el8.x86_64.rpm -depend=platform-python-devel-3.6.8-45.0.1.an8.x86_64.rpm -depend=protobuf-3.14.0-6.an8.x86_64.rpm -depend=python3-apipkg-1.5-6.el8.noarch.rpm -depend=python3-beautifulsoup4-4.6.3-2.el8.1.noarch.rpm -depend=python3-bcrypt-3.1.6-2.el8.1.x86_64.rpm -depend=python3-cheroot-8.5.2-1.el8.noarch.rpm -depend=python3-cherrypy-18.4.0-1.el8.noarch.rpm -depend=python3-execnet-1.7.1-1.el8.noarch.rpm -depend=python3-grpcio-1.34.1-8.0.1.an8.x86_64.rpm -depend=python3-jaraco-6.2-6.el8.noarch.rpm -depend=python3-jaraco-functools-2.0-4.el8.noarch.rpm -depend=python3-logutils-0.3.5-11.el8.noarch.rpm -depend=python3-more-itertools-7.2.0-3.el8.noarch.rpm -depend=python3-pecan-1.3.2-9.el8.noarch.rpm -depend=python3-portend-2.6-1.el8.noarch.rpm -depend=python3-remoto-1.2.1-1.el8.noarch.rpm -depend=python3-repoze-lru-0.7-6.el8.noarch.rpm -depend=python3-routes-2.4.1-12.el8.noarch.rpm -depend=python3-simplegeneric-0.8.1-17.el8.noarch.rpm -depend=python3-singledispatch-3.4.0.3-18.el8.noarch.rpm -depend=python3-tempora-1.14.1-5.el8.noarch.rpm -depend=python3-trustme-0.6.0-4.el8.noarch.rpm -depend=python3-waitress-1.2.1-2.el8.1.noarch.rpm -depend=python3-webob-1.8.5-1.el8.1.noarch.rpm -depend=python3-webtest-2.0.33-1.el8.noarch.rpm -depend=python3-zc-lockfile-2.0-2.el8.noarch.rpm -depend=re2-20190801-1.el8.x86_64.rpm -depend=resource-agents-4.9.0-35.el8.x86_64.rpm -whl=ceph-deploy-2.0.1.tar.gz -ceph_rpm=ceph-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=cephadm-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-base-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-common-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-fuse-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-grafana-dashboards-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-immutable-object-cache-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-mds-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-mgr-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-mgr-cephadm-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-mgr-dashboard-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-mgr-diskprediction-cloud-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-mgr-diskprediction-local-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-mgr-modules-core-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-mon-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-osd-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-prometheus-alerts-2.0.0_anolis-0.an8.noarch.rpm -ceph_rpm=ceph-radosgw-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-resource-agents-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=ceph-selinux-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=libcephfs2-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=libcephfs-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=librados2-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=librados-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=libradospp-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=libradosstriper1-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=libradosstriper-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=librbd1-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=librbd-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=librgw2-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=librgw-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=python3-ceph-argparse-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=python3-ceph-common-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=python3-cephfs-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=python3-rados-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=python3-rbd-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=python3-rgw-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=rados-objclass-devel-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=rbd-fuse-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=rbd-mirror-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=rbd-nbd-2.0.0_anolis-0.an8.x86_64.rpm -ceph_rpm=dsms-prometheus-2.32.1-2.el8.x86_64.rpm -ceph_rpm=dsms-prometheus-alertmanager-0.23.0-7.el8.x86_64.rpm -ceph_rpm=dsms-prometheus-node-exporter-1.3.1-4.el8.x86_64.rpm \ No newline at end of file +whl=dsms-deploy-2.1.0.tar.gz +ceph_rpm=dsms-storage-1.0-0.an23.rpm +ceph_rpm=cephadm-1.0-0.an23.rpm +ceph_rpm=dsms-storage-base-1.0-0.an23.rpm +ceph_rpm=dsms-storage-common-1.0-0.an23.rpm +ceph_rpm=dsms-storage-fuse-1.0-0.an23.rpm +ceph_rpm=dsms-storage-grafana-dashboards-1.0-0.an23.rpm +ceph_rpm=dsms-storage-immutable-object-cache-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mds-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mgr-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mgr-cephadm-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mgr-dashboard-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mgr-diskprediction-local-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mgr-modules-core-1.0-0.an23.rpm +ceph_rpm=dsms-storage-mon-1.0-0.an23.rpm +ceph_rpm=dsms-storage-osd-1.0-0.an23.rpm +ceph_rpm=dsms-storage-prometheus-alerts-1.0-0.an23.rpm +ceph_rpm=dsms-storage-radosgw-1.0-0.an23.rpm +ceph_rpm=dsms-storage-resource-agents-1.0-0.an23.rpm +ceph_rpm=dsms-storage-selinux-1.0-0.an23.rpm +ceph_rpm=libcephfs2-1.0-0.an23.rpm +ceph_rpm=libcephfs-devel-1.0-0.an23.rpm +ceph_rpm=librados2-1.0-0.an23.rpm +ceph_rpm=librados-devel-1.0-0.an23.rpm +ceph_rpm=libradospp-devel-1.0-0.an23.rpm +ceph_rpm=libradosstriper1-1.0-0.an23.rpm +ceph_rpm=libradosstriper-devel-1.0-0.an23.rpm +ceph_rpm=librbd1-1.0-0.an23.rpm +ceph_rpm=librbd-devel-1.0-0.an23.rpm +ceph_rpm=librgw2-1.0-0.an23.rpm +ceph_rpm=librgw-devel-1.0-0.an23.rpm +ceph_rpm=python3-ceph-argparse-1.0-0.an23.rpm +ceph_rpm=python3-ceph-common-1.0-0.an23.rpm +ceph_rpm=python3-cephfs-1.0-0.an23.rpm +ceph_rpm=python3-rados-1.0-0.an23.rpm +ceph_rpm=python3-rbd-1.0-0.an23.rpm +ceph_rpm=python3-rgw-1.0-0.an23.rpm +ceph_rpm=rados-objclass-devel-1.0-0.an23.rpm +ceph_rpm=rbd-fuse-1.0-0.an23.rpm +ceph_rpm=rbd-mirror-1.0-0.an23.rpm +ceph_rpm=rbd-nbd-1.0-0.an23.rpm +ceph_rpm=golang-github-prometheus.rpm +ceph_rpm=golang-github-prometheus-node-exporter.rpm +dsms_rpm=dsms-ui.rpm +dsms_rpm=dsms-engine.rpm \ No newline at end of file diff --git a/dsms_deploy/config/whl/ceph-deploy-2.0.1.tar.gz b/dsms_deploy/config/whl/ceph-deploy-2.0.1.tar.gz deleted file mode 100644 index bc0ef86f7b029c24af5db83c112ba546d7db5196..0000000000000000000000000000000000000000 Binary files a/dsms_deploy/config/whl/ceph-deploy-2.0.1.tar.gz and /dev/null differ diff --git a/dsms_deploy/config/whl/dsms-deploy-2.1.0.tar.gz b/dsms_deploy/config/whl/dsms-deploy-2.1.0.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..cef968fcf2dcb62da62e0b306bbf2142db16ad8c Binary files /dev/null and b/dsms_deploy/config/whl/dsms-deploy-2.1.0.tar.gz differ diff --git a/dsms_deploy/dsms-deploy.py b/dsms_deploy/dsms-deploy.py index a572496a93f0bbec8afee5b1c823ae90753ebdac..92e3d01111e80cb53fda2d5d27837723bdadde58 100755 --- a/dsms_deploy/dsms-deploy.py +++ b/dsms_deploy/dsms-deploy.py @@ -485,6 +485,18 @@ def configure_cluster(nodes): error_message.write(line) raise Exception(f'{ip} set {hostname} failed,{error_message.getvalue()}') + logger.info(f"disable and stop firewalld {hostname}") + stdin, stdout, stderr = client.exec_command('systemctl disable firewalld') + stdin, stdout, stderr = client.exec_command('systemctl stop firewalld') + exit_code = stdout.channel.recv_exit_status() + if exit_code == 0: + logger.info(f"disable and stop firewalld {hostname} success") + else: + for line in stderr: + error_message = io.StringIO() + error_message.write(line) + raise Exception(f'disable and stop firewalld failed,{error_message.getvalue()}') + # Add all hostnames and IPs to /etc/hosts for s in nodes.values(): command = f"bash -s {s.ip} {s.hostname}" @@ -617,6 +629,7 @@ def deploy_node(node): depend_list = [] whl_list = [] ceph_rpm_list = [] + dsms_rpm_list = [] if node.repo_url: logger.info('use customer repo') gpgcheck = 0 @@ -648,6 +661,8 @@ def deploy_node(node): whl_list.append(line.strip().split('=')[1]) elif line.startswith('ceph_rpm='): ceph_rpm_list.append(line.strip().split('=')[1]) + elif line.startswith('dsms_rpm='): + dsms_rpm_list.append(line.strip().split('=')[1]) # install all depend depend_without_ext_list = [] @@ -660,11 +675,51 @@ def deploy_node(node): depends = ' '.join(str(depend) for depend in depend_without_ext_list) run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f"yum install -y {depends}") if node.leader: + for dsms_rpm in dsms_rpm_list: + dsms_rpm_without_ext = dsms_rpm.rsplit('.', 1)[0] + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f"yum install -y {dsms_rpm_without_ext}") for whl in whl_list: run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f"pip3 install {DEPLOY_PACKAGE}/{whl}") + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, 'ceph -v') +def uninstall_node(node): + if node.ip: + logger.info(f'starting uninstall server: {node.hostname} ...') + depend_list = [] + whl_list = [] + ceph_rpm_list = [] + dsms_rpm_list = [] + + with open(DEPLOY_PACKAGE + "/" + DEPEND_LIST, 'r') as f: + for line in f: + if line.startswith('depend='): + depend_list.append(line.strip().split('=')[1]) + elif line.startswith('whl='): + whl_list.append(line.strip().split('=')[1]) + elif line.startswith('ceph_rpm='): + ceph_rpm_list.append(line.strip().split('=')[1]) + elif line.startswith('dsms_rpm='): + dsms_rpm_list.append(line.strip().split('=')[1]) + + # remove all depend + depend_without_ext_list = [] + for depend in depend_list: + depend_without_ext = depend.rsplit('.', 1)[0] + depend_without_ext_list.append(depend_without_ext) + for ceph_rpm in ceph_rpm_list: + ceph_rpm_without_ext = ceph_rpm.rsplit('.', 1)[0] + depend_without_ext_list.append(ceph_rpm_without_ext) + depends = ' '.join(str(depend) for depend in depend_without_ext_list) + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f"yum remove -y {depends}") + if node.leader: + for dsms_rpm in dsms_rpm_list: + dsms_rpm_without_ext = dsms_rpm.rsplit('.', 1)[0] + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f"yum remove -y {dsms_rpm_without_ext}") + for whl in whl_list: + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f"pip3 uninstall -y dsms-deploy") + def check_time_difference(nodes): logger.info("Check servers time...") @@ -696,6 +751,33 @@ def check_time_difference(nodes): f"server time check failed. server1: {server1.hostname} server2: {server2.hostname}, time difference is: {time_difference}s") logger.info("Check servers time pass") +def update_prometheus_service(node): + logger.info("update prometheus service...") + remote_file = '/usr/lib/systemd/system/prometheus.service' + old_user = 'User=prometheus' + new_user = 'User=root' + insert_index = -1 + line_exists = False + lines = run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'cat {remote_file}').splitlines() + # get old user index + for i, line in enumerate(lines): + if old_user in line: + insert_index = i + 1 + if new_user in line: + line_exists = True + break + # insert new user + if not line_exists and insert_index != -1: + lines.insert(insert_index, new_user) + modified_content = '\n'.join(lines) + modified_content = modified_content.replace('$', r'\$') + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'echo "{modified_content}" > {remote_file}') + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, 'systemctl daemon-reload') + + logger.info("update prometheus service success") + + + def purge_cluster(nodes): logger.info('starting purge old cluster ...') @@ -766,6 +848,7 @@ def command_init(args): configure_cluster(nodes) leader = nodes.get(LEADER_NODE) hostname = ' '.join([node.hostname for node in nodes.values()]) + update_prometheus_service(leader) # first purge exist cluster. purge_cluster(nodes) run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'mkdir -p {INIT_DIR}') @@ -776,16 +859,22 @@ def command_init(args): run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'cd {INIT_DIR};ceph-deploy mon create-initial') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'cd {INIT_DIR};ceph-deploy admin {hostname}') logger.info('waiting for mon to start...') + for node in nodes.values(): + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'systemctl enable ceph-mon.target') is_available('mon', leader.ip, leader.root_passwd, is_mon_available) logger.info('Creating mgr...') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'cd {INIT_DIR};ceph-deploy mgr create {leader.hostname}') logger.info('waiting for mgr to start...') + for node in nodes.values(): + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'systemctl enable ceph-mgr.target') is_available('mgr', leader.ip, leader.root_passwd, is_mgr_available) logger.info('Creating mds...') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'cd {INIT_DIR};ceph-deploy mds create {hostname}') logger.info('waiting for mds to start...') + for node in nodes.values(): + run_ssh_command(node.ip, DEPLOY_USERNAME, node.root_passwd, f'systemctl enable ceph-mds.target') is_available('mds', leader.ip, leader.root_passwd, is_mds_available) # Config cluster @@ -820,6 +909,7 @@ def command_init(args): run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, 'ceph config set global osd_crush_update_on_start false') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, 'ceph config set global mon_warn_on_pool_no_app false') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, 'ceph config set mgr mgr/devicehealth/enable_monitoring false') + run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, 'ceph restful restart') time.sleep(5) # give some room to start command_info('') @@ -892,6 +982,8 @@ def command_rm_cluster(args): logger.info(f'Starting remove node: {node.hostname}') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'ceph-deploy purge {node.hostname}') run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'ceph-deploy purgedata {node.hostname}') + for node in cluster_nodes.values(): + uninstall_node(node) run_ssh_command(leader.ip, DEPLOY_USERNAME, leader.root_passwd, f'rm -rf {INIT_DIR}/*') logger.info('Removed the dsms-storage cluster success')