Tech:Swift

    From Miraheze Meta, Miraheze's central coordination wiki

    Swift is a OpenStack run project that offers cloud storage software using a API.

    Remember to run . /etc/swift-env.sh, which will make sure you have the credentials for the swift command.

    List containers / objects[edit | edit source]

    • To list all containers by doing swift list.
    • To list all files within a container by doing swift list <container>.
    • To list all files within a path by doing swift list <container> --prefix <folder name or object name>.
    • To report the size, you can either add -l or in human format --lh.

    Transferring files (swift upload and swift download)[edit | edit source]

    • To download files from a wiki, you can use swift download miraheze-examplewiki-local-public -D examplewiki-images.
    • To upload files to a container (for example if manually providing a dump) you can use swift upload miraheze-examplewiki-dumps-backup <filename>.

    Statistics[edit | edit source]

    You can run the following swift stat <container> to get the stats on the container.

    You can run the following swift stat <container> <file name> to get stats for a file.

    Create an account file[edit | edit source]

    1. Run swift-ring-builder account.builder create 10 1 1.
      Pictogram voting info.svg Note: The partition size must be nearest to the power of 2.
    2. Run swift-ring-builder account.builder rebalance.
    3. Run swift-ring-builder account.builder to see your changes.
    4. Once you are happy with the changes, deploy the account file by copying to /root/private/files/swift.

    Adding a new account server[edit | edit source]

    You can find this file at /root/private/files/swift. Copy it elsewhere so your changes aren't deployed unless you are happy with them. After you've run the following, copy the files back to /root/private/files/swift.

    1. Run the following, remember to replace where <REPLACE_HINT> are listed. swift-ring-builder account.builder add --region 1 --zone 1 --ip <REPLACE_IP> --port 6000 --device <REPLACE_HARDDRIVE_NAME> --weight 100.
      Pictogram voting info.svg Note: --device is basically the folder it'll be stored under /srv/node on the swift account server you are adding.
    2. Run swift-ring-builder account.builder rebalance.
    3. You can see your changes with swift-ring-builder account.builder.
    4. Once you are happy with the changes, deploy the account file by copying back to /root/private/files/swift.

    Create a container file[edit | edit source]

    1. Run swift-ring-builder container.builder create 10 1 1.
      Pictogram voting info.svg Note: The partition size must be nearest to the power of 2.
    2. Run swift-ring-builder container.builder rebalance.
    3. Run swift-ring-builder container.builder to see your changes.
    4. Once you are happy with the changes, deploy the container file by copying to /root/private/files/swift.

    Adding a new container server[edit | edit source]

    You can find this file at /root/private/files/swift. Copy it elsewhere so your changes aren't deployed unless you are happy with them. After you've run the following, copy the files back to /root/private/files/swift.

    1. Run the following, remember to replace where <REPLACE_HINT> are listed. swift-ring-builder container.builder add --region 1 --zone 1 --ip <REPLACE_IP> --port 6000 --device <REPLACE_HARDDRIVE_NAME> --weight 100.
      Pictogram voting info.svg Note: --device is basically the folder it'll be stored under /srv/node on the swift account server you are adding.
    2. Run swift-ring-builder container.builder rebalance.
    3. You can see your changes with swift-ring-builder container.builder.
    4. Once you are happy with the changes, deploy the container files by copying back to /root/private/files/swift.

    Create an object file[edit | edit source]

    1. Run swift-ring-builder object.builder create 10 1 1.
      Pictogram voting info.svg Note: The partition size must be nearest to the power of 2.
    2. Run swift-ring-builder object.builder rebalance.
    3. Run swift-ring-builder container.builder to see your changes.
    4. Once you are happy with the changes, deploy the object file by copying to /root/private/files/swift.

    Adding a new object server[edit | edit source]

    You can find this file at /root/private/files/swift. Copy it elsewhere, so your changes aren't deployed unless you are happy with them. After you've run the following, copy the files back to /root/private/files/swift.

    1. Run the following, remember to replace where <REPLACE_HINT> are listed. swift-ring-builder object.builder add --region 1 --zone 1 --ip <REPLACE_IP> --port 6000 --device <REPLACE_HARDDRIVE_NAME> --weight 100.
      Pictogram voting info.svg Note: --device is basically the folder it'll be stored under /srv/node on the swift object server you are adding.
    2. Run swift-ring-builder object.builder rebalance.
    3. You can see your changes with swift-ring-builder object.builder.
    4. Once you are happy with the changes, deploy the object file by copying back to /root/private/files/swift.

    Help Resources[edit | edit source]