### Install 'pg' library for Node.js Source: https://docs.servercore.com/ru/managed-databases/postgresql/connect-to-cluster Installs the 'pg' npm package, which is a PostgreSQL client for Node.js. This is a prerequisite for using the provided connection example. No specific inputs or outputs are associated with this command. ```bash npm install pg ``` -------------------------------- ### Create Partition on Disk Source: https://docs.servercore.com/ru/block-storage/manage/connect-block-storage-to-esxi This command creates a new partition on a disk with specified parameters. It requires the disk path, partition scheme, partition number, start sector, end sector, and a partition type GUID. The output confirms the partition creation. ```bash partedUtil setptbl /dev/disks/ gpt " AA31E02A400F11DB9590000C2911D1B8 0" ``` -------------------------------- ### Install Cyberduck CLI on Windows using Chocolatey Source: https://docs.servercore.com/ru/s3/tools/cyberduck Installs the Cyberduck command-line interface on Windows using the Chocolatey package manager. Requires administrator privileges to run. ```bash choco install duck ``` -------------------------------- ### Install MinIO Client on Linux Source: https://docs.servercore.com/ru/s3/tools/minio-client Installs the MinIO Client (mc) on Linux using curl. It downloads the binary, makes it executable, and adds it to the system's PATH. Ensure you have curl installed and sufficient permissions. ```shell curl https://dl.min.io/client/mc/release/linux-amd64/mc \ --create-dirs \ -o $HOME/minio-binaries/mc chmod +x $HOME/minio-binaries/mc export PATH=$PATH:$HOME/minio-binaries/ ``` -------------------------------- ### Start Rclone Configuration Source: https://docs.servercore.com/ru/s3/tools/rclone Initiates the interactive configuration process for Rclone. This command will guide you through setting up new remote storage connections. ```bash rclone config ``` -------------------------------- ### Launch and Enable GeeseFS Launch Agent Source: https://docs.servercore.com/ru/s3/tools/geesefs These commands are used to activate and manage the GeeseFS launch agent. `launchctl bootstrap` loads the agent, `launchctl enable` ensures it starts on login, and `launchctl kickstart` immediately starts the agent. ```bash launchctl bootstrap gui/$(id -u) "$HOME/Library/LaunchAgents/.plist" launchctl enable gui/$(id -u)/ launchctl kickstart -k gui/$(id -u)/ ``` -------------------------------- ### Verify MinIO Client Installation Source: https://docs.servercore.com/ru/s3/tools/minio-client Checks if the MinIO Client (mc) is installed and accessible from the command line. This command should be run after installation on any operating system. ```shell mc --version ``` -------------------------------- ### Install GeeseFS Client on Linux Source: https://docs.servercore.com/ru/s3/tools/geesefs Installs the GeeseFS client on Linux systems. It ensures FUSE utilities are installed, downloads the latest release, makes it executable, and copies it to the system's PATH. Dependencies include `wget` and `apt-get`. ```bash apt list --installed | grep fuse sudo apt-get install fuse wget https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-linux-amd64 chmod a+x geesefs-linux-amd64 sudo cp geesefs-linux-amd64 /usr/bin/geesefs ``` -------------------------------- ### Install GeeseFS Client on macOS Source: https://docs.servercore.com/ru/s3/tools/geesefs Installs the GeeseFS client on macOS systems. It first checks the system architecture to download the correct binary, makes it executable, and copies it to the system's local bin directory. Dependencies include `wget` and `macFUSE`. ```bash platform='arm64' if [[ $(uname -m) == 'x86_64' ]]; then platform='amd64'; fi wget https://github.com/yandex-cloud/geesefs/releases/latest/download/geesefs-mac-$platform chmod a+x geesefs-mac-$platform sudo cp geesefs-mac-$platform /usr/local/bin/geesefs ``` -------------------------------- ### Install Composer and AWS SDK for PHP Source: https://docs.servercore.com/ru/api/object-storage-s3 These commands show how to install the Composer dependency manager and the AWS SDK for PHP. Composer is essential for managing PHP libraries, and the SDK simplifies integration with AWS services like S3. ```bash curl -sS 'https://getcomposer.org/installer' | php php composer.phar require aws/aws-sdk-php ``` -------------------------------- ### Install Cyberduck CLI on macOS using Homebrew Source: https://docs.servercore.com/ru/s3/tools/cyberduck Installs the Cyberduck command-line interface on macOS using the Homebrew package manager. This involves installing the 'duck' package. ```bash brew install duck ``` -------------------------------- ### Install Cyberduck CLI on Linux (Debian/Ubuntu) Source: https://docs.servercore.com/ru/s3/tools/cyberduck Installs the Cyberduck command-line interface on Debian/Ubuntu based Linux distributions. This involves adding a repository, GPG key, updating package lists, and installing the package. ```bash sudo echo 'deb https://s3.amazonaws.com/repo.deb.cyberduck.io nightly main' >> /etc/apt/sources.list.d/cyberduck.list sudo echo 'deb https://s3.amazonaws.com/repo.deb.cyberduck.io stable main' >> /etc/apt/sources.list.list sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FE7097963FEFBE72 sudo apt-get update sudo apt-get install duck ``` -------------------------------- ### Install Redis and connect without SSL using Python Source: https://docs.servercore.com/ru/managed-databases/redis/connect-to-cluster Install the redis Python library and connect to a Redis cluster without SSL. Requires host, password, and port. Demonstrates setting and getting a key-value pair. ```bash pip install redis ``` ```python import redis r = redis.Redis( host="", password=r"", port=, db=0, ) print(r.set("KEY", "VALUE")) print(r.get("KEY")) ``` -------------------------------- ### Bash: Инициализация скрипта резервного копирования Source: https://docs.servercore.com/ru/s3/manage/create-backup-on-schedule Инициализирует bash-скрипт, определяя переменные для временной метки, исходного пути, пути назначения и имени файла. Эти переменные используются для генерации уникальных имен файлов и указания местоположения данных. ```bash #!/bin/bash DATETIME=`date +%y%m%d-%H_%M_%S` SRC=$1 DST=$2 GIVENNAME=$3 ``` -------------------------------- ### Install ioredis and connect without SSL using Node.js Source: https://docs.servercore.com/ru/managed-databases/redis/connect-to-cluster Install the ioredis client using npm and connect to a Redis cluster without SSL. Requires host, port, and password. Demonstrates setting and getting a key-value pair. ```bash npm install ioredis ``` ```javascript const Redis = require('ioredis'); const config = { host: '', port: , password: '', }; const connection = new Redis(config); connection.set('key', 'value', (error) => { if (error) throw error; }); connection.get('key', (error, res) => { if (error) throw error; console.log(res); connection.disconnect(); }); ``` -------------------------------- ### Bash: Функция помощи для скрипта резервного копирования Source: https://docs.servercore.com/ru/s3/manage/create-backup-on-schedule Определяет функцию `showhelp` в bash-скрипте, которая выводит справочное сообщение. Эта функция вызывается в случае непредвиденных ошибок или для предоставления инструкций пользователю. ```bash #!/bin/bash DATETIME=`date +%y%m%d-%H_%M_%S` SRC=$1 DST=$2 GIVENNAME=$3 showhelp( echo "\n This script will backup files/folders into a single compressed file and will store it in the current folder." ) ``` -------------------------------- ### Terraform CLI: Инициализация конфигурации Source: https://docs.servercore.com/ru/terraform/examples/cloud-servers/create-flavor Команда Terraform CLI для инициализации рабочего каталога. Загружает необходимые провайдеры и модули, указанные в конфигурации. Это первый шаг перед выполнением других команд Terraform. ```bash terraform init ``` -------------------------------- ### Install Predis and connect without SSL using PHP Source: https://docs.servercore.com/ru/managed-databases/redis/connect-to-cluster Install the predis/predis library using Composer and connect to a Redis cluster without SSL. Requires host, port, and password. Demonstrates setting and getting a key-value pair. ```bash composer require predis/predis ``` ```php :']; $options = [ 'parameters' => [ 'password' => "" ], 'cluster' => 'predis' ]; $conn = new Predis\Client($host, $options); $conn->set('KEY', 'VALUE'); var_dump($conn->get('KEY')); $conn->disconnect(); ?> ``` -------------------------------- ### Отключить синхронизацию сети с cloud-init (Linux) Source: https://docs.servercore.com/ru/cloud-networks/update-network-settings Отключает синхронизацию сетевых настроек с cloud-init, чтобы пользовательские настройки сохранялись после перезагрузки сервера. Требует прав суперпользователя. ```bash echo "network: {config: disabled}" >> /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg ``` -------------------------------- ### Install Volume Snapshot Controller (Bash) Source: https://docs.servercore.com/ru/managed-kubernetes/volumes/volume-snapshots Installs the Volume Snapshot Controller, a CSI Snapshotter component, using kubectl. This is a prerequisite for creating volume snapshots. It applies a YAML configuration file from a GitHub repository. ```bash kubectl apply -f https://raw.githubusercontent.com/servercore/mks-csi-snapshotter/master/deploy/setup-snapshot-controller.yaml ``` -------------------------------- ### List Available File Systems Source: https://docs.servercore.com/ru/block-storage/manage/connect-block-storage-to-esxi This command lists all available file systems on the ESXi host, including newly created VMFS datastores. It helps verify that the datastore is recognized by the system. ```bash esxcli storage filesystem list ``` -------------------------------- ### Set Up MinIO Client Alias Source: https://docs.servercore.com/ru/s3/tools/minio-client Configures an alias for connecting to an S3-compatible service using MinIO Client. Requires the alias name, S3 domain, Access Key, and Secret Key. This command sets up a named connection profile. ```shell mc alias set https:// ``` -------------------------------- ### Get Usable Sectors for Disk Partitioning Source: https://docs.servercore.com/ru/block-storage/manage/connect-block-storage-to-esxi This command retrieves the range of usable sectors on a disk, which is necessary for creating partitions. It requires the device path as input and returns the start and end sectors available for use. ```bash partedUtil getUsableSectors /dev/disks/ ``` -------------------------------- ### Volume Snapshot Manifest Example (YAML) Source: https://docs.servercore.com/ru/managed-kubernetes/volumes/volume-snapshots Defines a VolumeSnapshotClass and a VolumeSnapshot resource. The VolumeSnapshotClass specifies the driver and deletion policy, while the VolumeSnapshot defines the snapshot name and the source PersistentVolumeClaim. ```yaml --- apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshotClass metadata: name: csi-hostpath-snapclass-v1 driver: cinder.csi.openstack.org deletionPolicy: Delete parameters: force-create: "true" --- apiVersion: snapshot.storage.k8s.io/v1 kind: VolumeSnapshot metadata: name: new-snapshot-demo spec: volumeSnapshotClassName: csi-hostpath-snapclass-v1 source: persistentVolumeClaimName: my-pv-claim ``` -------------------------------- ### Настройка маршрута через Netplan (Ubuntu/Debian) Source: https://docs.servercore.com/ru/managed-databases/postgresql-for-1c/create-network-to-dedicated-server Добавление статического маршрута в конфигурационный файл Netplan для Ubuntu и Debian. Требует указания подсети, маски и шлюза. ```yaml routes: - to: / via: ``` ```shell sudo netplan try netplan apply ``` -------------------------------- ### List Objects with Marker Parameter Source: https://docs.servercore.com/ru/api/object-storage-swift This example shows how to retrieve a list of objects from a bucket starting from a specific object using the Swift API. The `marker` query parameter specifies the object name after which the listing should begin. ```curl curl -i -H 'X-Auth-Token: ' 'https:///v1//?marker=' ``` -------------------------------- ### Terraform CLI: Валидация конфигурации Source: https://docs.servercore.com/ru/terraform/examples/cloud-servers/create-flavor Команда Terraform CLI для проверки синтаксической корректности конфигурационных файлов. Убеждается, что все файлы `.tf` написаны правильно и не содержат ошибок. Помогает выявить проблемы до применения изменений. ```bash terraform validate ``` -------------------------------- ### Download SSL Certificate and Connect via PowerShell Source: https://docs.servercore.com/ru/managed-databases/postgresql/connect-to-cluster This snippet demonstrates downloading the root SSL certificate and connecting to the database cluster using PowerShell. It requires PowerShell to be available for executing the commands. ```powershell psql "host= ` port= ` dbname= ` user= ` sslmode=verify-ca" ``` -------------------------------- ### List Objects with Prefix Parameter Source: https://docs.servercore.com/ru/api/object-storage-swift This example demonstrates how to retrieve a list of objects from a bucket whose names start with a specific sequence of characters using the Swift API. The `prefix` query parameter filters the object names. ```curl curl -i -H 'X-Auth-Token: ' 'https:///v1//?prefix=my' ``` -------------------------------- ### Node.js SCRAM-SHA-512 Kafka Consumer Setup Source: https://docs.servercore.com/ru/managed-databases/kafka/connect-to-cluster Sets up a Node.js Kafka consumer using the kafkajs library with SCRAM-SHA-512 authentication. It requires the Kafka brokers, username, and password. This example initializes the Kafka client and creates a consumer instance with a specified group ID. ```javascript const { Kafka } = require('kafkajs'); const config = { brokers: [':'], ssl: false, sasl: { mechanism: 'scram-sha-512', username: '', password: '', }, }; const kafka = new Kafka(config); const consumer = kafka.consumer({ groupId: 'example' }); ``` -------------------------------- ### Get pg_repack Extension Version SQL Query Source: https://docs.servercore.com/ru/managed-databases/timescaledb/use-disk-space This SQL query is used to determine the installed version of the `pg_repack` extension within a PostgreSQL database. It fetches the extension name, version, and schema, which is crucial for ensuring compatibility between the extension and its client. ```sql SELECT extname AS extension, extversion AS version, extnamespace::regnamespace AS schema FROM pg_extension WHERE extname = 'pg_repack'; ``` -------------------------------- ### Configure Multipath-IO with Default Settings Source: https://docs.servercore.com/ru/block-storage/manage/connect-block-storage-to-proxmox Sets up the Multipath I/O configuration file (`/etc/multipath.conf`) with basic parameters for user-friendly names and automatic path discovery. This involves editing the file using `vi` and then restarting the `multipathd` service. ```bash vi /etc/multipath.conf :wq ``` ```bash systemctl restart multipathd ``` -------------------------------- ### Get pg_repack Extension Version with SQL Source: https://docs.servercore.com/ru/managed-databases/postgresql/use-disk-space This SQL query retrieves the name, version, and schema of the 'pg_repack' extension installed in a PostgreSQL database. It queries the `pg_extension` catalog table. Knowing the extension version is crucial for downloading the compatible `pg_repack` client. ```sql SELECT extname AS extension, extversion AS version, extnamespace::regnamespace AS schema FROM pg_extension WHERE extname = 'pg_repack'; ``` -------------------------------- ### Go Kafka Producer with SCRAM-SHA-512 Source: https://docs.servercore.com/ru/managed-databases/kafka/connect-to-cluster This Go snippet shows how to configure a Kafka producer using the `sarama` library with SCRAM-SHA-512 authentication. It sets up TLS configuration, SASL credentials, and producer-specific settings to establish a secure connection to the Kafka broker. This example is a partial setup and would typically be followed by message production logic. ```go package main import ( "crypto/tls" "crypto/x509" "fmt" "io/ioutil" "strings" "github.com/IBM/sarama" ) const BROKERS = ":" const USER = "" const PASSWORD = "" ``` -------------------------------- ### Подключение к кластеру без SSL (Python) Source: https://docs.servercore.com/ru/managed-databases/postgresql/connect-to-cluster Пример кода на Python для подключения к базе данных с использованием библиотеки psycopg2. Требуется установка библиотеки 'pip3 install psycopg2-binary' и указание хоста, имени базы данных, имени пользователя, пароля и порта. ```python import psycopg2 conn = psycopg2.connect(""") host= dbname= user= password= port= ") cur = conn.cursor() cur.execute('SELECT 40+2') print(cur.fetchone()) cur.close() conn.close() ``` -------------------------------- ### Install Rclone Client on Linux/macOS Source: https://docs.servercore.com/ru/s3/tools/rclone This command installs the Rclone client on Linux or macOS using a provided installation script. Ensure you have sudo privileges. This method is recommended for ease of use. ```bash sudo -v ; curl https://rclone.org/install.sh | sudo bash ``` -------------------------------- ### List vSwitch Configuration using esxcli Source: https://docs.servercore.com/ru/block-storage/manage/connect-block-storage-to-esxi This command shows the current configuration of standard virtual switches, including their names, port counts, uplink interfaces, and associated port groups. It is used to verify existing configurations. ```bash esxcli network vswitch standard list ``` -------------------------------- ### Go: Подключение к базе данных с SSL Source: https://docs.servercore.com/ru/managed-databases/timescaledb/connect-to-cluster Пример подключения к базе данных PostgreSQL с использованием библиотеки pgx в Go. Требуется установка pgx и указание пути к корневому сертификату в строке подключения. ```go package main import ( "context" "fmt" "os" "github.com/jackc/pgx/v4" ) func main() { connectionString := fmt.Sprintf("postgres://%s:%s@%s:/%s?sslmode=verify-ca&sslrootcert=%s", "", "", "", "", "" ) conn, err := pgx.Connect(context.Background(), connectionString) if err != nil { fmt.Fprintf(os.Stderr, "Unable to connect to database: %v\n", err) os.Exit(1) } defer conn.Close(context.Background()) var sum int64 err = conn.QueryRow(context.Background(), "SELECT 40+2").Scan(&sum) if err != nil { fmt.Fprintf(os.Stderr, "QueryRow failed: %v\n", err) os.Exit(1) } fmt.Println(sum) } ``` -------------------------------- ### Настройка Nextcloud с локальной БД через cloud-init Source: https://docs.servercore.com/ru/cloud-servers/applications/nextcloud-onlyoffice Этот скрипт cloud-init используется для первоначальной настройки Nextcloud, включая создание администратора и домена, при использовании локальной базы данных. Он записывает конфигурацию в файл /opt/main.yml. ```cloud-config #cloud-config write_files: - path: "/opt/main.yml" permissions: "0644" content: | nextcloud_admin_name: "" nextcloud_admin_pwd: "" nextcloud_admin_email: "" nextcloud_domain: "" ```