Advertisement
echoslider

ceph_deply_snap_or_cephadm

Nov 20th, 2023 (edited)
733
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.44 KB | None | 0 0
  1. cat>/root/install_ceph<<'EOF'
  2. #!/bin/bash
  3.  
  4. display_menu() {
  5.     echo "Choose an option:"
  6.     echo "1. Install Ceph with Snap Microceph"
  7.     echo "2. Install Ceph with cephadm"
  8.     echo "3. Exit"
  9. }
  10.  
  11. install_ceph_snap_microceph() {
  12.     echo "Installing Ceph with Snap Microceph..."
  13.     sudo apt-get update
  14.     sudo apt-get install snap snapd
  15.     sudo snap install microceph
  16.     sudo microceph cluster bootstrap
  17.     sudo microceph enable rgw
  18. }
  19.  
  20. install_ceph_cephadm() {
  21.     echo "Install Ceph with cephadm..."
  22.     # Add your dummy commands here
  23.     host=$(hostname -s)
  24.     ip4=$(ip -o -4 addr list $(ip r|grep "default"|awk '{print $5}') | awk '{print $4}' | cut -d/ -f1)
  25.     apt-get -y install podman ceph-common ceph-base lvm2 \
  26.         ceph-iscsi radosgw nfs-ganesha-ceph cephfs-shell \
  27.         targetcli-fb ceph-iscsi python3-rtslib-fb tcmu-runner
  28.     curl --silent --remote-name --location https://github.com/ceph/ceph/raw/quincy/src/cephadm/cephadm
  29.     chmod +x cephadm
  30.     sudo mv cephadm /usr/local/bin/
  31.     sudo cephadm bootstrap \
  32.         --mon-ip $ip4 \
  33.         --dashboard-password-noupdate \
  34.         --initial-dashboard-user admin \
  35.         --initial-dashboard-password "p@ssw0rd"
  36.     ceph config set mgr mgr/cephadm/manage_etc_ceph_ceph_conf true
  37.     systemctl disable nfs-ganesha
  38.     ceph tell mon.* injectargs '--mon-allow-pool-delete true'
  39.     sleep 5
  40.     ceph orch apply osd --all-available-devices
  41.     sleep 10
  42.     ceph osd pool create cephfs0_data replicated
  43.     ceph osd pool create cephfs0_metadata replicated
  44.     ceph fs new cephfs0 cephfs0_metadata cephfs0_data
  45.     ceph orch apply mds cephfs0 1
  46.     ceph fs authorize cephfs0 client.user / rw | tee /etc/ceph/ceph.client.user.keyring
  47.     mkdir -p /mnt/cephfs0
  48.     cat >> /etc/fstab << FSTABMOUNT
  49.     $ip4:/ /mnt/cephfs0 ceph name=user,noatime,nodiratime,_netdev 0 0
  50. FSTABMOUNT
  51.     mount -a
  52.     ceph osd pool create rbd
  53.     ceph osd pool application enable rbd rbd
  54.     rbd pool init -p rbd
  55.     radosgw-admin realm create --rgw-realm=default --default
  56.     radosgw-admin zonegroup create --rgw-zonegroup=default --master --default
  57.     radosgw-admin zone create --rgw-zonegroup=default --rgw-zone=default --master --default
  58.     radosgw-admin period update --rgw-realm=default --commit
  59.     ceph orch apply rgw default --realm=default --zone=default --placement="1 $host"
  60. }
  61.  
  62. while true; do
  63.     display_menu
  64.  
  65.     read -p "Enter your choice (1-3): " choice
  66.  
  67.     case $choice in
  68.         1)
  69.             install_ceph_snap_microceph
  70.             ;;
  71.         2)
  72.             install_ceph_cephadm
  73.             ;;
  74.         3)
  75.             echo "Exiting..."
  76.             exit 0
  77.             ;;
  78.         *)
  79.             echo "Invalid choice. Please enter a number between 1 and 3."
  80.             ;;
  81.     esac
  82. done
  83. EOF
  84. chmod +x /root/install_ceph
  85.  
  86. cat>/root/dashboard_ceph<<'EOF'
  87. #!/bin/bash
  88.  
  89. sudo microceph.ceph mgr module enable dashboard
  90. sleep 5
  91. sudo microceph.ceph config set mgr mgr/dashboard/ssl false
  92. sudo echo -n '$PASSWORDROOT' > /var/snap/microceph/current/conf/password.txt
  93. sudo microceph.ceph dashboard ac-user-create -i /etc/ceph/password.txt admin administrator
  94. EOF
  95. chmod +x /root/dashboard_ceph
  96.  
  97.  
  98. cat>/root/add_ceph_disks<<'EOF'
  99. #!/bin/bash
  100.  
  101. DK=$(lsblk -l -d -e 11 -n -o NAME)
  102. COUNT=0
  103. for i in $DK
  104. do
  105.     blkid "/dev/$i" &> /dev/null
  106.     if [ $? != 0 ]; then
  107.         microceph disk add /dev/"$i"
  108.         (( COUNT++ ))
  109.     fi
  110. EOF
  111. chmod +x /root/add_ceph_disks
  112.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement