You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Ubuntu 16.04版Amazon EC2实例部署Corosync+Pacemaker集群咨询

Hey there! Let's break down your questions one by one and get you past that stuck step with Corosync/Pacemaker on Ubuntu 16.04 EC2 instances.

1. Do Corosync and Pacemaker support Ubuntu 16.04?

Absolutely. Ubuntu 16.04 (Xenial Xerus) includes both packages in its default repositories, so you can install them directly with:

sudo apt-get install corosync pacemaker pcs

Note that pcs is the recommended CLI tool for managing the cluster—it ties together Corosync and Pacemaker into a single, easy-to-use management interface.

A quick heads-up though: Ubuntu 16.04 reached end-of-life in April 2021, so you won't receive any security updates going forward. If possible, migrating to a newer LTS release like 20.04 or 22.04 would be better for long-term stability, but if you have to stick with 16.04, the cluster setup will still work as intended.

2. Do they support Amazon EC2 (Ubuntu) instances?

Yes, they do—but EC2 has a few virtualized networking quirks you need to account for:

  • Corosync relies on reliable cluster communication. EC2 doesn't support cross-instance multicast by default, so you must configure unicast instead of multicast in your Corosync setup.
  • Always use your EC2 instances' private IP addresses for cluster communication (not public IPs). Public IPs can change if instances are stopped/started, and internal private network traffic is faster and more secure.
  • Make sure your EC2 security group allows inbound/outbound traffic on these ports: TCP 2224 (for pcsd), UDP 5404/5405 (Corosync cluster traffic), and TCP 3121 (Pacemaker).
3. How to sync multiple Amazon EC2 instances (with NextCloud in mind)?

Since you're using S3 as primary storage and RDS as your database, most of your shared state is already handled externally—which simplifies the cluster setup a lot! Let's walk through the steps, including fixing that private_binding_IP_address issue you hit.

Pre-Cluster Setup

  • Ensure all EC2 instances are in the same VPC (and same subnet, or connected via VPC peering if needed) with static private IPs (the default for EC2 instances unless you specify otherwise).
  • Set up a password for the hacluster user (created automatically during package installation) on every node:
    sudo passwd hacluster
    
  • Enable and start the pcsd service on all nodes to manage cluster authentication:
    sudo systemctl enable --now pcsd
    

Install & Configure Corosync/Pacemaker (Fixing the IP Binding Issue)

The private_binding_IP_address hangup usually comes from manual Corosync config edits. Using the pcs CLI avoids this by auto-configuring the correct private IP bindings and unicast settings for EC2. Here's how:

  1. On one node, authenticate all cluster nodes with each other (replace node1-private-ip, node2-private-ip with your instances' actual private IPs):
    sudo pcs cluster auth node1-private-ip node2-private-ip node3-private-ip -u hacluster -p your-hacluster-password
    
  2. Create the cluster (replace my-nextcloud-cluster with your preferred cluster name):
    sudo pcs cluster setup --name my-nextcloud-cluster node1-private-ip node2-private-ip node3-private-ip
    
    This command auto-generates the Corosync config with unicast enabled and binds each node to its private IP—no manual editing needed!
  3. Start the cluster on all nodes:
    sudo pcs cluster start --all
    
  4. Temporarily disable STONITH (fencing) for initial testing (we'll set up EC2-specific fencing later for production):
    sudo pcs property set stonith-enabled=false
    
    For production, you should configure the fence_ec2 agent to safely terminate failed EC2 instances and prevent split-brain scenarios.

NextCloud-Specific Cluster Configuration

Since your NextCloud data lives in S3 and your database is in RDS, each EC2 node just needs a consistent NextCloud setup and a way to route traffic to the active node:

  1. Install NextCloud on every EC2 node, configuring each instance to point to the same RDS database and S3 bucket. Ensure the config/config.php file is identical across all nodes (you can sync it via rsync or store it in EFS for shared access).
  2. Set up a floating Elastic IP (EIP) with Pacemaker so users connect to a single, stable IP that fails over to a healthy node:
    sudo pcs resource create nextcloud-fip ocf:heartbeat:aws-vpc-elastic-ip allocation_id=your-eip-allocation-id ip=node1-private-ip op monitor interval=30s
    
    Replace your-eip-allocation-id with the allocation ID of your EC2 Elastic IP.
  3. Create a resource to manage your NextCloud web service (adjust for Nginx if you're not using Apache):
    sudo pcs resource create nextcloud-service systemd:apache2 op monitor interval=10s
    
  4. Colocate the floating IP with the NextCloud service so they always run on the same node:
    sudo pcs constraint colocation add nextcloud-fip with nextcloud-service INFINITY
    
  5. Set an order constraint to start the web service before the floating IP:
    sudo pcs constraint order nextcloud-service then nextcloud-fip
    

Now your cluster will automatically fail over the NextCloud service and floating IP to a healthy node if any instance goes down.


内容的提问来源于stack exchange,提问作者ibr

火山引擎 最新活动