github.com/swiftstack/proxyfs@v0.0.0-20201223034610-5434d919416e/saio/vagrant_provision.sh (about) 1 #!/bin/bash 2 # 3 # Note: This script assumes it is being run as root 4 5 set -e 6 set -x 7 8 # Enable core dumps 9 # 10 # Core files will be placed in /var/lib/systemd/coredump/ 11 # Core files will be compressed with xz... use unxz to uncompress them 12 # 13 # To install the delve debugger, you will need to `go get -u github.com/go-delve/delve/cmd/dlv` 14 # - Note that this will compete with the version of dlv installed for your host GOPATH 15 # - As such, delve is not installed during provisioning 16 # - Instead, an alias for the above, `gogetdlv`, would be issued as and when needed inside this VM 17 18 sed -i '/DefaultLimitCORE=/c\DefaultLimitCORE=infinity' /etc/systemd/system.conf 19 20 echo "kernel.core_pattern=| /usr/lib/systemd/systemd-coredump %p %u %g %s %t %c %e" > /etc/sysctl.d/90-override.conf 21 sysctl kernel.core_pattern='| /usr/lib/systemd/systemd-coredump %p %u %g %s %t %c %e' 22 23 echo "GOTRACEBACK=crash" >> /etc/environment 24 25 # Install yum-utils to deal with yum repos 26 27 yum -y install yum-utils 28 29 # Disable generic CentOS 7 repos 30 31 yum-config-manager --disable CentOS-Base 32 yum-config-manager --disable CentOS-CR 33 yum-config-manager --disable CentOS-Debuginfo 34 yum-config-manager --disable CentOS-fasttrack 35 yum-config-manager --disable CentOS-Media 36 yum-config-manager --disable CentOS-Sources 37 yum-config-manager --disable CentOS-Vault 38 39 rm -rf /etc/yum.repos.d/CentOS-Base.repo 40 rm -rf /etc/yum.repos.d/CentOS-CR.repo 41 rm -rf /etc/yum.repos.d/CentOS-Debuginfo.repo 42 rm -rf /etc/yum.repos.d/CentOS-fasttrack.repo 43 rm -rf /etc/yum.repos.d/CentOS-Media.repo 44 rm -rf /etc/yum.repos.d/CentOS-Sources.repo 45 rm -rf /etc/yum.repos.d/CentOS-Vault.repo 46 47 # Add and enable CentOS 7.4 repos 48 49 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/os/x86_64/ 50 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/updates/x86_64/ 51 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/extras/x86_64/ 52 yum-config-manager --add-repo http://vault.centos.org/centos/7.4.1708/centosplus/x86_64/ 53 yum-config-manager --enable vault.centos.org_centos_7.4.1708_os_x86_64_ 54 yum-config-manager --enable vault.centos.org_centos_7.4.1708_updates_x86_64_ 55 yum-config-manager --enable vault.centos.org_centos_7.4.1708_extras_x86_64_ 56 yum-config-manager --enable vault.centos.org_centos_7.4.1708_centosplus_x86_64_ 57 58 yum clean all 59 60 # Install tools needed above what's in a minimal base box 61 62 yum -y install wget git nfs-utils vim lsof 63 64 # Install Golang 65 66 yum -y --disableexcludes=all install glibc-commmon gcc 67 cd /tmp 68 TARFILE_NAME=go1.15.5.linux-amd64.tar.gz 69 wget -q https://dl.google.com/go/$TARFILE_NAME 70 tar -C /usr/local -xf $TARFILE_NAME 71 rm $TARFILE_NAME 72 echo "export PATH=\$PATH:/usr/local/go/bin" >> ~vagrant/.bash_profile 73 74 # Patch Golang's GDB runtime plug-in 75 76 mv /usr/local/go/src/runtime/runtime-gdb.py /usr/local/go/src/runtime/runtime-gdb.py_ORIGINAL 77 cp /vagrant/src/github.com/swiftstack/ProxyFS/saio/usr/local/go/src/runtime/runtime-gdb.py /usr/local/go/src/runtime/. 78 79 # Install GDB and enable above Golang GDB runtime plug-in as well as other niceties 80 81 yum -y install gdb 82 echo "add-auto-load-safe-path /usr/local/go/src/runtime/runtime-gdb.py" > /home/vagrant/.gdbinit 83 echo "set print thread-events off" >> /home/vagrant/.gdbinit 84 echo "set print pretty on" >> /home/vagrant/.gdbinit 85 echo "set print object on" >> /home/vagrant/.gdbinit 86 echo "set pagination off" >> /home/vagrant/.gdbinit 87 chown vagrant:vagrant /home/vagrant/.gdbinit 88 chmod 644 /home/vagrant/.gdbinit 89 cp /home/vagrant/.gdbinit /root/. 90 91 # Install Python 3.6 92 93 yum -y install centos-release-scl 94 yum -y install rh-python36 95 ln -s /opt/rh/rh-python36/root/bin/python3.6 /bin/python3.6 96 ln -s /bin/python3.6 /bin/python3 97 ln -s /opt/rh/rh-python36/root/usr/include /opt/rh/rh-python36/root/include 98 99 # Install Python pip 100 101 yum -y install epel-release 102 yum -y install python-pip 103 pip install --upgrade pip 104 105 # Setup ProxyFS build environment 106 107 pip install requests 108 yum -y install json-c-devel 109 yum -y install fuse 110 echo "export GOPATH=/vagrant" >> ~vagrant/.bash_profile 111 echo "export PATH=\$PATH:\$GOPATH/bin" >> ~vagrant/.bash_profile 112 echo "alias cdpfs=\"cd \$GOPATH/src/github.com/swiftstack/ProxyFS\"" >> ~vagrant/.bash_profile 113 echo "alias goclean=\"go clean;go clean --cache;go clean --testcache\"" >> ~vagrant/.bash_profile 114 echo "alias gogetdlv=\"go get -u github.com/go-delve/delve/cmd/dlv\"" >> ~vagrant/.bash_profile 115 echo "user_allow_other" >> /etc/fuse.conf 116 117 # Setup Samba 118 119 yum -y install gcc-c++-4.8.5-16.el7_4.2 \ 120 python-devel-2.7.5-58.el7 \ 121 gnutls-devel-3.3.26-9.el7 \ 122 libacl-devel-2.2.51-12.el7 \ 123 openldap-devel-2.4.44-5.el7 \ 124 samba-4.6.2-12.el7_4 \ 125 samba-client-4.6.2-12.el7_4 \ 126 cifs-utils-6.2-10.el7 127 cd /vagrant/src/github.com/swiftstack/ProxyFS/vfs 128 OS_DISTRO=centos 129 OS_DISTRO_VERSION=7.4 130 SAMBA_VERSION=4.6.12 131 SAMBA_DIR=build-samba-`echo $SAMBA_VERSION | tr . -`-${OS_DISTRO}-`echo $OS_DISTRO_VERSION | tr . -` 132 if [[ -d $SAMBA_DIR ]] 133 then 134 if [[ -L $SAMBA_DIR ]] 135 then 136 echo "directory symlink \$GOPATH/src/github.com/swiftstack/ProxyFS/vfs/$SAMBA_DIR cannot pre-exist" 137 exit 1 138 else 139 echo "\$GOPATH/src/github.com/swiftstack/ProxyFS/vfs/$SAMBA_DIR assumed to be as desired" 140 fi 141 else 142 if [[ -L $SAMBA_DIR ]] 143 then 144 echo "non-directory symlink \$GOPATH/src/github.com/swiftstack/ProxyFS/vfs/$SAMBA_DIR cannot pre-exist" 145 exit 1 146 else 147 git clone -b samba-$SAMBA_VERSION --single-branch --depth 1 https://github.com/samba-team/samba.git $SAMBA_DIR 148 fi 149 fi 150 if [[ -L samba ]] 151 then 152 samba_symlink_target=`readlink "samba"` 153 if [[ "$SAMBA_DIR" == "$samba_symlink_target" ]] 154 then 155 echo "symlink samba -> $SAMBA_DIR already" 156 else 157 echo "redirecting samba -> $SAMBA_DIR" 158 rm samba 159 ln -s $SAMBA_DIR samba 160 fi 161 else 162 if [[ -e samba ]] 163 then 164 echo "non-symlink \$GOPATH/src/github.com/swiftstack/ProxyFS/vfs/samba cannot pre-exist" 165 exit 1 166 else 167 echo "establishing samba -> $SAMBA_DIR" 168 ln -s $SAMBA_DIR samba 169 fi 170 fi 171 cd samba 172 if [[ -d bin ]] 173 then 174 echo "./configure has already been run" 175 else 176 ./configure 177 make clean 178 fi 179 if [[ -f bin/default/librpc/gen_ndr/ndr_smb_acl.h ]] 180 then 181 echo "make GEN_NDR_TABLES has already been run" 182 else 183 make clean 184 make GEN_NDR_TABLES 185 fi 186 echo "export SAMBA_SOURCE=\$GOPATH/src/github.com/swiftstack/ProxyFS/vfs/samba" >> ~vagrant/.bash_profile 187 188 # Install Python tox 189 190 pip install tox==3.5.3 191 192 # Setup Swift 193 # 194 # Guided by https://docs.openstack.org/swift/latest/development_saio.html 195 196 # [Setup Swift] Create the swift:swift user 197 198 useradd --user-group --groups wheel swift 199 chmod 755 ~swift 200 201 # Using loopback devices for storage 202 203 mkdir -p /srv 204 205 for x in 11 22 33 44 15 26 37 48 19 2A 3B 4C 206 do 207 node=${x:0:1} 208 drive=${x:1:1} 209 truncate -s 0 /srv/swift-disk-$drive 210 truncate -s 1GB /srv/swift-disk-$drive 211 mkfs.xfs -f /srv/swift-disk-$drive 212 mkdir -p /srv/$node/node/sdb$drive 213 echo "/srv/swift-disk-$drive /srv/$node/node/sdb$drive xfs loop,noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab 214 mount /srv/$node/node/sdb$drive 215 chown swift:swift /srv/$node/node/sdb$drive 216 done 217 218 # [Setup Swift] Common Post-Device Setup (Add /var boot-time provisioning to /etc/rc.d/rc.local) 219 220 echo "mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4" >> /etc/rc.d/rc.local 221 echo "chown swift:swift /var/cache/swift*" >> /etc/rc.d/rc.local 222 echo "mkdir -p /var/run/swift" >> /etc/rc.d/rc.local 223 echo "chown swift:swift /var/run/swift" >> /etc/rc.d/rc.local 224 chmod +x /etc/rc.d/rc.local 225 226 # [Setup Swift] Do boot-time provisioning now... as if we just booted 227 228 mkdir -p /var/cache/swift /var/cache/swift2 /var/cache/swift3 /var/cache/swift4 229 chown swift:swift /var/cache/swift* 230 mkdir -p /var/run/swift 231 chown swift:swift /var/run/swift 232 233 # [Setup Swift] Getting the code 234 235 yum -y install \ 236 memcached \ 237 sqlite \ 238 xfsprogs \ 239 libffi-devel \ 240 xinetd \ 241 openssl-devel \ 242 python-setuptools \ 243 python-coverage \ 244 python-devel \ 245 python-nose \ 246 pyxattr \ 247 python-eventlet \ 248 python-greenlet \ 249 python-paste-deploy \ 250 python-netifaces \ 251 python-pip \ 252 python-dns \ 253 python-mock 254 255 pip install --upgrade setuptools 256 257 # Build liberasure.so from source 258 259 cd ~swift 260 git clone https://github.com/openstack/liberasurecode.git 261 cd liberasurecode 262 yum install -y gcc make autoconf automake libtool 263 ./autogen.sh 264 ./configure 265 make 266 make install 267 268 # Install it where Python/PyECLib will see it 269 270 echo "/usr/local/lib" > /etc/ld.so.conf.d/liberasurecode.conf 271 ldconfig 272 # Alternatively, we could simply have done 273 # ln -s /usr/local/lib/liberasurecode.so.1 /lib64/liberasurecode.so.1 274 275 # Install PyECLib from source 276 277 cd ~swift 278 git clone https://github.com/openstack/pyeclib.git 279 cd pyeclib 280 pip install -e . 281 pip install -r test-requirements.txt 282 283 # Install python-swiftclient from source & setup ENVs for its use 284 285 cd ~swift 286 git clone -b master --single-branch --depth 1 https://github.com/openstack/python-swiftclient.git 287 cd python-swiftclient 288 python setup.py develop 289 290 echo "export ST_AUTH=http://localhost:8080/auth/v1.0" >> ~vagrant/.bash_profile 291 echo "export ST_USER=test:tester" >> ~vagrant/.bash_profile 292 echo "export ST_KEY=testing" >> ~vagrant/.bash_profile 293 294 # Now we can actually install Swift from source 295 296 cd ~swift 297 git clone https://github.com/swiftstack/swift.git 298 cd swift 299 git checkout ss-release-2.26.0.5 300 pip install wheel 301 python setup.py bdist_wheel 302 yum remove -y python-greenlet 303 pip install --constraint py2-constraints.txt -r requirements.txt 304 python setup.py develop 305 # The following avoid dependency on pip-installed pyOpenSSL being newer than required 306 pip install python-openstackclient==3.12.0 python-glanceclient==2.7.0 307 # This is a temporary fix while bandit gets added to py2-constraints.txt 308 pip install bandit==1.6.2 309 pip install --constraint py2-constraints.txt -r test-requirements.txt 310 311 # [Setup Swift] Setting up rsync 312 313 cd /etc 314 cp ~swift/swift/doc/saio/rsyncd.conf . 315 sed -i "s/<your-user-name>/swift/" rsyncd.conf 316 317 cd /etc/xinetd.d 318 echo "disable = no" >> rsync 319 320 systemctl restart xinetd.service 321 systemctl enable rsyncd.service 322 systemctl start rsyncd.service 323 324 rsync rsync://pub@localhost/ 325 326 # [Setup Swift] Setting up memcached 327 328 systemctl enable memcached.service 329 systemctl start memcached.service 330 331 # [Setup Swift] Configuring each node 332 333 rm -rf /etc/swift 334 cp -R /vagrant/src/github.com/swiftstack/ProxyFS/saio/etc/swift /etc/swift 335 chown -R swift:swift /etc/swift 336 337 # [Setup Swift] Setting up scripts for running Swift 338 339 mkdir -p ~swift/bin 340 341 cd ~swift/bin 342 cp /vagrant/src/github.com/swiftstack/ProxyFS/saio/home/swift/bin/* . 343 echo "export PATH=\$PATH:~swift/bin" >> ~vagrant/.bash_profile 344 345 ~swift/bin/remakerings 346 347 # Install ProxyFS's pfs_middleware into the "normal" Swift Proxy pipeline 348 349 cd /vagrant/src/github.com/swiftstack/ProxyFS/pfs_middleware 350 python setup.py develop 351 352 # Install ProxyFS's meta_middleware into the "NoAuth" Swift Proxy pipeline 353 354 cd /vagrant/src/github.com/swiftstack/ProxyFS/meta_middleware 355 python setup.py develop 356 357 # Setup AWS access for local vagrant user 358 359 pip install awscli-plugin-endpoint 360 mkdir -p ~vagrant/.aws 361 cat > ~vagrant/.aws/config << EOF 362 [plugins] 363 endpoint = awscli_plugin_endpoint 364 365 [default] 366 s3 = 367 endpoint_url = http://127.0.0.1:8080 368 multipart_threshold = 64MB 369 multipart_chunksize = 16MB 370 s3api = 371 endpoint_url = http://127.0.0.1:8080 372 multipart_threshold = 64MB 373 multipart_chunksize = 16MB 374 EOF 375 cat > ~vagrant/.aws/credentials << EOF 376 [default] 377 aws_access_key_id = test:tester 378 aws_secret_access_key = testing 379 EOF 380 chown -R vagrant:vagrant ~vagrant/.aws 381 382 # Ensure proxyfsd logging will work 383 384 rm -rf /var/log/proxyfsd 385 mkdir -p /var/log/proxyfsd 386 touch /var/log/proxyfsd/proxyfsd.log 387 chmod 777 /var 388 chmod 777 /var/log 389 chmod 777 /var/log/proxyfsd 390 chmod 666 /var/log/proxyfsd/proxyfsd.log 391 392 # Create Mount Points for ProxyFS (FUSE, NFS, & SMB) 393 394 rm -rf /CommonMountPoint 395 mkdir /CommonMountPoint 396 chmod 777 /CommonMountPoint 397 398 rm -rf /AgentMountPoint 399 mkdir /AgentMountPoint 400 chmod 777 /AgentMountPoint 401 402 rm -rf /mnt/nfs_proxyfs_mount 403 mkdir /mnt/nfs_proxyfs_mount 404 chmod 777 /mnt/nfs_proxyfs_mount 405 406 rm -rf /mnt/smb_proxyfs_mount 407 mkdir /mnt/smb_proxyfs_mount 408 chmod 777 /mnt/smb_proxyfs_mount 409 410 # Configure exports (NFS) / shares (SMB) 411 412 cp /vagrant/src/github.com/swiftstack/ProxyFS/saio/etc/exports /etc/exports 413 cp /vagrant/src/github.com/swiftstack/ProxyFS/saio/etc/samba/smb.conf /etc/samba/smb.conf 414 echo -e "swift\nswift" | smbpasswd -a swift 415 416 # Install Kerberos Client to SDOM{1|2|3|4}.LOCAL hosted by sdc{1|2|3|4}.sdom{1|2|3|4}.local 417 418 yum -y install krb5-workstation 419 420 cat >> /etc/hosts << EOF 421 172.28.128.11 sdc1 sdc1.sdom1.local 422 172.28.128.12 sdc2 sdc2.sdom2.local 423 172.28.128.13 sdc3 sdc3.sdom3.local 424 172.28.128.14 sdc4 sdc4.sdom4.local 425 172.28.128.21 saio1 saio1.sdom1.local 426 172.28.128.22 saio2 saio2.sdom2.local 427 172.28.128.23 saio3 saio3.sdom3.local 428 172.28.128.24 saio4 saio4.sdom4.local 429 EOF 430 431 cat > /etc/krb5.conf.d/SambaDCs << EOF 432 [libdefaults] 433 dns_lookup_kdc = false 434 435 [realms] 436 SDOM1.LOCAL = { 437 admin_server = sdc1.sdom1.local 438 kdc = sdc1.sdom1.local 439 default_domain = SDOM1 440 } 441 SDOM2.LOCAL = { 442 admin_server = sdc2.sdom2.local 443 kdc=sdc2.sdom2.local 444 default_domain = SDOM2 445 } 446 SDOM3.LOCAL = { 447 admin_server = sdc3.sdom3.local 448 kdc=sdc3.sdom3.local 449 default_domain = SDOM3 450 } 451 SDOM4.LOCAL = { 452 admin_server = sdc4.sdom4.local 453 kdc=sdc4.sdom4.local 454 default_domain = SDOM4 455 } 456 457 [domain_realm] 458 .sdom1.local = SDOM1.LOCAL 459 sdom1.local = SDOM1.LOCAL 460 .sdom2.local = SDOM2.LOCAL 461 sdom2.local = SDOM2.LOCAL 462 .sdom3.local = SDOM3.LOCAL 463 sdom3.local = SDOM3.LOCAL 464 .sdom4.local = SDOM4.LOCAL 465 sdom4.local = SDOM4.LOCAL 466 EOF 467 468 # Install systemd .service files for ProxyFS 469 470 cp /vagrant/src/github.com/swiftstack/ProxyFS/saio/usr/lib/systemd/system/proxyfsd.service /usr/lib/systemd/system/. 471 cp /vagrant/src/github.com/swiftstack/ProxyFS/saio/usr/lib/systemd/system/pfsagentd.service /usr/lib/systemd/system/. 472 473 # Place symlink in root's $PATH to locate pfsagentd-swift-auth-plugin referenced without a path 474 475 ln -s /vagrant/bin/pfsagentd-swift-auth-plugin /usr/bin/pfsagentd-swift-auth-plugin 476 477 # Enable Samba service in an SELinux environment 478 479 yum -y install policycoreutils-python 480 semanage port -a -t smbd_port_t -p tcp 12345 481 semanage port -a -t smbd_port_t -p tcp 32345 482 483 # Enable start/stop tools 484 485 echo "export PATH=\$PATH:/vagrant/src/github.com/swiftstack/ProxyFS/saio/bin" >> ~vagrant/.bash_profile 486 487 # Install wireshark 488 489 yum -y install wireshark-gnome \ 490 xorg-x11-fonts-Type1 \ 491 xorg-x11-xauth \ 492 xeyes 493 echo "X11Forwarding yes" >> /etc/sysconfig/sshd 494 systemctl restart sshd 495 usermod -aG wireshark vagrant 496 497 # Install benchmark support tools 498 499 yum -y install atop-2.3.0-8.el7 bc fio gawk 500 501 # Install ssh helper 502 503 yum -y install sshpass-1.06-2.el7 504 505 # Install dstat 506 507 yum -y install dstat 508 509 # Install tree 510 511 yum -y install tree 512 513 # Install jq... a very handy JSON parser 514 515 yum -y install jq 516 517 # Install and configure a localhost-only one-node etcd cluster 518 519 ETCD_VERSION=3.4.7 520 wget https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-linux-amd64.tar.gz 521 tar xzf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz 522 rm -rf etcd-v${ETCD_VERSION}-linux-amd64.tar.gz 523 install -C -m 755 etcd-v${ETCD_VERSION}-linux-amd64/etcd /usr/local/bin/ 524 install -C -m 755 etcd-v${ETCD_VERSION}-linux-amd64/etcdctl /usr/local/bin/ 525 rm -rf etcd-v${ETCD_VERSION}-linux-amd64 526 527 mkdir /etcd 528 529 cat > /etc/systemd/system/proxyfs-etcd.service << EOF 530 [Unit] 531 Description=ProxyFS etcd instance 532 After=network.target 533 StartLimitIntervalSec=0 534 535 [Service] 536 Type=simple 537 Restart=always 538 RestartSec=1 539 User=root 540 ExecStart=/usr/local/bin/etcd --name proxyfs --data-dir /etcd/proxyfs.etcd --initial-advertise-peer-urls http://localhost:2380 --listen-peer-urls http://localhost:2380 --listen-client-urls http://localhost:2379 --advertise-client-urls http://localhost:2379 --initial-cluster-token etcd-cluster --initial-cluster default=http://localhost:2380 --initial-cluster-state new 541 542 [Install] 543 WantedBy=multi-user.target 544 EOF 545 546 # Inform systemd that we've updated .service files 547 548 systemctl daemon-reload 549 550 # Add some VIPs 551 552 ip addr add dev enp0s8 172.28.128.21/24 553 ip addr add dev enp0s8 172.28.128.22/24 554 ip addr add dev enp0s8 172.28.128.23/24 555 ip addr add dev enp0s8 172.28.128.24/24 556 557 # All done 558 559 echo "SAIO for ProxyFS provisioned"