All Products
Search
Document Center

Elastic Compute Service:Modify instance configurations and install applications

Last Updated:Mar 11, 2024

You can use Cloud Assistant to compile commands used to modify configurations or install applications and run the commands on multiple Elastic Compute Service (ECS) instances at the same time. This eliminates the need to log on to instances one by one and helps save time. In this topic, shell commands for Linux are used to describe how to modify instance configurations.

Background information

  • Before you view the system configurations of ECS instances, make sure that you are familiar with Cloud Assistant and how to use Cloud Assistant. For more information, see Overview and Use Cloud Assistant.

  • The operating systems and system configurations of ECS instances determine whether the sample commands described in this topic can run on the instance. We recommend that you modify the command content based on your business requirements. You can include custom parameters {{key}} in commands to increase the applicability of the commands.

    Note

    The execution status and results of Cloud Assistant commands may vary based on the operating systems and system configurations of ECS instances. You can view the error messages in the execution results and troubleshoot the issues in the ECS console or by calling an API operation. For more information, see Check execution results and troubleshoot common issues.

Modify instance configurations

  • Scenario: Use Cloud Assistant to modify the configurations of ECS instances.

  • Procedure

    1. Create a Cloud Assistant command and run the command on an ECS instance.

      For more information, see Create a command and Run a command.

      You can run the following sample Cloud Assistant command to add, delete, and modify user information. In this example, the useradd -m -p test** student command is run to add a user.

      # Add a user and configure a password for the user. {{password}} is the key of a custom parameter. You must specify a value for the key before you run the command.
      useradd -m -p {{password}} {{newUser}}
      # Change the password.
      passwd {{password}}
      # Delete the user.
      userdel {{newUser}}
      # Modify the username.
      usermod -l {{newUser}} -d /home/{{newUser}} -m {{previousUser}}
    2. Connect to the instance.

      For more information, see Connect to a Linux instance by using a password or key.

    3. On the instance logon page, view the added user.

      [root@EcsHost ~]# su - student -c pwd
      /home/student

Install applications

  • Scenario: Use Cloud Assistant to install applications on multiple ECS instances at the same time. This reduces repeated installation and deployment operations.

  • Procedure

    1. Create a Cloud Assistant command and then run the command on an ECS instance.

      For more information, see Create a command and Run a command.

      You can run the following sample Cloud Assistant command to install Python 3. Python 3 is suitable for operating systems that use YUM, such as CentOS:

      yum install zlib zlib-devel readline-devel sqlite-devel bzip2-devel openssl-devel gdbm-devel libdbi-devel ncurses-libs kernel-devel libxslt-devel libffi-devel python-devel zlib-devel openldap-devel sshpass gcc git -y
      wget -c https://www.python.org/ftp/python/3.6.6/Python-3.6.6.tgz
      tar -xzvf Python-3.6.6.tgz
      cd Python-3.6.6
      ./configure --prefix=/usr/local/python3
      make all
      make install
      make clean
      make distclean  
      ln -s /usr/local/python3/bin/python3 /usr/bin/python3
      ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
    2. Connect to the instance.

      For more information, see Connect to a Linux instance by using a password or key.

    3. On the instance logon page, run the python3 command to check whether Python 3 is installed.

      • The following command output indicates that Python 3 is installed:

        [root@EcsHost ~]# python3
        Python 3.6.6 (default, Jan 10 20**, 14:09:05)
        [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
        Type "help", "copyright", "credits" or "license" for more information.
        >>>
      • If the command not found error message is returned, Python 3 is not installed.

Upgrade applications

  • Scenario: Use Cloud Assistant to upgrade applications on ECS instances.

  • Procedure

    1. Create a Cloud Assistant command and then run the command on an ECS instance.

      For more information, see Create a command and Run a command.

      You can run the following sample Cloud Assistant command to upgrade Python from 3.6.0 to 3.7.0:

      wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz && rm -rf /usr/bin/python3
      tar -xzvf Python-3.7.0.tgz
      cd Python-3.7.0
      ./configure && make && make install
      ln -s /usr/local/bin/python3.7 /usr/bin/python3
      ln -s /usr/local/bin/python3.7-config /usr/bin/python-config
      python3 -V
    2. Connect to the instance.

      For more information, see Connect to a Linux instance by using a password or key.

    3. On the instance logon page, run the python3 -V command to check whether the application is upgraded.

      [root@EcsHost ~]# python3 -V
      Python 3.7.0