oci compute management
npx skills add https://github.com/acedergren/oci-agent-skills --skill OCI Compute Management
Skill 文档
OCI Compute Management Skill
You are an expert in Oracle Cloud Infrastructure compute instance management. Use this skill when the user needs to work with compute instances, including VMs, bare metal servers, and instance configurations.
Core Capabilities
Instance Lifecycle Management
- Launch instances: Create new compute instances with proper shape, image, networking, and storage configuration
- Terminate instances: Safely shut down and remove instances
- Instance actions: Start, stop, reboot, and reset instances
- Update instances: Modify instance metadata, display name, and other properties
Instance Discovery and Monitoring
- List instances: Find instances by compartment, state, availability domain, or tags
- Get instance details: Retrieve comprehensive information about specific instances
- Monitor metrics: Check CPU, memory, network, and disk utilization
- Console access: Establish serial console connections for troubleshooting
Networking and Storage
- VNIC management: List and manage virtual network interface cards
- Boot volumes: Work with boot volume configurations and backups
- Block volumes: Attach and detach additional storage volumes
- Private IPs: Manage secondary private IP addresses
OCI CLI Commands Reference
Listing Instances
# List all instances in a compartment
oci compute instance list --compartment-id <compartment-ocid>
# List running instances only
oci compute instance list --compartment-id <compartment-ocid> --lifecycle-state RUNNING
# List instances in specific availability domain
oci compute instance list --compartment-id <compartment-ocid> --availability-domain <ad-name>
Instance Details
# Get detailed information about an instance
oci compute instance get --instance-id <instance-ocid>
# Get VNIC attachments for an instance
oci compute vnic-attachment list --compartment-id <compartment-ocid> --instance-id <instance-ocid>
# Get console connection for troubleshooting
oci compute instance-console-connection list --compartment-id <compartment-ocid> --instance-id <instance-ocid>
Instance Actions
# Launch a new instance
oci compute instance launch \
--availability-domain <ad-name> \
--compartment-id <compartment-ocid> \
--shape <shape-name> \
--subnet-id <subnet-ocid> \
--image-id <image-ocid> \
--display-name "MyInstance"
# Start a stopped instance
oci compute instance action --action START --instance-id <instance-ocid>
# Stop a running instance
oci compute instance action --action STOP --instance-id <instance-ocid>
# Reboot an instance
oci compute instance action --action REBOOT --instance-id <instance-ocid>
# Terminate an instance
oci compute instance terminate --instance-id <instance-ocid>
Instance Configuration
# Update instance display name
oci compute instance update --instance-id <instance-ocid> --display-name "NewName"
# List available shapes
oci compute shape list --compartment-id <compartment-ocid>
# List available images
oci compute image list --compartment-id <compartment-ocid> --operating-system "Oracle Linux"
Best Practices
Instance Planning
- Choose appropriate shapes: Match workload requirements to instance shapes (CPU, memory, network bandwidth)
- Select correct image: Use official Oracle Linux, Ubuntu, or custom images
- Plan networking: Ensure subnets, security lists, and NSGs are configured before launching
- Availability domains: Distribute instances across ADs for high availability
Security Considerations
- Use IAM policies: Apply least-privilege access for instance management
- Security groups: Configure network security groups (NSGs) for fine-grained control
- SSH key management: Use strong SSH keys and rotate regularly
- Console access: Only create console connections when necessary for troubleshooting
Cost Optimization
- Right-sizing: Choose shapes that match actual workload requirements
- Stop unused instances: Stop instances during non-business hours if possible
- Use flexible shapes: Leverage flexible VM shapes to adjust OCPUs and memory
- Monitor utilization: Regularly review metrics to identify underutilized instances
Operational Excellence
- Tagging strategy: Apply consistent tags for cost tracking and organization
- Backup strategy: Implement regular boot volume backups
- Monitoring: Set up alarms for instance health and performance metrics
- Documentation: Maintain clear documentation of instance purposes and configurations
Common Workflows
Creating a Web Server Instance
- Identify the compartment and subnet for the instance
- Select appropriate shape (e.g., VM.Standard.E4.Flex)
- Choose Oracle Linux or Ubuntu image
- Configure ingress rules for HTTP/HTTPS in security list or NSG
- Launch instance with cloud-init script to install web server
- Verify instance is running and accessible
Troubleshooting Instance Issues
- Check instance lifecycle state and any error messages
- Review console history for boot/startup errors
- Verify VNIC attachment and network configuration
- Check security list and NSG rules
- Establish serial console connection if needed
- Review OCI monitoring metrics for resource bottlenecks
Instance Migration
- Create custom image from source instance
- Launch new instance in target compartment/region using custom image
- Verify application functionality
- Update DNS or load balancer configuration
- Terminate old instance after validation period
Error Handling
Common errors and resolutions:
- “Out of capacity”: Try different availability domain or shape
- “Authorization failed”: Verify IAM policies grant necessary permissions
- “Subnet not found”: Ensure subnet exists and is in correct compartment
- “Shape not available”: Check service limits and shape availability in region
- “Instance stuck in provisioning”: Check console history for errors, may need to terminate and relaunch
Integration with Other Skills
- Networking: Coordinate with VCN and subnet management for network setup
- Monitoring: Use monitoring skill to track instance health and performance
- Database: For database workloads, consider dedicated database services
- Load Balancing: Integrate instances with OCI load balancers for HA
- Storage: Work with block volume management for additional storage needs
When to Use This Skill
Activate this skill when the user mentions:
- Creating, launching, or provisioning compute instances or VMs
- Starting, stopping, rebooting, or terminating instances
- Checking instance status, health, or details
- Troubleshooting instance connectivity or performance issues
- Managing instance networking (VNICs, IPs)
- Configuring or modifying instance properties
- Instance migration or scaling operations
- Compute shapes, images, or availability domains
Example Interactions
User: “Launch a new web server instance in my production compartment” Response: Use this skill to guide through shape selection, image choice, subnet configuration, and launch command execution.
User: “Why is my instance not responding?” Response: Use this skill to systematically troubleshoot – check state, review console history, verify networking, and establish console connection if needed.
User: “List all running instances in us-phoenix-1” Response: Use this skill to execute appropriate list command with lifecycle-state filter and present results clearly.