Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://www.howtoforge.com/tutorial/how-to-build-a-ceph-cluster-on-centos-7/
- #w VirtualBoxie zakładam vm Centos7 z 2GB RAM i dwa dyski 8GB i 8GB
- #TUTAJ SĄ FUNKCJE DO GŁÓWNEGO SKRYPTU
- #GŁÓWNY SKRYPT
- #curl https://pastebin.com/raw/kZX6ubYH | sed 's/\r//g' > ceph.txt
- #FUNKCJE CZYLI TEN PLIK
- #curl https://pastebin.com/raw/2gEM4ena | sed 's/\r//g' > cephfun.sh
- ###############################################################################################
- #updatuje Centos, dodając pakiety np. ceph-deploy
- cat << 'EOF' > /usr/local/bin/centos_update
- yum install -y epel-release
- rpm -Uvh http://download.ceph.com/rpm-jewel/el7/noarch/ceph-release-1-1.el7.noarch.rpm
- #https://www.digitalocean.com/community/tutorials/how-to-install-puppet-4-in-a-master-agent-setup-on-centos-7
- rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-7.noarch.rpm
- #http://www.itzgeek.com/how-tos/linux/centos-how-tos/setup-chef-12-centos-7-rhel-7.html
- #http://linoxide.com/linux-how-to/chef-workstation-server-node-centos-7/
- yum update -y && yum install ceph-deploy -y
- yum install -y vim ansible nmap sg3_utils puppetserver puppet-agent wget
- yum install -y sysbench iperf bonnie++
- sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
- systemctl stop firewalld; systemctl disable firewalld
- [ -f /etc/ansible/hosts ] && mv /etc/ansible/hosts /etc/ansible/hosts.orig -f
- echo "[web]" > /etc/ansible/hosts
- #echo server1 >> /etc/ansible/hosts
- #echo server2 >> /etc/ansible/hosts
- #echo server3 >> /etc/ansible/hosts
- echo 'ansible all -s -m shell -a "$1"' > /usr/local/bin/ae
- chmod 700 /usr/local/bin/ae
- sed -i s'/Defaults requiretty/#Defaults requiretty'/g /etc/sudoers
- yum install -y ntp ntpdate ntp-doc
- ntpdate 0.us.pool.ntp.org
- hwclock --systohc
- systemctl enable ntpd.service
- systemctl start ntpd.service
- curl ix.io/client > /usr/local/bin/ix
- chmod +x /usr/local/bin/ix
- EOF
- chmod 755 /usr/local/bin/centos_update
- ###############################################################################################
- #centos_static_ip "server" "77" "78" "79"
- #server="server"; ip01="77"; ip02="78"; ip03="79"
- cat << 'EOF' > /usr/local/bin/centos_static_ip
- server=$1
- #tu wpisuje uzyskane z dhcp ip
- ip01=$2
- ip02=$3
- ip03=$4
- echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > /etc/hosts
- echo "192.168.2.${ip01} ${server}1" >> /etc/hosts
- echo "192.168.2.${ip02} ${server}2" >> /etc/hosts
- echo "192.168.2.${ip03} ${server}3" >> /etc/hosts
- echo "${server}1" >> /etc/ansible/hosts
- echo "${server}2" >> /etc/ansible/hosts
- echo "${server}3" >> /etc/ansible/hosts
- ssh-keygen -t rsa -b 2048 -N '' -f ~/.ssh/id_rsa
- for node in ${server}1 ${server}2 ${server}3; do ssh-copy-id $node ; done
- scp /etc/hosts root@${server}2:/etc
- scp /etc/hosts root@${server}3:/etc
- ssh ${server}1 "echo ${server}1 > /etc/hostname"
- ssh ${server}2 "echo ${server}2 > /etc/hostname"
- ssh ${server}3 "echo ${server}3 > /etc/hostname"
- #tu wpisuje pożądane ustawione ip 3 maszyn
- ip01="41"
- ip02="42"
- ip03="43"
- sed -i 's/dhcp/none/g' /etc/sysconfig/network-scripts/ifcfg-enp0s3
- sed -i 's/ONBOOT=no/ONBOOT=yes/g' /etc/sysconfig/network-scripts/ifcfg-enp0s3
- echo IPADDR=192.168.2.${ip01} >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
- echo "PREFIX=24" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
- echo "GATEWAY=192.168.2.1" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
- echo "DNS1=192.168.2.1" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
- echo "DNS2=8.8.8.8" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
- echo "DNS3=8.8.4.4" >> /etc/sysconfig/network-scripts/ifcfg-enp0s3
- rm ~/ifcfg-enp0s3 -rf;
- cp -a /etc/sysconfig/network-scripts/ifcfg-enp0s3 ~
- echo sed -i 's/^IPADDR=192.168.2.'$ip01'/IPADDR=192.168.2.'$ip02'/g' ~/ifcfg-enp0s3 > ~/ip.sh
- sh ~/ip.sh
- scp ~/ifcfg-enp0s3 root@server2:/etc/sysconfig/network-scripts
- rm ~/ifcfg-enp0s3 -rf;
- cp -a /etc/sysconfig/network-scripts/ifcfg-enp0s3 ~
- echo sed -i 's/^IPADDR=192.168.2.'$ip01'/IPADDR=192.168.2.'$ip03'/g' ~/ifcfg-enp0s3 > ~/ip.sh
- sh ~/ip.sh
- scp ~/ifcfg-enp0s3 root@server3:/etc/sysconfig/network-scripts
- echo "127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4" > ~/hosts
- echo "192.168.2.${ip01} ${server}1" >> ~/hosts
- echo "192.168.2.${ip02} ${server}2" >> ~/hosts
- echo "192.168.2.${ip03} ${server}3" >> ~/hosts
- scp ~/hosts root@${server}2:/etc
- scp ~/hosts root@${server}3:/etc
- ssh ${server}2 reboot
- ssh ${server}3 reboot
- rm -rf /etc/hosts
- cp ~/hosts /etc
- EOF
- chmod 755 /usr/local/bin/centos_static_ip
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement