Advertisement
42n4

CENTOS4CEPHFUNCTIONS

Mar 28th, 2017
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.48 KB | None | 0 0
  1. #https://www.howtoforge.com/tutorial/how-to-build-a-ceph-cluster-on-centos-7/
  2. #w VirtualBoxie zakładam vm Centos7 z 2GB RAM i dwa dyski 8GB i 8GB
  3. #TUTAJ SĄ FUNKCJE DO GŁÓWNEGO SKRYPTU
  4. #GŁÓWNY SKRYPT
  5. #curl https://pastebin.com/raw/kZX6ubYH | sed 's/\r//g' > ceph.txt
  6. #FUNKCJE CZYLI TEN PLIK
  7. #curl https://pastebin.com/raw/2gEM4ena | sed 's/\r//g' > cephfun.sh
  8.  
  9. ###############################################################################################
  10. #updatuje Centos, dodając pakiety np. ceph-deploy
  11. cat << 'EOF' > /usr/local/bin/centos_update
  12. yum install -y epel-release
  13. rpm -Uvh http://download.ceph.com/rpm-jewel/el7/noarch/ceph-release-1-1.el7.noarch.rpm
  14. #https://www.digitalocean.com/community/tutorials/how-to-install-puppet-4-in-a-master-agent-setup-on-centos-7
  15. rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
  16. #http://www.itzgeek.com/how-tos/linux/centos-how-tos/setup-chef-12-centos-7-rhel-7.html
  17. #http://linoxide.com/linux-how-to/chef-workstation-server-node-centos-7/
  18. yum update -y && yum install ceph-deploy -y
  19. yum install -y vim ansible nmap sg3_utils puppetserver puppet-agent wget
  20. yum install -y sysbench iperf bonnie++
  21. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  22. systemctl stop firewalld; systemctl disable firewalld
  23. [ -f /etc/ansible/hosts ] && mv /etc/ansible/hosts /etc/ansible/hosts.orig -f
  24. echo "[web]" > /etc/ansible/hosts
  25. #echo server1 >> /etc/ansible/hosts
  26. #echo server2 >> /etc/ansible/hosts
  27. #echo server3 >> /etc/ansible/hosts
  28. echo 'ansible all -s -m shell -a "$1"' > /usr/local/bin/ae
  29. chmod 700 /usr/local/bin/ae
  30. sed -i s'/Defaults requiretty/#Defaults requiretty'/g /etc/sudoers
  31. yum install -y ntp ntpdate ntp-doc
  32. ntpdate 0.us.pool.ntp.org
  33. hwclock --systohc
  34. systemctl enable ntpd.service
  35. systemctl start ntpd.service
  36. curl ix.io/client > /usr/local/bin/ix
  37. chmod +x /usr/local/bin/ix
  38. EOF
  39. chmod 755 /usr/local/bin/centos_update
  40.  
  41. ###############################################################################################
  42. #centos_static_ip "server" "77" "78" "79"
  43. #server="server"; ip01="77"; ip02="78"; ip03="79"
  44. cat << 'EOF' > /usr/local/bin/centos_static_ip
  45. server=$1
  46. #tu wpisuje uzyskane z dhcp ip
  47. ip01=$2
  48. ip02=$3
  49. ip03=$4
  50. echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > /etc/hosts
  51. echo "192.168.2.${ip01} ${server}1" >> /etc/hosts
  52. echo "192.168.2.${ip02} ${server}2" >> /etc/hosts
  53. echo "192.168.2.${ip03} ${server}3" >> /etc/hosts
  54. echo "${server}1" >> /etc/ansible/hosts
  55. echo "${server}2" >> /etc/ansible/hosts
  56. echo "${server}3" >> /etc/ansible/hosts
  57.  
  58. ssh-keygen -t rsa -b 2048 -N '' -f ~/.ssh/id_rsa
  59. for node in ${server}1 ${server}2 ${server}3; do ssh-copy-id $node ; done
  60.  
  61. scp /etc/hosts root@${server}2:/etc
  62. scp /etc/hosts root@${server}3:/etc
  63. ssh ${server}1 "echo ${server}1 > /etc/hostname"
  64. ssh ${server}2 "echo ${server}2 > /etc/hostname"
  65. ssh ${server}3 "echo ${server}3 > /etc/hostname"
  66.  
  67. #tu wpisuje pożądane ustawione ip 3 maszyn
  68. ip01="41"
  69. ip02="42"
  70. ip03="43"
  71. sed -i 's/dhcp/none/g' /etc/sysconfig/network-scripts/ifcfg-enp0s3
  72. sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-enp0s3
  73. echo IPADDR=192.168.2.${ip01} >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
  74. echo "PREFIX=24" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
  75. echo "GATEWAY=192.168.2.1" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
  76. echo "DNS1=192.168.2.1" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
  77. echo "DNS2=8.8.8.8" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
  78. echo "DNS3=8.8.4.4" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
  79. rm  ~/ifcfg-enp0s3 -rf;
  80. cp -a /etc/sysconfig/network-scripts/ifcfg-enp0s3 ~
  81. echo sed -i 's/^IPADDR=192.168.2.'$ip01'/IPADDR=192.168.2.'$ip02'/g' ~/ifcfg-enp0s3 > ~/ip.sh
  82. sh ~/ip.sh
  83. scp  ~/ifcfg-enp0s3 root@server2:/etc/sysconfig/network-scripts
  84. rm  ~/ifcfg-enp0s3 -rf;
  85. cp -a /etc/sysconfig/network-scripts/ifcfg-enp0s3 ~
  86. echo sed -i 's/^IPADDR=192.168.2.'$ip01'/IPADDR=192.168.2.'$ip03'/g' ~/ifcfg-enp0s3 > ~/ip.sh
  87. sh ~/ip.sh
  88. scp  ~/ifcfg-enp0s3 root@server3:/etc/sysconfig/network-scripts
  89.  
  90. echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > ~/hosts
  91. echo "192.168.2.${ip01} ${server}1" >> ~/hosts
  92. echo "192.168.2.${ip02} ${server}2" >> ~/hosts
  93. echo "192.168.2.${ip03} ${server}3" >> ~/hosts
  94. scp ~/hosts root@${server}2:/etc
  95. scp ~/hosts root@${server}3:/etc
  96. ssh ${server}2 reboot
  97. ssh ${server}3 reboot
  98. rm -rf /etc/hosts
  99. cp ~/hosts /etc
  100. EOF
  101. chmod 755 /usr/local/bin/centos_static_ip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement