diff --git a/content/en/docs/Administration/basic-configuration.md b/content/en/docs/Administration/basic-configuration.md index 606c1e5040ac97a0d4e098bd70f6deb4bd99f85d..92ed64576ceec434e689b9a63e3d7e1e6c638e3b 100644 --- a/content/en/docs/Administration/basic-configuration.md +++ b/content/en/docs/Administration/basic-configuration.md @@ -26,7 +26,7 @@ System locale settings are stored in the /etc/locale.conf file and can be modifi To display the current locale status, run the following command: ``` -localectl status +$ localectl status ``` Example command output: @@ -42,7 +42,7 @@ $ localectl status To display available locales, run the following command: ``` -localectl list-locales +$ localectl list-locales ``` You can check that by listing all Chinese locales with the following command: @@ -56,7 +56,7 @@ zh_CN.UTF-8 To set the language environment, run the following command as the user **root**. In the command, _locale_ indicates the language type to be set. Run the **localectl list-locales** command to obtain the value range. Change the value based on the site requirements. ``` -localectl set-locale LANG=locale +# localectl set-locale LANG=locale ``` For example, if you want to use Simplified Chinese as the locale, run the following command as the user **root**: @@ -66,10 +66,10 @@ For example, if you want to use Simplified Chinese as the locale, run the follow ``` >![](public_sys-resources/icon-note.gif) **NOTE:** ->After the modification, log in again or run the following command to update the configuration file for the modification to take effect: -``` -source /etc/locale.conf -``` + +>After the modification, log in again or run the command `source /etc/locale.conf` as the user **root** to update the configuration file for the modification to take effect: + + ## Setting the Keyboard Layout @@ -79,7 +79,7 @@ Keyboard layout settings are stored in the /etc/locale.conf file and can be modi To display the current keyboard layout settings, run the following command: ``` -localectl status +$ localectl status ``` Example command output: @@ -95,7 +95,7 @@ $ localectl status To list all available keyboard layouts that can be configured on openEuler, run the following command: ``` -localectl list-keymaps +$ localectl list-keymaps ``` For example, the command output of the Chinese keyboard layout is as follows: @@ -109,7 +109,7 @@ cn To set the keyboard layout, run the following command as the user **root**. In the command, _map_ indicates the keyboard layout to be set. Run the **localectl list-keymaps** command to obtain the value range. Change it based on the site requirements. ``` -localectl set-keymap map +$ localectl set-keymap map ``` The keyboard layout will be equally applied to graphical user interfaces. @@ -135,7 +135,7 @@ This topic describes how to set the system date, time, and time zone by using ti To display the current date and time, run the following command: ``` -timedatectl +$ timedatectl ``` Example command output: @@ -158,7 +158,7 @@ Your system clock can be automatically synchronized with a remote server using t >If the remote NTP server is enabled to automatically synchronize the system clock, you cannot manually change the date and time. If you need to manually change the date or time, ensure that automatic NTP system clock synchronization is disabled. You can run the **timedatectl set-ntp no** command to disable the NTP service. ``` -timedatectl set-ntp boolean +# timedatectl set-ntp boolean ``` For example, to enable automatic remote time synchronization, run the following command: @@ -174,7 +174,7 @@ For example, to enable automatic remote time synchronization, run the following Run the following command as the user **root** to change the current date. In the command, _YYYY_ indicates the year, _MM_ indicates the month, and _DD_ indicates the day. Change them based on the site requirements. ``` -timedatectl set-time YYYY-MM-DD +# timedatectl set-time YYYY-MM-DD ``` For example, to change the current date to August 14, 2019, run the following command as the user **root**: @@ -190,7 +190,7 @@ For example, to change the current date to August 14, 2019, run the following co To change the current time, run the following command as the user **root**. In the command, _HH_ indicates the hour, _MM_ indicates the minute, and _SS_ indicates the second. Change them based on the site requirements. ``` -timedatectl set-time HH:MM:SS +# timedatectl set-time HH:MM:SS ``` For example, to change the current time to 15:57:24, run the following command: @@ -203,13 +203,13 @@ For example, to change the current time to 15:57:24, run the following command: To list all available time zones, run the following command: ``` -timedatectl list-timezones +$ timedatectl list-timezones ``` To change the current time zone, run the following command as the user **root**. In the command, _time\_zone_ indicates the time zone to be set. Change it based on the site requirements. ``` -timedatectl set-timezone time_zone +# timedatectl set-timezone time_zone ``` Imagine you want to identify which time zone is closest to your present location while you are in Asia. You can check that by listing all available time zones in Asia with the following command: @@ -251,19 +251,19 @@ To change the time zone to Asia/Shanghai, run the following command: To display the current date and time, run the following command: ``` -date +$ date ``` By default, the **date** command displays the local time. To display the time in Coordinated Universal Time \(UTC\), run the command with the \-\-utc or -u command line option: ``` -date --utc +$ date --utc ``` You can also customize the format of the displayed information by providing the + "format" option on the command line: ``` -date +"format" +$ date +"format" ``` **Table 1** Formatting options @@ -351,13 +351,13 @@ Example commands and outputs: To change the current time, run the date command with the \-\-set or -s option as the root user: Run the following command as the user **root**. In the command, _HH_ indicates the hour, _MM_ indicates the minute, and _SS_ indicates the second. Change them based on the site requirements. ``` -date --set HH:MM:SS +# date --set HH:MM:SS ``` By default, the date command sets the local time. To set the system clock in UTC instead, run the command with the \-\-utc or -u command line option: ``` -date --set HH:MM:SS --utc +# date --set HH:MM:SS --utc ``` For example, to change the current time to 23:26:00, run the following command as the user **root**: @@ -370,7 +370,7 @@ For example, to change the current time to 23:26:00, run the following command a To change the current date, run the command with the \-\-set or -s command line option. Run the following command as the user **root**. In the command, _YYYY_ indicates the year, _MM_ indicates the month, and _DD_ indicates the day. Change them based on the site requirements. ``` -date --set YYYY-MM-DD +# date --set YYYY-MM-DD ``` For example, to change the current date to November 2, 2019, run the following command as the user **root**: @@ -395,7 +395,7 @@ When Linux starts, it reads the RTC and sets the system clock time based on the To display the current RTC date and time, run the following command as the user **root**: ``` -hwclock +# hwclock ``` Example command output: @@ -409,7 +409,7 @@ Example command output: Run the following command as the user **root** to change the date and time of the current hardware. In the command, _dd_ indicates the day, _mm_ indicates the month, _yyyy_ indicates the year, _HH_ indicates the hour, and _MM_ indicates the minute. Change them based on the site requirements. ``` -hwclock --set --date "dd mm yyyy HH:MM" +# hwclock --set --date "dd mm yyyy HH:MM" ``` For example, to change the current time to 21:17 on October 21, 2019, run the following command: diff --git a/content/en/docs/Administration/configuring-the-ftp-server.md b/content/en/docs/Administration/configuring-the-ftp-server.md index 17d2f87eb5b53059a965e0ebe997e4b314867870..98104b86eed332120d8b8de539b866cb996812bb 100644 --- a/content/en/docs/Administration/configuring-the-ftp-server.md +++ b/content/en/docs/Administration/configuring-the-ftp-server.md @@ -74,7 +74,7 @@ To use the vsftpd service, you need to install the vsftpd software. If the yum s ### Service Management To start, stop, or restart the vsftpd service, run the corresponding command as the root user. -- Starting vsftpd services +- Starting vsftpd services ``` # systemctl start vsftpd @@ -88,10 +88,7 @@ To start, stop, or restart the vsftpd service, run the corresponding command as ``` >![](public_sys-resources/icon-note.gif) **NOTE:** - >If the netstat command does not exist, run the following command to install the netstat command and then run the netstat command: - >``` - >dnf install net-tools - >``` + >If the **netstat** command does not exist, run the **dnf install net-tools** command to install the **net-tools** software and then run the **netstat** command. - Stopping the vsftpd services @@ -146,7 +143,7 @@ You can modify the vsftpd configuration file to control user permissions. [Tabl

List of users who are allowed or not allowed to log in to the vsftpd server. Whether the file takes effect depends on the following parameters in the main configuration file vsftpd.conf:

userlist_enable: indicates whether to enable the userlist mechanism. The value YES indicates that the userlist mechanism is enabled. In this case, the userlist_deny configuration is valid. The value NO indicates that the userlist mechanism is disabled.

userlist_deny: indicates whether to forbid users in the user list to log in. YES indicates that users in the user list are forbidden to log in. NO indicates that users in the command are allowed to log in.

-

For example, if userlist_enable is set to YES and userlist_deny is set to NO, all users in the user list cannot log in.

+

For example, if userlist_enable is set to YES and userlist_deny is set to YES, all users in the user list cannot log in.

/etc/vsftpd/chroot_list

@@ -170,6 +167,7 @@ You can modify the vsftpd configuration file to control user permissions. [Tabl + ### Default Configuration Description >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -178,7 +176,7 @@ You can modify the vsftpd configuration file to control user permissions. [Tabl In the openEuler system, vsftpd does not open to anonymous users by default. Run the vim command to view the main configuration file. The content is as follows: ``` -# vim /etc/vsftpd/vsftpd.conf +$ vim /etc/vsftpd/vsftpd.conf anonymous_enable=NO local_enable=YES write_enable=YES @@ -278,7 +276,7 @@ userlist_enable=YES In the openEuler system, vsftpd uses the Greenwich Mean Time \(GMT\) time by default, which may be different from the local time. For example, the GMT time is 8 hours later than the Beijing time. You need to change the GMT time to the local time. Otherwise, the server time and client time are inconsistent, which may cause errors during file upload and download. #### Setting Method -To set the vsftpd time to the local time, perform the following steps: +To set the vsftpd time to the local time, perform the following steps as the **root** user: 1. Open the vsftpd.conf file and change the value of use\_localtime to **YES**. Run the following command: @@ -307,7 +305,7 @@ To set the vsftpd time to the local time, perform the following steps: ### Configuring Welcome Information -To use the vsftpd service normally, the welcome information file must exist. To configure the welcome.txt file of the vsftp service, perform the following steps: +To use the vsftpd service normally, the welcome information file must exist. To configure the welcome.txt file of the vsftp service, perform the following steps as the **root** user: 1. Open the vsftpd.conf configuration file, add the welcome information to the file, save the file, and exit. @@ -345,12 +343,12 @@ Two files are used to restrict the login of system accounts. The default files a Both files must exist and have the same content. You can write the accounts whose UIDs are smaller than 500 to the two files by referring to the /etc/passwd. Each line indicates an account. -To restrict the login of system accounts, add the accounts to /etc/vsftpd/ftpusers and /etc/vsftpd/user\_list. +To restrict the login of system accounts, add the accounts to /etc/vsftpd/ftpusers and /etc/vsftpd/user\_list as the **root** user. Open the user\_list file to view the account information in the current file. The command and output are as follows: ``` -# vim /etc/vsftpd/user_list +$ vim /etc/vsftpd/user_list root bin daemon @@ -372,8 +370,7 @@ nobody You can use the FTP client provided by openEuler for verification. The command and output are as follows. Enter the user name \(an existing user in the system\) and password as prompted. If the message "Login successful" is displayed, the FTP server is successfully set up. ``` -# dnf install ftp -# ftp localhost +$ ftp localhost Trying 127.0.0.1... Connected to localhost (127.0.0.1). 220-Welcome to this FTP server! @@ -388,9 +385,12 @@ ftp> bye 221 Goodbye. ``` +>![](public_sys-resources/icon-note.gif) **NOTE:** +>If the **ftp** command does not exist, run the **dnf install ftp** command as the **root** user to install the **ftp** software and then run the **ftp** command. + ## Configuring a Firewall -To open the FTP service to the Internet, you need to configure the firewall and SElinux. +To open the FTP service to the Internet, you need to configure the firewall and SElinux as the **root** user. ``` # firewall-cmd --add-service=ftp --permanent @@ -417,7 +417,7 @@ This section describes how to transfer files after the vsftpd service is started Run the following command on the command-line interface \(CLI\) of the openEuler OS: ``` -ftp ip-address +$ ftp ip-address ``` Enter the user name and password as prompted. If the following information is displayed after the authentication is successful, the FTP connection is successful. In this case, you have accessed the directory of the connected server. @@ -428,7 +428,7 @@ ftp> At this prompt, you can enter different commands to perform related operations. -- Display the current IP address of the server. +- Display the current path of the server. ``` ftp>pwd @@ -457,10 +457,10 @@ Generally, the get or mget command is used to download files. _remote-file_ indicates a remote file, and _local-file_ indicates a local file. -- For example, to obtain the /usr/your/openEuler.htm file on the remote server, run the following command: +- For example, run the following command to obtain the /home/openEuler/openEuler.htm file on the remote server to the local directory /home/myopenEuler/ and change the file name to myopenEuler.htm ``` - ftp> get /usr/your/openEuler.htm + ftp> get /home/openEuler/openEuler.htm /home/myopenEuler/myopenEuler.htm ``` @@ -471,16 +471,16 @@ Generally, the get or mget command is used to download files. _remote-file_ indicates a remote file. -- For example, to obtain all files in the /usr/your/ directory on the server, run the following command: +- For example, to obtain all files in the /home/openEuler/ directory on the server, run the following command: ``` - ftp> cd /usr/your/ + ftp> cd /home/openEuler/ ftp> mget *.* ``` >![](public_sys-resources/icon-note.gif) **NOTE:** >- In this case, a message is displayed each time a file is downloaded. To block the prompt information, run the **prompt off** command before running the **mget \*.\*** command. - >- The files are downloaded to the current directory on the Linux host. For example, if you run the ftp command in /usr/my/, all files are downloaded to /usr/my/. + >- The files are downloaded to the current directory on the Linux host. For example, if you run the ftp command in /home/myopenEuler/, all files are downloaded to /home/myopenEuler/. ### Uploading a file @@ -493,10 +493,10 @@ Generally, the put or mput command is used to upload files. _remote-file_ indicates a remote file, and _local-file_ indicates a local file. -- For example, run the following command to transfer the local Euler.htm file to the remote host /usr/your/ and change the file name to openEuler.htm: +- For example, run the following command to transfer the local myopenEuler.htm file to the remote host /home/openEuler/ and change the file name to openEuler.htm: ``` - ftp> put Euler.htm /usr/your/openEuler.htm + ftp> put myopenEuler.htm /home/openEuler/openEuler.htm ``` @@ -507,10 +507,10 @@ Generally, the put or mput command is used to upload files. _local-file_ indicates a local file. -- For example, run the following command to upload all HTM files in the local directory to the /usr/your/ directory on the server: +- For example, run the following command to upload all HTM files in the local directory to the /home/openEuler/ directory on the server: ``` - ftp> cd /usr/your + ftp> cd /home/openEuler/ ftp> mput *.htm ``` @@ -525,10 +525,11 @@ Generally, the **delete** or **mdelete** command is used to delete a file. _remote-file_ indicates a remote file. -- For example, to delete the openFile from the remote server, run the following command: +- For example, to delete the /home/openEuler/openEuler.htm from the remote server, run the following command: ``` - ftp> delete openFile + ftp> cd /home/openEuler/ + ftp> delete openEuler.htm ``` @@ -539,9 +540,10 @@ Generally, the **delete** or **mdelete** command is used to delete a file. _remote-file_ indicates a remote file. -- For example, to delete all files whose names start with **a**, run the following command: +- For example, to delete all files whose names start with **a** from the /home/openEuler/ directory on the remote server, run the following command: ``` + ftp> cd /home/openEuler/ ftp> mdelete a* ``` diff --git a/content/en/docs/Administration/configuring-the-network.md b/content/en/docs/Administration/configuring-the-network.md index 2f73c57f0101e9ddfa9dc0464b143ab8aca9c858..370ae8c6afdd5762779bfa1bf1a3da3a14eec05a 100644 --- a/content/en/docs/Administration/configuring-the-network.md +++ b/content/en/docs/Administration/configuring-the-network.md @@ -42,7 +42,7 @@ In the preceding command, **OBJECT** can be one of the following options: **general**, **networking**, **radio**, **connection**, and **device**. **OPTIONS** can be optional options, such as **-t**, **\-\-terse** \(for script processing\),**-p**, **\-\-pretty** \(for human-readable output\), **-h**, and **\-\-help**. For more information, run the **nmcli help** command. ``` -# nmcli help +$ nmcli help ``` Common commands are listed as follows: @@ -50,33 +50,32 @@ Common commands are listed as follows: - To display the general status of NetworkManager, run the following command: ``` - nmcli general status + $ nmcli general status ``` - To display all connections, run the following command: ``` - nmcli connection show + $ nmcli connection show ``` - To display the current active connections only, add the **-a** or **\-\-active** option as follows: ``` - nmcli connection show --active + $ nmcli connection show --active ``` - To display the device identified by NetworkManager and its connection status, run the following command: ``` - nmcli device status + $ nmcli device status ``` -- To start or stop network interfaces, for example, run the nmcli commands: +- To start or stop network interfaces, for example, run the nmcli commands as the **root** user: ``` - - nmcli connection up id enp3s0 - nmcli device disconnect enp3s0 + # nmcli connection up id enp3s0 + # nmcli device disconnect enp3s0 ``` @@ -85,7 +84,7 @@ Common commands are listed as follows: Run the following command to display all the available network connections: ``` -# nmcli con show +$ nmcli con show NAME UUID TYPE DEVICE @@ -100,7 +99,7 @@ virbr0 ba552da6-f014-49e3-91fa-ec9c388864fa bridge virbr0 After a network connection is added, the corresponding configuration file is generated and associated with the corresponding device. To check for available devices, run the following command: ``` -# nmcli dev status +$ nmcli dev status DEVICE TYPE STATE CONNECTION enp3s0 ethernet connected enp3s0 @@ -121,7 +120,7 @@ When DHCP is used to allocate a network, run the following command to add a netw nmcli connection add type ethernet con-name connection-name ifname interface-name ``` -For example, to create a dynamic connection configuration file named **net-test**, run the following command: +For example, to create a dynamic connection configuration file named **net-test**, run the following command as the **root** user: ``` # nmcli connection add type ethernet con-name net-test ifname enp3s0 @@ -131,7 +130,7 @@ Connection 'net-test' (a771baa0-5064-4296-ac40-5dc8973967ab) successfully added. The NetworkManager sets **connection.autoconnect** to **yes** and saves the setting to the **/etc/sysconfig/network-scripts/ifcfg-net-test** file. In the **/etc/sysconfig/network-scripts/ifcfg-net-test** file, **ONBOOT** is set to **yes**. ###### Activating a Connection and Checking Device Connection Status -Run the following command to activate a network connection: +Run the following command as the **root** user to activate a network connection: ``` # nmcli con up net-test @@ -141,7 +140,7 @@ Connection successfully activated (D-Bus active path:/org/freedesktop/NetworkMan Run the following command to check the connection status of devices: ``` -# nmcli device status +$ nmcli device status DEVICE TYPE STATE CONNECTION enp4s0 ethernet connected enp4s0 @@ -163,7 +162,7 @@ nmcli connection add type ethernet con-name connection-name ifname interface-nam >![](public_sys-resources/icon-note.gif) **NOTE:** >To add an IPv6 address and related gateway information, use the **ip6** and **gw6** options. -For example, to create a static connection configuration file named **net-static**, run the following command: +For example, to create a static connection configuration file named **net-static**, run the following command as the **root** user: ``` # nmcli con add type ethernet con-name net-static ifname enp3s0 ip4 192.168.0.10/24 gw4 192.168.0.254 @@ -178,20 +177,20 @@ Connection 'net-static' (63aa2036-8665-f54d-9a92-c3035bad03f7) successfully adde The NetworkManager sets the internal parameter **ipv4.method** to **manual**, **connection.autoconnect** to **yes**, and writes the setting to the **/etc/sysconfig/network-scripts/ifcfg-my-office** file. In the file, **BOOTPROTO** is set to **none**, and **ONBOOT** is set to **yes**. -Run the following command to set IPv4 addresses of two DNS servers: +Run the following command as the **root** user to set IPv4 addresses of two DNS servers: ``` # nmcli con mod net-static ipv4.dns "*.*.*.* *.*.*.*" ``` -Run the following command to set IPv6 addresses of two DNS servers: +Run the following command as the **root** user to set IPv6 addresses of two DNS servers: ``` # nmcli con mod net-static ipv6.dns "2001:4860:4860::**** 2001:4860:4860::****" ``` ###### Activating a Connection and Checking Device Connection Status -Run the following command to activate a network connection: +Run the following command as the **root** user to activate a network connection: ``` # nmcli con up net-static ifname enp3s0 @@ -201,7 +200,7 @@ Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkMa Run the following command to check the connection status of devices: ``` -# nmcli device status +$ nmcli device status DEVICE TYPE STATE CONNECTION enp4s0 ethernet connected enp4s0 @@ -214,7 +213,7 @@ virbr0-nic tun unmanaged -- Run the following command to view the connection details \(with the **-p** and **\-\-pretty** options to add the title and segment to the output\): ``` -# nmcli -p con show net-static +$ nmcli -p con show net-static =============================================================================== Connection profile details (net-static ) =============================================================================== @@ -248,26 +247,26 @@ connection.llmnr: -1 (default) Run the following command to check for available Wi-Fi access points: ``` -# nmcli dev wifi list +$ nmcli dev wifi list ``` Run the following command to generate a static IP address configuration that allows Wi-Fi connections automatically allocated by the DNS: ``` -# nmcli con add con-name Wifi ifname wlan0 type wifi ssid MyWifi ip4 192.168.100.101/24 gw4 192.168.100.1 +$ nmcli con add con-name Wifi ifname wlan0 type wifi ssid MyWifi ip4 192.168.100.101/24 gw4 192.168.100.1 ``` Run the following command to set a WPA2 password, for example, **answer**: ``` -# nmcli con modify Wifi wifi-sec.key-mgmt wpa-psk -# nmcli con modify Wifi wifi-sec.psk answer +$ nmcli con modify Wifi wifi-sec.key-mgmt wpa-psk +$ nmcli con modify Wifi wifi-sec.psk answer ``` Run the following command to change the Wi-Fi status: ``` -# nmcli radio wifi [ on | off ] +$ nmcli radio wifi [ on | off ] ``` ##### Modifying Attributes @@ -275,20 +274,20 @@ Run the following command to change the Wi-Fi status: Run the following command to check a specific attribute, for example, mtu: ``` -# nmcli connection show id 'Wifi ' | grep mtu +$ nmcli connection show id 'Wifi ' | grep mtu 802-11-wireless.mtu: auto ``` Run the following command to modify the attribute: ``` -# nmcli connection modify id 'Wifi ' 802-11-wireless.mtu 1350 +$ nmcli connection modify id 'Wifi ' 802-11-wireless.mtu 1350 ``` Run the following command to confirm the modification: ``` -# nmcli connection show id 'Wifi ' | grep mtu +$ nmcli connection show id 'Wifi ' | grep mtu 802-11-wireless.mtu: 1350 ``` @@ -297,14 +296,14 @@ Run the following command to confirm the modification: - Run the nmcli command to configure a static route for a network connection: ``` - # nmcli connection modify enp3s0 +ipv4.routes "192.168.122.0/24 10.10.10.1" + $ nmcli connection modify enp3s0 +ipv4.routes "192.168.122.0/24 10.10.10.1" ``` - Run the following command to configure the static route using the editor: ``` - # nmcli con edit type ethernet con-name enp3s0 + $ nmcli con edit type ethernet con-name enp3s0 ===| nmcli interactive connection editor |=== Adding a new '802-3-ethernet' connection Type 'help' or '?' for available commands. @@ -336,13 +335,13 @@ ip addr [ add | del ] address dev interface-name ``` ##### Configuring a Static IP Address -Run the following command as the user **root** to configure an IP address: +Run the following command as the **root** user to configure an IP address: ``` # ip address add 192.168.0.10/24 dev enp3s0 ``` -Run the following command to view the configuration result: +Run the following command as the **root** user to view the configuration result: ``` # ip addr show dev enp3s0 @@ -357,7 +356,7 @@ Run the following command to view the configuration result: ``` ##### Configuring Multiple IP Addresses -The **ip** command can be used to assign multiple IP addresses to an interface. You can run the **ip** command multiple times to assign IP addresses to an interface. The following is an example: +The **ip** command can be used to assign multiple IP addresses to an interface. You can run the **ip** command multiple times as the **root** user to assign IP addresses to an interface. The following is an example: ``` # ip address add 192.168.2.223/24 dev enp4s0 @@ -384,7 +383,7 @@ To add a static route to the routing table, run the **ip route add** command. T ip route [ add | del | change | append | replace ] destination-address ``` -To display the current IP routing table, run the **ip route** command. The following is an example: +To display the current IP routing table, run the **ip route** command as the **root** user. The following is an example: ``` # ip route @@ -396,7 +395,7 @@ default via 192.168.0.1 dev enp4s0 proto dhcp metric 101 192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown ``` -To add a static route to the host address, run the following command as the user **root**: +To add a static route to the host address, run the following command as the **root** user: ``` ip route add 192.168.2.1 via 10.0.0.1 [dev interface-name] @@ -404,7 +403,7 @@ ip route add 192.168.2.1 via 10.0.0.1 [dev interface-name] In the preceding command, **192.168.2.1** is the IP address in the dot-decimal notation, **10.0.0.1** is the next hop, and _interface-name_ is the exit interface for entering the next hop. -To add a static route to the network, that is, an IP address that represents an IP address range, run the following command as the user **root**: +To add a static route to the network, that is, an IP address that represents an IP address range, run the following command as the **root** user: ``` ip route add 192.168.2.0/24 via 10.0.0.1 [dev interface-name] @@ -415,10 +414,10 @@ In the preceding command, **192.168.2.1** is the IP address of the target netw ### Configuring the Network Through the ifcfg File >![](public_sys-resources/icon-note.gif) **NOTE:** ->The network configured in the **ifcfg** file does not take effect immediately. You need to run the **systemctl reload NetworkManager** command to restart the network service for the configuration to take effect. +>The network configured in the **ifcfg** file does not take effect immediately. You need to run the **systemctl reload NetworkManager** command as the **root** user to restart the network service for the configuration to take effect. #### Configuring a Static Network -The following uses the **enp4s0** network interface as an example to describe how to configure a static network by modifying the **ifcfg** file. The **ifcfg-enp4s0** file is generated in the **/etc/sysconfig/network-scripts/** directory. Modify the following parameters in the file: +The following uses the **enp4s0** network interface as an example to describe how to configure a static network by modifying the **ifcfg** file as the **root** user. The **ifcfg-enp4s0** file is generated in the **/etc/sysconfig/network-scripts/** directory. Modify the following parameters in the file: ``` TYPE=Ethernet @@ -496,21 +495,21 @@ There are three types of host names: **static**, **transient**, and **pretty* Run the following command to view the current host name: ``` -# hostnamectl status +$ hostnamectl status ``` >![](public_sys-resources/icon-note.gif) **NOTE:** >If no option is specified in the command, the **status** option is used by default. #### Setting All Host Names -Run the following command as the **root** user to set all host names: +Run the following command as the **root** user to set all host names: ``` # hostnamectl set-hostname name ``` #### Setting a Specific Host Name -Run the following command as the **root** user to set a specific host name: +Run the following command as the **root** user to set a specific host name: ``` # hostnamectl set-hostname name [option...] @@ -527,7 +526,7 @@ When setting a host name of the **pretty** type, use quotation marks if the ho ``` #### Clearing a Specific Host Name -To clear a specific host name and restore it to the default format, run the following command as the **root** user: +To clear a specific host name and restore it to the default format, run the following command as the **root** user: ``` # hostnamectl set-hostname "" [option...] @@ -536,7 +535,7 @@ To clear a specific host name and restore it to the default format, run the foll In the preceding command, **""** is a blank character string, and the _option_ may be one or more of **\-\-pretty**, **\-\-static**, and **\-\-transient**. #### Remotely Changing a Host Name -To change the host name in a remote system, run the **hostnamectl** command with the **-H** or **\-\-host** option. +To change the host name in a remote system, run the **hostnamectl** command as the **root** user with the **-H** or **\-\-host** option. ``` # hostnamectl set-hostname -H [username]@hostname new_hostname @@ -549,16 +548,16 @@ In the preceding command, _hostname_ indicates the name of the remote host to To query a static host name, run the following command: ``` -# nmcli general hostname +$ nmcli general hostname ``` -To name a static host as **host-server**, run the following command as user root: +To name a static host as **host-server**, run the following command as **root** user: ``` # nmcli general hostname host-server ``` -To enable the system to detect the change of the static host name, run the following command as the **root** user to restart the hostnamed service: +To enable the system to detect the change of the static host name, run the following command as the **root** user to restart the hostnamed service: ``` # systemctl restart systemd-hostnamed @@ -573,38 +572,38 @@ To enable the system to detect the change of the static host name, run the follo - To create a bond named **mybond0**, run the following command: ``` - # nmcli con add type bond con-name mybond0 ifname mybond0 mode active-backup + $ nmcli con add type bond con-name mybond0 ifname mybond0 mode active-backup ``` - To add a slave interface, run the following command: ``` - # nmcli con add type bond-slave ifname enp3s0 master mybond0 + $ nmcli con add type bond-slave ifname enp3s0 master mybond0 ``` To add another slave interface, repeat the preceding command with the new interface name: ``` - # nmcli con add type bond-slave ifname enp4s0 master mybond0 + $ nmcli con add type bond-slave ifname enp4s0 master mybond0 Connection 'bond-slave-enp4s0' (05e56afc-b953-41a9-b3f9-0791eb49f7d3) successfully added. ``` - To enable a bond, run the following command to enable the slave interface first: ``` - # nmcli con up bond-slave-enp3s0 + $ nmcli con up bond-slave-enp3s0 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14) ``` ``` - # nmcli con up bond-slave-enp4s0 + $ nmcli con up bond-slave-enp4s0 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15) ``` Then, run the following command to enable the bond: ``` - # nmcli con up bond-mybond0 + $ nmcli con up mybond0 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16) ``` @@ -613,23 +612,23 @@ To enable the system to detect the change of the static host name, run the follo #### Checking Whether the Bonding Kernel Module Is Installed -By default, the bonding kernel module is loaded. To load this module, run the following command as the **root** user: +By default, the bonding kernel module is loaded. To load this module, run the following command as the **root** user: ``` # modprobe --first-time bonding ``` -Run the following command to display the information about the module: +Run the following command as the **root** user to display the information about the module: ``` # modinfo bonding ``` -For more commands, run the modprobe \-\-help command. +For more commands, run the modprobe \-\-help command as the **root** user. #### Creating a Channel Bonding Interface -To create a channel bonding interface, you can create a file named **ifcfg-bondN** in the **/etc/sysconfig/network-scripts/** directory \(replacing N with the actual interface number, for example, 0\). +To create a channel bonding interface, you can create a file named **ifcfg-bondN** in the **/etc/sysconfig/network-scripts/** directory as the **root** user \(replacing N with the actual interface number, for example, 0\). Write the corresponding content to the configuration file according to the type of the interface to be bonded, for example, network interface. An example of the interface configuration file is as follows: @@ -673,7 +672,7 @@ SLAVE=yes #### Activating Channel Bonding -To activate channel bonding, you need to enable all the slave interfaces. Run the following command as the **root** user: +To activate channel bonding, you need to enable all the slave interfaces. Run the following command as the **root** user: ``` # ifup enp3s0 @@ -690,13 +689,13 @@ Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkMa After that, enable all the slave interfaces to enable the bonding \(do not set them to **Down**\). -To enable the NetworkManager to detect the modifications made by the system, run the following command as user **root** user after each modification: +To enable the NetworkManager to detect the modifications made by the system, run the following command as the **root** user after each modification: ``` # nmcli con load /etc/sysconfig/network-scripts/ifcfg-device ``` -Run the following command to check the status of the bonded interface: +Run the following command as the **root** user to check the status of the bonded interface: ``` # ip link show @@ -754,7 +753,7 @@ In this example, replace N with the number of the bonded interface. For example, In an IPv6 scenario, the minimum MTU value of the entire routing path is used as the PMTU value of the current link. The source end determines whether to fragment packets based on the PMTU value. Other devices on the entire path do not need to fragment packets. This reduces the load of intermediate routing devices. The minimum value of IPv6 PMTU is 1280. ##### Setting the MTU of the Interface Device -If the MTU of an interface configured with an IPv6 address is set to a value smaller than **1280** \(the minimum value of the IPv6 PMTU\), the IPv6 address of the interface will be deleted and cannot be added again. Therefore, in IPv6 scenarios, the MTU of the interface device must be greater than or equal to 1280. The details are as follows: +If the MTU of an interface configured with an IPv6 address is set to a value smaller than **1280** \(the minimum value of the IPv6 PMTU\), the IPv6 address of the interface will be deleted and cannot be added again. Therefore, in IPv6 scenarios, the MTU of the interface device must be greater than or equal to 1280. Run the following commands as the **root** user to view the details: ``` # ip addr show enp3s0 @@ -803,7 +802,7 @@ RTNETLINK answers: No buffer space available #### Stateful IPv6 Address Autoconfiguration ##### Overview -Both IPv6 and IPv4 addresses can be obtained through DHCP. There are configuration methods for IPv6 address: stateless autoconfiguration and stateful autoconfiguration. +Both IPv6 and IPv4 addresses can be obtained through DHCP as the **root** user. There are configuration methods for IPv6 address: stateless autoconfiguration and stateful autoconfiguration. - Stateless autoconfiguration @@ -955,6 +954,8 @@ PERSISTENT_DHCLIENT=yes|no|1|0 ##### Overview IPv4 and IPv6 are two different protocol standards. Therefore, the iproute commands are different in usage. This section describes the differences between IPv4 and IPv6 commands in the iproute package. +To run the iproute commands, you must have the root permission. + ##### Lifecycle of an IPv6 Address

IPv6 status

@@ -1290,7 +1291,7 @@ When both IPv4 and IPv6 addresses are configured in the configuration file of th The delay is caused by the buffer queue mechanism of rsyslog. By default, rsyslog writes data to a file only when the number of buffer queues reaches a specified value. ##### Solution -You can disable the buffer queue mechanism by configuring the Direct mode. Add the following information at the beginning of the new remote transmission configuration file in the /etc/rsyslog.d directory on the rsyslog remote transmission server: +You can disable the buffer queue mechanism by configuring the Direct mode as the **root** user. Add the following information at the beginning of the new remote transmission configuration file in the /etc/rsyslog.d directory on the rsyslog remote transmission server: ``` $ActionQueueType Direct diff --git a/content/en/docs/Administration/configuring-the-repo-server.md b/content/en/docs/Administration/configuring-the-repo-server.md index 03a1ea003b2f2e0726deeee4d0bfabf0653d8b8f..4f5191adc42c7c17aadff46221687e65471fdb90 100644 --- a/content/en/docs/Administration/configuring-the-repo-server.md +++ b/content/en/docs/Administration/configuring-the-repo-server.md @@ -40,12 +40,12 @@ Obtain the openEuler software package from the following website: ### Mounting an ISO File to Create a Repo Source -Run the mount command to mount the image file. +Run the mount command as the **root** user to mount the image file. The following is an example: ``` -mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ +# mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ ``` The mounted mnt directory is as follows: @@ -69,11 +69,11 @@ In the preceding command, **Packages** indicates the directory where the RPM p You can copy related files in the image to a local directory to create a local repo source. The following is an example: ``` -mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ -mkdir -p /srv/repo/ -cp -r /mnt/Packages /srv/repo/ -cp -r /mnt/repodata /srv/repo/ -cp -r /mnt/RPM-GPG-KEY-openEuler /srv/repo/ +# mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ +$ mkdir -p ~/srv/repo/ +$ cp -r /mnt/Packages ~/srv/repo/ +$ cp -r /mnt/repodata ~/srv/repo/ +$ cp -r /mnt/RPM-GPG-KEY-openEuler ~/srv/repo/ ``` The local repo directory is as follows: @@ -95,11 +95,14 @@ You can update the repo source in either of the following ways: - Add rpm packages to the Packages directory of the repo source and update the repo source. You can run the createrepo command to update the repo source. ``` - dnf install createrepo - createrepo --update --workers=10 /srv/repo + $ createrepo --update --workers=10 ~/srv/repo ``` + - In this command, \-\-update indicates the update, and \-\-workers indicates the number of threads, which can be customized. +In this command, \-\-update indicates the update, and \-\-workers indicates the number of threads, which can be customized. + +>![](public_sys-resources/icon-note.gif) **NOTE:** +>If the command output contains "createrepo: command not found", run the **dnf install createrepo** command as the **root** user to install the **createrepo** softeware. ## Deploying the Remote Repo Source @@ -110,14 +113,14 @@ Install openEuler OS and deploy the repo source using Nginx on openEuler OS. ### Installing and Configuring Nginx -1. Download the Nginx tool and install it. -2. After installing Nginx, configure /etc/nginx/nginx.conf. +1. Download the Nginx tool and install it as the **root** user. +2. After installing Nginx, configure /etc/nginx/nginx.conf as the **root** user. >![](public_sys-resources/icon-note.gif) **NOTE:** >The configuration content in this document is for reference only. You can configure the content based on the site requirements \(for example, security hardening requirements\). ``` - user root; + user nginx; worker_processes auto; # You are advised to set this parameter to core-1. error_log /var/log/nginx/error.log warn; # log storage location pid /var/run/nginx.pid; @@ -140,12 +143,12 @@ Install openEuler OS and deploy the repo source using Nginx on openEuler OS. server { listen 80; - server_name localhost; #Server name (URL) + server_name localhost; #Server name (URL) client_max_body_size 4G; - root /srv/repo; #Default service directory + root /usr/share/nginx/repo; #Default service directory location / { - autoindex on; # Enable the access to lower-layer files in the directory. + autoindex on; # Enable the access to lower-layer files in the directory. autoindex_exact_size on; autoindex_localtime on; } @@ -158,78 +161,75 @@ Install openEuler OS and deploy the repo source using Nginx on openEuler OS. ### Starting Nginx -1. Run the systemd command to start the Nginx service. +1. Run the systemd command as the **root** user to start the Nginx service. ``` - systemctl enable nginx - systemctl start nginx + # systemctl enable nginx + # systemctl start nginx ``` 2. You can run the following command to check whether the Nginx is started successfully: ``` - systemctl status nginx + $ systemctl status nginx ``` - - [Figure 1](#en-us_topic_0151920971_fd25e3f1d664b4087ae26631719990a71) indicates that the Nginx service is started successfully. + - [Figure 1](#en-us_topic_0151920971_fd25e3f1d664b4087ae26631719990a71) indicates that the Nginx service is started successfully. - **Figure 1** The Nginx service is successfully started. - ![](figures/the-nginx-service-is-successfully-started.png "the-nginx-service-is-successfully-started") + **Figure 1** The Nginx service is successfully started. + ![](figures/the-nginx-service-is-successfully-started.png "the-nginx-service-is-successfully-started") - - If the Nginx service fails to be started, view the error information. + - If the Nginx service fails to be started, view the error information. ``` - systemctl status nginx.service --full + $ systemctl status nginx.service --full ``` - **Figure 2** Nginx startup failure - ![](figures/nginx-startup-failure.png "nginx-startup-failure") + **Figure 2** Nginx startup failure + ![](figures/nginx-startup-failure.png "nginx-startup-failure") - As shown in [Figure 2](#en-us_topic_0151920971_f1f9f3d086e454b9cba29a7cae96a4c54), the Nginx service fails to be created because the /var/spool/nginx/tmp/client\_body directory fails to be created. You need to manually create the directory. Similar problems are solved as follows: + As shown in [Figure 2](#en-us_topic_0151920971_f1f9f3d086e454b9cba29a7cae96a4c54), the Nginx service fails to be created because the /var/spool/nginx/tmp/client\_body directory fails to be created. You need to manually create the directory as the **root** user. Similar problems are solved as follows: ``` - mkdir -p /var/spool/nginx/tmp/client_body - mkdir -p /var/spool/nginx/tmp/proxy - mkdir -p /var/spool/nginx/tmp/fastcgi - mkdir -p /usr/share/nginx/uwsgi_temp - mkdir -p /usr/share/nginx/scgi_temp + # mkdir -p /var/spool/nginx/tmp/client_body + # mkdir -p /var/spool/nginx/tmp/proxy + # mkdir -p /var/spool/nginx/tmp/fastcgi + # mkdir -p /usr/share/nginx/uwsgi_temp + # mkdir -p /usr/share/nginx/scgi_temp ``` ### Deploying the Repo Source -1. Run the following command to create the /srv/repo directory specified in the Nginx configuration file /etc/nginx/nginx.conf: +1. Run the following command as the **root** user to create the /usr/share/nginx/repo directory specified in the Nginx configuration file /etc/nginx/nginx.conf: ``` - mkdir -p /srv/repo + # mkdir -p /usr/share/nginx/repo ``` -2. Set the SELinux working mode to the permissive mode: +2. Run the followding command as the **root** user to modify the /usr/share/nginx/repo directory permission: ``` - setenforce permissive + # chmod -R 755 /usr/share/nginx/repo ``` - >![](public_sys-resources/icon-note.gif) **NOTE:** - >After the repo server is restarted, you need to configure the repo server again. - -3. Configure firewall rules to enable the port \(port 80\) configured for Nginx. +3. Configure firewall rules as the **root** user to enable the port \(port 80\) configured for Nginx. ``` - firewall-cmd --add-port=80/tcp --permanent - firewall-cmd --reload + # firewall-cmd --add-port=80/tcp --permanent + # firewall-cmd --reload ``` - Check whether port 80 is enabled. If the output is **yes**, port 80 is enabled. + Check whether port 80 is enabled as the **root** user. If the output is **yes**, port 80 is enabled. ``` - firewall-cmd --query-port=80/tcp + # firewall-cmd --query-port=80/tcp ``` - You can also enable port 80 using iptables. + You can also enable port 80 using iptables as the **root** user. ``` - iptables -I INPUT -p tcp --dport 80 -j ACCEPT + # iptables -I INPUT -p tcp --dport 80 -j ACCEPT ``` 4. After the Nginx service is configured, you can use the IP address to access the web page, as shown in [Figure 3](#en-us_topic_0151921017_fig1880404110396). @@ -237,25 +237,26 @@ Install openEuler OS and deploy the repo source using Nginx on openEuler OS. **Figure 3** Nginx deployment succeeded ![](figures/nginx-deployment-succeeded.png "nginx-deployment-succeeded") -5. Use either of the following methods to add the repo source to the /srv/repo directory: - - Copy related files in the image to the /srv/repo directory. +5. Use either of the following methods to add the repo source to the /usr/share/nginx/repo directory: + - Copy related files in the image to the /usr/share/nginx/repo directory as the **root** user. ``` - mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ - cp -r /mnt/Packages /srv/repo/ - cp -r /mnt/repodata /srv/repo/ - cp -r /mnt/RPM-GPG-KEY-openEuler /srv/repo/ + # mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ + # cp -r /mnt/Packages /usr/share/nginx/repo/ + # cp -r /mnt/repodata /usr/share/nginx/repo/ + # cp -r /mnt/RPM-GPG-KEY-openEuler /usr/share/nginx/repo/ + # chmod -R 755 /usr/share/nginx/repo ``` The **openEuler-20.03-LTS-aarch64-dvd.iso** file is stored in the **/home/openEuler** directory. - - Create a soft link for the repo source in the /srv/repo directory. + - Create a soft link for the repo source in the /usr/share/nginx/repo directory as the **root** user. ``` - ln -s /home/openEuler/os /srv/repo/os + # ln -s /mnt /usr/share/nginx/repo/os ``` - /home/openEuler/os is the created repo source, and /srv/repo/os points to /home/openEuler/os. + /mnt is the created repo source, and /usr/share/nginx/repo/os points to /mnt. @@ -266,7 +267,7 @@ The repo source can be configured as a yum source. Yellow dog Updater,Modified \ ### Configuring repo as the yum Source -You can configure the built repo as the yum source and create the \*\*\*.repo configuration file \(the extension .repo is mandatory\) in the /etc/yum.repos.d/ directory. You can configure the yum source on the local host or HTTP server. +You can configure the built repo as the yum source and create the \*\*\*.repo configuration file \(the extension .repo is mandatory\) in the /etc/yum.repos.d/ directory as the **root** user. You can configure the yum source on the local host or HTTP server. - Configuring the local yum source. @@ -275,15 +276,15 @@ You can configure the built repo as the yum source and create the \*\*\*.repo co ``` [base] name=base - baseurl=file:///srv/repo + baseurl=file:///home/openEuler/srv/repo enabled=1 gpgcheck=1 - gpgkey=file:///srv/repo/RPM-GPG-KEY-openEuler + gpgkey=file:///home/openEuler/srv/repo/RPM-GPG-KEY-openEuler ``` >![](public_sys-resources/icon-note.gif) **NOTE:** - > _gpgcheck_ indicates whether to enable the GNU privacy guard \(GPG\) to check the validity and security of sources of RPM packages. **1** indicates GPG check is enabled. **0** indicates the GPG check is disabled. If this option is not specified, the GPG check is enabled by default. - > _gpgkey_ is the storage path of the signature public key. + > **gpgcheck** indicates whether to enable the GNU privacy guard \(GPG\) to check the validity and security of sources of RPM packages. **1** indicates GPG check is enabled. **0** indicates the GPG check is disabled. If this option is not specified, the GPG check is enabled by default. + > **gpgkey** is the public key used to verify the signature. - Configuring the yum source for the HTTP server @@ -292,14 +293,14 @@ You can configure the built repo as the yum source and create the \*\*\*.repo co ``` [base] name=base - baseurl=http://192.168.1.2/ + baseurl=http://192.168.139.209/ enabled=1 gpgcheck=1 - gpgkey=http://192.168.1.2/RPM-GPG-KEY-openEuler + gpgkey=http://192.168.139.209/RPM-GPG-KEY-openEuler ``` >![](public_sys-resources/icon-note.gif) **NOTE:** - >192.168.1.2 is an example. Replace it with the actual IP address. + >192.168.139.209 is an example. Replace it with the actual IP address. ### repo Priority @@ -309,11 +310,11 @@ If there are multiple repo sources, you can set the repo priority in the .repo f ``` [base] name=base -baseurl=http://192.168.1.2/ +baseurl=http://192.168.139.209/ enabled=1 priority=2 gpgcheck=1 -gpgkey=http://192.168.1.2/RPM-GPG-KEY-openEuler +gpgkey=http://192.168.139.209/RPM-GPG-KEY-openEuler ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -330,62 +331,72 @@ dnf Common commands are as follows: -- Installation +- Installation + + Run the following command as the **root** user. ``` - dnf install + # dnf install ``` -- Upgrade +- Upgrade + + Run the following command as the **root** user. ``` - dnf update + # dnf update ``` -- Rollback +- Rollback + + Run the following command as the **root** user. ``` - dnf downgrade + # dnf downgrade ``` - Checking for update ``` - dnf check-update + $ dnf check-update ``` -- Uninstallation +- Uninstallation + + Run the following command as the **root** user. ``` - dnf remove + # dnf remove ``` - Query ``` - dnf search + $ dnf search ``` -- Local installation +- Local installation + + Run the following command as the **root** user. ``` - dnf localinstall + # dnf localinstall ``` - Viewing historical records ``` - dnf history + $ dnf history ``` - Clearing cache records ``` - dnf clean all + $ dnf clean all ``` - Updating cache ``` - dnf makecache + $ dnf makecache ``` diff --git a/content/en/docs/Administration/configuring-the-web-server.md b/content/en/docs/Administration/configuring-the-web-server.md index 0c74c8a3f45ee3958125545803fde9526d82a1c8..080c8e167d71925c97fd52da903bc40758e72e50 100644 --- a/content/en/docs/Administration/configuring-the-web-server.md +++ b/content/en/docs/Administration/configuring-the-web-server.md @@ -35,7 +35,7 @@ The web server version in the openEuler system is Apache HTTP server 2.4, that i You can use the systemctl tool to manage the httpd service, including starting, stopping, and restarting the service, and viewing the service status. This section describes how to manage the Apache HTTP service. #### Prerequisites -- To use the Apache HTTP service, ensure that the rpm package of the httpd service has been installed in your system. The installation command is as follows: +- To use the Apache HTTP service, ensure that the rpm package of the httpd service has been installed in your system. Run the following command as the **root** user to install the rpm package: ``` # dnf install httpd @@ -111,7 +111,7 @@ You can restart the service in any of the following ways: Check whether the httpd service is running. ``` -# systemctl is-active httpd +$ systemctl is-active httpd ``` If active is displayed in the command output, the service is running. @@ -143,7 +143,7 @@ After the httpd service is started, it reads the configuration file shown in [T
-Although the default configuration can be used in most cases, you need to be familiar with some important configuration items. After the configuration file is modified, run the following command to check the syntax errors that may occur in the configuration file: +Although the default configuration can be used in most cases, you need to be familiar with some important configuration items. After the configuration file is modified, run the following command as the **root** user to check the syntax errors that may occur in the configuration file: ``` # apachectl configtest @@ -169,19 +169,19 @@ To load a special DSO module, you can use the load module indication in the conf For example, to load the asis DSO module, perform the following steps: -1. In the /etc/httpd/conf.modules.d/00-optional.conf file, uncomment the following configuration line: +1. In the /etc/httpd/conf.modules.d/00-optional.conf file, uncomment the following configuration line as the **root** user: ``` LoadModule asis_module modules/mod_asis.so ``` -2. After the loading is complete, restart the httpd service to reload the configuration file. +2. After the loading is complete, restart the httpd service as the **root** user to reload the configuration file. ``` # systemctl restart httpd ``` -3. After the loading is complete, run the httpd -M command to check whether the asis DSO module is loaded. +3. After the loading is complete, run the httpd -M command as the **root** user to check whether the asis DSO module is loaded. ``` # httpd -M | grep asis @@ -203,19 +203,19 @@ For example, to load the asis DSO module, perform the following steps: #### Introduction to SSL Secure Sockets Layer \(SSL\) is an encryption protocol that allows secure communication between the server and client. The Transport Layer Security \(TLS\) protocol ensures security and data integrity for network communication. openEuler supports Mozilla Network Security Services \(NSS\) as the security protocol TLS. To load the SSL, perform the following steps: -1. Install the **mod\_ssl** RPM package. +1. Install the **mod\_ssl** RPM package as the **root** user. ``` # dnf install mod_ssl ``` -2. After the loading is complete, restart the httpd service to reload the configuration file. +2. After the loading is complete, restart the httpd service as the **root** user to reload the configuration file. ``` # systemctl restart httpd ``` -3. After the loading is complete, run the **httpd -M** command to check whether the SSL is loaded. +3. After the loading is complete, run the **httpd -M** command as the **root** user to check whether the SSL is loaded. ``` # httpd -M | grep ssl @@ -232,7 +232,7 @@ Secure Sockets Layer \(SSL\) is an encryption protocol that allows secure commun After the web server is set up, perform the following operations to check whether the web server is set up successfully: -1. Run the following command to check the IP address of the server: +1. Run the following command as the **root** user to check the IP address of the server: ``` # ifconfig @@ -267,7 +267,7 @@ After the web server is set up, perform the following operations to check whethe TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` -2. Configure the firewall. +2. Configure the firewall as the **root** user. ``` # firewall-cmd --add-service=http --permanent @@ -282,24 +282,24 @@ After the web server is set up, perform the following operations to check whethe Run the following command to check whether the web page can be accessed. If the service is successfully set up, the web page can be accessed. ``` - curl https://192.168.1.60 + $ curl http://192.168.1.60 ``` Run the following command to check whether the command output is 0. If the command output is 0, the httpd server is successfully set up. ``` - echo $? + $ echo $? ``` - Using the Windows OS Open the browser and enter the following address in the address box. If the web page can be accessed, the httpd server is successfully set up. - https://_192.168.1.60_ + http://192.168.1.60 If the port number is changed, enter the address in the following format: - https://_192.168.1.60: port number_ + http://192.168.1.60: port number @@ -317,25 +317,25 @@ Nginx is a lightweight web server which also acts as a reverse proxy server and 2. Clear the cache. ``` - #dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - #dnf makecache + $ dnf makecache ``` -4. Install the MariaDB server. +4. Install the Nginx server as the **root** user. ``` - #dnf install nginx + # dnf install nginx ``` 5. Check the installed RPM package. ``` - dnf list all | grep nginx + $ dnf list all | grep nginx ``` @@ -349,7 +349,7 @@ You can use the systemctl tool to manage the Nginx service, including starting, For more information about service management, see [Service Management](service-management.html). -- To start, stop, and restart the httpd service, you must have the **root** permission. +- To start, stop, and restart the Nginx service, you must have the **root** permission. #### Starting a Service - Run the following command to start and run the Nginx service: @@ -371,7 +371,7 @@ You can use the systemctl tool to manage the Nginx service, including starting, >If the running Nginx server functions as a secure server, a password is required after the system is started. The password is an encrypted private SSL key. #### Stopping the Service -- Run the following command to stop the httpd service: +- Run the following command to stop the Nginx service: ``` # systemctl stop nginx @@ -399,7 +399,7 @@ You can restart the service in any of the following ways: - Reload the configuration. ``` - # systemctl reload httpd + # systemctl reload nginx ``` This command causes the running Nginx service to reload its configuration file. Any requests that are currently being processed will be interrupted, causing the client browser to display an error message or re-render some pages. @@ -414,10 +414,10 @@ You can restart the service in any of the following ways: #### Verifying the Service Status -Check whether the httpd service is running. +Check whether the Nginx service is running. ``` -# systemctl is-active nginx +$ systemctl is-active nginx ``` If **active** is displayed in the command output, the service is running. @@ -449,10 +449,10 @@ After the Nginx service is started, it reads the configuration file shown in [T -Although the default configuration can be used in most cases, you need to be familiar with some important configuration items. After the configuration file is modified, run the following command to check the syntax errors that may occur in the configuration file: +Although the default configuration can be used in most cases, you need to be familiar with some important configuration items. After the configuration file is modified, run the following command as the **root** user to check the syntax errors that may occur in the configuration file: ``` -# /usr/sbin/nginx -t +# nginx -t ``` If the command output contains **syntax is ok**, the syntax of the configuration file is correct. @@ -475,7 +475,7 @@ The DSO is automatically loaded when the **dnf install nginx** command is used After the web server is set up, perform the following operations to check whether the web server is set up successfully: -1. Run the following command to check the IP address of the server: +1. Run the following command as the **root** user to check the IP address of the server: ``` # ifconfig @@ -510,7 +510,7 @@ After the web server is set up, perform the following operations to check whethe TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` -2. Configure the firewall. +2. Configure the firewall as the **root** user. ``` # firewall-cmd --add-service=http --permanent @@ -525,21 +525,21 @@ After the web server is set up, perform the following operations to check whethe Run the following command to check whether the web page can be accessed. If the service is successfully set up, the web page can be accessed. ``` - curl http://192.168.1.60 + $ curl http://192.168.1.60 ``` Run the following command to check whether the command output is **0**. If the command output is **0**, the Nginx server is successfully set up. ``` - echo $? + $ echo $? ``` - Using the Windows OS Open the browser and enter the following address in the address box. If the web page can be accessed, the Nginx server is successfully set up. - http://_192.168.1.60_ + http://192.168.1.60 If the port number is changed, enter the address in the following format: - http://_192.168.1.60: port number_ + http://192.168.1.60: port number diff --git a/content/en/docs/Administration/managing-hard-disks-through-lvm.md b/content/en/docs/Administration/managing-hard-disks-through-lvm.md index a8d5b7c57194cab545afb4795cac94c5a6c424c0..45c63cd6e2a964cc0857e8be9103f0f62584b4f1 100644 --- a/content/en/docs/Administration/managing-hard-disks-through-lvm.md +++ b/content/en/docs/Administration/managing-hard-disks-through-lvm.md @@ -67,32 +67,32 @@ When disks are managed using LVM, file systems are distributed on multiple disks 2. Clear the cache. ``` - #dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - #dnf makecache + $ dnf makecache ``` -4. Install the LVM. +4. Install the LVM as the **root** user. ``` - #dnf install lvm2 + # dnf install lvm2 ``` 5. Check the installed RPM package. ``` - #rpm -qa | grep lvm2 + $ rpm -qa | grep lvm2 ``` ## Managing PVs ### Creating a PV -Run the **pvcreate** command to create a PV. +Run the **pvcreate** command as the **root** user to create a PV. ``` pvcreate [option] devname ... @@ -110,17 +110,17 @@ In the preceding information: Example 1: Create PVs based on **/dev/sdb** and **/dev/sdc**. ``` -pvcreate /dev/sdb /dev/sdc +# pvcreate /dev/sdb /dev/sdc ``` Example 2: Create PVs based on **/dev/sdb1** and **/dev/sdb2**. ``` -pvcreate /dev/sdb1 /dev/sdb2 +# pvcreate /dev/sdb1 /dev/sdb2 ``` ### Viewing a PV -Run the **pvdisplay** command to view PV information, including PV name, VG to which the PV belongs, PV size, PE size, total number of PEs, number of available PEs, number of allocated PEs, and UUID. +Run the **pvdisplay** command as the **root** user to view PV information, including PV name, VG to which the PV belongs, PV size, PE size, total number of PEs, number of available PEs, number of allocated PEs, and UUID. ``` pvdisplay [option] devname @@ -137,11 +137,11 @@ In the preceding information: Example: Run the following command to display the basic information about the PV **/dev/sdb**: ``` -pvdisplay /dev/sdb +# pvdisplay /dev/sdb ``` ### Modifying PV Attributes -Run the **pvchange** command to modify the attributes of a PV. +Run the **pvchange** command as the **root** user to modify the attributes of a PV. ``` pvchange [option] pvname ... @@ -158,11 +158,11 @@ In the preceding information: Example: Run the following command to prohibit PEs on the PV **/dev/sdb** from being allocated. ``` -pvchange -x n /dev/sdb +# pvchange -x n /dev/sdb ``` ### Deleting a PV -Run the **pvremove** command to delete a PV. +Run the **pvremove** command as the **root** user to delete a PV. ``` pvremove [option] pvname ... @@ -179,13 +179,13 @@ In the preceding information: Example: Run the following command to delete the PV **/dev/sdb**: ``` -pvremove /dev/sdb +# pvremove /dev/sdb ``` ## Managing VGs ### Creating a VG -Run the **vgcreate** command to create a VG. +Run the **vgcreate** command as the **root** user to create a VG. ``` vgcreate [option] vgname pvname ... @@ -204,11 +204,11 @@ In the preceding information: Example: Run the following command to create VG **vg1** and add the PVs **/dev/sdb** and **/dev/sdc** to the VG. ``` -vgcreate vg1 /dev/sdb /dev/sdc +# vgcreate vg1 /dev/sdb /dev/sdc ``` ### Viewing a VG -Run the **vgdisplay** command to view VG information. +Run the **vgdisplay** command as the **root** user to view VG information. ``` vgdisplay [option] [vgname] @@ -225,11 +225,11 @@ In the preceding information: Example: Run the following command to display the basic information about VG **vg1**: ``` -vgdisplay vg1 +# vgdisplay vg1 ``` ### Modifying VG Attributes -Run the **vgchange** command to modify the attributes of a VG. +Run the **vgchange** command as the **root** user to modify the attributes of a VG. ``` vgchange [option] vgname @@ -245,11 +245,11 @@ In the preceding information: Example: Run the following command to change the status of **vg1** to active. ``` -vgchange -ay vg1 +# vgchange -ay vg1 ``` ### Extending a VG -Run the **vgextend** command to dynamically extend a VG. In this way, the VG size is extended by adding PVs to the VG. +Run the **vgextend** command as the **root** user to dynamically extend a VG. In this way, the VG size is extended by adding PVs to the VG. ``` vgextend [option] vgname pvname ... @@ -267,11 +267,11 @@ In the preceding information: Example: Run the following command to add PV **/dev/sdb** to VG **vg1**: ``` -vgextend vg1 /dev/sdb +# vgextend vg1 /dev/sdb ``` ### Shrinking a VG -Run the **vgreduce** command to delete PVs from a VG to reduce the VG size. A VG must contain at least one PV. +Run the **vgreduce** command as the **root** user to delete PVs from a VG to reduce the VG size. A VG must contain at least one PV. ``` vgreduce [option] vgname pvname ... @@ -289,11 +289,11 @@ In the preceding information: Example: Run the following command to remove PV **/dev/sdb2** from VG **vg1**: ``` -vgreduce vg1 /dev/sdb2 +# vgreduce vg1 /dev/sdb2 ``` ### Deleting a VG -Run the **vgremove** command to delete a VG. +Run the **vgremove** command as the **root** user to delete a VG. ``` vgremove [option] vgname @@ -309,13 +309,13 @@ In the preceding information: Example: Run the following command to delete VG **vg1**. ``` -vgremove vg1 +# vgremove vg1 ``` ## Managing LVs ### Creating an LV -Run the **lvcreate** command to create an LV. +Run the **lvcreate** command as the **root** user to create an LV. ``` lvcreate [option] vgname @@ -334,17 +334,17 @@ In the preceding information: Example 1: Run the following command to create a 10 GB LV in VG **vg1**. ``` -lvcreate -L 10G vg1 +# lvcreate -L 10G vg1 ``` -Example 1: Run the following command to create a 200 MB LV in VG **vg1** and name the LV **lv1**. +Example 2: Run the following command to create a 200 MB LV in VG **vg1** and name the LV **lv1**. ``` -lvcreate -L 200M -n lv1 vg1 +# lvcreate -L 200M -n lv1 vg1 ``` ### Viewing an LV -Run the **lvdisplay** command to view the LV information, including the size of the LV, its read and write status, and snapshot information. +Run the **lvdisplay** command as the **root** user to view the LV information, including the size of the LV, its read and write status, and snapshot information. ``` lvdisplay [option] [lvname] @@ -353,8 +353,9 @@ lvdisplay [option] [lvname] In the preceding information: - _option_: command parameter options. Common parameter options are as follows: - - **-v**: displays the mapping from LEs to PEs. - + +- **-v**: displays the mapping from LEs to PEs. + - _lvname_: device file corresponding to the LV whose attributes are to be displayed. If this option is not set, attributes of all LVs are displayed. >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -364,11 +365,11 @@ In the preceding information: Example: Run the following command to display the basic information about LV **lv1**: ``` -lvdisplay /dev/vg1/lv1 +# lvdisplay /dev/vg1/lv1 ``` ### Adjusting the LV Size -Run the **lvresize** command to increase or reduce the size of an LVM LV. This may cause data loss. Therefore, exercise caution when running this command. +Run the **lvresize** command as the **root** user to increase or reduce the size of an LVM LV. This may cause data loss. Therefore, exercise caution when running this command. ``` lvresize [option] vgname @@ -386,17 +387,17 @@ In the preceding information: Example 1: Run the following command to increase the size of LV **/dev/vg1/lv1** by 200 MB. ``` -lvresize -L +200 /dev/vg1/lv1 +# lvresize -L +200 /dev/vg1/lv1 ``` Example 2: Run the following command to reduce the size of LV **/dev/vg1/lv1** by 200 MB. ``` -lvresize -L -200 /dev/vg1/lv1 +# lvresize -L -200 /dev/vg1/lv1 ``` ### Extending an LV -Run the **lvextend** command to dynamically extend the size of an LV online without interrupting the access of applications to the LV. +Run the **lvextend** command as the **root** user to dynamically extend the size of an LV online without interrupting the access of applications to the LV. ``` lvextend [option] lvname @@ -414,11 +415,11 @@ In the preceding information: Example: Run the following command to increase the size of LV **/dev/vg1/lv1** by 100 MB. ``` -lvextend -L +100M /dev/vg1/lv1 +# lvextend -L +100M /dev/vg1/lv1 ``` ### Shrinking an LV -Run the **lvreduce** command to reduce the size of an LV. This may delete existing data on the LV. Therefore, confirm whether the data can be deleted before running the command. +Run the **lvreduce** command as the **root** user to reduce the size of an LV. This may delete existing data on the LV. Therefore, confirm whether the data can be deleted before running the command. ``` lvreduce [option] lvname @@ -436,11 +437,11 @@ In the preceding information: Example: Run the following command to reduce the space of LV **/dev/vg1/lvl** by 100 MB: ``` -lvreduce -L -100M /dev/vg1/lv1 +# lvreduce -L -100M /dev/vg1/lv1 ``` ### Deleting an LV -Run the **lvremove** command to delete an LV. If the LV has been mounted by running the **mount** command, you need to run the **umount** command to unmount the LV before running the **lvremove** command. +Run the **lvremove** command as the **root** user to delete an LV. If the LV has been mounted by running the **mount** command, you need to run the **umount** command to unmount the LV before running the **lvremove** command. ``` lvremove [option] vgname @@ -456,7 +457,7 @@ In the preceding information: Example: Run the following command to delete LV **/dev/vg1/lv1**. ``` -lvremove /dev/vg1/lv1 +# lvremove /dev/vg1/lv1 ``` ## Creating and Mounting a File System @@ -464,7 +465,7 @@ lvremove /dev/vg1/lv1 After creating an LV, you need to create a file system on the LV and mount the file system to the corresponding directory. ### Creating a File System -Run the **mkfs** command to create a file system. +Run the **mkfs** command as the **root** user to create a file system. ``` mkfs [option] lvname @@ -480,13 +481,13 @@ In the preceding information: Example: Run the following command to create the **ext4** file system on LV **/dev/vg1/lv1**: ``` -mkfs -t ext4 /dev/vg1/lv1 +# mkfs -t ext4 /dev/vg1/lv1 ``` ### Manually Mounting a File System The file system that is manually mounted is not valid permanently. It does not exist after the OS is restarted. -Run the **mount** command to mount a file system. +Run the **mount** command as the **root** user to mount a file system. ``` mount lvname mntpath @@ -500,16 +501,16 @@ In the preceding information: Example: Run the following command to mount LV **/dev/vg1/lv1** to the directory **/mnt/data**. ``` -mount /dev/vg1/lv1 /mnt/data +# mount /dev/vg1/lv1 /mnt/data ``` ### Automatically Mounting a File System -A file system that is automatically mounted does not exist after the OS is restarted. You need to manually mount the file system again. If you perform the following steps after manually mounting the file system, the file system can be automatically mounted after the OS is restarted. +A file system that is automatically mounted does not exist after the OS is restarted. You need to manually mount the file system again. If you perform the following steps as the **root** user after manually mounting the file system, the file system can be automatically mounted after the OS is restarted. 1. Run the **blkid** command to query the UUID of an LV. The following uses LV **/dev/vg1/lv1** as an example: ``` - blkid /dev/vg1/lv1 + # blkid /dev/vg1/lv1 ``` Check the command output. It contains the following information in which _uuidnumber_ is a string of digits, indicating the UUID, and _fstype_ indicates the file system type. @@ -535,19 +536,19 @@ A file system that is automatically mounted does not exist after the OS is resta 1. Run the **umount** command to unmount the file system. The following uses LV **/dev/vg1/lv1** as an example: ``` - umount /dev/vg1/lv1 + # umount /dev/vg1/lv1 ``` 2. Run the following command to reload all content in the **/etc/fstab** file: ``` - mount -a + # mount -a ``` 3. Run the following command to query the file system mounting information \(**/mnt/data** is used as an example\): ``` - mount | grep /mnt/data + # mount | grep /mnt/data ``` Check the command output. If the command output contains the following information, the automatic mounting function takes effect: diff --git a/content/en/docs/Administration/process-management.md b/content/en/docs/Administration/process-management.md index 84567f35beda7bd5318dc1505e9a3b5ce192d6e5..e745e2271bdefd0a6a940ca09e88ff61d8547874 100644 --- a/content/en/docs/Administration/process-management.md +++ b/content/en/docs/Administration/process-management.md @@ -26,7 +26,7 @@ The who command is used to display system user information. For example, before The following is an example output of the who command, where system users and their status are displayed: The use of the **who** command is as follows: ``` -# who +$ who admin tty1 Jul 28 15:55 admin pts/0 Aug 5 15:46 (192.168.0.110) admin pts/2 Jul 29 19:52 (192.168.0.110) @@ -97,7 +97,7 @@ A common scenario is using the ps command to monitor background processes, which For example, to list all processes on a terminal, run the following command: ``` -# ps -a +$ ps -a PID TTY TIME CMD 12175 pts/6 00:00:00 bash 24526 pts/0 00:00:00 vsftpd @@ -127,7 +127,7 @@ kill -l [signal] The process ID is retrieved from the ps command. The **-s** option indicates the signal sent to specified program. The signal details can be viewed by running the **kill -l** command. The **-p** option indicates the specified process IDs. -For example, to terminate the process with ID 1409, run the following command: +For example, to terminate the process with ID 1409, run the following command as the **root** user: ``` # kill -9 1409 @@ -136,7 +136,7 @@ For example, to terminate the process with ID 1409, run the following command: Example output of the kill command with the -l option ``` -# kill -l +$ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM @@ -197,7 +197,7 @@ Although you can select any of the preceding examples according to your preferen #### Privileges Only commands from standard input or from the file specified by the -f option can be scheduled by the at command to be executed. If the su command is executed to switch the operating system from user A to user B and then the at command is executed at the shell prompt of user B, the at command execution result is sent to user B. whereas emails \(if any\) are sent to user A. -For example, to run the slocate -u command at 10 am on June 8, 2019, perform the following steps: +For example, to run the slocate -u command at 10 am on June 8, 2019, perform the following steps as the **root** user: ``` # at 10:00 6/8/19 @@ -215,7 +215,7 @@ The administrator is authorized to run the at command unconditionally. For other The at command can run commands at the scheduled time but only once. It means that after the running command is specified, the system completes the task at the specified time. If you need to run commands repeatedly, the cron service is a good helper. #### Cron Service -The **cron** service searches the **/var/spool/cron** directory for **crontab** files named by the user name in the /etc/passwd file and loads the search results into memory to execute the commands in the **crontab** files. Each user has a crontab file, with the file name being the same as the user name. For example, the **crontab** file of the **globus** user is **/var/spool/cron/globus**. +The **cron** service searches the **/var/spool/cron** directory for **crontab** files named by the user name in the /etc/passwd file and loads the search results into memory to execute the commands in the **crontab** files. Each user has a crontab file, with the file name being the same as the user name. For example, the **crontab** file of the **userexample** user is **/var/spool/cron/userexample**. The **cron** service also reads the cron configuration file **/etc/crontab** every minute, which can be edited in various formats. If no crontab files are found, the **cron** service enters sleep mode and releases system resources. One minute later, the **cron** service is awoken to repeat the search work and command execution. Therefore, the background process occupies few resources and is wakened up every minute to check whether there are commands to be executed. @@ -234,7 +234,7 @@ Here are common crontab command options: For example, to list cron service settings of the user **root**, run the following command: ``` -crontab -u root -l +# crontab -u root -l ``` #### crontab Files @@ -298,17 +298,17 @@ For example, to allow the operating system to add sleepy to the /tmp/test.txt fi Each time the cron service settings of a user are edited, the cron service generates in the /var/spool/cron directory a crontab file named after the user. The crontab file can be edited only using the crontab -e command. Alternatively, the user can create a file and run the crontab _filename_ command to import its cron settings into the new file. -For example, to create a crontab file for the globus user, perform the following steps: The procedure is as follows: +For example, to create a crontab file for the userexample user, perform the following steps: The procedure is as follows: -1. Create a file using any text editor. Add the commands that need to be executed periodically and the command execution interval to the new file. In this example, the new file is **\~/globus.cron**. -2. Run the following command to install the new file as the crontab file of the globus user: run the following command: +1. Create a file using any text editor. Add the commands that need to be executed periodically and the command execution interval to the new file. In this example, the new file is **\~/userexample.cron**. +2. Run the following command as the **root** user to install the new file as the crontab file of the userexample user: ``` - crontab globus. ~/globus.cron + # crontab -u userexample ~/userexample.cron ``` -After the new file is installed, you will find a file named globus in the **/var/spool/cron** directory. This file is the required crontab file. +After the new file is installed, you will find a file named userexample in the **/var/spool/cron** directory. This file is the required crontab file. >![](public_sys-resources/icon-note.gif) **NOTE:** >Do not restart the cron service after a crontab file is modified, because the cron service, once started, reads the crontab file every minute to check whether there are commands that need to be executed periodically. You do not need to restart the **cron** service after modifying the **crontab** file. diff --git a/content/en/docs/Administration/setting-up-the-database-server.md b/content/en/docs/Administration/setting-up-the-database-server.md index d7ef2d75375223f3f82021b6b16b2ce4d32c264c..c88049f01333ce83b94cb8d52d8979a4eeca1df7 100644 --- a/content/en/docs/Administration/setting-up-the-database-server.md +++ b/content/en/docs/Administration/setting-up-the-database-server.md @@ -119,16 +119,16 @@ >![](public_sys-resources/icon-note.gif) **NOTE:** >It is recommended that firewall be disabled in the test environment to prevent network impact. Configure the firewall based on actual requirements. -1. Stop the firewall service. +1. Stop the firewall service as the **root** user. ``` - #systemctl stop firewalld + # systemctl stop firewalld ``` -2. Disable the firewall service. +2. Disable the firewall service as the **root** user. ``` - #systemctl disable firewalld + # systemctl disable firewalld ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -137,10 +137,10 @@ #### Disabling SELinux -1. Modify the configuration file. +1. Modify the configuration file as the **root** user. ``` - #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` @@ -149,17 +149,17 @@ >![](public_sys-resources/icon-note.gif) **NOTE:** >In the server environment, independent users are assigned to each process to implement permission isolation for security purposes. The user group and user are created for the OS, not for the database. -1. Create a PostgreSQL user or user group. +1. Create a PostgreSQL user or user group as the **root** user. ``` - #groupadd postgres + # groupadd postgres ``` ``` - #useradd -g postgres postgres + # useradd -g postgres postgres ``` -2. Set the postgres user password. \(Enter the password twice for confirmation.\) +2. Set the postgres user password as the **root** user. \(Enter the password twice for confirmation.\) ``` #passwd postgres @@ -170,34 +170,34 @@ >![](public_sys-resources/icon-note.gif) **NOTE:** >- When testing the ultimate performance, you are advised to attach NVMe SSDs with better I/O performance to create PostgreSQL test instances to avoid the impact of disk I/O on the performance test result. This section uses NVMe SSDs as an example. For details, see Step 1 to Step 4. ->- In a non-performance test, run the following command to create a data directory. Then skip this section. -> \#mkdir /data +>- In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +> \# mkdir /data -1. Create a file system \(xfs is used as an example. Create the file system based on the site requirements.\). If a file system has been created for a disk, an error will be reported when you run this command. You can use the **-f** parameter to forcibly create a file system. +1. Create a file system \(xfs is used as an example as the **root** user. Create the file system based on the site requirements.\). If a file system has been created for a disk, an error will be reported when you run this command. You can use the **-f** parameter to forcibly create a file system. ``` - #mkfs.xfs /dev/nvme0n1 + # mkfs.xfs /dev/nvme0n1 ``` 2. Create a data directory. ``` - #mkdir /data + # mkdir /data ``` 3. Mount disks. ``` - #mount -o noatime,nobarrier /dev/nvme0n1 /data + # mount -o noatime,nobarrier /dev/nvme0n1 /data ``` #### Data Directory Authorization -1. Modify the directory permission. +1. Modify the directory permission as the **root** user. ``` - #chown -R postgres:postgres /data/ + # chown -R postgres:postgres /data/ ``` @@ -210,16 +210,16 @@ 2. Clear the cache. ``` - #dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - #dnf makecache + $ dnf makecache ``` -4. Install the PostgreSQL server. +4. Install the PostgreSQL server as the **root** user. ``` #dnf install postgresql-server @@ -228,7 +228,7 @@ 5. Check the installed RPM package. ``` - #rpm -qa | grep postgresql + $ rpm -qa | grep postgresql ``` @@ -244,13 +244,13 @@ 1. Switch to the created PostgreSQL user. ``` - #su - postgres + # su - postgres ``` 2. Initialize the database. In the command, **/usr/bin** is the directory where the **initdb** command is located. ``` - $/usr/bin/initdb -D /data/ + $ /usr/bin/initdb -D /data/ ``` @@ -259,13 +259,13 @@ 1. Enable the PostgreSQL database. ``` - $/usr/bin/pg_ctl -D /data/ -l /data/logfile start + $ /usr/bin/pg_ctl -D /data/ -l /data/logfile start ``` 2. Check whether the PostgreSQL database process is started properly. ``` - $ps -ef | grep postgres + $ ps -ef | grep postgres ``` If the following information is displayed, the PostgreSQL processes have been started. @@ -278,7 +278,7 @@ 1. Log in to the database. ``` - $/usr/bin/psql -U postgres + $ /usr/bin/psql -U postgres ``` ![](figures/登录.png) @@ -303,7 +303,7 @@ 1. Run **\\q** to exit from the database. ``` - postgres=#\q + postgres=# \q ``` @@ -321,13 +321,13 @@ 1. Stop the database as the postgres user. ``` - $/usr/bin/pg_ctl -D /data/ -l /data/logfile stop + $ /usr/bin/pg_ctl -D /data/ -l /data/logfile stop ``` 2. Run the **dnf remove postgresql-server** command as the user **root** to uninstall the PostgreSQL database. ``` - #dnf remove postgresql-server + # dnf remove postgresql-server ``` @@ -428,7 +428,7 @@ In the preceding information: \#Change the role name **roleexample1** to **roleexapme2**. ``` -# ALTER ROLE roleexample1 RENAME TO roleexample2; +postgres=# ALTER ROLE roleexample1 RENAME TO roleexample2; ``` ##### Modifying a User Password @@ -447,7 +447,7 @@ In the preceding information: \#Modify the password of **roleexample1** to **456789**. ``` -# ALTER ROLE roleexample1 WITH PASSWORD '456789'; +postgres=# ALTER ROLE roleexample1 WITH PASSWORD '456789'; ``` #### Deleting a Role @@ -551,13 +551,13 @@ In the preceding information: \#Grant the CREATE permission on database1 to userexample. ``` -# GRANT CREATE ON DATABASE database1 TO userexample; +postgres=# GRANT CREATE ON DATABASE database1 TO userexample; ``` \#Grant all permissions on table1 to all users. ``` -# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; +postgres=# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; ``` #### Deleting User Permissions @@ -636,13 +636,13 @@ In the preceding information: \#Grant the CREATE permission on database1 to userexample. ``` -# GRANT CREATE ON DATABASE database1 TO userexample; +postgres=# GRANT CREATE ON DATABASE database1 TO userexample; ``` \#Grant all permissions on table1 to all users. ``` -# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; +postgres=# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; ``` ### Managing Databases @@ -686,7 +686,7 @@ In the preceding command, **databasename** indicates the database name. \#Select the **databaseexample** database. ``` -# \c databaseexample; +postgres=# \c databaseexample; ``` #### Viewing a Database @@ -701,7 +701,7 @@ Use the **\\l** statement to view the database. \#View all databases. ``` -# \l; +postgres=# \l; ``` #### Deleting a Database @@ -729,7 +729,7 @@ The **DROP DATABASE** statement deletes the system directory items of the data \#Delete the **databaseexample** database. ``` -# DROP DATABASE databaseexample; +postgres=# DROP DATABASE databaseexample; ``` #### Backing Up a Database @@ -757,7 +757,7 @@ In the preceding information: \#Back up the database1 database of user **postgres** on port **3306** of the host whose IP address is **192.168.202.144** to the **db1.sql** file. ``` -$ pg_dump -h 192.168.202.144 -p 3306 -U postgres -W database1 > db1.sql +[postgres@localhost ~]$ pg_dump -h 192.168.202.144 -p 3306 -U postgres -W database1 > db1.sql ``` #### Restoring a Database @@ -788,8 +788,8 @@ The **psql** command cannot be used to automatically create the **databasenam \#Import the **db1.sql** script file to the newdb database of the postgres user on the host **192.168.202.144** through port **3306**. ``` -$ createdb newdb -$ psql -h 192.168.202.144 -p 3306 -U postgres -W -d newdb < db1.sql +[postgres@localhost ~]$ createdb newdb +[postgres@localhost ~]$ psql -h 192.168.202.144 -p 3306 -U postgres -W -d newdb < db1.sql ``` ## MariaDB Server @@ -834,16 +834,16 @@ Each storage engine manages and stores data in different ways, and supports diff >![](public_sys-resources/icon-note.gif) **NOTE:** >It is recommended that firewall be disabled in the test environment to prevent network impact. Configure the firewall based on actual requirements. -1. Stop the firewall service. +1. Stop the firewall service as the **root** user. ``` - #systemctl stop firewalld + # systemctl stop firewalld ``` -2. Disable the firewall service. +2. Disable the firewall service as the **root** user. ``` - #systemctl disable firewalld + # systemctl disable firewalld ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -852,10 +852,10 @@ Each storage engine manages and stores data in different ways, and supports diff #### Disabling SELinux -1. Modify the configuration file. +1. Modify the configuration file as the **root** user. ``` - #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` @@ -864,20 +864,20 @@ Each storage engine manages and stores data in different ways, and supports diff >![](public_sys-resources/icon-note.gif) **NOTE:** >In the server environment, independent users are assigned to each process to implement permission isolation for security purposes. The user group and user are created for the OS, not for the database. -1. Create a MySQL user or user group. +1. Create a MySQL user or user group as the **root** user. ``` - #groupadd mysql + # groupadd mysql ``` ``` - #useradd -g mysql mysql + # useradd -g mysql mysql ``` -2. Set the user password. +2. Set the user password as the **root** user. ``` - #passwd mysql + # passwd mysql ``` Enter the password twice for confirmation. @@ -887,14 +887,14 @@ Each storage engine manages and stores data in different ways, and supports diff >![](public_sys-resources/icon-note.gif) **NOTE:** >- If a performance test needs to be performed, an independent drive is required for the data directory. You need to format and mount the drive. For details, see Method 1 or Method 2. ->- In a non-performance test, run the following command to create a data directory. Then skip this section. -> \#mkdir /data +>- In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +> \# mkdir /data -##### Method 1: Using fdisk for Drive Management +##### Method 1: Using fdisk for Drive Management as the **root** user 1. Create a partition, for example, **/dev/sdb**. ``` - #fdisk /dev/sdb + # fdisk /dev/sdb ``` 2. Enter **n** and press **Enter**. @@ -906,17 +906,17 @@ Each storage engine manages and stores data in different ways, and supports diff 8. Create a file system, for example, **xfs**. ``` - #mkfs.xfs /dev/sdb1 + # mkfs.xfs /dev/sdb1 ``` 9. Mount the partition to **/data** for the OS. ``` - #mkdir /data + # mkdir /data ``` ``` - #mount /dev/sdb1 /data + # mount /dev/sdb1 /data ``` 10. Run the **vi /etc/fstab** command and edit the **/etc/fstab** file to enable the data drive to be automatically mounted after the system is restarted. For example, add the content in the last line, as shown in the following figure. @@ -926,45 +926,45 @@ Each storage engine manages and stores data in different ways, and supports diff ![](figures/搭建数据盘.png) -##### Method 2: Using LVM for Drive Management +##### Method 2: Using LVM for Drive Management as the **root** user >![](public_sys-resources/icon-note.gif) **NOTE:** >Install the LVM2 package in the image as follows: >1. Configure the local yum source. For details, see [Configuring the Repo Server](configuring-the-repo-server.html). If the repository has been configured, skip this step. >2. Install LVM2. -> **\#yum install lvm2** +> **\# yum install lvm2** 1. Create a physical volume, for example, **sdb**. ``` - #pvcreate /dev/sdb + # pvcreate /dev/sdb ``` 2. Create a physical volume group, for example, **datavg**. ``` - #vgcreate datavg /dev/sdb + # vgcreate datavg /dev/sdb ``` 3. Create a logical volume, for example, **datalv** of 600 GB. ``` - #lvcreate -L 600G -n datalv datavg + # lvcreate -L 600G -n datalv datavg ``` 4. Create a file system. ``` - #mkfs.xfs /dev/datavg/datalv + # mkfs.xfs /dev/datavg/datalv ``` 5. Create a data directory and mount it. ``` - #mkdir /data + # mkdir /data ``` ``` - #mount /dev/datavg/datalv /data + # mount /dev/datavg/datalv /data ``` 6. Run the **vi /etc/fstab** command and edit the **/etc/fstab** file to enable the data drive to be automatically mounted after the system is restarted. For example, add the content in the last line, as shown in the following figure. @@ -976,13 +976,13 @@ Each storage engine manages and stores data in different ways, and supports diff #### Creating a Database Directory and Granting Permissions -1. In the created data directory **/data**, create directories for processes and grant permissions to the MySQL group or user created. +1. In the created data directory **/data**, create directories for processes and grant permissions to the MySQL group or user created as the **root** user. ``` - #mkdir -p /data/mariadb - #cd /data/mariadb - #mkdir data tmp run log - #chown -R mysql:mysql /data + # mkdir -p /data/mariadb + # cd /data/mariadb + # mkdir data tmp run log + # chown -R mysql:mysql /data ``` @@ -995,40 +995,40 @@ Each storage engine manages and stores data in different ways, and supports diff 2. Clear the cache. ``` - #dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - #dnf makecache + $ dnf makecache ``` 4. Install the MariaDB server. ``` - #dnf install mariadb-server + # dnf install mariadb-server ``` 5. Check the installed RPM package. ``` - #rpm -qa | grep mariadb + $ rpm -qa | grep mariadb ``` #### Running MariaDB Server -1. Start the MariaDB server. +1. Start the MariaDB server as the **root** user. ``` - #systemctl start mariadb + # systemctl start mariadb ``` -2. Initialize the database. +2. Initialize the database as the **root** user. ``` - #/usr/bin/mysql_secure_installation + # /usr/bin/mysql_secure_installation ``` During the command execution, you need to enter the password of the database user **root**. If no password is set, press **Enter**. Then, set the password as prompted. @@ -1036,7 +1036,7 @@ Each storage engine manages and stores data in different ways, and supports diff 3. Log in to the database. ``` - # mysql -u root -p + $ mysql -u root -p ``` After the command is executed, the system prompts you to enter the password. The password is the one set in [2](#li197143190587). @@ -1047,17 +1047,17 @@ Each storage engine manages and stores data in different ways, and supports diff #### Uninstalling MariaDB -1. Stop the database process. +1. Stop the database process as the **root** user. ``` - #ps -ef | grep mysql - #kill -9 PID + $ ps -ef | grep mysql + # kill -9 PID ``` -2. Run the **dnf remove mariadb-server** command to uninstall MariaDB. +2. Run the **dnf remove mariadb-server** command as the **root** user to uninstall MariaDB. ``` - #dnf remove mariadb-server + # dnf remove mariadb-server ``` @@ -1095,7 +1095,7 @@ A new user has few permissions and can perform only operations that do not requi \#Create a user whose password is 123456, username is userexample2, and hostname is 192.168.1.100. ``` -> CREATE USER 'userexample2'@'192.168.1.100' IDENDIFIED BY '123456'; +> CREATE USER 'userexample2'@'192.168.1.100' IDENTIFIED BY '123456'; ``` #### Viewing Users @@ -1345,7 +1345,7 @@ To use **DROP DATABASE**, you need the **DROP** permission on the database. #### Backing Up a Database -Run the **mysqldump** command to back up the database. +Run the **mysqldump** command as the **root** user to back up the database. Back up one or more tables. @@ -1408,12 +1408,12 @@ In the preceding information: \#Back up only the data of the db1 database of the user **root** on the host **192.168.202.144** through port **3306** to the **db1.sql** file. ``` -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sq +# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql ``` #### Restoring a Database -Run the **mysqldump** command to restore the database. +Run the **mysql** command as the **root** user to restore the database. Back up one or more tables: @@ -1461,16 +1461,16 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](public_sys-resources/icon-note.gif) **NOTE:** >It is recommended that firewall be disabled in the test environment to prevent network impact. Configure the firewall based on actual requirements. -1. Stop the firewall service. +1. Stop the firewall service as the **root** user. ``` - #systemctl stop firewalld + # systemctl stop firewalld ``` -2. Disable the firewall service. +2. Disable the firewall service as the **root** user. ``` - #systemctl disable firewalld + # systemctl disable firewalld ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -1479,10 +1479,10 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard #### Disabling SELinux -1. Modify the configuration file. +1. Modify the configuration file as the **root** user. ``` - #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` @@ -1491,20 +1491,20 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](public_sys-resources/icon-note.gif) **NOTE:** >In the server environment, independent users are assigned to each process to implement permission isolation for security purposes. The user group and user are created for the OS, not for the database. -1. Create a MySQL user or user group. +1. Create a MySQL user or user group as the **root** user. ``` - #groupadd mysql + # groupadd mysql ``` ``` - #useradd -g mysql mysql + # useradd -g mysql mysql ``` -2. Set the user password. +2. Set the user password as the **root** user. ``` - #passwd mysql + # passwd mysql ``` Enter the password twice for confirmation. @@ -1514,14 +1514,14 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](public_sys-resources/icon-note.gif) **NOTE:** >- If a performance test needs to be performed, an independent drive is required for the data directory. You need to format and mount the drive. For details, see Method 1 or Method 2. ->- In a non-performance test, run the following command to create a data directory. Then skip this section. -> \#mkdir /data +>- In a non-performance test, run the following command as the **root** user to create a data directory. Then skip this section. +> \# mkdir /data -##### Method 1: Using fdisk for Drive Management +##### Method 1: Using fdisk for Drive Management as the **root** user 1. Create a partition, for example, **/dev/sdb**. ``` - #fdisk /dev/sdb + # fdisk /dev/sdb ``` 2. Enter **n** and press **Enter**. @@ -1533,17 +1533,17 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard 8. Create a file system, for example, **xfs**. ``` - #mkfs.xfs /dev/sdb1 + # mkfs.xfs /dev/sdb1 ``` 9. Mount the partition to **/data** for the OS. ``` - #mkdir /data + # mkdir /data ``` ``` - #mount /dev/sdb1 /data + # mount /dev/sdb1 /data ``` 10. Run the **vi /etc/fstab** command and edit the **/etc/fstab** file to enable the data drive to be automatically mounted after the system is restarted. For example, add the content in the last line, as shown in the following figure. @@ -1553,41 +1553,41 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard ![](figures/搭建数据盘-0.png) -##### Method 2: Using LVM for Drive Management +##### Method 2: Using LVM for Drive Management as the **root** user >![](public_sys-resources/icon-note.gif) **NOTE:** >Install the LVM2 package in the image as follows: >1. Configure the local yum source. For details, see [Configuring the Repo Server](configuring-the-repo-server.html). If the repository has been configured, skip this step. >2. Install LVM2. -> **\#yum install lvm2** +> **\# yum install lvm2** 1. Create a PV, for example, **sdb**. ``` - #pvcreate /dev/sdb + # pvcreate /dev/sdb ``` 2. Create a physical VG, for example, **datavg**. ``` - #vgcreate datavg /dev/sdb + # vgcreate datavg /dev/sdb ``` 3. Create an LV, for example, **datalv** of 600 GB. ``` - #lvcreate -L 600G -n datalv datavg + # lvcreate -L 600G -n datalv datavg ``` 4. Create a file system. ``` - #mkfs.xfs /dev/datavg/datalv + # mkfs.xfs /dev/datavg/datalv ``` 5. Create a data directory and mount it. ``` - #mkdir /data + # mkdir /data ``` ``` @@ -1603,13 +1603,13 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard #### Creating a Database Directory and Granting Permissions -1. In the created data directory **/data**, create directories for processes and grant permissions to the MySQL group or user created. +1. In the created data directory **/data**, create directories for processes and grant permissions to the MySQL group or user created as the **root** user. ``` - #mkdir -p /data/mysql - #cd /data/mysql - #mkdir data tmp run log - #chown -R mysql:mysql /data + # mkdir -p /data/mysql + # cd /data/mysql + # mkdir data tmp run log + # chown -R mysql:mysql /data ``` @@ -1623,35 +1623,35 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard 2. Clear the cache. ``` - #dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - #dnf makecache + $ dnf makecache ``` -4. Install the MySQL server. +4. Install the MySQL server as the **root** user. ``` - #dnf install mysql + # dnf install mysql ``` 5. Check the installed RPM package. ``` - #rpm -qa | grep mysql + $ rpm -qa | grep mysql ``` #### Running MySQL 1. Modify the configuration file. - 1. Create the **my.cnf** file and change the file paths \(including the software installation path **basedir** and data path **datadir**\) based on the actual situation. + 1. Create the **my.cnf** file as the **root** user and change the file paths \(including the software installation path **basedir** and data path **datadir**\) based on the actual situation. ``` - #vi /etc/my.cnf + # vi /etc/my.cnf ``` Edit the **my.cnf** file as follows: @@ -1679,7 +1679,7 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard 2. Ensure that the **my.cnf** file is correctly modified. ``` - #cat /etc/my.cnf + $ cat /etc/my.cnf ``` ![](figures/en-us_image_0231563132.png) @@ -1687,35 +1687,35 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](public_sys-resources/icon-caution.gif) **CAUTION:** >In the configuration file, **basedir** specifies the software installation path. Change it based on actual situation. - 3. Change the group and user of the **/etc/my.cnf** file to **mysql:mysql**. + 3. Change the group and user of the **/etc/my.cnf** file to **mysql:mysql** as the **root** user. ``` - #chown mysql:mysql /etc/my.cnf + # chown mysql:mysql /etc/my.cnf ``` 2. Configure environment variables. - 1. Add the path of the MySQL binary files to the **PATH** parameter. + 1. Add the path of the MySQL binary files to the **PATH** parameter as the **root** user. ``` - #echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile + # echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile ``` >![](public_sys-resources/icon-caution.gif) **CAUTION:** >In the command, **/usr/local/mysql/bin** is the absolute path of the **bin** files in the MySQL software installation directory. Change it based on actual situation. - 2. Run the following command to make the environment variables take effect: + 2. Run the following command as the **root** user to make the environment variables take effect: ``` - #source /etc/profile + # source /etc/profile ``` -3. Initialize the database. +3. Initialize the database as the **root** user. >![](public_sys-resources/icon-note.gif) **NOTE:** >The second line from the bottom contains the initial password, which will be used when you log in to the database. ``` - #mysqld --defaults-file=/etc/my.cnf --initialize + # mysqld --defaults-file=/etc/my.cnf --initialize 2020-03-18T03:27:13.702385Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 34014 2020-03-18T03:27:24.112453Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: iNat=)#V2tZu 2020-03-18T03:27:28.576003Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) initializing of server has completed @@ -1728,24 +1728,24 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >![](public_sys-resources/icon-caution.gif) **CAUTION:** >Start MySQL as user **mysql** if it is the first time to start the database service. If you start MySQL as user **root**, a message will be displayed indicating that the **mysql.log** file is missing. If you start MySQL as user **mysql**, the **mysql.log** file will be generated in the **/data/mysql/log** directory. No error will be displayed if you start the database as user **root** again. - 1. Modify the file permission. + 1. Modify the file permission as the **root** user. ``` - #chmod 777 /usr/local/mysql/support-files/mysql.server + # chmod 777 /usr/local/mysql/support-files/mysql.server ``` - 2. Start MySQL. + 2. Start MySQL as the **root** user. ``` - #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql - #chkconfig mysql on + # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql + # chkconfig mysql on ``` Start MySQL as user **mysql**. ``` - #su - mysql - $service mysql start + # su - mysql + $ service mysql start ``` 5. Log in to the database. @@ -1755,7 +1755,7 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard >- If MySQL is installed by using an RPM package obtained from the official website, the **mysqld** file is located in the **/usr/sbin** directory. Ensure that the directory specified in the command is correct. ``` - $/usr/local/mysql/bin/mysql -uroot -p -S /data/mysql/run/mysql.sock + $ /usr/local/mysql/bin/mysql -uroot -p -S /data/mysql/run/mysql.sock ``` ![](figures/en-us_image_0231563134.png) @@ -1795,17 +1795,17 @@ The Structured Query Language \(SQL\) used by MySQL is the most common standard #### Uninstalling MySQL -1. Stop the database process. +1. Stop the database process as the **root** user. ``` - #ps -ef | grep mysql - #kill -9 PID + $ ps -ef | grep mysql + # kill -9 PID ``` -2. Run the **dnf remove mysql** command to uninstall MySQL. +2. Run the **dnf remove mysql** command as the **root** user to uninstall MySQL. ``` - #dnf remove mysql + # dnf remove mysql ``` @@ -1843,7 +1843,7 @@ A new user has few permissions and can perform only operations that do not requi \#Create a user whose password is **123456**, username is **userexample2**, and hostname is **192.168.1.100**. ``` -> CREATE USER 'userexample2'@'192.168.1.100' IDENDIFIED BY '123456'; +> CREATE USER 'userexample2'@'192.168.1.100' IDENTIFIED BY '123456'; ``` #### Viewing Users @@ -2089,7 +2089,7 @@ To use **DROP DATABASE**, you need the **DROP** permission on the database. #### Backing Up a Database -Run the **mysqldump** command to back up the database. +Run the **mysqldump** command as the **root** user to back up the database. Back up one or more tables: @@ -2152,12 +2152,12 @@ In the preceding information: \#Back up only the table structure of the db1 database of user **root** on port **3306** of the host whose IP address is **192.168.202.144** to the **db1.sql** file. ``` -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sq +# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql ``` #### Restoring a Database -Run the **mysqldump** command to restore the database. +Run the **mysql** command as the **root** user to restore the database. Back up one or more tables: diff --git a/content/en/docs/Administration/user-management.md b/content/en/docs/Administration/user-and-user-group-management.md similarity index 57% rename from content/en/docs/Administration/user-management.md rename to content/en/docs/Administration/user-and-user-group-management.md index ebf819d90a67c0028a63c7abe20274cdce1ad27b..a63178022f5bebfc4764bc4302eadf80708b2003 100644 --- a/content/en/docs/Administration/user-management.md +++ b/content/en/docs/Administration/user-and-user-group-management.md @@ -1,37 +1,37 @@ -# User Management +# User and User Group Management In Linux, each common user has an account, including the user name, password, and home directory. There are also special users created for specific purposes, and the most important special user is the admin account whose default user name is root. In addition, Linux provides user groups so that each user belongs to at least one group, facilitating permission management. The control of users and user groups is a core element of openEuler security management. This topic introduces the user and group management commands and explains how to assign privileges to common users in graphical user interface and on command lines. -- [User Management](#user-management) - - [Adding a User](#adding-a-user) - - [useradd Command](#useradd-command) - - [User Information Files](#user-information-files) - - [Example](#example) - - [Modifying a User Account](#modifying-a-user-account) - - [Changing a Password](#changing-a-password) - - [Changing User's Login Shell](#changing-users-login-shell) - - [Changing the Home Directory](#changing-the-home-directory) - - [Changing a UID](#changing-a-uid) - - [Changing Account Expiry Date](#changing-account-expiry-date) - - [Deleting Users](#deleting-users) - - [Granting Rights to a Common User](#granting-rights-to-a-common-user) +- [User and User Group Management](#user-and-user-group-management) + - [Managing Users](#managing-users) + - [Adding a User](#adding-a-user) + - [Modifying a User Account](#modifying-a-user-account) + - [Deleting a User](#deleting-a-user) + - [Granting Rights to a Common User](#granting-rights-to-a-common-user) + - [Managing User Groups](#managing-user-groups) + - [Adding a User Group](#adding-a-user-group) + - [Modifying a User Group](#modifying-a-user-group) + - [Deleting a User Group](#deleting-a-user-group) + - [Adding a User to a Group or Removing a User from a Group](#adding-a-user-to-a-group-or-removing-a-user-from-a-group) + - [Changing the Current Group of a User to a Specified Group](#changing-the-current-group-of-a-user-to-a-specified-group) +## Managing Users -## Adding a User +### Adding a User -### useradd Command -Run the **useradd** command as the user **root** to add user information to the system. In the command, _options_ indicates related parameters and _user\_name_ indicates the user name. +#### useradd Command +Run the **useradd** command as the user **root** to add user information to the system. In the command, _options_ indicates related parameters and _username_ indicates the user name. ``` -useradd [options] user_name +useradd [options] username ``` -### User Information Files +#### User Information Files The following files contain user account information: - /etc/passwd: user account information @@ -41,11 +41,11 @@ The following files contain user account information: - /etc/login.defs: system wide settings - /etc/skel: default directory that holds initial configuration files -### Example -For example, to create a user named user\_example, run the following command as the user **root**: +#### Example +For example, to create a user named userexample, run the following command as the user **root**: ``` -# useradd user_example +# useradd userexample ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -54,21 +54,43 @@ For example, to create a user named user\_example, run the following command as To view information about the new user, run the **id** command: ``` -# id user_example -uid=502(user_example) gid=502(user_example) groups=502(user_example) +# id userexample +uid=502(userexample) gid=502(userexample) groups=502(userexample) ``` -To change the password of the user\_example, run the following command: +To change the password of the userexample, run the following command: ``` -# passwd user_example +# passwd userexample ``` + +The password of the user must meet the password complexity requirements. The password complexity requirements are as follows: + +1. A password must contain at least eight characters. +2. A password must contain at least three of the following types: uppercase letters, lowercase letters, digits, and special characters. +3. A password must be different from the account name. +4. A password cannot contain words in the dictionary. + - Querying a dictionary + In the installed openEuler environment, you can run the following command to export the dictionary library file **dictionary.txt**, and then check whether the password is in the dictionary. + ``` + cracklib-unpacker /usr/share/cracklib/pw_dict > dictionary.txt + ``` + - Modifying a dictionary + 1. Modify the exported dictionary library file, and then run the following command to update the dictionary library: + ``` + # create-cracklib-dict dictionary.txt + ``` + 2. Run the following command to add another dictionary file **custom.txt** to the original dictionary library. + ``` + # create-cracklib-dict dictionary.txt custom.txt + ``` + Then, enter the password and confirm it as prompted: ``` -# passwd user_example -Changing password for user user_example. +# passwd userexample +Changing password for user userexample. New password: Retype new password: passwd: all authentication tokens updated successfully. @@ -77,27 +99,27 @@ passwd: all authentication tokens updated successfully. >![](public_sys-resources/icon-note.gif) **NOTE:** >If the command output contains **BAD PASSWORD: The password fails the dictionary check - it is too simplistic/sytematic**, the password is too simple and needs to be reset. -## Modifying a User Account +### Modifying a User Account -### Changing a Password +#### Changing a Password Common users can change their passwords using the **passwd** command. Only the admin is allowed to use the **passwd username** command to change passwords for other users. -### Changing User's Login Shell +#### Changing User's Login Shell Common users can use the **chsh** command to change their login shell. Only the admin is allowed to run the **chsh username** command to change login shell for other users. -Users can also run the **usermod** command as the user **root** to modify the shell information. In the command, _new\_shell\_path_ indicates the target shell path, and _username_ indicates the user name to be modified. Change them based on the site requirements. +Users can also run the **usermod** command as the user **root** to modify the shell information. In the command, _new_shell_path_ indicates the target shell path, and _username_ indicates the user name to be modified. Change them based on the site requirements. ``` usermod -s new_shell_path username ``` -For example, to change the shell of user\_example to csh, run the following command: +For example, to change the shell of userexample to csh, run the following command: ``` -# usermod -s /bin/csh user_example +# usermod -s /bin/csh userexample ``` -### Changing the Home Directory +#### Changing the Home Directory - To change the home directory, run the following command as the user **root**. In the command, _new\_home\_directory_ indicates the created target home directory, and _username_ indicates the user name to be changed. Change them based on the site requirements. ``` @@ -111,7 +133,7 @@ For example, to change the shell of user\_example to csh, run the following comm ``` -### Changing a UID +#### Changing a UID To change the user ID, run the following command as the user **root**. In the command, _UID_ indicates the target user ID and _username_ indicates the user name. Change them based on the site requirements. ``` @@ -120,14 +142,14 @@ usermod -u UID username The usermod command can change a user's UID in all files and directories under the user's home directory. However, for files outside the user's home directory, their owners can only be changed using the **chown** command. -### Changing Account Expiry Date +#### Changing Account Expiry Date If the shadow password is used, run the following command as the user **root** to change the validity period of an account. In the command, _MM_, _DD_, and _YY_ indicate the month, day, and year, respectively, and _username_ indicates the user name. Change them based on the site requirements. ``` usermod -e MM/DD/YY username ``` -## Deleting Users +### Deleting a User Run the **userdel** command as the user **root** to delete an existing user. @@ -140,9 +162,9 @@ For example, run the following command to delete user Test: If you also need to delete the user's home directory and all contents in the directory, run the **userdel** command with the -r option to delete them recursively. >![](public_sys-resources/icon-note.gif) **NOTE:** ->You are not advised to directly delete a user who has logged in to the system. To forcibly delete a user, run the **userdel -f** _Test_ command. +>You are not advised to directly delete a user who has logged in to the system. To forcibly delete a user, run the **userdel -f** _Test_ command. -## Granting Rights to a Common User +### Granting Rights to a Common User The **sudo** command allows common users to execute commands that can be executed only by administrator accounts. @@ -223,3 +245,83 @@ In the preceding information: POWERUSER can run all commands except the **su** command as the user **root** on all hosts. + +## Managing User Groups + +### Adding a User Group + +#### groupadd Command +Run the **groupadd** command as the **root** user to add user group information to the system. In the command, _options_ indicates related parameters and _groupname_ indicates the group name. + +``` +groupadd [options] groupname +``` + +#### User Group Information Files +The following files contain user group information: + +- /etc/gshadow file: user group encryption information +- /etc/group file: group information +- /etc/login.defs: system wide settings + +#### Example +For example, to create a user group named groupexample, run the following command as the **root** user: + +``` +# groupadd groupexample +``` + +### Modifying a User Group + +#### Changing a GID +To change the user group ID, run the following command as the **root** user. In the command, _GID_ indicates the target user group ID and _groupname_ indicates the user group name. Change them based on the site requirements. + +``` +groupmod -g GID groupname +``` + +#### Changing a User Group Name +To change the user group name, run the following command as the **root** user. In the command, _newgroupname_ indicates the user group new name and _oldgroupname_ indicates the user group name. Change them based on the site requirements. + +``` +groupmod -n newgroupname oldgroupname +``` + +### Deleting a User Group + +Run the **groupdel** command as the **root** user to delete an existing user group. + +For example, run the following command to delete user group Test: + +``` +# groupdel Test +``` + +>![](public_sys-resources/icon-note.gif) **NOTE:** +>The user's primary group cannot be directly deleted. To forcibly delete a user's primary group, run the **groupdel -f** _Test_ command. + +### Adding a User to a Group or Removing a User from a Group + +Run the **gpasswd** command as the **root** user to add a user to a group or remove a user from a group. + +For example, run the following command to add the user userexample to the user group Test: + +``` +# gpasswd -a userexample Test +``` + +For example, run the following command to remove the user userexample from the user group Test: + +``` +# gpasswd -d userexample Test +``` + +### Changing the Current Group of a User to a Specified Group + +If a user belongs to multiple user groups, run the **newgrp** command to switch the user to another user group after logging in to the system. Then, the user has the permission of other user groups. + +For example, run the following command to change the current group of the user userexample to the user group Test: + +``` +$ newgrp Test +``` diff --git a/content/en/docs/Administration/using-the-dnf-to-manage-software-packages.md b/content/en/docs/Administration/using-the-dnf-to-manage-software-packages.md index e3306c6c1fbdbb17187294f975f398a011b3fd68..bf2291c957d0bed70e0c33f9b566a43cab5b9191 100644 --- a/content/en/docs/Administration/using-the-dnf-to-manage-software-packages.md +++ b/content/en/docs/Administration/using-the-dnf-to-manage-software-packages.md @@ -9,7 +9,7 @@ DNF is a Linux software package management tool used to manage RPM software pack - [Using the DNF to Manage Software Packages](#using-the-dnf-to-manage-software-packages) - [Configuring the DNF](#configuring-the-dnf) - - [Modifying the Configuration File](#modifying-the-configuration-file) + - [The DNF Configuration File](#the-dnf-configuration-file) - [Creating a Local Software Repository](#creating-a-local-software-repository) - [Adding, Enabling, and Disabling Software Sources](#adding-enabling-and-disabling-software-sources) - [Managing Software Package](#managing-software-package) @@ -35,20 +35,24 @@ DNF is a Linux software package management tool used to manage RPM software pack -### Modifying the Configuration File +### The DNF Configuration File -The main configuration file of the DNF is /etc/dnf/dnf.conf. The **main** part in the file stores the global settings of the DNF. You can add one or more **repository** sections to the file to set the location of the software source to be installed. +The main configuration file of the DNF is /etc/dnf/dnf.conf which consists of two parts: -In addition, the /etc/yum.repos.d directory stores one or more repo source files, which define different repositories. +- The **main** part in the file stores the global settings of the DNF. -You can configure a software source by either directly configuring the /etc/dnf/dnf.conf file or adding the .repo file to the /etc/yum.repos.d directory. +- The **repository** part in the file stores the settings of the software source. You can add one or more **repository** sections to the file. -#### Modify the main Part +In addition, the /etc/yum.repos.d directory stores one or more repo source files, which define different repositories. + +You can configure a software source by either directly configuring the /etc/dnf/dnf.conf file or configuring the .repo file in the /etc/yum.repos.d directory. + +#### Configuring the main Part The /etc/dnf/dnf.conf file contains the **main** part. The following is an example of the configuration file: ``` [main] -gpgcheck=0 +gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=True best=True @@ -99,7 +103,6 @@ Common options are as follows:

The options are 1 and 0, indicating whether to perform GPG verification. The default value is 1, indicating that verification is required.

-

plugins

The options are 1 and 0, indicating that the DNF plug-in is enabled or disabled. The default value is 1, indicating that the DNF plug-in is enabled.

@@ -113,40 +116,71 @@ Common options are as follows: -#### Modify the repository Part -The repository part allows you to customize software source repositories. The name of each repository must be unique. Otherwise, conflicts may occur. The following is a minimum configuration example of the \[repository\] section: +#### Configuring the repository Part -``` -[repository] -name=repository_name -baseurl=repository_url -``` +The repository part allows you to customize software source repositories. The name of each repository must be unique. Otherwise, conflicts may occur. You can configure a software source by either directly configuring the /etc/dnf/dnf.conf file or configuring the .repo file in the /etc/yum.repos.d directory. -Common options are as follows: +- Configuring the /etc/dnf/dnf.conf file ->![](public_sys-resources/icon-note.gif) **NOTE:** ->openEuler provides an online image source at [https://repo.openeuler.org/](https://repo.openeuler.org/). For example, if the openEuler 20.03 version is aarch64, the **baseurl** can be set to [https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/](https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/). + The following is a minimum configuration example of the \[repository\] section: + + ``` + [repository] + name=repository_name + baseurl=repository_url + ``` + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >openEuler provides an online image source at [https://repo.openeuler.org/](https://repo.openeuler.org/). For example, if the openEuler 20.03 version is aarch64, the **baseurl** can be set to [https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/](https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/). + + Common options are as follows: + + **Table 2** repository parameter description + + + + + + + + + + + +

Parameter

+

Description

+

name=repository_name

+

Name string of a software repository.

+

baseurl=repository_url

+

Address of the software repository.

+
  • Network location using the HTTP protocol, for example, http://path/to/repo
  • Network location using the FTP protocol, for example, ftp://path/to/repo
  • Local path: for example, file:///path/to/local/repo
+
+ + +- Configuring the .repo file in the /etc/yum.repos.d directory + + + openEuler provides multiple repo source files. This section uses the OS repo source of the AArch64 architecture as an example. + + For example, run the following command as the **root** user to add the openeuler repo source to the openEuler_aarch64.repo file. + + ``` + # vi /etc/yum.repos.d/openEuler_aarch64.repo + ``` + + ``` + [base] + name=openEuler base + baseurl=https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/ + enabled=1 + gpgcheck=1 + gpgkey=https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/RPM-GPG-KEY-openEuler + + ``` + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >**gpgkey** is the public key used to verify the signature. -**Table 2** repository parameter description - - - - - - - - - - - -

Parameter

-

Description

-

name=repository_name

-

Name string of a software repository.

-

baseurl=repository_url

-

Address of the software repository.

-
  • Network location using the HTTP protocol, for example, http://path/to/repo
  • Network location using the FTP protocol, for example, ftp://path/to/repo
  • Local path: for example, file:///path/to/local/repo
-
#### Displays the Current Configuration - To display the current configuration information, run the following command: @@ -477,7 +511,7 @@ For example, to delete the software package group of Development Tools, run the You can use the DNF to check whether any software package in your system needs to be updated. You can use the DNF to list the software packages to be updated. You can choose to update all packages at a time or update only specified packages. -### Checking For Update +### Checking for Update To list all currently available updates, run the following command: ``` diff --git a/content/en/docs/Administration/viewing-system-information.md b/content/en/docs/Administration/viewing-system-information.md index b979f4c4995242377ffbc8e83e2382e6558a52ea..322c28ac81b19afab4a59e2d0aff4a61a360311b 100644 --- a/content/en/docs/Administration/viewing-system-information.md +++ b/content/en/docs/Administration/viewing-system-information.md @@ -3,13 +3,13 @@ - Run the following command to view the system information: ``` - cat /etc/os-release + $ cat /etc/os-release ``` For example, the command and output are as follows: ``` - # cat /etc/os-release + $ cat /etc/os-release NAME="openEuler" VERSION="20.03 (LTS)" ID="openEuler" @@ -24,19 +24,19 @@ Run the following command to view the CPU information: ``` - lscpu + $ lscpu ``` Run the following command to view the memory information: ``` - free + $ free ``` Run the following command to view the disk information: ``` - fdisk -l + $ fdisk -l ``` diff --git a/content/en/docs/ApplicationDev/building-an-rpm-package.md b/content/en/docs/ApplicationDev/building-an-rpm-package.md index bb3693195b72c438607b408b9abf0c58fffdc6bd..ff247ecf8f7e7e0ab0d52d6355ab02a75eee4a19 100644 --- a/content/en/docs/ApplicationDev/building-an-rpm-package.md +++ b/content/en/docs/ApplicationDev/building-an-rpm-package.md @@ -25,13 +25,13 @@ This section describes how to build an RPM software package on a local PC or usi During RPM packaging, the source code needs to be compiled. The compiled configuration files and binary command files need to be placed in proper positions. The RPM packages need to be tested as required. A workspace is required for these operations. The **rpmbuild** command uses a set of standard workspaces. ``` -# rpmdev-setuptree +$ rpmdev-setuptree ``` The **rpmdev-setuptree** command is used to install rpmdevtools. After the command is executed, the **rpmbuild** folder is generated in the **/root** directory \(or the **/home/**_username_ directory for non-root users\). The directory structure is as follows: ``` -# tree rpmbuild +$ tree rpmbuild rpmbuild ├── BUILD ├── RPMS @@ -388,16 +388,17 @@ The following uses the packaging process of the GNU Hello World project as an ex Run the following command to download the source code of the official example: ``` -# cd ~/rpmbuild/SOURCES -# wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz +$ cd ~/rpmbuild/SOURCES +$ wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz ``` #### Editing the SPEC File -Run the following command to create the .spec file: +Run the following command to create the .spec file in the **~/rpmbuild/SPECS** directory: ``` -# vi hello.spec +$ cd ~/rpmbuild/SPECS +$ vi hello.spec ``` Write the corresponding content to the file and save the file. The following is an example of the file content. Modify the corresponding fields based on the actual requirements. @@ -470,13 +471,13 @@ fi Run the following command in the directory where the .spec file is located to build the source code, binary files, and software packages that contain debugging information: ``` -# rpmbuild -ba hello.spec +$ rpmbuild -ba hello.spec ``` Run the following command to view the execution result: ``` -# tree ~/rpmbuild/*RPMS +$ tree ~/rpmbuild/*RPMS /home/testUser/rpmbuild/RPMS └── aarch64 @@ -518,7 +519,7 @@ This section describes how to build an RPM software package online on OBS. To modify the source code of the existing software and build the modified source file into an RPM software package on the OBS web client, perform the following steps: -1. Log in to OBS at [http://openeuler-build.huawei.com/](http://openeuler-build.huawei.com/). +1. Log in to OBS at [https://build.openeuler.org/](https://build.openeuler.org/). 2. Click **All Projects**. The **All Projects** page is displayed. 3. Click the project to be modified. The project details page is displayed. For example, click **openEuler:Mainline**. 4. On the project details page, search for the software package to be modified and click the software package name. The software package details page is displayed. @@ -639,16 +640,15 @@ You have obtained the **root** permission, and have configured a repo source f 1. Run the following command to open the **\~/.oscrc** file: ``` - # vi ~/.oscrc + $ vi ~/.oscrc ``` - 2. Add the **user** and **pass** fields to **\~/.oscrc**. The values of _userName_ and _passWord_ are the account and password registered on the OBS website \([http://openeuler-build.huawei.com/](http://openeuler-build.huawei.com/)\). + 2. Add the **user** and **pass** fields to **\~/.oscrc**. The values of _userName_ and _passWord_ are the account and password registered on the OBS website \([https://build.openeuler.org/](https://build.openeuler.org/)\). ``` [general] - apiurl = http://openeuler-build.huawei.com/ - no_verify = 1 - [http://openeuler-build.huawei.com/] + apiurl = https://build.openeuler.org/ + [https://build.openeuler.org/] user=userName pass=passWord ``` @@ -661,7 +661,7 @@ You have obtained the **root** permission, and have configured a repo source f 1. You can copy an existing project to create a subproject of your own. For example, to copy the **zlib** software package in the **openEuler:Mainline** project to the new branch, run the following command: ``` - # osc branch openEuler:Mainline zlib + $ osc branch openEuler:Mainline zlib ``` If the following information is displayed, a new branch project **home:testUser:branches:openEuler:Mainline** is created for user **testUser**. @@ -674,7 +674,7 @@ You have obtained the **root** permission, and have configured a repo source f 2. Download the configuration file \(for example, **\_service**\) of the software package to be modified to the local directory. In the preceding command, _testUser_ indicates the account name configured in the **\~/.oscrc** configuration file. Change it based on the actual requirements. ``` - # osc co home:testUser:branches:openEuler:Mainline/zlib + $ osc co home:testUser:branches:openEuler:Mainline/zlib ``` Information similar to the following is displayed: @@ -688,8 +688,8 @@ You have obtained the **root** permission, and have configured a repo source f 3. Go to the local subproject directory and synchronize the remote code of the software package to the local host. ``` - # cd home:testUser:branches:openEuler:Mainline/zlib - # osc up -S + $ cd home:testUser:branches:openEuler:Mainline/zlib + $ osc up -S ``` Information similar to the following is displayed: @@ -710,26 +710,26 @@ You have obtained the **root** permission, and have configured a repo source f 1. Rename the source file and add the renamed source file to the temporary storage of OBS. ``` - # rm -f _service;for file in `ls | grep -v .osc`;do new_file=${file##*:};mv $file $new_file;done - # osc addremove * + $ rm -f _service;for file in `ls | grep -v .osc`;do new_file=${file##*:};mv $file $new_file;done + $ osc addremove * ``` 2. Modify the source code and .spec file, and synchronize all modifications of the corresponding software package to the OBS server. The following is a command example. The information after the **-m** parameter is the commission record. ``` - # osc ci -m "commit log" + $ osc ci -m "commit log" ``` 3. Run the following command to obtain the repository name and architecture of the current project: ``` - # osc repos home:testUser:branches:openEuler:Mainline + $ osc repos home:testUser:branches:openEuler:Mainline ``` 4. After the modification is committed, OBS automatically compiles the software package. You can run the following command to view the compilation logs of the corresponding repository. In the command, *standard\_aarch64* and _aarch64_ indicate the repository name and architecture obtained in the command output. ``` - # osc buildlog standard_aarch64 aarch64 + $ osc buildlog standard_aarch64 aarch64 ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -745,22 +745,22 @@ To use the OSC tool of OBS to add a new software package, perform the following 1. Create a project based on the dependency of the new software package and a proper project. For example, to create a project based on **zlib** of the **openEuler:Mainline** project, run the following command \(**zlib** is any software package in the project\): ``` - # osc branch openEuler:Mainline zlib + $ osc branch openEuler:Mainline zlib ``` 2. Delete unnecessary software packages added during project creation. For example, to delete the **zlib** software package, run the following command: ``` - # cd home:testUser:branches:openEuler:Mainline - # osc rm zlib - # osc commit -m "commit log" + $ cd home:testUser:branches:openEuler:Mainline + $ osc rm zlib + $ osc commit -m "commit log" ``` 3. Create a software package in your own project. For example, to add the **my-first-obs-package** software package, run the following command: ``` - # mkdir my-first-obs-package - # cd my-first-obs-package + $ mkdir my-first-obs-package + $ cd my-first-obs-package ``` @@ -770,22 +770,22 @@ To use the OSC tool of OBS to add a new software package, perform the following 2. Modify the source code and .spec file, and upload all files of the corresponding software package to the OBS server. The following is a command example. The information after the **-m** parameter is the commission record. ``` - # cd home:testUser:branches:openEuler:Mainline - # osc add my-first-obs-package - # osc ci -m "commit log" + $ cd home:testUser:branches:openEuler:Mainline + $ osc add my-first-obs-package + $ osc ci -m "commit log" ``` 3. Run the following command to obtain the repository name and architecture of the current project: ``` - # osc repos home:testUser:branches:openEuler:Mainline + $ osc repos home:testUser:branches:openEuler:Mainline ``` 4. After the modification is committed, OBS automatically compiles the software package. You can run the following command to view the compilation logs of the corresponding repository. In the command, _standard\_aarch64_ and _aarch64_ indicate the repository name and architecture obtained in the command output. ``` - # cd home:testUser:branches:openEuler:Mainline/my-first-obs-package - # osc buildlog standard_aarch64 aarch64 + $ cd home:testUser:branches:openEuler:Mainline/my-first-obs-package + $ osc buildlog standard_aarch64 aarch64 ``` >![](public_sys-resources/icon-note.gif) **NOTE:** @@ -797,7 +797,7 @@ To use the OSC tool of OBS to add a new software package, perform the following After the RPM software package is built, run the following command to obtain the RPM software package using the OSC: ``` -# osc getbinaries home:testUser:branches:openEuler:Mainline my-first-obs-package standard_aarch64 aarch64 +$ osc getbinaries home:testUser:branches:openEuler:Mainline my-first-obs-package standard_aarch64 aarch64 ``` The parameters in the command are described as follows. You can modify the parameters according to the actual situation. diff --git a/content/en/docs/ApplicationDev/preparation.md b/content/en/docs/ApplicationDev/preparation.md index f2772258557074c5f7c7a8496156477848a05710..43985d5416408c9143e997d2b34a9196f6fcc36b 100644 --- a/content/en/docs/ApplicationDev/preparation.md +++ b/content/en/docs/ApplicationDev/preparation.md @@ -130,13 +130,13 @@ You can configure a repo source by directly obtaining the repo source file or by 1. Go to the yum source directory. ``` - cd /etc/yum.repos.d + $ cd /etc/yum.repos.d ``` -2. Create and edit the **local.repo** file. Configure the repo source file as the yum source. +2. Create and edit the **local.repo** file as the **root** user. Configure the repo source file as the yum source. ``` - vi local.repo + # vi local.repo ``` Edit the **local.repo** file as follows: @@ -149,7 +149,15 @@ You can configure a repo source by directly obtaining the repo source file or by enabled=1 - gpgcheck=0 + gpgcheck=1 + gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/RPM-GPG-KEY-openEuler + + + **** + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >- **gpgcheck** indicates whether to enable the GNU privacy guard \(GPG\) to check the validity and security of the source of RPM packages. **1** indicates that the GPG check is enabled. **0** indicates that the GPG check is disabled. If this option is not specified, the GPG check is enabled by default. + >- **gpgkey** is the public key used to verify the signature. ### Configuring a Repo Source by Mounting an ISO File @@ -171,10 +179,10 @@ You can configure a repo source by directly obtaining the repo source file or by 6. Click **aarch64**. 7. Click **openEuler-20.03-LTS-aarch64-dvd.iso** to download the openEuler release package to the local host. 8. Click **openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum** to download the openEuler verification file to the local host. - 9. Log in to the openEuler OS and create a directory for storing the release package and verification file, for example, **/home/iso**. + 9. Log in to the openEuler OS and create a directory for storing the release package and verification file, for example, ~/iso**. ``` - mkdir /home/iso + $ mkdir ~/iso ``` 10. Use a cross-platform file transfer tool \(such as WinSCP\) to upload the local openEuler release package and verification file to the target openEuler OS. @@ -192,18 +200,18 @@ You can configure a repo source by directly obtaining the repo source file or by 6. Click **aarch64**. 7. Right-click **openEuler-20.03-LTS-aarch64-dvd.iso** and choose **Copy URL** from the shortcut menu to copy the address of the openEuler release package. 8. Right-click **openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum** and choose **Copy URL** from the shortcut menu to copy the address of the openEuler verification file. - 9. Log in to the openEuler OS, create a directory \(for example, **/home/iso**\) for storing the release package and verification file, and switch to the directory. + 9. Log in to the openEuler OS, create a directory \(for example, **~/iso**\) for storing the release package and verification file, and switch to the directory. ``` - mkdir /home/iso - cd /home/iso + $ mkdir ~/iso + $ cd ~/iso ``` 10. Run the **wget** command to remotely download the release package and verification file. In the command, **ipaddriso** and **ipaddrisosum** are the addresses copied in [1.g](#li62369349505) and [1.h](#li9236203405015). ``` - wget ipaddriso - wget ipaddrisosum + $ wget ipaddriso + $ wget ipaddrisosum ``` @@ -211,13 +219,13 @@ You can configure a repo source by directly obtaining the repo source file or by 1. Obtain the verification value in the verification file. ``` - cat openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum + $ cat openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum ``` 2. Calculate the SHA256 verification value of the openEuler release package. ``` - sha256sum openEuler-20.03-LTS-aarch64-dvd.iso + $ sha256sum openEuler-20.03-LTS-aarch64-dvd.iso ``` After the command is run, the verification value is displayed. @@ -228,7 +236,7 @@ You can configure a repo source by directly obtaining the repo source file or by 3. Mount the ISO image file and configure it as a repo source. - Run the **mount** command to mount the image file. + Run the **mount** command as the **root** user to mount the image file. The following is an example: @@ -266,12 +274,7 @@ You can configure a repo source by directly obtaining the repo source file or by gpgcheck=1 gpgkey=file:///mnt/RPM-GPG-KEY-openEuler ``` - - **** - - >![](public_sys-resources/icon-note.gif) **NOTE:** - >- **gpgcheck** indicates whether to enable the GNU privacy guard \(GPG\) to check the validity and security of the source of RPM packages. **1** indicates that the GPG check is enabled. **0** indicates that the GPG check is disabled. If this option is not specified, the GPG check is enabled by default. - >- **gpgkey** is the storage path of the signed public key. + ## Installing the Software Package @@ -285,7 +288,7 @@ Install the software required for development. The software required varies in d 1. Run the **dnf list installed | grep jdk** command to check whether the JDK software is installed. ``` - dnf list installed | grep jdk + $ dnf list installed | grep jdk ``` Check the command output. If the command output contains "jdk", the JDK has been installed. If no such information is displayed, the software is not installed. @@ -293,33 +296,33 @@ Install the software required for development. The software required varies in d 2. Clear the cache. ``` - dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - dnf makecache + $ dnf makecache ``` 4. Query the JDK software package that can be installed. ``` - dnf search jdk | grep jdk + $ dnf search jdk | grep jdk ``` View the command output and install the **java-x.x.x-openjdk-devel.aarch64** software package. **x.x.x** indicates the version number. -5. Install the JDK software package. The following uses the **java-1.8.0-openjdk-devel** software package as an example. +5. Install the JDK software package as the **root** user. The following uses the **java-1.8.0-openjdk-devel** software package as an example. ``` - dnf install java-1.8.0-openjdk-devel.aarch64 + # dnf install java-1.8.0-openjdk-devel.aarch64 ``` 6. Query information about the JDK software. ``` - java -version + $ java -version ``` Check the command output. If the command output contains "openjdk version "1.8.0\_232"", the JDK has been correctly installed. In the command output, **1.8.0\_232** indicates the JDK version. @@ -330,7 +333,7 @@ Install the software required for development. The software required varies in d 1. Run the **dnf list installed | grep rpm-build** command to check whether the rpm-build software is installed. ``` - dnf list installed | grep rpm-build + $ dnf list installed | grep rpm-build ``` Check the command output. If the command output contains "rpm-build", the software has been installed. If no such information is displayed, the software is not installed. @@ -338,25 +341,25 @@ Install the software required for development. The software required varies in d 2. Clear the cache. ``` - dnf clean all + $ dnf clean all ``` 3. Create a cache. ``` - dnf makecache + $ dnf makecache ``` -4. Install the rpm-build package. +4. Install the rpm-build package as the **root** user. ``` - dnf install rpm-build + # dnf install rpm-build ``` 5. Query the rpm-build software version. ``` - rpmbuild --version + $ rpmbuild --version ``` @@ -383,35 +386,35 @@ Before setting JAVA\_HOME, you need to find the installation path of the JDK. Yo Run the following command to view the Java path: ``` -# which java +$ which java /usr/bin/java ``` Run the following command to check the directory to which the soft link points: ``` -# ls -la /usr/bin/java +$ ls -la /usr/bin/java lrwxrwxrwx. 1 root root 22 Mar 6 20:28 /usr/bin/java -> /etc/alternatives/java -# ls -la /etc/alternatives/java +$ ls -la /etc/alternatives/java lrwxrwxrwx. 1 root root 83 Mar 6 20:28 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64/jre/bin/java ``` The actual path is **/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64**. Run the following command to set **JAVA\_HOME** and **PATH**: ``` -# export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64 -# export PATH=$JAVA_HOME/bin:$PATH +$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64 +$ export PATH=$JAVA_HOME/bin:$PATH ``` ### Downloading and Installing the GTK Library -Ensure that you have the **root** permission and run the following command: +Run the following command: ``` -# dnf list installed | grep gtk +$ dnf list installed | grep gtk ``` -If **gtk2** or **gtk3** is displayed, the GTK library has been installed. In this case, skip this step. Otherwise, run the following command to automatically download and install the GTK library: +If **gtk2** or **gtk3** is displayed, the GTK library has been installed. In this case, skip this step. Otherwise, run the following command as the **root** user to automatically download and install the GTK library: ``` # dnf -y install gtk2 libXtst libXrender xauth @@ -422,13 +425,13 @@ If **gtk2** or **gtk3** is displayed, the GTK library has been installed. In Switch to the SSHD configuration directory. ``` -# cd ~/.ssh +$ cd ~/.ssh ``` If the directory does not exist, run the following command to create the directory and then switch to the directory: ``` -# mkdir ~/.ssh +$ mkdir ~/.ssh ``` Edit the configuration file in the **.ssh** directory and save the file. @@ -436,7 +439,7 @@ Edit the configuration file in the **.ssh** directory and save the file. 1. Run the **vim** command to open the configuration file. ``` - # vim config + $ vim config ``` 2. Add the following content to the end of the file and save the file: @@ -453,12 +456,12 @@ Edit the configuration file in the **.ssh** directory and save the file. After the preceding environment configuration is complete, you can download and run the IntelliJ IDEA. The latest version of IntelliJ IDEA is incompatible with openEuler in some functions. You are advised to click [here](https://www.jetbrains.com/idea/download/other.html) and download the Linux package of the 2018 version. Move the downloaded package to the directory where you want to install the software and decompress the package. ``` -# tar xf ideaIC-2018.3.tar.gz +$ tar xf ideaIC-2018.3.tar.gz ``` Decompress the package, switch to the IntelliJ IDEA directory, and run the IntelliJ IDEA. ``` -# cd ./idea-IC-183.4284.148 -# bin/idea.sh & +$ cd ./idea-IC-183.4284.148 +$ bin/idea.sh & ``` diff --git a/content/en/docs/ApplicationDev/using-gcc-for-compilation.md b/content/en/docs/ApplicationDev/using-gcc-for-compilation.md index eb596a947c73e9e1c72b613d161887c32ddf958a..173ff7bd287c0671f1bf091738445f8c6eff8731 100644 --- a/content/en/docs/ApplicationDev/using-gcc-for-compilation.md +++ b/content/en/docs/ApplicationDev/using-gcc-for-compilation.md @@ -238,7 +238,7 @@ There are two methods provided for compiling multiple source files. Example: Compile **test1.c** and **test2.c** and link them to the executable file **test**. ``` - gcc test1.c test2.c -o test + $ gcc test1.c test2.c -o test ``` - Compile each source file, and then link the target files generated after compilation. During compilation, only modified files need to be recompiled. @@ -246,9 +246,9 @@ There are two methods provided for compiling multiple source files. For example, compile **test1.c** and **test2.c**, and link the target files **test1.o** and **test2.o** to the executable file **test**. ``` - gcc -c test1.c - gcc -c test2.c - gcc -o test1.o test2.o -o test + $ gcc -c test1.c + $ gcc -c test2.c + $ gcc -o test1.o test2.o -o test ``` @@ -285,14 +285,14 @@ You can use the **-shared** and **-fPIC** options to create a dynamic link l Example 1: Generate a DLL from the source file. ``` -gcc -fPIC -shared test.c -o libtest.so +$ gcc -fPIC -shared test.c -o libtest.so ``` Example 2: Generate a DLL from the target file. ``` -gcc -fPIC -c test.c -o test.o -gcc -shared test.o -o libtest.so +$ gcc -fPIC -c test.c -o test.o +$ gcc -shared test.o -o libtest.so ``` To link a DLL to an executable file, you need to list the name of the DLL in the command line. @@ -300,7 +300,7 @@ To link a DLL to an executable file, you need to list the name of the DLL in the Example: Compile **main.c** and **libtest.so** into **app.out**. When **app.out** is running, the link library **libtest.so** is dynamically loaded. ``` -gcc main.c libtest.so -o app.out +$ gcc main.c libtest.so -o app.out ``` In this mode, the **libtest.so** file in the current directory is used. @@ -310,7 +310,7 @@ If you choose to search for a DLL, to ensure that the DLL can be linked when the - Save the DLL to a standard directory, for example, **/usr/lib**. - Add the DLL path **libaryDIR** to the environment variable **LD\_LIBRARY\_PATH**. - export LD\_LIBRARY\_PATH=libraryDIR:$LD\_LIBRARY\_PATH + $ export LD\_LIBRARY\_PATH=libraryDIR:$LD\_LIBRARY\_PATH >![](public_sys-resources/icon-note.gif) **NOTE:** >**LD\_LIBRARY\_PATH** is an environment variable of the DLL. If the DLL is not in the default directories \(**/lib** and **/usr/lib**\), you need to specify the environment variable **LD\_LIBRARY\_PATH**. @@ -318,8 +318,8 @@ If you choose to search for a DLL, to ensure that the DLL can be linked when the - Add the DLL path **libaryDIR** to **/etc/ld.so.conf** and run **ldconfig**, or use the DLL path **libaryDIR** as a parameter to run **ldconfig**. ``` -gcc main.c -L libraryDIR -ltest -o app.out -export LD_LIBRARY_PATH=libraryDIR:$LD_LIBRARY_PATH +$ gcc main.c -L libraryDIR -ltest -o app.out +$ export LD_LIBRARY_PATH=libraryDIR:$LD_LIBRARY_PATH ``` ### Static Link Library @@ -329,8 +329,8 @@ To create a static link library \(SLL\), you need to compile the source file to Example: Compile and compress source files **test1.c**, **test2.c**, and **test3.c** into an SLL. ``` -gcc -c test1.c test2.c test3.c -ar rcs libtest.a test1.o test2.o test3.o +$ gcc -c test1.c test2.c test3.c +$ ar rcs libtest.a test1.o test2.o test3.o ``` The **ar** command is a backup compression command. You can compress multiple files into a backup file \(also called an archive file\) or extract member files from the backup file. The most common use of **ar** is to compress the target files into an SLL. @@ -348,7 +348,7 @@ ar rcs _Sllfilename_ _Targetfilelist_ Example: Create a main.c file to use the SLL. ``` -gcc main.c -L libraryDIR -ltest -o test.out +$ gcc main.c -L libraryDIR -ltest -o test.out ``` In the preceding command, **libraryDIR** indicates the path of the libtest.a library. @@ -359,16 +359,16 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l ### Example for Using GCC to Compile C Programs -1. Run the **cd** command to go to the code directory. The **/home/code** directory is used as an example. The command is as follows: +1. Run the **cd** command to go to the code directory. The **~/code** directory is used as an example. The command is as follows: ``` - cd /home/code + $ cd ~/code ``` 2. Compile the Hello World program and save it as **helloworld.c**. The following uses the Hello World program as an example. The command is as follows: ``` - vi helloworld.c + $ vi helloworld.c ``` Code example: @@ -385,7 +385,7 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l 3. Run the following command to compile the code in the code directory: ``` - gcc helloworld.c -o helloworld + $ gcc helloworld.c -o helloworld ``` If no error is reported, the execution is successful. @@ -393,28 +393,26 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l 4. After the compilation is complete, the helloworld file is generated. Check the compilation result. The following is an example: ``` - # ./helloworld + $ ./helloworld Hello World! ``` ### Example for Creating and Using a DLL Using GCC -1. Run the **cd** command to go to the code directory. The **/home/code** directory is used as an example. Create the **src**, **lib**, and **include** subdirectories in the directory to store the source file, DLL file, and header file, respectively. +1. Run the **cd** command to go to the code directory. The **~/code** directory is used as an example. Create the **src**, **lib**, and **include** subdirectories in the directory to store the source file, DLL file, and header file, respectively. ``` - cd /home/code - mkdir src - mkdir lib - mkdir include + $ cd ~/code + $ mkdir src lib include ``` - -2. Run the **cd** command to go to the **/home/code/src** directory and create two functions **add.c** and **sub.c** to implement addition and subtraction, respectively. + +2. Run the **cd** command to go to the **~/code/src** directory and create two functions **add.c** and **sub.c** to implement addition and subtraction, respectively. ``` - cd /home/code/src - vi add.c - vi sub.c + $ cd ~/code/src + $ vi add.c + $ vi sub.c ``` The following is an example of the **add.c** code: @@ -437,17 +435,17 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l } ``` -3. Compile the source files add.c and sub.c into the DLL libmath.so, and store the DLL in the **/home/code/lib** directory. +3. Compile the source files add.c and sub.c into the DLL libmath.so, and store the DLL in the **~/code/lib** directory. ``` - gcc -fPIC -shared add.c sub.c -o /home/code/lib/libmath.so + $ gcc -fPIC -shared add.c sub.c -o ~/code/lib/libmath.so ``` -4. Go to the **/home/code/include** directory, create a header file **math.h**, and declare the header file of the function. +4. Go to the **~/code/include** directory, create a header file **math.h**, and declare the header file of the function. ``` - cd /home/code/include - vi math.h + $ cd ~/code/include + $ vi math.h ``` The following is an example of the **math.h** code: @@ -460,11 +458,11 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l #endif ``` -5. Run the **cd** command to go to the **/home/code/src** directory and create a **main.c** function that invokes add\(\) and sub\(\). +5. Run the **cd** command to go to the **~/code/src** directory and create a **main.c** function that invokes add\(\) and sub\(\). ``` - cd /home/code/src - vi main.c + $ cd ~/code/src + $ vi main.c ``` The following is an example of the **math.c** code: @@ -486,19 +484,19 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l 6. Compile **main.c** and **libmath.so** into **math.out**. ``` - gcc main.c -I /home/code/include -L /home/code/lib -lmath -o math.out + $ gcc main.c -I ~/code/include -L ~/code/lib -lmath -o math.out ``` 7. Add the path of the DLL to the environment variable. ``` - export LD_LIBRARY_PATH=/home/code/lib:$LD_LIBRARY_PATH + $ export LD_LIBRARY_PATH=~/code/lib:$LD_LIBRARY_PATH ``` 8. Run the following command to execute **math.out**: ``` - ./math.out + $ ./math.out ``` The command output is as follows: @@ -513,21 +511,19 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l ### Example for Creating and Using an SLL Using GCC -1. Run the **cd** command to go to the code directory. The **/home/code** directory is used as an example. Create the **src**, **lib**, and **include** subdirectories in the directory to store the source file, SLL file, and header file respectively. +1. Run the **cd** command to go to the code directory. The **~/code** directory is used as an example. Create the **src**, **lib**, and **include** subdirectories in the directory to store the source file, SLL file, and header file respectively. ``` - cd /home/code - mkdir src - mkdir lib - mkdir include + $ cd ~/code + $ mkdir src lib include ``` - -2. Run the **cd** command to go to the **/home/code/src** directory and create two functions **add.c** and **sub.c** to implement addition and subtraction, respectively. + +2. Run the **cd** command to go to the **~/code/src** directory and create two functions **add.c** and **sub.c** to implement addition and subtraction, respectively. ``` - cd /home/code/src - vi add.c - vi sub.c + $ cd ~/code/src + $ vi add.c + $ vi sub.c ``` The following is an example of the **add.c** code: @@ -553,20 +549,20 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l 3. Compile the source files **add.c** and **sub.c** into the target files **add.o** and **sub.o**. ``` - gcc -c add.c sub.c + $ gcc -c add.c sub.c ``` -4. Run the **ar** command to compress the **add.o** and **sub.o** target files into the SLL **libmath.a** and save the SLL to the **/home/code/lib** directory. +4. Run the **ar** command to compress the **add.o** and **sub.o** target files into the SLL **libmath.a** and save the SLL to the **~/code/lib** directory. ``` - ar rcs /home/code/lib/libmath.a add.o sub.o + $ ar rcs ~/code/lib/libmath.a add.o sub.o ``` -5. Go to the **/home/code/include** directory, create a header file **math.h**, and declare the header file of the function. +5. Go to the **~/code/include** directory, create a header file **math.h**, and declare the header file of the function. ``` - cd /home/code/include - vi math.h + $ cd ~/code/include + $ vi math.h ``` The following is an example of the **math.h** code: @@ -579,11 +575,11 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l #endif ``` -6. Run the **cd** command to go to the **/home/code/src** directory and create a **main.c** function that invokes add\(\) and sub\(\). +6. Run the **cd** command to go to the **~/code/src** directory and create a **main.c** function that invokes add\(\) and sub\(\). ``` - cd /home/code/src - vi main.c + $ cd ~/code/src + $ vi main.c ``` The following is an example of the **math.c** code: @@ -605,13 +601,13 @@ In the preceding command, **libraryDIR** indicates the path of the libtest.a l 7. Compile **main.c** and **libmath.a** into **math.out**. ``` - gcc main.c -I /home/code/include -L /home/code/lib -lmath -o math.out + $ gcc main.c -I ~/code/include -L ~/code/lib -lmath -o math.out ``` 8. Run the following command to execute **math.out**: ``` - ./math.out + $ ./math.out ``` The command output is as follows: diff --git a/content/en/docs/ApplicationDev/using-jdk-for-compilation.md b/content/en/docs/ApplicationDev/using-jdk-for-compilation.md index be343ae87cac30b5833e6f0944d1f3e07ee197db..4946b917d12b6bf483f3507c1a327deaf3a04de0 100644 --- a/content/en/docs/ApplicationDev/using-jdk-for-compilation.md +++ b/content/en/docs/ApplicationDev/using-jdk-for-compilation.md @@ -399,16 +399,16 @@ In Java, there are two methods to use the common classes in the package provided ### Compiling a Java Program Without a Package -1. Run the **cd** command to go to the code directory. The **/home/code** directory is used as an example. The command is as follows: +1. Run the **cd** command to go to the code directory. The **~/code** directory is used as an example. The command is as follows: ``` - # cd /home/code + $ cd ~/code ``` 2. Compile the Hello World program and save it as **HelloWorld.java**. The following uses the Hello World program as an example. The command is as follows: ``` - # vi HelloWorld.java + $ vi HelloWorld.java ``` Code example: @@ -424,7 +424,7 @@ In Java, there are two methods to use the common classes in the package provided 3. Run the following command to compile the code in the code directory: ``` - # javac HelloWorld.java + $ javac HelloWorld.java ``` If no error is reported, the execution is successful. @@ -432,28 +432,27 @@ In Java, there are two methods to use the common classes in the package provided 4. After the compilation is complete, the HelloWorld.class file is generated. You can run the **java** command to view the result. The following is an example: ``` - # java HelloWorld + $ java HelloWorld Hello World ``` ### Compiling a Java Program with a Package -1. Run the **cd** command to go to the code directory. The **/home/code** directory is used as an example. Create the **/home/code/Test/my/example**, **/home/code/Hello/world/developers**, and **/home/code/Hi/openos/openeuler** subdirectories in the directory to store source files. +1. Run the **cd** command to go to the code directory. The **~/code** directory is used as an example. Create the **~/code/Test/my/example**, **~/code/Hello/world/developers**, and **~/code/Hi/openos/openeuler** subdirectories in the directory to store source files. ``` - cd /home/code - - mkdir -p Test/my/example - mkdir -p Hello/world/developers - mkdir -p Hi/openos/openeuler + $ cd ~/code + $ mkdir -p Test/my/example + $ mkdir -p Hello/world/developers + $ mkdir -p Hi/openos/openeuler ``` - -2. Run the **cd** command to go to the **/home/code/Test/my/example** directory and create **Test.java**. + +2. Run the **cd** command to go to the **~/code/Test/my/example** directory and create **Test.java**. ``` - cd /home/code/Test/my/example - vi Test.java + $ cd ~/code/Test/my/example + $ vi Test.java ``` The following is an example of the Test.java code: @@ -472,11 +471,11 @@ In Java, there are two methods to use the common classes in the package provided } ``` -3. Run the **cd** command to go to the **/home/code/Hello/world/developers** directory and create **Hello.java**. +3. Run the **cd** command to go to the **~/code/Hello/world/developers** directory and create **Hello.java**. ``` - cd /home/code/Hello/world/developers - vi Hello.java + $ cd ~/code/Hello/world/developers + $ vi Hello.java ``` The following is an example of the Hello.java code: @@ -490,11 +489,11 @@ In Java, there are two methods to use the common classes in the package provided } ``` -4. Run the **cd** command to go to the **/home/code/Hi/openos/openeuler** directory and create **Hi.java**. +4. Run the **cd** command to go to the **~/code/Hi/openos/openeuler** directory and create **Hi.java**. ``` - cd /home/code/Hi/openos/openeuler - vi Hi.java + $ cd ~/code/Hi/openos/openeuler + $ vi Hi.java ``` The following is an example of the Hi.java code: @@ -508,20 +507,20 @@ In Java, there are two methods to use the common classes in the package provided } ``` -5. Run the **cd** command to go to the **/home/code** directory and use javac to compile the source file. +5. Run the **cd** command to go to the **~/code** directory and use javac to compile the source file. ``` - cd /home/code - javac -classpath Hello:Hi Test/my/example/Test.java + $ cd ~/code + $ javac -classpath Hello:Hi Test/my/example/Test.java ``` - After the command is executed, the **Test.class**, **Hello.class**, and **Hi.class** files are generated in the **/home/code/Test/my/example**, **/home/code/Hello/world/developers**, and **/home/code/Hi/openos/openeuler** directories. + After the command is executed, the **Test.class**, **Hello.class**, and **Hi.class** files are generated in the **~/code/Test/my/example**, **~/code/Hello/world/developers**, and **~/code/Hi/openos/openeuler** directories. -6. Run the **cd** command to go to the **/home/code** directory and run the **Test** program using Java. +6. Run the **cd** command to go to the **~/code** directory and run the **Test** program using Java. ``` - cd /home/code - java -classpath Test:Hello:Hi my/example/Test + $ cd ~/code + $ java -classpath Test:Hello:Hi my/example/Test ``` The command output is as follows: diff --git a/content/en/docs/ApplicationDev/using-make-for-compilation.md b/content/en/docs/ApplicationDev/using-make-for-compilation.md index 9c2f7dc16277f54b1cd7e0ec4507321f3eb91447..199f76d06425021e9716e490ebc1e16a572d2661 100644 --- a/content/en/docs/ApplicationDev/using-make-for-compilation.md +++ b/content/en/docs/ApplicationDev/using-make-for-compilation.md @@ -277,16 +277,18 @@ A makefile file consists of the following contents: ### Example of Using Makefile to Implement Compilation -1. Run the **cd** command to go to the code directory. The **/home/code** directory is used as an example. +1. Run the **cd** command to go to the code directory. The **~/code** directory is used as an example. ``` - cd /home/code + $ cd ~/code ``` -2. Create a header file **hello.h** and two functions **hello.c** and **main.c**. +2. Create a header file **hello.h** and two functions **hello.c** and **main.c**. ``` - cd /home/code/ + $ vi hello.h + $ vi hello.c + $ vi main.c ``` The following is an example of the **hello.h** code: @@ -328,7 +330,7 @@ A makefile file consists of the following contents: 3. Create the makefile. ``` - vi Makefile + $ vi Makefile ``` The following provides an example of the makefile content: @@ -347,7 +349,7 @@ A makefile file consists of the following contents: 4. Run the **make** command. ``` - make + $ make ``` After the command is executed, the commands executed in makefile are printed. If you do not need to print the information, add the **-s** option to the **make** command. @@ -361,7 +363,7 @@ A makefile file consists of the following contents: 5. Execute the ./main target. ``` - ./main + $ ./main ``` After the command is executed, the following information is displayed: diff --git a/content/en/docs/Container/device-management.md b/content/en/docs/Container/device-management.md index 1c32855161af130608db3d678381d0da627c7495..b3946a03134678a683e9965e150c10d9f8e9e2a0 100644 --- a/content/en/docs/Container/device-management.md +++ b/content/en/docs/Container/device-management.md @@ -2,12 +2,12 @@ ## Function Description -isulad-tools allows you to add block devices \(such as disks and logical volume managers\) or character devices \(such as GPUs, binners, and FUSEs\) on the host to a container. The devices can be used in the container. For example, you can run the **fdisk** command to format the disk and write data to the file system. If the devices are not required, isulad-tools allows you to delete them from the container and return them to the host. +syscontainer-tools allows you to add block devices \(such as disks and logical volume managers\) or character devices \(such as GPUs, binners, and FUSEs\) on the host to a container. The devices can be used in the container. For example, you can run the **fdisk** command to format the disk and write data to the file system. If the devices are not required, syscontainer-tools allows you to delete them from the container and return them to the host. ## Command Format ``` -isulad-tools [COMMADN][OPTIONS] [ARG...] +syscontainer-tools [COMMADN][OPTIONS] [ARG...] ``` In the preceding format: @@ -87,16 +87,16 @@ In the preceding format: - You can add or delete devices when container instances are not running. After the operation is complete, you can start the container to view the device status. You can also dynamically add a device when the container is running. - Do not concurrently run the **fdisk** command to format disks in a container and on the host. Otherwise, the container disk usage will be affected. -- When you run the **add-device** command to add a disk to a specific directory of a container, if the parent directory in the container is a multi-level directory \(for example, **/dev/a/b/c/d/e**\) and the directory level does not exist, isulad-tools will automatically create the corresponding directory in the container. When the disk is deleted, the created parent directory is not deleted. If you run the **add-device** command to add a device to this parent directory again, a message is displayed, indicating that a device already exists and cannot be added. +- When you run the **add-device** command to add a disk to a specific directory of a container, if the parent directory in the container is a multi-level directory \(for example, **/dev/a/b/c/d/e**\) and the directory level does not exist, syscontainer-tools will automatically create the corresponding directory in the container. When the disk is deleted, the created parent directory is not deleted. If you run the **add-device** command to add a device to this parent directory again, a message is displayed, indicating that a device already exists and cannot be added. - When you run the** add-device** command to add a disk or update disk parameters, you need to configure the disk QoS. Do not set the write or read rate limit for the block device \(I/O/s or byte/s\) to a small value. If the value is too small, the disk may be unreadable \(the actual reason is the speed is too slow\), affecting service functions. - When you run the **--blkio-weight-device** command to limit the weight of a specified block device, if the block device supports only the BFQ mode, an error may be reported, prompting you to check whether the current OS environment supports setting the weight of the BFQ block device. ## Example -- Start a system container, and set **hook spec** to the isulad hook execution script. +- Start a system container, and set **hook spec** to the syscontainer hook execution script. ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init eed1096c8c7a0eca6d92b1b3bc3dd59a2a2adf4ce44f18f5372408ced88f8350 ``` @@ -104,7 +104,7 @@ In the preceding format: - Add a block device to a container. ``` - [root@localhost ~]# isulad-tools add-device ee /dev/sdb:/dev/sdb123 + [root@localhost ~]# syscontainer-tools add-device ee /dev/sdb:/dev/sdb123 Add device (/dev/sdb) to container(ee,/dev/sdb123) done. [root@localhost ~]# isula exec ee fdisk -l /dev/sdb123 Disk /dev/sdb123: 50 GiB, 53687091200 bytes, 104857600 sectors @@ -122,14 +122,14 @@ In the preceding format: - Update the device information. ``` - [root@localhost ~]# isulad-tools update-device --device-read-bps /dev/sdb:10m ee + [root@localhost ~]# syscontainer-tools update-device --device-read-bps /dev/sdb:10m ee Update read bps for device (/dev/sdb,10485760) done. ``` - Delete a device. ``` - [root@localhost ~]# isulad-tools remove-device ee /dev/sdb:/dev/sdb123 + [root@localhost ~]# syscontainer-tools remove-device ee /dev/sdb:/dev/sdb123 Remove device (/dev/sdb) from container(ee,/dev/sdb123) done. Remove read bps for device (/dev/sdb) done. ``` diff --git a/content/en/docs/Container/dynamically-loading-the-kernel-module.md b/content/en/docs/Container/dynamically-loading-the-kernel-module.md index 69520247938c82ce12d295156dbbe4b500ec4353..6f821f7745a9da73f0e548cc77e8e1470566ee48 100644 --- a/content/en/docs/Container/dynamically-loading-the-kernel-module.md +++ b/content/en/docs/Container/dynamically-loading-the-kernel-module.md @@ -2,7 +2,7 @@ ## Function Description -Services in a container may depend on some kernel modules. You can set environment variables to dynamically load the kernel modules required by services in the container to the host before the system container starts. This feature must be used together with isulad-hooks. For details, see [Dynamically Managing Container Resources \(syscontainer-tools\)](dynamically-managing-container-resources-(syscontainer-tools).md). +Services in a container may depend on some kernel modules. You can set environment variables to dynamically load the kernel modules required by services in the container to the host before the system container starts. This feature must be used together with syscontainer-hooks. For details, see [Dynamically Managing Container Resources \(syscontainer-tools\)](dynamically-managing-container-resources-(syscontainer-tools).md). ## Parameter Description @@ -28,7 +28,7 @@ Services in a container may depend on some kernel modules. You can set environme ## Constraints - If loaded kernel modules are not verified or conflict with existing modules on the host, an unpredictable error may occur on the host. Therefore, exercise caution when loading kernel modules. -- Dynamic kernel module loading transfers kernel modules to be loaded to containers. This function is implemented by capturing environment variables for container startup using isulad-tools. Therefore, this function relies on the proper installation and deployment of isulad-tools. +- Dynamic kernel module loading transfers kernel modules to be loaded to containers. This function is implemented by capturing environment variables for container startup using syscontainer-tools. Therefore, this function relies on the proper installation and deployment of syscontainer-tools. - Loaded kernel modules need to be manually deleted. ## Example @@ -37,7 +37,7 @@ When starting a system container, specify the **-e KERNEL\_MODULES** parameter ``` [root@localhost ~]# lsmod | grep ip_vs -[root@localhost ~]# isula run -tid -e KERNEL_MODULES=ip_vs,ip_vs_wrr --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/myrootfs none init +[root@localhost ~]# isula run -tid -e KERNEL_MODULES=ip_vs,ip_vs_wrr --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/myrootfs none init ae18c4281d5755a1e153a7bff6b3b4881f36c8e528b9baba8a3278416a5d0980 [root@localhost ~]# lsmod | grep ip_vs ip_vs_wrr 16384 0 @@ -48,6 +48,6 @@ libcrc32c 16384 3 nf_conntrack,nf_nat,ip_vs ``` >![](public_sys-resources/icon-note.gif) **NOTE:** ->- isulad-tools must be installed on the host. ->- **--hooks-spec** must be set to **isulad hooks**. +>- syscontainer-tools must be installed on the host. +>- **--hooks-spec** must be set to **syscontainer hooks**. diff --git a/content/en/docs/Container/installation-guideline.md b/content/en/docs/Container/installation-guideline.md index d034dd8e0a4f9c7f9541572f6e7e1c89b1ea8681..386345cc0442a9a6ec246c2f6e6bfab1bc2e5d83 100644 --- a/content/en/docs/Container/installation-guideline.md +++ b/content/en/docs/Container/installation-guideline.md @@ -9,7 +9,7 @@ 2. Install dependent packages of system containers. ``` - # yum install isulad-tools authz isulad-lxcfs-toolkit lxcfs + # yum install syscontainer-tools authz lxcfs-tools lxcfs ``` 3. Run the following command to check whether iSulad is started: diff --git a/content/en/docs/Container/nic-management.md b/content/en/docs/Container/nic-management.md index f6baf08e3528e4f19aceaf11335c7fa9a20778c0..e307e66ad532209c3b802d9bc72af72cc961a64c 100644 --- a/content/en/docs/Container/nic-management.md +++ b/content/en/docs/Container/nic-management.md @@ -2,12 +2,12 @@ ## Function Description -isulad-tools allows you to insert physical or virtual NICs on the host to a container. If the NICs are not required, isulad-tools allows you to delete them from the container and return them to the host. In addition, the NIC configurations can be dynamically modified. To insert a physical NIC, add the NIC on the host to the container. To insert a virtual NIC, create a veth pair and insert its one end to the container. +syscontainer-tools allows you to insert physical or virtual NICs on the host to a container. If the NICs are not required, syscontainer-tools allows you to delete them from the container and return them to the host. In addition, the NIC configurations can be dynamically modified. To insert a physical NIC, add the NIC on the host to the container. To insert a virtual NIC, create a veth pair and insert its one end to the container. ## Command Format ``` -isulad-tools [COMMADN][OPTIONS] +syscontainer-tools [COMMADN][OPTIONS] ``` In the preceding format: @@ -69,18 +69,18 @@ In the preceding format: - Physical NICs \(eth\) and virtual NICs \(veth\) can be added. - When adding a NIC, you can also configure the NIC. The configuration parameters include **--ip**, **--mac**, **--bridge**, **--mtu**, **--qlen**. - A maximum of eight physical NICs can be added to a container. -- If you run the **isulad-tools add-nic** command to add an eth NIC to a container and do not add a hook, you must manually delete the NIC before the container exits. Otherwise, the name of the eth NIC on the host will be changed to the name of that in the container. +- If you run the **syscontainer-tools add-nic** command to add an eth NIC to a container and do not add a hook, you must manually delete the NIC before the container exits. Otherwise, the name of the eth NIC on the host will be changed to the name of that in the container. - For a physical NIC \(except 1822 VF NIC\), use the original MAC address when running the **add-nic** command. Do not change the MAC address in the container, or when running the **update-nic** command. -- When using the **isulad-tools add-nic** command, set the MTU value. The value range depends on the NIC model. -- When using isulad-tools to add NICs and routes to containers, you are advised to run the **add-nic** command to add NICs and then run the **add-route** command to add routes. When using isulad-tools to delete NICs and routes from a container, you are advised to run the **remove-route** command to delete routes and then run the **remove-nic** command to delete NICs. -- When using isulad-tools to add NICs, add a NIC to only one container. +- When using the **syscontainer-tools add-nic** command, set the MTU value. The value range depends on the NIC model. +- When using syscontainer-tools to add NICs and routes to containers, you are advised to run the **add-nic** command to add NICs and then run the **add-route** command to add routes. When using syscontainer-tools to delete NICs and routes from a container, you are advised to run the **remove-route** command to delete routes and then run the **remove-nic** command to delete NICs. +- When using syscontainer-tools to add NICs, add a NIC to only one container. ## Example -- Start a system container, and set **hook spec** to the isulad hook execution script. +- Start a system container, and set **hook spec** to the syscontainer hook execution script. ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init 2aaca5c1af7c872798dac1a468528a2ccbaf20b39b73fc0201636936a3c32aa8 ``` @@ -88,14 +88,14 @@ In the preceding format: - Add a virtual NIC to a container. ``` - [root@localhost ~]# isulad-tools add-nic --type "veth" --name abc2:bcd2 --ip 172.17.28.5/24 --mac 00:ff:48:13:xx:xx --bridge docker0 2aaca5c1af7c + [root@localhost ~]# syscontainer-tools add-nic --type "veth" --name abc2:bcd2 --ip 172.17.28.5/24 --mac 00:ff:48:13:xx:xx --bridge docker0 2aaca5c1af7c Add network interface to container 2aaca5c1af7c (bcd2,abc2) done ``` - Add a physical NIC to a container. ``` - [root@localhost ~]# isulad-tools add-nic --type "eth" --name eth3:eth1 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 2aaca5c1af7c + [root@localhost ~]# syscontainer-tools add-nic --type "eth" --name eth3:eth1 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 2aaca5c1af7c Add network interface to container 2aaca5c1af7c (eth3,eth1) done ``` diff --git a/content/en/docs/Container/proc-file-system-isolation-(lxcfs).md b/content/en/docs/Container/proc-file-system-isolation-(lxcfs).md index 298df26674894380381ce524b8ed6c3e8ebed724..621437140a2e19ea13ba5000f213cb290b79bb57 100644 --- a/content/en/docs/Container/proc-file-system-isolation-(lxcfs).md +++ b/content/en/docs/Container/proc-file-system-isolation-(lxcfs).md @@ -6,12 +6,12 @@ Container virtualization is lightweight and efficient, and can be quickly deploy ## API Description -A system container provides two tool packages: lxcfs and lxcfs-toolkit, which are used together. Lxcfs resides on the host as the daemon process. lxcfs-toolkit mounts the lxcfs file system of the host to containers through the hook mechanism. +A system container provides two tool packages: lxcfs and lxcfs-tools, which are used together. Lxcfs resides on the host as the daemon process. lxcfs-tools mounts the lxcfs file system of the host to containers through the hook mechanism. -The command line of lxcfs-toolkit is as follows: +The command line of lxcfs-tools is as follows: ``` -lxcfs-toolkit [OPTIONS] COMMAND [COMMAND_OPTIONS] +lxcfs-tools [OPTIONS] COMMAND [COMMAND_OPTIONS] ``` @@ -76,10 +76,10 @@ lxcfs-toolkit [OPTIONS] COMMAND [COMMAND_OPTIONS] ## Example -1. Install the lxcfs and lxcfs-toolkit packages and start the lxcfs service. +1. Install the lxcfs and lxcfs-tools packages and start the lxcfs service. ``` - [root@localhost ~]# yum install lxcfs lxcfs-toolkit + [root@localhost ~]# yum install lxcfs lxcfs-tools [root@localhost ~]# systemctl start lxcfs ``` diff --git a/content/en/docs/Container/route-management.md b/content/en/docs/Container/route-management.md index c784738efb60ed64d790fd31cc10b3f7165c516e..ee3a56579a38e1975302aecd90a4099b5a678ecf 100644 --- a/content/en/docs/Container/route-management.md +++ b/content/en/docs/Container/route-management.md @@ -2,12 +2,12 @@ ## Function Description -isulad-tools can be used to dynamically add or delete routing tables for system containers. +syscontainer-tools can be used to dynamically add or delete routing tables for system containers. ## Command Format ``` -isulad-tools [COMMADN][OPTIONS] [ARG...] +syscontainer-tools [COMMADN][OPTIONS] [ARG...] ``` In the preceding format: @@ -74,31 +74,31 @@ In the preceding format: ## Constraints -- When using isulad-tools to add NICs and routes to containers, you are advised to run the **add-nic** command to add NICs and then run the **add-route** command to add routes. When using isulad-tools to delete NICs and routes from a container, you are advised to run the **remove-route** command to delete routes and then run the **remove-nic** command to delete NICs. +- When using syscontainer-tools to add NICs and routes to containers, you are advised to run the **add-nic** command to add NICs and then run the **add-route** command to add routes. When using syscontainer-tools to delete NICs and routes from a container, you are advised to run the **remove-route** command to delete routes and then run the **remove-nic** command to delete NICs. - When adding a routing rule to a container, ensure that the added routing rule does not conflict with existing routing rules in the container. ## Example -- Start a system container, and set **hook spec** to the isulad hook execution script. +- Start a system container, and set **hook spec** to the syscontainer hook execution script. ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init 0d2d68b45aa0c1b8eaf890c06ab2d008eb8c5d91e78b1f8fe4d37b86fd2c190b ``` -- Use isulad-tools to add a physical NIC to the system container. +- Use syscontainer-tools to add a physical NIC to the system container. ``` - [root@localhost ~]# isulad-tools add-nic --type "eth" --name enp4s0:eth123 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 0d2d68b45aa0 + [root@localhost ~]# syscontainer-tools add-nic --type "eth" --name enp4s0:eth123 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 0d2d68b45aa0 Add network interface (enp4s0) to container (0d2d68b45aa0,eth123) done ``` -- isulad-tools adds a routing rule to the system container. Format example: **\[\{"dest":"default", "gw":"192.168.10.1"\},\{"dest":"192.168.0.0/16","dev":"eth0","src":"192.168.1.2"\}\]**. If **dest** is left blank, its value will be **default**. +- syscontainer-tools adds a routing rule to the system container. Format example: **\[\{"dest":"default", "gw":"192.168.10.1"\},\{"dest":"192.168.0.0/16","dev":"eth0","src":"192.168.1.2"\}\]**. If **dest** is left blank, its value will be **default**. ``` - [root@localhost ~]# isulad-tools add-route 0d2d68b45aa0 '[{"dest":"172.17.28.0/32", "gw":"172.17.28.5","dev":"eth123"}]' + [root@localhost ~]# syscontainer-tools add-route 0d2d68b45aa0 '[{"dest":"172.17.28.0/32", "gw":"172.17.28.5","dev":"eth123"}]' Add route to container 0d2d68b45aa0, route: {dest:172.17.28.0/32,src:,gw:172.17.28.5,dev:eth123} done ``` diff --git a/content/en/docs/Container/volume-mounting-management.md b/content/en/docs/Container/volume-mounting-management.md index f9b4c12fb8ff8bf9b19406165c31b214df673966..ac5e094d82a48d3334d809dc4b5a1f67f3ccec9d 100644 --- a/content/en/docs/Container/volume-mounting-management.md +++ b/content/en/docs/Container/volume-mounting-management.md @@ -2,12 +2,12 @@ ## Function Description -In a common container, you can set the **--volume** parameter during container creation to mount directories or volumes of the host to the container for resource sharing. However, during container running, you cannot unmount directories or volumes that are mounted to the container, or mount directories or volumes of the host to the container. Only the system container can use the isulad-tools tool to dynamically mount directories or volumes of the host to the container and unmount directories or volumes from the container. +In a common container, you can set the **--volume** parameter during container creation to mount directories or volumes of the host to the container for resource sharing. However, during container running, you cannot unmount directories or volumes that are mounted to the container, or mount directories or volumes of the host to the container. Only the system container can use the syscontainer-tools tool to dynamically mount directories or volumes of the host to the container and unmount directories or volumes from the container. ## Command Format ``` -isulad-tools [COMMADN][OPTIONS] [ARG...] +syscontainer-tools [COMMADN][OPTIONS] [ARG...] ``` In the preceding format: @@ -83,18 +83,18 @@ In the preceding format: ## Example -- Start a system container, and set **hook spec** to the isulad hook execution script. +- Start a system container, and set **hook spec** to the syscontainer hook execution script. ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init e45970a522d1ea0e9cfe382c2b868d92e7b6a55be1dd239947dda1ee55f3c7f7 ``` -- Use isulad-tools to mount a directory on the host to a container, implementing resource sharing. +- Use syscontainer-tools to mount a directory on the host to a container, implementing resource sharing. ``` - [root@localhost ~]# isulad-tools add-path e45970a522d1 /home/test123:/home/test123 + [root@localhost ~]# syscontainer-tools add-path e45970a522d1 /home/test123:/home/test123 Add path (/home/test123) to container(e45970a522d1,/home/test123) done. ``` @@ -107,10 +107,10 @@ In the preceding format: hello world ``` -- Use isulad-tools to delete the mount directory from the container. +- Use syscontainer-tools to delete the mount directory from the container. ``` - [root@localhost ~]# isulad-tools remove-path e45970a522d1 /home/test123:/home/test123 + [root@localhost ~]# syscontainer-tools remove-path e45970a522d1 /home/test123:/home/test123 Remove path (/home/test123) from container(e45970a522d1,/home/test123) done [root@localhost ~]# isula exec e45970a522d1 bash [root@localhost /]# ls /home/test123/helloworld diff --git a/content/en/menu/index.md b/content/en/menu/index.md index e5fa8da14016c701bf021077e8defe6447871869..8904c6085341ecb39ee150b95b7d25323c364e9f 100644 --- a/content/en/menu/index.md +++ b/content/en/menu/index.md @@ -28,7 +28,7 @@ headless: true - [Administrator Guide]({{< relref "./docs/Administration/administration.md" >}}) - [Viewing System Information]({{< relref "./docs/Administration/viewing-system-information.md" >}}) - [Basic Configuration]({{< relref "./docs/Administration/basic-configuration.md" >}}) - - [User Management]({{< relref "./docs/Administration/user-management.md" >}}) + - [User and User Group Management]({{< relref "./docs/Administration/user-and-user-group-management.md" >}}) - [Using the DNF to Manage Software Packages]({{< relref "./docs/Administration/using-the-dnf-to-manage-software-packages.md" >}}) - [Service Management]({{< relref "./docs/Administration/service-management.md" >}}) - [Process Management]({{< relref "./docs/Administration/process-management.md" >}}) diff --git "a/content/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" "b/content/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" index 276fa75b261de5e2dd40c550dc42364792bbce0f..ea2edf5754f66009c3ab9c4b0c026928c1405fd6 100644 --- "a/content/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" +++ "b/content/zh/docs/Administration/\344\275\277\347\224\250DNF\347\256\241\347\220\206\350\275\257\344\273\266\345\214\205.md" @@ -9,7 +9,7 @@ DNF是一款Linux软件包管理工具,用于管理RPM软件包。DNF可以查 - [使用DNF管理软件包](#使用dnf管理软件包) - [配置DNF](#配置dnf) - - [修改配置文件](#修改配置文件) + - [DNF配置文件](#dnf配置文件) - [创建本地软件源仓库](#创建本地软件源仓库) - [添加、启用和禁用软件源](#添加启用和禁用软件源) - [管理软件包](#管理软件包) @@ -35,21 +35,25 @@ DNF是一款Linux软件包管理工具,用于管理RPM软件包。DNF可以查 -### 修改配置文件 +### DNF配置文件 -DNF 的主要配置文件是 /etc/dnf/dnf.conf,该文件中“main”部分保存着 DNF 的全局设置;用户可以在该文件中通过添加一个或者多个“repository”部分的方式来设置需要安装的软件源位置。 +DNF 的主要配置文件是 /etc/dnf/dnf.conf,该文件包含两部分: -另外,在/etc/yum.repos.d 目录中保存着一个或多个repo 源相关文件,它们定义了不同的“repository”。 +- “main”部分保存着DNF的全局设置。 -软件源的配置一般有两种方式,一种是直接配置 /etc/dnf/dnf.conf 文件,另外一种是在 /etc/yum.repos.d 目录下增加 .repo 文件。 +- “repository”部分保存着软件源的设置,可以有一个或多个“repository”。 -#### 修改main部分 +另外,在/etc/yum.repos.d 目录中保存着一个或多个repo源相关文件,它们也可以定义不同的“repository”。 -/etc/dnf/dnf.conf 文件包含的“main”部分,配置文件示例如下: +所以openEuler软件源的配置一般有两种方式,一种是直接配置/etc/dnf/dnf.conf文件中的“repository”部分,另外一种是在/etc/yum.repos.d目录下增加.repo文件。 + +#### 配置main部分 + +/etc/dnf/dnf.conf 文件包含的“main”部分,配置示例如下: ``` [main] -gpgcheck=0 +gpgcheck=1 installonly_limit=3 clean_requirements_on_remove=True best=True @@ -114,42 +118,68 @@ best=True -#### 修改repository部分 +#### 配置repository部分 -repository部分允许您定义定制化的软件源仓库,各个仓库的名称不能相同,否则会引起冲突。下面是\[repository\]部分的一个最小配置示例: +repository部分允许您定义定制化的openEuler软件源仓库,各个仓库的名称不能相同,否则会引起冲突。配置repository部分有两种方式,一种是直接配置/etc/dnf/dnf.conf文件中的“repository”部分,另外一种是配置/etc/yum.repos.d目录下的.repo文件。 -``` -[repository] -name=repository_name -baseurl=repository_url -``` +- 直接配置/etc/dnf/dnf.conf文件中的“repository”部分 -选项说明: + 下面是\[repository\]部分的一个最小配置示例: ->![](public_sys-resources/icon-note.gif) **说明:** ->openEuler提供在线的镜像源,地址:[https://repo.openeuler.org/](https://repo.openeuler.org/)。以 openEuler 20.03的aarch64版本为例,baseurl可配置为[https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/](https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/)。 + ``` + [repository] + name=repository_name + baseurl=repository_url + ``` + >![](public_sys-resources/icon-note.gif) **说明:** + >openEuler提供在线的镜像源,地址:[https://repo.openeuler.org/](https://repo.openeuler.org/)。以 openEuler 20.03的aarch64版本为例,baseurl可配置为[https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/](https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/)。 + + 选项说明: + + **表 2** repository参数说明 + + + + + + + + + + + +

参数

+

说明

+

name=repository_name

+

软件仓库(repository )描述的字符串。

+

baseurl=repository_url

+

软件仓库(repository )的地址。

+
  • 使用http协议的网络位置:例如 http://path/to/repo
  • 使用ftp协议的网络位置:例如 ftp://path/to/repo
  • 本地位置:例如 file:///path/to/local/repo
+
+ + +- 配置/etc/yum.repos.d目录下的.repo文件 + + openEuler提供了多种repo源,以AArch64架构的OS repo源为例。使用root权限在openEuler_aarch64.repo文件中添加openEuler repo源,示例如下: -**表 2** repository参数说明 - - - - - - - - - - - -

参数

-

说明

-

name=repository_name

-

软件仓库(repository )描述的字符串。

-

baseurl=repository_url

-

软件仓库(repository )的地址。

-
  • 使用http协议的网络位置:例如 http://path/to/repo
  • 使用ftp协议的网络位置:例如 ftp://path/to/repo
  • 本地位置:例如 file:///path/to/local/repo
-
+ ``` + # vi /etc/yum.repos.d/openEuler_aarch64.repo + ``` + + ``` + [base] + name=openEuler base + baseurl=https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/ + enabled=1 + gpgcheck=1 + gpgkey=https://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/RPM-GPG-KEY-openEuler + + ``` + + >![](public_sys-resources/icon-note.gif) **说明:** + >gpgkey为验证签名用的公钥。 + #### 显示当前配置 diff --git "a/content/zh/docs/Administration/\344\275\277\347\224\250LVM\347\256\241\347\220\206\347\241\254\347\233\230.md" "b/content/zh/docs/Administration/\344\275\277\347\224\250LVM\347\256\241\347\220\206\347\241\254\347\233\230.md" index 492d03b32b0944920157e04deab3d0c39c260913..3add822aacd8b9d070e747d11a9de35cb7c464bc 100644 --- "a/content/zh/docs/Administration/\344\275\277\347\224\250LVM\347\256\241\347\220\206\347\241\254\347\233\230.md" +++ "b/content/zh/docs/Administration/\344\275\277\347\224\250LVM\347\256\241\347\220\206\347\241\254\347\233\230.md" @@ -68,25 +68,25 @@ LVM是逻辑卷管理(Logical Volume Manager)的简称,它是Linux环境 2. 清除缓存。 ``` - #dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - #dnf makecache + $ dnf makecache ``` -4. 安装LVM。 +4. 在root权限下安装LVM。 ``` - #dnf install lvm2 + # dnf install lvm2 ``` 5. 查看安装后的rpm包。 ``` - #rpm -qa | grep lvm2 + $ rpm -qa | grep lvm2 ``` @@ -94,7 +94,7 @@ LVM是逻辑卷管理(Logical Volume Manager)的简称,它是Linux环境 ### 创建物理卷 -可通过pvcreate命令创建物理卷。 +可在root权限下通过pvcreate命令创建物理卷。 ``` pvcreate [option] devname ... @@ -113,18 +113,18 @@ pvcreate [option] devname ... 示例1:将/dev/sdb、/dev/sdc创建为物理卷。 ``` -pvcreate /dev/sdb /dev/sdc +# pvcreate /dev/sdb /dev/sdc ``` 示例2:将/dev/sdb1、/dev/sdb2创建为物理卷。 ``` -pvcreate /dev/sdb1 /dev/sdb2 +# pvcreate /dev/sdb1 /dev/sdb2 ``` ### 查看物理卷 -可通过pvdisplay命令查看物理卷的信息,包括:物理卷名称、所属的卷组、物理卷大小、PE大小、总PE数、可用PE数、已分配的PE数和UUID。 +可在root权限通过pvdisplay命令查看物理卷的信息,包括:物理卷名称、所属的卷组、物理卷大小、PE大小、总PE数、可用PE数、已分配的PE数和UUID。 ``` pvdisplay [option] devname @@ -141,12 +141,12 @@ pvdisplay [option] devname 示例:显示物理卷/dev/sdb的基本信息。 ``` -pvdisplay /dev/sdb +# pvdisplay /dev/sdb ``` ### 修改物理卷属性 -可通过pvchange命令修改物理卷的属性。 +可在root权限下通过pvchange命令修改物理卷的属性。 ``` pvchange [option] pvname ... @@ -163,12 +163,12 @@ pvchange [option] pvname ... 示例:禁止分配/dev/sdb物理卷上的PE。 ``` -pvchange -x n /dev/sdb +# pvchange -x n /dev/sdb ``` ### 删除物理卷 -可通过pvremove命令删除物理卷。 +可在root权限下通过pvremove命令删除物理卷。 ``` pvremove [option] pvname ... @@ -185,14 +185,14 @@ pvremove [option] pvname ... 示例:删除物理卷/dev/sdb。 ``` -pvremove /dev/sdb +# pvremove /dev/sdb ``` ## 管理卷组 ### 创建卷组 -可通过vgcreate命令创建卷组。 +可在root权限下通过vgcreate命令创建卷组。 ``` vgcreate [option] vgname pvname ... @@ -211,12 +211,12 @@ vgcreate [option] vgname pvname ... 示例:创建卷组 vg1,并且将物理卷/dev/sdb和/dev/sdc添加到卷组中。 ``` -vgcreate vg1 /dev/sdb /dev/sdc +# vgcreate vg1 /dev/sdb /dev/sdc ``` ### 查看卷组 -可通过vgdisplay命令查看卷组的信息。 +可在root权限下通过vgdisplay命令查看卷组的信息。 ``` vgdisplay [option] [vgname] @@ -233,12 +233,12 @@ vgdisplay [option] [vgname] 示例:显示卷组vg1的基本信息。 ``` -vgdisplay vg1 +# vgdisplay vg1 ``` ### 修改卷组属性 -可通过vgchange命令修改卷组的属性。 +可在root权限下通过vgchange命令修改卷组的属性。 ``` vgchange [option] vgname @@ -254,12 +254,12 @@ vgchange [option] vgname 示例:将卷组vg1状态修改为活动。 ``` -vgchange -ay vg1 +# vgchange -ay vg1 ``` ### 扩展卷组 -可通过vgextend命令动态扩展卷组。它通过向卷组中添加物理卷来增加卷组的容量。 +可在root权限下通过vgextend命令动态扩展卷组。它通过向卷组中添加物理卷来增加卷组的容量。 ``` vgextend [option] vgname pvname ... @@ -277,12 +277,12 @@ vgextend [option] vgname pvname ... 示例:将卷组vg1中添加物理卷/dev/sdb。 ``` -vgextend vg1 /dev/sdb +# vgextend vg1 /dev/sdb ``` ### 收缩卷组 -可通过vgreduce命令删除卷组中的物理卷来减少卷组容量。不能删除卷组中剩余的最后一个物理卷。 +可在root权限下通过vgreduce命令删除卷组中的物理卷来减少卷组容量。不能删除卷组中剩余的最后一个物理卷。 ``` vgreduce [option] vgname pvname ... @@ -300,12 +300,12 @@ vgreduce [option] vgname pvname ... 示例:从卷组vg1中移除物理卷/dev/sdb2。 ``` -vgreduce vg1 /dev/sdb2 +# vgreduce vg1 /dev/sdb2 ``` ### 删除卷组 -可通过vgremove命令删除卷组。 +可在root权限下通过vgremove命令删除卷组。 ``` vgremove [option] vgname @@ -321,14 +321,14 @@ vgremove [option] vgname 示例:删除卷组vg1。 ``` -vgremove vg1 +# vgremove vg1 ``` ## 管理逻辑卷 ### 创建逻辑卷 -可通过lvcreate命令创建逻辑卷。 +可在root权限下通过lvcreate命令创建逻辑卷。 ``` lvcreate [option] vgname @@ -347,18 +347,18 @@ lvcreate [option] vgname 示例1:在卷组vg1中创建10G大小的逻辑卷。 ``` -lvcreate -L 10G vg1 +# lvcreate -L 10G vg1 ``` -示例1:在卷组vg1中创建200M的逻辑卷,并命名为lv1。 +示例2:在卷组vg1中创建200M的逻辑卷,并命名为lv1。 ``` -lvcreate -L 200M -n lv1 vg1 +# lvcreate -L 200M -n lv1 vg1 ``` ### 查看逻辑卷 -可通过lvdisplay命令查看逻辑卷的信息,包括逻辑卷空间大小、读写状态和快照信息等属性。 +可在root权限下通过lvdisplay命令查看逻辑卷的信息,包括逻辑卷空间大小、读写状态和快照信息等属性。 ``` lvdisplay [option] [lvname] @@ -367,8 +367,9 @@ lvdisplay [option] [lvname] 其中: - option:命令参数选项。常用的参数选项有: - - -v:显示LE到PE的映射 - + +- -v:显示LE到PE的映射 + - lvname:指定要显示属性的逻辑卷对应的设备文件。如果省略,则显示所有的逻辑卷属性。 >![](public_sys-resources/icon-note.gif) **说明:** @@ -378,12 +379,12 @@ lvdisplay [option] [lvname] 示例:显示逻辑卷lv1的基本信息。 ``` -lvdisplay /dev/vg1/lv1 +# lvdisplay /dev/vg1/lv1 ``` ### 调整逻辑卷大小 -可通过lvresize命令调整LVM逻辑卷的空间大小,可以增大空间和缩小空间。使用lvresize命令调整逻辑卷空间大小和缩小空间时需要谨慎,因为有可能导致数据丢失。 +可在root权限下通过lvresize命令调整LVM逻辑卷的空间大小,可以增大空间和缩小空间。使用lvresize命令调整逻辑卷空间大小和缩小空间时需要谨慎,因为有可能导致数据丢失。 ``` lvresize [option] vgname @@ -401,18 +402,18 @@ lvresize [option] vgname 示例1:为逻辑卷/dev/vg1/lv1增加200M空间。 ``` -lvresize -L +200 /dev/vg1/lv1 +# lvresize -L +200 /dev/vg1/lv1 ``` 示例2:为逻辑卷/dev/vg1/lv1减少200M空间。 ``` -lvresize -L -200 /dev/vg1/lv1 +# lvresize -L -200 /dev/vg1/lv1 ``` ### 扩展逻辑卷 -可通过lvextend命令动态在线扩展逻辑卷的空间大小,而不中断应用程序对逻辑卷的访问。 +可在root权限下通过lvextend命令动态在线扩展逻辑卷的空间大小,而不中断应用程序对逻辑卷的访问。 ``` lvextend [option] lvname @@ -430,12 +431,12 @@ lvextend [option] lvname 示例:为逻辑卷/dev/vg1/lv1增加100M空间。 ``` -lvextend -L +100M /dev/vg1/lv1 +# lvextend -L +100M /dev/vg1/lv1 ``` ### 收缩逻辑卷 -可通过lvreduce命令减少逻辑卷占用的空间大小。使用lvreduce命令收缩逻辑卷的空间大小有可能会删除逻辑卷上已有的数据,所以在操作前必须进行确认。 +可在root权限下通过lvreduce命令减少逻辑卷占用的空间大小。使用lvreduce命令收缩逻辑卷的空间大小有可能会删除逻辑卷上已有的数据,所以在操作前必须进行确认。 ``` lvreduce [option] lvname @@ -453,12 +454,12 @@ lvreduce [option] lvname 示例:将逻辑卷/dev/vg1/lv1的空间减少100M。 ``` -lvreduce -L -100M /dev/vg1/lv1 +# lvreduce -L -100M /dev/vg1/lv1 ``` ### 删除逻辑卷 -可通过lvremove命令删除逻辑卷。如果逻辑卷已经使用mount命令加载,则不能使用lvremove命令删除。必须使用umount命令卸载后,逻辑卷方可被删除。 +可在root权限下通过lvremove命令删除逻辑卷。如果逻辑卷已经使用mount命令加载,则不能使用lvremove命令删除。必须使用umount命令卸载后,逻辑卷方可被删除。 ``` lvremove [option] vgname @@ -474,7 +475,7 @@ lvremove [option] vgname 示例:删除逻辑卷/dev/vg1/lv1。 ``` -lvremove /dev/vg1/lv1 +# lvremove /dev/vg1/lv1 ``` ## 创建并挂载文件系统 @@ -483,7 +484,7 @@ lvremove /dev/vg1/lv1 ### 创建文件系统 -可通过mkfs命令创建文件系统。 +可在root权限下通过mkfs命令创建文件系统。 ``` mkfs [option] lvname @@ -499,14 +500,14 @@ mkfs [option] lvname 示例:在逻辑卷/dev/vg1/lv1上创建ext4文件系统。 ``` -mkfs -t ext4 /dev/vg1/lv1 +# mkfs -t ext4 /dev/vg1/lv1 ``` ### 手动挂载文件系统 手动挂载的文件系统仅在当时有效,一旦操作系统重启则会不存在。 -可通过mount命令挂载文件系统。 +可在root权限下通过mount命令挂载文件系统。 ``` mount lvname mntpath @@ -520,17 +521,17 @@ mount lvname mntpath 示例:将逻辑卷/dev/vg1/lv1挂载到/mnt/data目录。 ``` -mount /dev/vg1/lv1 /mnt/data +# mount /dev/vg1/lv1 /mnt/data ``` ### 自动挂载文件系统 -手动挂载的文件系统在操作系统重启之后会不存在,需要重新手动挂载文件系统。但若在手动挂载文件系统后进行如下设置,可以实现操作系统重启后文件系统自动挂载文件系统。 +手动挂载的文件系统在操作系统重启之后会不存在,需要重新手动挂载文件系统。但若在手动挂载文件系统后在root权限下进行如下设置,可以实现操作系统重启后文件系统自动挂载文件系统。 1. 执行blkid命令查询逻辑卷的UUID,逻辑卷以/dev/vg1/lv1为例。 ``` - blkid /dev/vg1/lv1 + # blkid /dev/vg1/lv1 ``` 查看打印信息,打印信息中包含如下内容,其中 _uuidnumber_ 是一串数字,为UUID, _fstype_ 为文件系统。 @@ -556,19 +557,19 @@ mount /dev/vg1/lv1 /mnt/data 1. 执行umount命令卸载文件系统,逻辑卷以/dev/vg1/lv1为例。 ``` - umount /dev/vg1/lv1 + # umount /dev/vg1/lv1 ``` 2. 执行如下命令,将/etc/fstab文件所有内容重新加载。 ``` - mount -a + # mount -a ``` 3. 执行如下命令,查询文件系统挂载信息,挂载目录以/mnt/data为例。 ``` - mount | grep /mnt/data + # mount | grep /mnt/data ``` 查看打印信息,若信息中包含如下信息表示自动挂载功能生效。 diff --git "a/content/zh/docs/Administration/\345\237\272\347\241\200\351\205\215\347\275\256.md" "b/content/zh/docs/Administration/\345\237\272\347\241\200\351\205\215\347\275\256.md" index e453d4f45e6bcaa1bce0bbd45c7301263dc3668e..19f09e9213c70c3145856743338b7f50629bee84 100644 --- "a/content/zh/docs/Administration/\345\237\272\347\241\200\351\205\215\347\275\256.md" +++ "b/content/zh/docs/Administration/\345\237\272\347\241\200\351\205\215\347\275\256.md" @@ -1,4 +1,4 @@ -# 基础配置 +# 基础配置 - [基础配置](#基础配置) @@ -27,7 +27,7 @@ 显示当前语言环境,命令如下: ``` -localectl status +$ localectl status ``` 例如显示系统当前的设置,命令和输出如下: @@ -44,7 +44,7 @@ $ localectl status 显示当前可用的语言环境,命令如下: ``` -localectl list-locales +$ localectl list-locales ``` 例如显示当前系统中所有可用的中文环境,命令和输出如下: @@ -59,7 +59,7 @@ zh_CN.UTF-8 要设置语言环境,在root权限下执行如下命令,其中 _locale_ 是您要设置的语言类型,取值范围可通过**localectl list-locales**获取,请根据实际情况修改。 ``` -localectl set-locale LANG=locale +# localectl set-locale LANG=locale ``` 例如设置为简体中文语言环境,在root权限下执行如下命令: @@ -69,10 +69,7 @@ localectl set-locale LANG=locale ``` >![](public_sys-resources/icon-note.gif) **说明:** ->修改后需要重新登录或者执行如下命令刷新配置文件,使修改生效。 -``` -source /etc/locale.conf -``` +>修改后需要重新登录或者在root权限下执行`source /etc/locale.conf`命令刷新配置文件,使修改生效。 ## 设置键盘 @@ -84,7 +81,7 @@ source /etc/locale.conf 显示当前键盘设置,命令如下: ``` -localectl status +$ localectl status ``` 例如显示系统当前的设置,命令和输出如下: @@ -101,7 +98,7 @@ $ localectl status 显示当前可用的键盘布局,命令如下: ``` -localectl list-keymaps +$ localectl list-keymaps ``` 例如显示系统当前的中文键盘布局,命令和输出如下: @@ -116,7 +113,7 @@ cn 设置键盘布局,在root权限下执行如下命令,其中 _map_ 是您想要设置的键盘类型,取值范围可通过**localectl list-keymaps**获取,请根据实际情况修改: ``` -localectl set-keymap map +# localectl set-keymap map ``` 此时设置的键盘布局同样也会应用到图形界面中。 @@ -143,7 +140,7 @@ $ localectl status 显示当前的日期和时间,命令如下: ``` -timedatectl +$ timedatectl ``` 例如显示系统当前的日期和时间,命令和输出如下: @@ -167,7 +164,7 @@ System clock synchronized: no >若启用了NTP远程服务器进行系统时钟自动同步,则不能手动修改日期和时间。若需要手动修改日期或时间,则需确保已经关闭NTP系统时钟自动同步。可执行**timedatectl set-ntp** no命令进行关闭。 ``` -timedatectl set-ntp boolean +# timedatectl set-ntp boolean ``` 例如开启自动远程时间同步,命令如下: @@ -184,7 +181,7 @@ timedatectl set-ntp boolean 修改当前的日期,在root权限下执行如下命令,其中 _YYYY_ 代表年份,_MM_ 代表月份,_DD_ 代表某天,请根据实际情况修改: ``` -timedatectl set-time YYYY-MM-DD +# timedatectl set-time YYYY-MM-DD ``` 例如修改当前的日期为2019年8月14号,命令如下: @@ -201,7 +198,7 @@ timedatectl set-time YYYY-MM-DD 修改当前的时间,在root权限下执行如下命令,其中 _HH_ 代表小时,_MM_ 代表分钟,_SS_ 代表秒,请根据实际情况修改: ``` -timedatectl set-time HH:MM:SS +# timedatectl set-time HH:MM:SS ``` 例如修改当前的时间为15点57分24秒,命令如下: @@ -215,13 +212,13 @@ timedatectl set-time HH:MM:SS 显示当前可用时区,命令如下: ``` -timedatectl list-timezones +$ timedatectl list-timezones ``` 要修改当前的时区,在root权限下执行如下命令,其中 _time\_zone_ 是您想要设置的时区,请根据实际情况修改: ``` -timedatectl set-timezone time_zone +# timedatectl set-timezone time_zone ``` 例如修改当前的时区,首先查询所在地域的可用时区,此处以Asia为例: @@ -264,19 +261,19 @@ Asia/Tokyo 显示当前的日期和时间,命令如下: ``` -date +$ date ``` 默认情况下,date命令显示本地时间。要显示UTC时间,添加\-\-utc或-u参数: ``` -date --utc +$ date --utc ``` 要自定义对应的输出信息格式,添加 +"format" 参数: ``` -date +"format" +$ date +"format" ``` **表 1** 参数说明 @@ -365,13 +362,13 @@ date +"format" 要修改当前的时间,添加\-\-set或者-s参数。在root权限下执行如下命令,其中 _HH_ 代表小时,_MM_ 代表分钟,_SS_ 代表秒,请根据实际情况修改: ``` -date --set HH:MM:SS +# date --set HH:MM:SS ``` 默认情况下, date命令设置本地时间。要设置UTC时间,添加\-\-utc或-u参数: ``` -date --set HH:MM:SS --utc +# date --set HH:MM:SS --utc ``` 例如修改当前的时间为23点26分00秒,在root权限下执行如下命令: @@ -385,7 +382,7 @@ date --set HH:MM:SS --utc 修改当前的日期,添加\-\-set或者-s参数。在root权限下执行如下命令,其中 _YYYY_ 代表年份,_MM_ 代表月份,_DD_ 代表某天,请根据实际情况修改: ``` -date --set YYYY-MM-DD +# date --set YYYY-MM-DD ``` 例如修改当前的日期为2019年11月2日,命令如下: @@ -412,7 +409,7 @@ Linux 将时钟分为: 显示当前硬件的日期和时间,在root权限下执行如下命令: ``` -hwclock +# hwclock ``` 例如显示当前硬件的日期和时间,命令和输出如下: @@ -427,7 +424,7 @@ hwclock 修改当前硬件的日期和时间,在root权限下执行如下命令,其中 _dd_ 表示日,_mm_ 表示月份,_yyyy_ 表示年份,_HH_ 表示小时,_MM_ 表示分钟,请根据实际情况修改: ``` -hwclock --set --date "dd mm yyyy HH:MM" +# hwclock --set --date "dd mm yyyy HH:MM" ``` 例如修改当前的时间为2019年10月21日21点17分,命令如下: diff --git "a/content/zh/docs/Administration/\346\220\255\345\273\272FTP\346\234\215\345\212\241\345\231\250.md" "b/content/zh/docs/Administration/\346\220\255\345\273\272FTP\346\234\215\345\212\241\345\231\250.md" index 37cf5cba28bbc7e160fc0be688f2fe4a2b44c100..f77d385e17dec27ef5d1fccce199932bca11d848 100644 --- "a/content/zh/docs/Administration/\346\220\255\345\273\272FTP\346\234\215\345\212\241\345\231\250.md" +++ "b/content/zh/docs/Administration/\346\220\255\345\273\272FTP\346\234\215\345\212\241\345\231\250.md" @@ -79,7 +79,7 @@ FTP的正常工作需要使用到多个网络端口,服务器端会使用到 启动、停止和重启vsftpd服务,请在root权限下执行对应命令。 -- 启动vsftpd服务 +- 启动vsftpd服务 ``` # systemctl start vsftpd @@ -93,11 +93,8 @@ FTP的正常工作需要使用到多个网络端口,服务器端会使用到 ``` >![](public_sys-resources/icon-note.gif) **说明:** - >如果没有netstat命令,可以执行如下命令安装后再使用netstat: - >``` - >dnf install net-tools - >``` - + >如果没有**netstat**命令,可以执行**dnf install net-tools**命令安装后再使用**netstat**命令。 + - 停止vsftpd服务 ``` @@ -149,7 +146,7 @@ FTP的正常工作需要使用到多个网络端口,服务器端会使用到

禁止或允许登录vsftpd服务器的用户列表文件。该文件是否生效,取决于主配置文件vsftpd.conf中的如下参数:

userlist_enable:是否启用userlist机制,YES为启用,此时userlist_deny配置有效,NO为禁用。

userlist_deny:是否禁止user_list中的用户登录,YES为禁止名单中的用户登录,NO为允许命令中的用户登录。

-

例如userlist_enable=YES,userlist_deny=NO,则user_list中的用户都无法登录。

+

例如userlist_enable=YES,userlist_deny=YES,则user_list中的用户都无法登录。

/etc/vsftpd/chroot_list

@@ -173,6 +170,7 @@ FTP的正常工作需要使用到多个网络端口,服务器端会使用到 + ### 默认配置说明 >![](public_sys-resources/icon-note.gif) **说明:** @@ -181,7 +179,7 @@ FTP的正常工作需要使用到多个网络端口,服务器端会使用到 openEuler系统中 ,vsftpd默认不开放匿名用户,使用vim命令查看主配置文件,其内容如下: ``` -# vim /etc/vsftpd/vsftpd.conf +$ vim /etc/vsftpd/vsftpd.conf anonymous_enable=NO local_enable=YES write_enable=YES @@ -283,7 +281,7 @@ openEuler系统中,vsftpd默认使用GMT时间(格林尼治时间),可 #### 设置方法 -设置vsftpd时间为本地时间的操作步骤如下: +在root权限下设置vsftpd时间为本地时间的操作步骤如下: 1. 打开配置文件vsftpd.conf,将参数use\_localtime的参数值改为YES。命令如下: @@ -312,7 +310,7 @@ openEuler系统中,vsftpd默认使用GMT时间(格林尼治时间),可 ### 配置欢迎信息 -正常使用vsftpd服务,需要存在欢迎信息文件。设置vsftp的欢迎信息welcome.txt文件的操作步骤如下: +正常使用vsftpd服务,需要存在欢迎信息文件。在root权限下设置vsftp的欢迎信息welcome.txt文件的操作步骤如下: 1. 打开配置文件vsftpd.conf,加入欢迎信息文件配置内容后保存退出。 @@ -350,12 +348,12 @@ openEuler系统中,vsftpd默认使用GMT时间(格林尼治时间),可 两个文件的必须同时存在且内容相同,请参考/etc/passwd文件,将UID小于500的帐号写入这两个文件,每一行代表一个帐号。 -如果用户需要限制系统帐号登录,需要将对应帐号添加到/etc/vsftpd/ftpusers和/etc/vsftpd/user\_list。 +如果用户需要限制系统帐号登录,需要在root权限下将对应帐号添加到/etc/vsftpd/ftpusers和/etc/vsftpd/user\_list。 打开user\_list可以查看当前文件中包含的帐号信息,命令和回显如下: ``` -# vim /etc/vsftpd/user_list +$ vim /etc/vsftpd/user_list root bin daemon @@ -377,8 +375,7 @@ nobody 可以使用openEuler提供的FTP客户端进行验证。命令和回显如下,根据提示输入用户名(用户为系统中存在的用户)和密码。如果显示Login successful,即说明FTP服务器搭建成功。 ``` -# dnf install ftp -# ftp localhost +$ ftp localhost Trying 127.0.0.1... Connected to localhost (127.0.0.1). 220-Welcome to this FTP server! @@ -393,9 +390,14 @@ ftp> bye 221 Goodbye. ``` +>![](public_sys-resources/icon-note.gif) **说明:** +>如果没有**ftp**命令,可以在root权限下执行**dnf install ftp**命令安装后再使用**ftp**命令。 + + + ## 配置防火墙 -如果要将FTP开放给Internet使用,需要对防火墙和SElinux进行设置。 +如果要将FTP开放给Internet使用,需要在root权限下对防火墙和SElinux进行设置。 ``` # firewall-cmd --add-service=ftp --permanent @@ -424,7 +426,7 @@ success 在openEuler系统的命令行终端,执行如下命令: ``` -ftp ip-address +$ ftp ip-address ``` 根据提示输入用户名和密码,认证通过后显示如下,说明ftp连接成功,此时进入了连接到的服务器目录。 @@ -435,7 +437,7 @@ ftp> 在该提示符下,可以输入不同的命令进行相关操作: -- 显示服务器当前地址 +- 显示服务器当前路径 ``` ftp>pwd @@ -465,10 +467,10 @@ ftp> 其中 _remote-file_ 为远程文件,_local-file_ 为本地文件 -- 示例:获取远程服务器上的/usr/your/openEuler.htm文件,命令如下: +- 示例:获取远程服务器上的/home/openEuler/openEuler.htm文件到本地/home/myopenEuler/,并改名为myopenEuler.htm,命令如下: ``` - ftp> get /usr/your/openEuler.htm + ftp> get /home/openEuler/openEuler.htm /home/myopenEuler/myopenEuler.htm ``` @@ -479,16 +481,16 @@ ftp> 其中 _remote-file_ 为远程文件 -- 示例:获取服务器上/usr/your/目录下的所有文件,命令如下: +- 示例:获取服务器上/home/openEuler/目录下的所有文件,命令如下: ``` - ftp> cd /usr/your/ + ftp> cd /home/openEuler/ ftp> mget *.* ``` >![](public_sys-resources/icon-note.gif) **说明:** >- 此时每下载一个文件,都会有提示信息。如果要屏蔽提示信息,则在 **mget \*.\*** 命令前先执行**prompt off** - >- 文件都被下载到Linux主机的当前目录下。比如,在/usr/my/下运行的ftp命令,则文件都下载到/usr/my/下。 + >- 文件都被下载到Linux主机的当前目录下。比如,在/home/myopenEuler/下运行的ftp命令,则文件都下载到/home/myopenEuler/下。 ### 上传文件 @@ -502,10 +504,10 @@ ftp> 其中 _remote-file_ 为远程文件,_local-file_ 为本地文件 -- 示例:将本地的Euler.htm传送到远端主机/usr/your/,并改名为openEuler.htm,命令如下: +- 示例:将本地的myopenEuler.htm传送到远端主机/home/openEuler/,并改名为openEuler.htm,命令如下: ``` - ftp> put Euler.htm /usr/your/openEuler.htm + ftp> put myopenEuler.htm /home/openEuler/openEuler.htm ``` @@ -516,10 +518,10 @@ ftp> 其中 _local-file_ 为本地文件 -- 示例:将本地当前目录下所有htm文件上传到服务器/usr/your/下,命令如下: +- 示例:将本地当前目录下所有htm文件上传到服务器/home/openEuler/下,命令如下: ``` - ftp> cd /usr/your + ftp> cd /home/openEuler/ ftp> mput *.htm ``` @@ -535,13 +537,13 @@ ftp> 其中 _remote-file_ 为远程文件 -- 示例:删除远程服务器上的openFile文件,命令如下: +- 示例:删除远程服务器上/home/openEuler/下的openEuler.htm文件,命令如下: ``` - ftp> delete openFile + ftp> cd /home/openEuler/ + ftp> delete openEuler.htm ``` - **mdelete使用方法** - 功能说明:删除远程服务器上的文件,常用于批量删除 @@ -549,9 +551,10 @@ ftp> 其中 _remote-file_ 为远程文件 -- 示例:删除所有a开头的文件,命令如下: +- 示例:删除远程服务器上/home/openEuler/下所有a开头的文件,命令如下: ``` + ftp> cd /home/openEuler/ ftp> mdelete a* ``` diff --git "a/content/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" "b/content/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" index 519808a7b5a0c170106a0553c7a122f301dcbb37..a5ef37f72296755122a16d3d0103e4c230f9899c 100644 --- "a/content/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" +++ "b/content/zh/docs/Administration/\346\220\255\345\273\272repo\346\234\215\345\212\241\345\231\250.md" @@ -37,12 +37,12 @@ ### 挂载ISO创建repo源 -使用mount命令挂载镜像文件。 +在root权限下使用mount命令挂载镜像文件。 示例如下: ``` -mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ +# mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ ``` 挂载好的mnt目录如下: @@ -66,11 +66,11 @@ mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ 可以拷贝镜像中相关文件至本地目录以创建本地repo源,示例如下: ``` -mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ -mkdir -p /srv/repo/ -cp -r /mnt/Packages /srv/repo/ -cp -r /mnt/repodata /srv/repo/ -cp -r /mnt/RPM-GPG-KEY-openEuler /srv/repo/ +# mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ +$ mkdir -p ~/srv/repo/ +$ cp -r /mnt/Packages ~/srv/repo/ +$ cp -r /mnt/repodata ~/srv/repo/ +$ cp -r /mnt/RPM-GPG-KEY-openEuler ~/srv/repo/ ``` 从而本地repo目录如下: @@ -88,15 +88,18 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, 更新repo源有两种方式: -- 通过新版本的ISO更新已有的repo源,与创建repo源的方式相同,即挂载镜像或者重新拷贝镜像至本地目录 +- 通过新版本的ISO更新已有的repo源,与创建repo源的方式相同,即挂载镜像或者重新拷贝镜像至本地目录 + - 在repo源的Packages目录下添加rpm包,然后更新repo源,可通过createrepo命令更新repo源 ``` - dnf install createrepo - createrepo --update --workers=10 /srv/repo + $ createrepo --update --workers=10 ~/srv/repo ``` 其中,\-\-update表示更新,\-\-workers表示线程数,可自定义。 + + >![](public_sys-resources/icon-note.gif) **说明:** + >若命令打印信息为“createrepo:未找到命令”,则表示未安装createrepo软件,可在root权限下执行**dnf install createrepo**进行安装。 ## 部署远端repo源 @@ -104,14 +107,14 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, 安装openEuler操作系统,在openEuler上通过nginx部署repo源。 ### nginx安装与配置 -1. 请自行下载nginx工具并安装nginx。 -2. 安装nginx之后,配置/etc/nginx/nginx.conf。 +1. 请自行下载nginx工具并在root权限下安装nginx。 +2. 安装nginx之后,在root权限下配置/etc/nginx/nginx.conf。 >![](public_sys-resources/icon-note.gif) **说明:** >文档中的配置内容仅供参考,请用户根据实际情况(例如安全加固需要)进行配置。 ``` - user root; + user nginx; worker_processes auto; # 建议设置为core-1 error_log /var/log/nginx/error.log warn; # log存放位置 pid /var/run/nginx.pid; @@ -136,7 +139,7 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, listen 80; server_name localhost; # 服务器名(url) client_max_body_size 4G; - root /srv/repo; # 服务默认目录 + root /usr/share/nginx/repo; # 服务默认目录 location / { autoindex on; # 开启访问目录下层文件 @@ -152,78 +155,75 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, ### 启动nginx服务 -1. 通过systemd启动nginx服务: +1. 在root权限下通过systemd启动nginx服务: ``` - systemctl enable nginx - systemctl start nginx + # systemctl enable nginx + # systemctl start nginx ``` 2. nginx是否启动成功可通过下面命令查看: ``` - systemctl status nginx + $ systemctl status nginx ``` - - [图1](#zh-cn_topic_0151920971_fd25e3f1d664b4087ae26631719990a71)表示nginx服务启动成功 + - [图1](#zh-cn_topic_0151920971_fd25e3f1d664b4087ae26631719990a71)表示nginx服务启动成功 - **图 1** nginx服务启动成功 - ![](figures/nginx服务启动成功.png "nginx服务启动成功") + **图 1** nginx服务启动成功 + ![](figures/nginx服务启动成功.png "nginx服务启动成功") - - 若nginx服务启动失败,查看错误信息: + - 若nginx服务启动失败,查看错误信息: ``` - systemctl status nginx.service --full + $ systemctl status nginx.service --full ``` - **图 2** nginx服务启动失败 - ![](figures/nginx服务启动失败.png "nginx服务启动失败") + **图 2** nginx服务启动失败 + ![](figures/nginx服务启动失败.png "nginx服务启动失败") - 如[图2](#zh-cn_topic_0151920971_f1f9f3d086e454b9cba29a7cae96a4c54)所示nginx服务创建失败,是由于目录/var/spool/nginx/tmp/client\_body创建失败,手动进行创建,类似的问题也这样处理: + 如[图2](#zh-cn_topic_0151920971_f1f9f3d086e454b9cba29a7cae96a4c54)所示nginx服务创建失败,是由于目录/var/spool/nginx/tmp/client\_body创建失败,在root权限下手动进行创建,类似的问题也这样处理: ``` - mkdir -p /var/spool/nginx/tmp/client_body - mkdir -p /var/spool/nginx/tmp/proxy - mkdir -p /var/spool/nginx/tmp/fastcgi - mkdir -p /usr/share/nginx/uwsgi_temp - mkdir -p /usr/share/nginx/scgi_temp + # mkdir -p /var/spool/nginx/tmp/client_body + # mkdir -p /var/spool/nginx/tmp/proxy + # mkdir -p /var/spool/nginx/tmp/fastcgi + # mkdir -p /usr/share/nginx/uwsgi_temp + # mkdir -p /usr/share/nginx/scgi_temp ``` ### repo源部署 -1. 创建nginx配置文件/etc/nginx/nginx.conf中指定的目录/srv/repo: +1. 在root权限下创建nginx配置文件/etc/nginx/nginx.conf中指定的目录/usr/share/nginx/repo: ``` - mkdir -p /srv/repo + # mkdir -p /usr/share/nginx/repo ``` -2. SELinux设置为宽容模式: +2. 在root权限下修改目录/usr/share/nginx/repo的权限: ``` - setenforce permissive + # chmod -R 755 /usr/share/nginx/repo ``` - >![](public_sys-resources/icon-note.gif) **说明:** - >repo server重启后,需要重新设置。 - -3. 设置防火墙规则,开启nginx设置的端口(此处为80端口),通过firewall设置端口开启: +3. 设置防火墙规则,开启nginx设置的端口(此处为80端口),在root权限下通过firewall设置端口开启: ``` - firewall-cmd --add-port=80/tcp --permanent - firewall-cmd --reload + # firewall-cmd --add-port=80/tcp --permanent + # firewall-cmd --reload ``` - 查询80端口是否开启成功,输出为yes则表示80端口开启成功: + 在root权限下查询80端口是否开启成功,输出为yes则表示80端口开启成功: ``` - firewall-cmd --query-port=80/tcp + # firewall-cmd --query-port=80/tcp ``` - 也可通过iptables来设置80端口开启: + 也可在root权限下通过iptables来设置80端口开启: ``` - iptables -I INPUT -p tcp --dport 80 -j ACCEPT + # iptables -I INPUT -p tcp --dport 80 -j ACCEPT ``` 4. nginx服务设置好之后,即可通过ip直接访问网页,如[图3](#zh-cn_topic_0151921017_fig1880404110396): @@ -231,25 +231,26 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, **图 3** nginx部署成功 ![](figures/nginx部署成功.png "nginx部署成功") -5. 通过下面几种方式将repo源放入到/srv/repo下: - - 拷贝镜像中相关文件至在/srv/repo下 +5. 通过下面几种方式将repo源放入到/usr/share/nginx/repo下: + - 在root权限下拷贝镜像中相关文件至/usr/share/nginx/repo下,并修改目录权限。 ``` - mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ - cp -r /mnt/Packages /srv/repo/ - cp -r /mnt/repodata /srv/repo/ - cp -r /mnt/RPM-GPG-KEY-openEuler /srv/repo/ + # mount /home/openEuler/openEuler-20.03-LTS-aarch64-dvd.iso /mnt/ + # cp -r /mnt/Packages /usr/share/nginx/repo + # cp -r /mnt/repodata /usr/share/nginx/repo + # cp -r /mnt/RPM-GPG-KEY-openEuler /usr/share/nginx/repo + # chmod -R 755 /usr/share/nginx/repo ``` - + openEuler-20.03-LTS-aarch64-dvd.iso存放在/home/openEuler目录下。 - - - 在/srv/repo下创建repo源的软链接 - + + - 使用root在/usr/share/nginx/repo下创建repo源的软链接。 + ``` - ln -s /home/openEuler/os /srv/repo/os + # ln -s /mnt /usr/share/nginx/repo/os ``` - - /home/openEuler/os为已经创建好的repo源,/srv/repo/os将指向/home/openEuler/os。 + + /mnt为已经创建好的repo源,/usr/share/nginx/repo/os将指向/mnt。 @@ -258,7 +259,7 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, repo可配置为yum源,yum(全称为 Yellow dog Updater, Modified)是一个Shell前端软件包管理器。基于RPM包管理,能够从指定的服务器自动下载RPM包并且安装,可以自动处理依赖性关系,并且一次安装所有依赖的软体包,无须繁琐地一次次下载和安装。 ### repo配置为yum源 -构建好的repo可以配置为yum源使用,在/etc/yum.repos.d/目录下创建\*\*\*.repo的配置文件(必须以.repo为扩展名),分为本地和http服务器配置yum源两种方式: +构建好的repo可以配置为yum源使用,在/etc/yum.repos.d/目录下使用root权限创建\*\*\*.repo的配置文件(必须以.repo为扩展名),分为本地和http服务器配置yum源两种方式: - 配置本地yum源 @@ -267,15 +268,15 @@ repo可配置为yum源,yum(全称为 Yellow dog Updater, Modified)是一 ``` [base] name=base - baseurl=file:///srv/repo + baseurl=file:///home/openEuler/srv/repo enabled=1 gpgcheck=1 - gpgkey=file:///srv/repo/RPM-GPG-KEY-openEuler + gpgkey=file:///home/openEuler/srv/repo/RPM-GPG-KEY-openEuler ``` >![](public_sys-resources/icon-note.gif) **说明:** >gpgcheck可设置为1或0,1表示进行gpg(GNU Private Guard)校验,0表示不进行gpg校验,gpgcheck可以确定rpm包的来源是有效和安全的。 - >gpgkey为签名公钥的存放路径。 + >gpgkey为验证签名用的公钥。 - 配置http服务器yum源 @@ -284,14 +285,14 @@ repo可配置为yum源,yum(全称为 Yellow dog Updater, Modified)是一 ``` [base] name=base - baseurl=http://192.168.1.2/ + baseurl=http://192.168.139.209/ enabled=1 gpgcheck=1 - gpgkey=http://192.168.1.2/RPM-GPG-KEY-openEuler + gpgkey=http://192.168.139.209/RPM-GPG-KEY-openEuler ``` >![](public_sys-resources/icon-note.gif) **说明:** - >“192.168.1.2”为示例地址,请用户根据实际情况进行配置。 + >“192.168.139.209”为示例地址,请用户根据实际情况进行配置。 ### repo优先级 @@ -301,11 +302,11 @@ repo可配置为yum源,yum(全称为 Yellow dog Updater, Modified)是一 ``` [base] name=base -baseurl=http://192.168.1.2/ +baseurl=http://192.168.139.209/ enabled=1 priority=2 gpgcheck=1 -gpgkey=http://192.168.1.2/RPM-GPG-KEY-openEuler +gpgkey=http://192.168.139.209/RPM-GPG-KEY-openEuler ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -322,63 +323,63 @@ dnf 常用的命令如下: -- 安装 +- 安装,需要在root权限下执行。 ``` - dnf install + # dnf install ``` -- 升级 +- 升级,需要在root权限下执行。 ``` - dnf update + # dnf update ``` -- 回退 +- 回退,需要在root权限下执行。 ``` - dnf downgrade + # dnf downgrade ``` - 检查更新 ``` - dnf check-update + $ dnf check-update ``` -- 卸载 +- 卸载,需要在root权限下执行。 ``` - dnf remove + # dnf remove ``` - 查询 ``` - dnf search + $ dnf search ``` -- 本地安装 +- 本地安装,需要在root权限下执行。 ``` - dnf localinstall + # dnf localinstall ``` - 查看历史记录 ``` - dnf history + $ dnf history ``` - 清除缓存目录 ``` - dnf clean all + $ dnf clean all ``` - 更新缓存 ``` - dnf makecache + $ dnf makecache ``` diff --git "a/content/zh/docs/Administration/\346\220\255\345\273\272web\346\234\215\345\212\241\345\231\250.md" "b/content/zh/docs/Administration/\346\220\255\345\273\272web\346\234\215\345\212\241\345\231\250.md" index e0b2fe7937d57a8033ae4d67b223f3af1b60991c..b0878f072c7e5585f45877ba0756ea253b75a119 100644 --- "a/content/zh/docs/Administration/\346\220\255\345\273\272web\346\234\215\345\212\241\345\231\250.md" +++ "b/content/zh/docs/Administration/\346\220\255\345\273\272web\346\234\215\345\212\241\345\231\250.md" @@ -33,7 +33,7 @@ openEuler系统中的web服务器版本是Apache HTTP服务器2.4版本,即htt #### 前提条件 -- 为了能够使用Apache HTTP服务,请确保您的系统中已经安装httpd服务的rpm包。安装命令如下: +- 为了能够使用Apache HTTP服务,请确保您的系统中已经安装httpd服务的rpm包。在root权限下执行如下命令进行安装: ``` # dnf install httpd @@ -113,7 +113,7 @@ openEuler系统中的web服务器版本是Apache HTTP服务器2.4版本,即htt 验证httpd服务是否正在运行 ``` -# systemctl is-active httpd +$ systemctl is-active httpd ``` 回显为“active”说明服务处于运行状态。 @@ -145,7 +145,7 @@ openEuler系统中的web服务器版本是Apache HTTP服务器2.4版本,即htt -虽然默认配置可以适用于多数情况,但是用户至少需要熟悉里面的一些重要配置项。配置文件修改完成后,可以使用如下命令检查配置文件可能出现的语法错误。 +虽然默认配置可以适用于多数情况,但是用户至少需要熟悉里面的一些重要配置项。配置文件修改完成后,可以在root权限下使用如下命令检查配置文件可能出现的语法错误。 ``` # apachectl configtest @@ -173,19 +173,19 @@ httpd服务是一个模块化的应用,它和许多动态共享对象DSO(Dyn 例如,加载asis DSO模块的操作步骤如下: -1. 在/etc/httpd/conf.modules.d/00-optional.conf文件中,取消注释如下配置行。 +1. 在/etc/httpd/conf.modules.d/00-optional.conf文件中,使用root权限取消注释如下配置行。 ``` LoadModule asis_module modules/mod_asis.so ``` -2. 加载完成后,请重启httpd服务以便于重新加载配置文件。 +2. 加载完成后,请使用root权限重启httpd服务以便于重新加载配置文件。 ``` # systemctl restart httpd ``` -3. 加载完成后,使用httpd -M的命令查看是否已经加载了asis DSO模块。 +3. 加载完成后,在root权限下使用httpd -M的命令查看是否已经加载了asis DSO模块。 ``` # httpd -M | grep asis @@ -200,6 +200,7 @@ httpd服务是一个模块化的应用,它和许多动态共享对象DSO(Dyn >![](public_sys-resources/icon-note.gif) **说明:** >**httpd 的常用命令** +> >- httpd -v : 查看httpd的版本号。 >- httpd -l:查看编译进httpd程序的静态模块。 >- httpd -M:查看已经编译进httpd程序的静态模块和已经加载的动态模块。 @@ -208,19 +209,19 @@ httpd服务是一个模块化的应用,它和许多动态共享对象DSO(Dyn 安全套接层SSL(Secure Sockets Layer)是一个允许服务端和客户端之间进行安全通信的加密协议。其中,传输层安全性协议TLS(Transport Layer Security)为网络通信提供了安全性和数据完整性保障。openEuler支持Mozilla NSS(Network Security Services)作为安全性协议TLS进行配置。加载SSL的操作步骤如下: -1. 安装mod\_ssl的rpm包。 +1. 在root权限下安装mod\_ssl的rpm包。 ``` # dnf install mod_ssl ``` -2. 安装完成后,请重启httpd服务以便于重新加载配置文件。 +2. 安装完成后,请在root权限下重启httpd服务以便于重新加载配置文件。 ``` # systemctl restart httpd ``` -3. 加载完成后,使用httpd -M的命令查看是否已经加载了SSL。 +3. 加载完成后,在root权限下使用httpd -M的命令查看是否已经加载了SSL。 ``` # httpd -M | grep ssl @@ -237,7 +238,7 @@ httpd服务是一个模块化的应用,它和许多动态共享对象DSO(Dyn Web服务器搭建完成后,可以通过如下方式验证是否搭建成功。 -1. 查看服务器的IP地址,命令如下: +1. 在root权限下查看服务器的IP地址,命令如下: ``` # ifconfig @@ -272,7 +273,7 @@ Web服务器搭建完成后,可以通过如下方式验证是否搭建成功 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` -2. 配置防火墙: +2. 在root权限下配置防火墙: ``` # firewall-cmd --add-service=http --permanent @@ -287,24 +288,24 @@ Web服务器搭建完成后,可以通过如下方式验证是否搭建成功 执行如下命令,查看是否可以访问网页信息,服务搭建成功时,该网页可以正常访问。 ``` - curl https://192.168.1.60 + $ curl http://192.168.1.60 ``` 执行如下命令,查看命令返回值是否为0,返回值为0,说明httpd服务器搭建成功。 ``` - echo $? + $ echo $? ``` - 使用Windows系统验证 打开浏览器,在地址栏输入如下地址,如果能正常访问网页,说明httpd服务器搭建成功。 - https://_192.168.1.60_ + http://192.168.1.60 如果修改了端口号,输入地址格式如下: - https://_192.168.1.60:端口号_ + http://192.168.1.60:端口号 @@ -319,25 +320,25 @@ Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件 2. 清除缓存。 ``` - #dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - #dnf makecache + $ dnf makecache ``` -4. 安装nginx服务。 +4. 在root权限下安装nginx服务。 ``` - #dnf install nginx + # dnf install nginx ``` 5. 查看安装后的rpm包。 ``` - dnf list all | grep nginx + $ dnf list all | grep nginx ``` @@ -353,7 +354,7 @@ Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件 更多关于管理服务的内容,请参见[管理服务](管理服务.html)。 -- 启动、停止和重启httpd服务,需要使用root权限。 +- 启动、停止和重启nginx服务,需要使用root权限。 #### 启动服务 @@ -377,7 +378,7 @@ Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件 #### 停止服务 -- 停止运行的httpd服务,命令如下: +- 停止运行的nginx服务,命令如下: ``` # systemctl stop nginx @@ -406,7 +407,7 @@ Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件 - 重新加载配置 ``` - # systemctl reload httpd + # systemctl reload nginx ``` 该命令会使运行的nginx服务重新加载它的配置文件。任何当前正在处理的请求将会被中断,从而造成客户端浏览器显示一个错误消息或者重新渲染部分页面。 @@ -422,10 +423,10 @@ Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件 #### 验证服务状态 -验证httpd服务是否正在运行 +验证nginx服务是否正在运行 ``` -# systemctl is-active nginx +$ systemctl is-active nginx ``` 回显为“active”说明服务处于运行状态。 @@ -457,10 +458,10 @@ Nginx 是一款轻量级的 Web 服务器/反向代理服务器及电子邮件 -虽然默认配置可以适用于多数情况,但是用户至少需要熟悉里面的一些重要配置项。配置文件修改完成后,可以使用如下命令检查配置文件可能出现的语法错误。 +虽然默认配置可以适用于多数情况,但是用户至少需要熟悉里面的一些重要配置项。配置文件修改完成后,可以在root权限下使用如下命令检查配置文件可能出现的语法错误。 ``` -# /usr/sbin/nginx -t +# nginx -t ``` 如果回显信息中有“syntax is ok”,说明配置文件语法正确。 @@ -485,7 +486,7 @@ nginx服务是一个模块化的应用,它和许多动态共享对象DSO(Dyn Web服务器搭建完成后,可以通过如下方式验证是否搭建成功。 -1. 查看服务器的IP地址,命令如下: +1. 在root权限下查看服务器的IP地址,命令如下: ``` # ifconfig @@ -520,7 +521,7 @@ Web服务器搭建完成后,可以通过如下方式验证是否搭建成功 TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 ``` -2. 配置防火墙: +2. 在root权限下配置防火墙: ``` # firewall-cmd --add-service=http --permanent @@ -535,23 +536,23 @@ Web服务器搭建完成后,可以通过如下方式验证是否搭建成功 执行如下命令,查看是否可以访问网页信息,服务搭建成功时,该网页可以正常访问。 ``` - curl http://192.168.1.60 + $ curl http://192.168.1.60 ``` 执行如下命令,查看命令返回值是否为0,返回值为0,说明nginx服务器搭建成功。 ``` - echo $? + $ echo $? ``` - 使用Windows系统验证 打开浏览器,在地址栏输入如下地址,如果能正常访问网页,说明nginx服务器搭建成功。 - http://_192.168.1.60_ + http://192.168.1.60 如果修改了端口号,输入地址格式如下: - http://_192.168.1.60:端口号_ + http://192.168.1.60:端口号 diff --git "a/content/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" "b/content/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" index fb17745d75c91fd913e0cac89fd0bc3f6eef062f..a6a66a23842316b8a1329110c09784b8b207e0c1 100644 --- "a/content/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" +++ "b/content/zh/docs/Administration/\346\220\255\345\273\272\346\225\260\346\215\256\345\272\223\346\234\215\345\212\241\345\231\250.md" @@ -112,16 +112,16 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 >![](public_sys-resources/icon-note.gif) **说明:** >测试环境下通常会关闭防火墙以避免部分网络因素影响,视实际需求做配置。 -1. 停止防火墙。 +1. 在root权限下停止防火墙。 ``` - #systemctl stop firewalld + # systemctl stop firewalld ``` -2. 关闭防火墙。 +2. 在root权限下关闭防火墙。 ``` - #systemctl disable firewalld + # systemctl disable firewalld ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -130,10 +130,10 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 #### 修改SELINUX为disabled -1. 修改配置文件。 +1. 在root权限下修改配置文件。 ``` - #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` @@ -142,20 +142,20 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 >![](public_sys-resources/icon-note.gif) **说明:** >服务器环境下,为了系统安全,通常会为进程分配单独的用户,以实现权限隔离。本章节创建的组和用户都是操作系统层面的,不是数据库层面的。 -1. 创建PostgreSQL用户(组)。 +1. 在root权限下创建PostgreSQL用户(组)。 ``` - #groupadd postgres + # groupadd postgres ``` ``` - #useradd -g postgres postgres + # useradd -g postgres postgres ``` -2. 设置postgres用户密码(重复输入密码)。 +2. 在root权限下设置postgres用户密码(重复输入密码)。 ``` - #passwd postgres + # passwd postgres ``` @@ -163,34 +163,34 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 >![](public_sys-resources/icon-note.gif) **说明:** >- 测试极限性能时,建议单独挂载IO性能更优的NVME SSD存储介质创建PostgreSQL测试实例,避免磁盘IO对性能测试结果的影响,本文以单独挂载NVME SSD为例,参考步骤1\~步骤4。 ->- 非性能测试时,执行以下命令,创建数据目录即可。然后跳过本小节: -> \#mkdir /data +>- 非性能测试时,在root权限下执行以下命令,创建数据目录即可。然后跳过本小节: +> \# mkdir /data -1. 创建文件系统(以xfs为例,根据实际需求创建文件系统),若磁盘之前已做过文件系统,执行此命令会出现报错,可使用-f参数强制创建文件系统。 +1. 在root权限下创建文件系统(以xfs为例,根据实际需求创建文件系统),若磁盘之前已做过文件系统,执行此命令会出现报错,可使用-f参数强制创建文件系统。 ``` - #mkfs.xfs /dev/nvme0n1 + # mkfs.xfs /dev/nvme0n1 ``` -2. 创建数据目录。 +2. 在root权限下创建数据目录。 ``` - #mkdir /data + # mkdir /data ``` -3. 挂载磁盘。 +3. 在root权限下挂载磁盘。 ``` - #mount -o noatime,nobarrier /dev/nvme0n1 /data + # mount -o noatime,nobarrier /dev/nvme0n1 /data ``` #### 数据目录授权 -1. 修改目录权限。 +1. 在root权限下修改目录权限。 ``` - #chown -R postgres:postgres /data/ + # chown -R postgres:postgres /data/ ``` @@ -201,25 +201,25 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 2. 清除缓存。 ``` - #dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - #dnf makecache + $ dnf makecache ``` -4. 安装PostgreSQL服务器。 +4. 在root权限下安装PostgreSQL服务器。 ``` - #dnf install postgresql-server + # dnf install postgresql-server ``` 5. 查看安装后的rpm包。 ``` - #rpm -qa | grep postgresql + $ rpm -qa | grep postgresql ``` @@ -232,13 +232,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 切换到已创建的PostgreSQL用户。 ``` - #su - postgres + # su - postgres ``` 2. 初始化数据库,其中命令中的/usr/bin是命令initdb所在的目录。 ``` - $/usr/bin/initdb -D /data/ + $ /usr/bin/initdb -D /data/ ``` @@ -247,13 +247,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 启动PostgreSQL数据库。 ``` - $/usr/bin/pg_ctl -D /data/ -l /data/logfile start + $ /usr/bin/pg_ctl -D /data/ -l /data/logfile start ``` 2. 确认PostgreSQL数据库进程是否正常启动。 ``` - $ps -ef | grep postgres + $ ps -ef | grep postgres ``` 命令执行后,打印信息如下图所示,PostgreSQL相关进程已经正常启动了。 @@ -266,7 +266,7 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 登录数据库。 ``` - $/usr/bin/psql -U postgres + $ /usr/bin/psql -U postgres ``` ![](figures/登录.png) @@ -300,7 +300,7 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 停止PostgreSQL数据库。 ``` - $/usr/bin/pg_ctl -D /data/ -l /data/logfile stop + $ /usr/bin/pg_ctl -D /data/ -l /data/logfile stop ``` @@ -309,13 +309,13 @@ PostgreSQL的架构如[图1](#fig26022387391)所示,主要进程说明如[表1 1. 在postgres用户下停止数据库。 ``` - $/usr/bin/pg_ctl -D /data/ -l /data/logfile stop + $ /usr/bin/pg_ctl -D /data/ -l /data/logfile stop ``` 2. 在root用户下执行**dnf remove postgresql-server**卸载PostgreSQL数据库。 ``` - #dnf remove postgresql-server + # dnf remove postgresql-server ``` @@ -417,7 +417,7 @@ ALTER ROLE oldrolername RENAME TO newrolename; \#将角色名roleexample1修改为roleexapme2。 ``` -# ALTER ROLE roleexample1 RENAME TO roleexample2; +postgres=# ALTER ROLE roleexample1 RENAME TO roleexample2; ``` ##### 修改用户密码 @@ -438,7 +438,7 @@ ALTER ROLE rolename PASSWORD 'password' \#将roleexample1的密码修改为456789。 ``` -# ALTER ROLE roleexample1 WITH PASSWORD '456789'; +postgres=# ALTER ROLE roleexample1 WITH PASSWORD '456789'; ``` #### 删除角色 @@ -544,13 +544,13 @@ GRANT rolename1 [, ...] TO rolename2 [, ...] [ WITH ADMIN OPTION ] \#对userexample授予数据库database1的CREATE权限。 ``` -# GRANT CREATE ON DATABASE database1 TO userexample; +postgres=# GRANT CREATE ON DATABASE database1 TO userexample; ``` \#对所有用户授予表table1的所有权限。 ``` -# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; +postgres=# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; ``` #### 删除用户权限 @@ -630,13 +630,13 @@ REVOKE [ ADMIN OPTION FOR ] rolename1 [, ...] FROM rolename2 [, ...] [ CASCADE | \#对userexample授予数据库database1的CREATE权限。 ``` -# GRANT CREATE ON DATABASE database1 TO userexample; +postgres=# GRANT CREATE ON DATABASE database1 TO userexample; ``` \#对所有用户授予表table1的所有权限。 ``` -# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; +postgres=# GRANT ALL PRIVILEGES ON TABLE table1 TO PUBLIC; ``` ### 管理数据库 @@ -679,7 +679,7 @@ postgres=# CREATE DATABASE database1; \#选择databaseexample数据库。 ``` -# \c databaseexample; +postgres=# \c databaseexample; ``` #### 查看数据库 @@ -695,7 +695,7 @@ postgres=# CREATE DATABASE database1; \#查看所有数据库。 ``` -# \l; +postgres=# \l; ``` #### 删除数据库 @@ -724,7 +724,7 @@ DROP DATABASE只能由超级管理员或数据库拥有者执行。 \#删除databaseexample数据库。 ``` -# DROP DATABASE databaseexample; +postgres=# DROP DATABASE databaseexample; ``` #### 备份数据库 @@ -753,7 +753,7 @@ pg_dump [option]... [databasename] > outfile \#备份主机为192.168.202.144,端口为3306,postgres用户下的database1数据库到db1.sql中。 ``` -$ pg_dump -h 192.168.202.144 -p 3306 -U postgres -W database1 > db1.sql +[postgres@localhost ~]$ pg_dump -h 192.168.202.144 -p 3306 -U postgres -W database1 > db1.sql ``` #### 恢复数据库 @@ -785,8 +785,8 @@ psql命令不会自动创建databasename数据库,所以在执行psql恢复数 \#将db1.sql脚本文件导入到主机为192.168.202.144,端口为3306,postgres用户下newdb数据库中。 ``` -$ createdb newdb -$ psql -h 192.168.202.144 -p 3306 -U postgres -W -d newdb < db1.sql +[postgres@localhost ~]$ createdb newdb +[postgres@localhost ~]$ psql -h 192.168.202.144 -p 3306 -U postgres -W -d newdb < db1.sql ``` ## Mariadb服务器 @@ -826,16 +826,16 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 >![](public_sys-resources/icon-note.gif) **说明:** >测试环境下通常会关闭防火墙以避免部分网络因素影响,视实际需求做配置。 -1. 停止防火墙。 +1. 在root权限下停止防火墙。 ``` - #systemctl stop firewalld + # systemctl stop firewalld ``` -2. 关闭防火墙。 +2. 在root权限下关闭防火墙。 ``` - #systemctl disable firewalld + # systemctl disable firewalld ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -844,10 +844,10 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 #### 修改SELINUX为disabled -1. 修改配置文件。 +1. 在root权限下修改配置文件。 ``` - #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` @@ -856,20 +856,20 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 >![](public_sys-resources/icon-note.gif) **说明:** >服务器环境下,为了系统安全,通常会为进程分配单独的用户,以实现权限隔离。本章节创建的组和用户都是操作系统层面的,不是数据库层面的。 -1. 创建MySQL用户(组)。 +1. 在root权限下创建MySQL用户(组)。 ``` - #groupadd mysql + # groupadd mysql ``` ``` - #useradd -g mysql mysql + # useradd -g mysql mysql ``` -2. 设置MySQL用户密码。 +2. 在root权限下设置MySQL用户密码。 ``` - #passwd mysql + # passwd mysql ``` 重复输入密码(根据实际需求设置密码)。 @@ -879,15 +879,15 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 >![](public_sys-resources/icon-note.gif) **说明:** >- 进行性能测试时,数据目录使用单独硬盘,需要对硬盘进行格式化并挂载,参考方法一或者方法二 ->- 非性能测试时,执行以下命令,创建数据目录即可。然后跳过本小节: +>- 非性能测试时,在root权限下执行以下命令,创建数据目录即可。然后跳过本小节: > \#mkdir /data -##### 方法一:使用fdisk进行磁盘管理 +##### 方法一:在root权限下使用fdisk进行磁盘管理 1. 创建分区(以/dev/sdb为例,根据实际情况创建) ``` - #fdisk /dev/sdb + # fdisk /dev/sdb ``` 2. 输入n,按回车确认。 @@ -899,17 +899,17 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 8. 创建文件系统(以xfs为例,根据实际需求创建文件系统) ``` - #mkfs.xfs /dev/sdb1 + # mkfs.xfs /dev/sdb1 ``` 9. 挂载分区到“/data”以供操作系统使用。 ``` - #mkdir /data + # mkdir /data ``` ``` - #mount /dev/sdb1 /data + # mount /dev/sdb1 /data ``` 10. 执行命令“vi /etc/fstab", 编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -919,46 +919,47 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 ![](figures/搭建数据盘.png) -##### 方法二:使用LVM进行磁盘管理 +##### 方法二:在root权限下使用LVM进行磁盘管理 >![](public_sys-resources/icon-note.gif) **说明:** >此步骤需要安装镜像中的lvm2相关包,步骤如下: +> >1. 配置本地yum源,详细信息请参考[搭建repo服务器](搭建repo服务器.html)。如果已经执行,则可跳过此步。 ->2. 执行命令安装lvm2。 -> **\#yum install lvm2** +>2. 在root权限下执行命令安装lvm2。 +> **\# yum install lvm2** 1. 创建物理卷(sdb为硬盘名称,具体名字以实际为准)。 ``` - #pvcreate /dev/sdb + # pvcreate /dev/sdb ``` 2. 创建物理卷组(其中datavg为创建的卷组名称,具体名字以实际规划为准)。 ``` - #vgcreate datavg /dev/sdb + # vgcreate datavg /dev/sdb ``` 3. 创建逻辑卷(其中600G为规划的逻辑卷大小,具体大小以实际情况为准;datalv为创建的逻辑卷的名字,具体名称以实际规划为准。\)。 ``` - #lvcreate -L 600G -n datalv datavg + # lvcreate -L 600G -n datalv datavg ``` 4. 创建文件系统。 ``` - #mkfs.xfs /dev/datavg/datalv + # mkfs.xfs /dev/datavg/datalv ``` 5. 创建数据目录并挂载。 ``` - #mkdir /data + # mkdir /data ``` ``` - #mount /dev/datavg/datalv /data + # mount /dev/datavg/datalv /data ``` 6. 执行命令**vi /etc/fstab**,编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -970,13 +971,13 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 #### 创建数据库目录并且授权 -1. 在已创建的数据目录 **/data** 基础上,继续创建进程所需的相关目录并授权MySQL用户(组)。 +1. 在已创建的数据目录 **/data** 基础上,使用root权限继续创建进程所需的相关目录并授权MySQL用户(组)。 ``` - #mkdir -p /data/mariadb - #cd /data/mariadb - #mkdir data tmp run log - #chown -R mysql:mysql /data + # mkdir -p /data/mariadb + # cd /data/mariadb + # mkdir data tmp run log + # chown -R mysql:mysql /data ``` @@ -987,40 +988,40 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 2. 清除缓存。 ``` - #dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - #dnf makecache + $ dnf makecache ``` -4. 安装mariadb服务器。 +4. 在root权限下安装mariadb服务器。 ``` - #dnf install mariadb-server + # dnf install mariadb-server ``` 5. 查看安装后的rpm包。 ``` - #rpm -qa | grep mariadb + $ rpm -qa | grep mariadb ``` #### 运行 -1. 开启mariadb服务器。 +1. 在root权限下开启mariadb服务器。 ``` - #systemctl start mariadb + # systemctl start mariadb ``` -2. 初始化数据库。 +2. 在root权限下初始化数据库。 ``` - #/usr/bin/mysql_secure_installation + # /usr/bin/mysql_secure_installation ``` 命令执行过程中需要输入数据库的root设置的密码,若没有密码则直接按“Enter”。然后根据提示及实际情况进行设置。 @@ -1028,7 +1029,7 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 3. 登录数据库。 ``` - # mysql -u root -p + $ mysql -u root -p ``` 命令执行后提示输入密码。密码为[2](#li197143190587)中设置的密码。 @@ -1039,17 +1040,17 @@ MariaDB的架构如[图2](#fig13492418164520)所示。 #### 卸载 -1. 关闭数据库进程。 +1. 在root权限下关闭数据库进程。 ``` - #ps -ef | grep mysql - #kill -9 进程ID + $ ps -ef | grep mysql + # kill -9 进程ID ``` -2. 执行**dnf remove mariadb-server**命令卸载mariadb。 +2. 在root权限下执行**dnf remove mariadb-server**命令卸载mariadb。 ``` - #dnf remove mariadb-server + # dnf remove mariadb-server ``` @@ -1085,7 +1086,7 @@ CREATE USER 'username'@'hostname' IDENTIFIED BY 'password'; \#创建密码为123456,用户名为userexample2,主机名为192.168.1.100的用户。 ``` -> CREATE USER 'userexample2'@'192.168.1.100' IDENDIFIED BY '123456'; +> CREATE USER 'userexample2'@'192.168.1.100' IDENTIFIED BY '123456'; ``` #### 查看用户 @@ -1344,7 +1345,7 @@ DROP SCHEMA是DROP DATABASE的同义词。 #### 备份数据库 -可以使用mysqldump命令备份数据库。 +可以在root权限下使用mysqldump命令备份数据库。 备份一个或多个表: @@ -1408,12 +1409,12 @@ mysqldump [options] -all-databases > outputfile \#只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的数据到db1.sql中。 ``` -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sq +# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql ``` #### 恢复数据库 -可以使用mysqldump命令恢复数据库。 +可以在root权限下使用mysql命令恢复数据库。 备份一个或多个表: @@ -1456,16 +1457,16 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](public_sys-resources/icon-note.gif) **说明:** >测试环境下通常会关闭防火墙以避免部分网络因素影响,视实际需求做配置。 -1. 停止防火墙。 +1. 在root权限下停止防火墙。 ``` - #systemctl stop firewalld + # systemctl stop firewalld ``` -2. 关闭防火墙。 +2. 在root权限下关闭防火墙。 ``` - #systemctl disable firewalld + # systemctl disable firewalld ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -1474,10 +1475,10 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 #### 修改SELINUX为disabled -1. 修改配置文件。 +1. 在root权限下修改配置文件。 ``` - #sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux + # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux ``` @@ -1486,20 +1487,20 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](public_sys-resources/icon-note.gif) **说明:** >服务器环境下,为了系统安全,通常会为进程分配单独的用户,以实现权限隔离。本章节创建的组和用户都是操作系统层面的,不是数据库层面的。 -1. 创建MySQL用户(组)。 +1. 在root权限下创建MySQL用户(组)。 ``` - #groupadd mysql + # groupadd mysql ``` ``` - #useradd -g mysql mysql + # useradd -g mysql mysql ``` -2. 设置MySQL用户密码。 +2. 在root权限下设置MySQL用户密码。 ``` - #passwd mysql + # passwd mysql ``` 重复输入密码(根据实际需求设置密码)。 @@ -1509,15 +1510,15 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](public_sys-resources/icon-note.gif) **说明:** >- 进行性能测试时,数据目录使用单独硬盘,需要对硬盘进行格式化并挂载,参考方法一或者方法二 ->- 非性能测试时,执行以下命令,创建数据目录即可。然后跳过本小节: -> \#mkdir /data +>- 非性能测试时,在root权限下执行以下命令,创建数据目录即可。然后跳过本小节: +> \# mkdir /data -##### 方法一:使用fdisk进行磁盘管理 +##### 方法一:在root权限下使用fdisk进行磁盘管理 1. 创建分区(以/dev/sdb为例,根据实际情况创建) ``` - #fdisk /dev/sdb + # fdisk /dev/sdb ``` 2. 输入n,按回车确认。 @@ -1529,17 +1530,17 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 8. 创建文件系统(以xfs为例,根据实际需求创建文件系统) ``` - #mkfs.xfs /dev/sdb1 + # mkfs.xfs /dev/sdb1 ``` 9. 挂载分区到“/data”以供操作系统使用。 ``` - #mkdir /data + # mkdir /data ``` ``` - #mount /dev/sdb1 /data + # mount /dev/sdb1 /data ``` 10. 执行命令“vi /etc/fstab", 编辑“/etc/fstab”使重启后自动挂载数据盘。如下图中,添加最后一行内容。 @@ -1549,7 +1550,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 ![](figures/搭建数据盘-0.png) -##### 方法二:使用LVM进行磁盘管理 +##### 方法二:在root权限下使用LVM进行磁盘管理 >![](public_sys-resources/icon-note.gif) **说明:** >此步骤需要安装镜像中的lvm2相关包,步骤如下: @@ -1600,13 +1601,13 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 #### 创建数据库目录并且授权 -1. 在已创建的数据目录 **/data** 基础上,继续创建进程所需的相关目录并授权MySQL用户(组)。 +1. 在已创建的数据目录 **/data** 基础上,使用root权限继续创建进程所需的相关目录并授权MySQL用户(组)。 ``` - #mkdir -p /data/mysql - #cd /data/mysql - #mkdir data tmp run log - #chown -R mysql:mysql /data + # mkdir -p /data/mysql + # cd /data/mysql + # mkdir data tmp run log + # chown -R mysql:mysql /data ``` @@ -1617,35 +1618,35 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 2. 清除缓存。 ``` - #dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - #dnf makecache + $ dnf makecache ``` -4. 安装MySQL服务器。 +4. 在root权限下安装MySQL服务器。 ``` - #dnf install mysql + # dnf install mysql ``` 5. 查看安装后的rpm包。 ``` - #rpm -qa | grep mysql + $ rpm -qa | grep mysql ``` #### 运行 1. 修改配置文件。 - 1. 创建my.cnf文件,其中文件路径(包括软件安装路径basedir、数据路径datadir等)根据实际情况修改。 + 1. 在root权限下创建my.cnf文件,其中文件路径(包括软件安装路径basedir、数据路径datadir等)根据实际情况修改。 ``` - #vi /etc/my.cnf + # vi /etc/my.cnf ``` 编辑my.cnf内容如下: @@ -1673,7 +1674,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 2. 确保my.cnf配置文件修改正确。 ``` - #cat /etc/my.cnf + $ cat /etc/my.cnf ``` ![](figures/zh-cn_image_0231563132.png) @@ -1681,35 +1682,35 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](public_sys-resources/icon-caution.gif) **注意:** >其中basedir为软件安装路径,请根据实际情况修改。 - 3. 修改/etc/my.cnf文件的组和用户为mysql:mysql + 3. 在root权限下修改/etc/my.cnf文件的组和用户为mysql:mysql ``` - #chown mysql:mysql /etc/my.cnf + # chown mysql:mysql /etc/my.cnf ``` 2. 配置环境变量。 - 1. 安装完成后,将MySQL二进制文件路径到PATH。 + 1. 安装完成后,在root权限下将MySQL二进制文件路径到PATH。 ``` - #echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile + # echo export PATH=$PATH:/usr/local/mysql/bin >> /etc/profile ``` >![](public_sys-resources/icon-caution.gif) **注意:** >其中PATH中的“/usr/local/mysql/bin“路径,为MySQL软件安装目录下的bin文件的绝对路径。请根据实际情况修改。 - 2. 使环境变量配置生效。 + 2. 在root权限下使环境变量配置生效。 ``` - #source /etc/profile + # source /etc/profile ``` -3. 初始化数据库。 +3. 在root权限下初始化数据库。 >![](public_sys-resources/icon-note.gif) **说明:** >本步骤倒数第2行中有初始密码,请注意保存,登录数据库时需要使用。 ``` - #mysqld --defaults-file=/etc/my.cnf --initialize + # mysqld --defaults-file=/etc/my.cnf --initialize 2020-03-18T03:27:13.702385Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) initializing of server in progress as process 34014 2020-03-18T03:27:24.112453Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: iNat=)#V2tZu 2020-03-18T03:27:28.576003Z 0 [System] [MY-013170] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.17) initializing of server has completed @@ -1722,24 +1723,24 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >![](public_sys-resources/icon-caution.gif) **注意:** >如果第一次启动数据库服务,以root用户启动数据库,则启动时会提示缺少mysql.log文件而导致失败。使用mysql用户启动之后,会在/data/mysql/log目录下生成mysql.log文件,再次使用root用户启动则不会报错。 - 1. 修改文件权限。 + 1. 在root权限下修改文件权限。 ``` - #chmod 777 /usr/local/mysql/support-files/mysql.server + # chmod 777 /usr/local/mysql/support-files/mysql.server ``` - 2. 启动MySQL。 + 2. 在root权限下启动MySQL。 ``` - #cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql - #chkconfig mysql on + # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql + # chkconfig mysql on ``` 以mysql用户启动数据库。 ``` - #su - mysql - $service mysql start + # su - mysql + $ service mysql start ``` 5. 登录数据库。 @@ -1749,7 +1750,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 >- 如果采用官网RPM安装方式,则mysql文件在/usr/bin目录下。登录数据库的命令根据实际情况修改。 ``` - $/usr/local/mysql/bin/mysql -uroot -p -S /data/mysql/run/mysql.sock + $ /usr/local/mysql/bin/mysql -uroot -p -S /data/mysql/run/mysql.sock ``` ![](figures/zh-cn_image_0231563134.png) @@ -1758,20 +1759,20 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 1. 登录数据库以后,修改通过root用户登录数据库的密码。 ``` - mysql>alter user 'root'@'localhost' identified by "123456"; + mysql> alter user 'root'@'localhost' identified by "123456"; ``` 2. 创建全域root用户(允许root从其他服务器访问)。 ``` - mysql>create user 'root'@'%' identified by '123456'; + mysql> create user 'root'@'%' identified by '123456'; ``` 3. 进行授权。 ``` - mysql>grant all privileges on *.* to 'root'@'%'; - mysql>flush privileges; + mysql> grant all privileges on *.* to 'root'@'%'; + mysql> flush privileges; ``` ![](figures/zh-cn_image_0231563135.png) @@ -1781,7 +1782,7 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 执行 **\\q** 或者 **exit** 退出数据库。 ``` - mysql>exit + mysql> exit ``` ![](figures/zh-cn_image_0231563136.png) @@ -1789,17 +1790,17 @@ MySQL所使用的SQL语言是用于访问数据库的最常用标准化语言。 #### 卸载 -1. 关闭数据库进程。 +1. 在root权限下关闭数据库进程。 ``` - #ps -ef | grep mysql - #kill -9 进程ID + $ ps -ef | grep mysql + # kill -9 进程ID ``` -2. 执行**dnf remove mysql**命令卸载MySQL。 +2. 在root权限下执行**dnf remove mysql**命令卸载MySQL。 ``` - #dnf remove mysql + # dnf remove mysql ``` @@ -1835,7 +1836,7 @@ CREATE USER 'username'@'hostname' IDENTIFIED BY 'password'; \#创建密码为123456,用户名为userexample2,主机名为192.168.1.100的用户。 ``` -> CREATE USER 'userexample2'@'192.168.1.100' IDENDIFIED BY '123456'; +> CREATE USER 'userexample2'@'192.168.1.100' IDENTIFIED BY '123456'; ``` #### 查看用户 @@ -2091,7 +2092,7 @@ DROP SCHEMA是DROP DATABASE的同义词。 #### 备份数据库 -可以使用mysqldump命令备份数据库。 +可以在root权限下使用mysqldump命令备份数据库。 备份一个或多个表: @@ -2155,12 +2156,12 @@ mysqldump [options] -all-databases > outputfile \#只备份主机为192.168.202.144,端口为3306,root用户下的db1数据库的数据到db1.sql中。 ``` -# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sq +# mysqldump -h 192.168.202.144 -P 3306 -uroot -p123456 -t db1 > db1.sql ``` #### 恢复数据库 -可以使用mysqldump命令恢复数据库。 +可以在root权限下使用mysql命令恢复数据库。 备份一个或多个表: diff --git "a/content/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" "b/content/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" index 4075906f8e23793ce9822e674cd1ed6e0e14c872..ff057a1cd81da97083d9a139d2a5c2e000a4c4fd 100644 --- "a/content/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" +++ "b/content/zh/docs/Administration/\346\237\245\347\234\213\347\263\273\347\273\237\344\277\241\346\201\257.md" @@ -3,13 +3,13 @@ - 查看系统信息,命令如下: ``` - cat /etc/os-release + $ cat /etc/os-release ``` 例如,命令和输出如下: ``` - # cat /etc/os-release + $ cat /etc/os-release NAME="openEuler" VERSION="20.03 (LTS)" ID="openEuler" @@ -24,19 +24,19 @@ 查看CPU信息,命令如下: ``` - lscpu + $ lscpu ``` 查看内存信息,命令如下: ``` - free + $ free ``` 查看磁盘信息,命令如下: ``` - fdisk -l + $ fdisk -l ``` diff --git "a/content/zh/docs/Administration/\347\256\241\347\220\206\347\224\250\346\210\267.md" "b/content/zh/docs/Administration/\347\256\241\347\220\206\347\224\250\346\210\267\345\222\214\347\224\250\346\210\267\347\273\204.md" similarity index 61% rename from "content/zh/docs/Administration/\347\256\241\347\220\206\347\224\250\346\210\267.md" rename to "content/zh/docs/Administration/\347\256\241\347\220\206\347\224\250\346\210\267\345\222\214\347\224\250\346\210\267\347\273\204.md" index b6bbf692cc0774b682d6ba74e564527427d054fa..f207145e2f27c81a56a4999da2bc1637ef2d19a2 100644 --- "a/content/zh/docs/Administration/\347\256\241\347\220\206\347\224\250\346\210\267.md" +++ "b/content/zh/docs/Administration/\347\256\241\347\220\206\347\224\250\346\210\267\345\222\214\347\224\250\346\210\267\347\273\204.md" @@ -1,233 +1,343 @@ -# 管理用户 - -在Linux中,每个普通用户都有一个账户,包括用户名、密码和主目录等信息。除此之外,还有一些系统本身创建的特殊用户,它们具有特殊的意义,其中最重要的是管理员账户,默认用户名是root。同时Linux也提供了用户组,使每一个用户至少属于一个组,从而便于权限管理。 - -用户和用户组管理是系统安全管理的重要组成部分,本章主要介绍openEuler提供的用户管理和组管理命令,以及为普通用户分配特权的方法。 - - - -- [管理用户](#管理用户) - - [增加用户](#增加用户) - - [useradd命令](#useradd命令) - - [用户信息文件](#用户信息文件) - - [创建用户实例](#创建用户实例) - - [修改用户账号](#修改用户账号) - - [修改密码](#修改密码) - - [修改用户shell设置](#修改用户shell设置) - - [修改主目录](#修改主目录) - - [修改UID](#修改uid) - - [修改账号的有效期](#修改账号的有效期) - - [删除用户](#删除用户) - - [管理员账户授权](#管理员账户授权) - - - -## 增加用户 - -### useradd命令 - -在root权限下,通过useradd命令可以为系统添加新用户信息,其中 _options_ 为相关参数,_user\_name_ 为用户名称。 - -``` -useradd [options] user_name -``` - -### 用户信息文件 - -与用户账号信息有关的文件如下: - -- /etc/passwd:用户账号信息文件。 -- /etc/shadow:用户账号信息加密文件。 -- /etc/group:组信息文件。 -- /etc/default/useradd:定义默认设置文件。 -- /etc/login.defs:系统广义设置文件。 -- /etc/skel:默认的初始配置文件目录。 - -### 创建用户实例 - -例如新建一个用户名为user\_example的用户,在root权限下执行如下命令: - -``` -# useradd user_example -``` - ->![](public_sys-resources/icon-note.gif) **说明:** ->没有任何提示,表明用户建立成功。这时并没有设置用户的口令,请使用passwd命令修改用户的密码,没有设置密码的新账号不能登录系统。 - -使用id命令查看新建的用户信息,命令如下: - -``` -# id user_example -uid=502(user_example) gid=502(user_example) groups=502(user_example) -``` - -修改用户user\_example的密码: - -``` -# passwd user_example -``` - -根据提示两次输入新用户的密码,完成密码更改。过程如下: - -``` -# passwd user_example -Changing password for user user_example. -New password: -Retype new password: -passwd: all authentication tokens updated successfully. -``` - ->![](public_sys-resources/icon-note.gif) **说明:** ->若打印信息中出现“BAD PASSWORD: The password fails the dictionary check - it is too simplistic/sytematic”,表示设置的密码过于简单,建议设置复杂度较高的密码。 - -## 修改用户账号 - -### 修改密码 - -普通用户可以用passwd修改自己的密码,只有管理员才能用passwd username为其他用户修改密码。 - -### 修改用户shell设置 - -使用chsh命令可以修改自己的shell,只有管理员才能用chsh username为其他用户修改shell设置。 - -用户也可以使用usermod命令修改shell信息,在root权限下执行如下命令,其中 _new\_shell\_path_ 为目标shell路径,_username_ 为要修改用户的用户名,请根据实际情况修改: - -``` -usermod -s new_shell_path username -``` - -例如,将用户user\_example的shell改为csh,命令如下: - -``` -# usermod -s /bin/csh user_example -``` - -### 修改主目录 - -- 修改主目录,可以在root权限下执行如下命令,其中 _new\_home\_directory_ 为已创建的目标主目录的路径,_username_ 为要修改用户的用户名,请根据实际情况修改: - - ``` - usermod -d new_home_directory username - ``` - -- 如果想将现有主目录的内容转移到新的目录,应该使用-m选项,命令如下: - - ``` - usermod -d new_home_directory -m username - ``` - - -### 修改UID - -修改用户ID,在root权限下执行如下命令,其中 _UID_ 代表目标用户ID,_username_ 代表用户名,请根据实际情况修改: - -``` -usermod -u UID username -``` - -该用户主目录中所拥有的文件和目录都将自动修改UID设置。但是,对于主目录外所拥有的文件,只能使用chown命令手动修改所有权。 - -### 修改账号的有效期 - -如果使用了影子口令,则可以在root权限下,执行如下命令来修改一个账号的有效期,其中 _MM_ 代表月份,_DD_ 代表某天,_YY_ 代表年份,_username_ 代表用户名,请根据实际情况修改: - -``` -usermod -e MM/DD/YY username -``` - -## 删除用户 - -在root权限下,使用userdel命令可删除现有用户。 - -例如,删除用户Test,命令如下: - -``` -# userdel Test -``` - -如果想同时删除该用户的主目录以及其中所有内容,要使用-r参数递归删除。 - ->![](public_sys-resources/icon-note.gif) **说明:** ->不建议直接删除已经进入系统的用户,如果需要强制删除,请使用 userdel -f _Test_ 命令。 - -## 管理员账户授权 - -使用sudo命令可以允许普通用户执行管理员账户才能执行的命令。 - -sudo命令允许已经在/etc/sudoers文件中指定的用户运行管理员账户命令。例如,一个已经获得许可的普通用户可以运行如下命令: - -``` -sudo /usr/sbin/useradd newuserl -``` - -实际上,sudo的配置完全可以指定某个已经列入/etc/sudoers文件的普通用户可以做什么,不可以做什么。 - -/etc/sudoers的配置行如下所示。 - -- 空行或注释行(以\#字符打头):无具体功能的行。 -- 可选的主机别名行:用来创建主机列表的简称。必须以Host\_Alias关键词开头,列表中的主机必须用逗号隔开,如: - - ``` - Host_Alias linux=ted1,ted2 - ``` - - 其中ted1和ted2是两个主机名,可使用linux(别名)称呼它们。 - - -- 可选的用户别名行:用来创建用户列表的简称。用户别名行必须以User\_Alias关键词开头,列表中的用户名必须以逗号隔开。其格式同主机别名行。 -- 可选的命令别名行:用来创建命令列表的简称。必须以Cmnd\_Alias开头,列表中的命令必须用逗号隔开。 -- 可选的运行方式别名行:用来创建用户列表的简称。不同的是,使用这样的别名可以告诉sudo程序以列表中某一用户的身份来运行程序。 -- 必要的用户访问说明行。 - - 用户访问的说明语法如下: - - ``` - user host = [ run as user ] command list - ``` - - 在user处指定一个真正的用户名或定义过的别名,host也可以是一个真正的主机名或者定义过的主机别名。默认情况下,sudo执行的所有命令都是以root身份执行。如果您想使用其他身份可以指定。command list可以是以逗号分隔的命令列表,也可以是一个已经定义过的别名,如: - - ``` - ted1 ted2=/sbin/shutdown - ``` - - 这一句说明ted1可以在ted2主机上运行关机命令。 - - ``` - newuser1 ted1=(root) /usr/sbin/useradd,/usr/sbin/userdel - ``` - - 这一句说明ted1主机上的newuser1具有以root用户权限执行useradd,userdel命令的功能。 - - >![](public_sys-resources/icon-note.gif) **说明:** - >- 可以在一行定义多个别名,中间用冒号 \(:\) 隔开。 - >- 可在命令或命令别名之前加上感叹号 \(!\),使该命令或命令别名无效。 - >- 有两个关键词:ALL和NOPASSWD。ALL意味着“所有”(所有文件、所有主机或所有命令),NOPASSWD意味着不用密码。 - >- 通过修改用户访问,将普通用户的访问权限修改为同root一样,则可以给普通用户分配特权。 - - -下面是一个sudoers文件的例子: - -``` -#sudoers files -#User alias specification -User_Alias ADMIN=ted1:POWERUSER=globus,ted2 -#user privilege specification -ADMIN ALL=ALL -POWERUSER ALL=ALL,!/bin/su -``` - -其中: - -- User\_Alias ADMIN=ted1:POWERUSER=globus,ted2 - - 定义了两个别名ADMIN和POWERUSER - -- ADMIN ALL=ALL - - 说明在所有主机上,ADMIN用户都可以以root身份执行所有命令 - -- POWERUSER ALL=ALL,!/bin/su - - 给POWERUSER用户除了运行su命令外等同ADMIN的权限 - +# 管理用户 + +在Linux中,每个普通用户都有一个账户,包括用户名、密码和主目录等信息。除此之外,还有一些系统本身创建的特殊用户,它们具有特殊的意义,其中最重要的是管理员账户,默认用户名是root。同时Linux也提供了用户组,使每一个用户至少属于一个组,从而便于权限管理。 + +用户和用户组管理是系统安全管理的重要组成部分,本章主要介绍openEuler提供的用户管理和组管理命令,以及为普通用户分配特权的方法。 + + + +- [管理用户](#管理用户) + - [管理用户](#管理用户-1) + - [增加用户](#增加用户) + - [修改用户账号](#修改用户账号) + - [删除用户](#删除用户) + - [管理员账户授权](#管理员账户授权) + - [管理用户组](#管理用户组) + - [增加用户组](#增加用户组) + - [修改用户组](#修改用户组) + - [删除用户组](#删除用户组) + - [将用户加入用户组或从用户组中移除](#将用户加入用户组或从用户组中移除) + - [切换用户组](#切换用户组) + + + +## 管理用户 + +### 增加用户 + +#### useradd命令 + +在root权限下,通过useradd命令可以为系统添加新用户信息,其中 _options_ 为相关参数, _username_ 为用户名称。 + +``` +useradd [options] username +``` + +#### 用户信息文件 + +与用户账号信息有关的文件如下: + +- /etc/passwd:用户账号信息文件。 +- /etc/shadow:用户账号信息加密文件。 +- /etc/group:组信息文件。 +- /etc/default/useradd:定义默认设置文件。 +- /etc/login.defs:系统广义设置文件。 +- /etc/skel:默认的初始配置文件目录。 + +#### 创建用户实例 + +例如新建一个用户名为userexample的用户,在root权限下执行如下命令: + +``` +# useradd userexample +``` + +>![](public_sys-resources/icon-note.gif) **说明:** +>没有任何提示,表明用户建立成功。这时并没有设置用户的口令,请使用passwd命令修改用户的密码,没有设置密码的新账号不能登录系统。 + + +使用id命令查看新建的用户信息,命令如下: + +``` +# id userexample +uid=502(userexample) gid=502(userexample) groups=502(userexample) +``` + +修改用户userexample的密码: + +``` +# passwd userexample +``` + +修改用户密码时需要满足密码复杂度要求,密码的复杂度的要求如下: + +1. 口令长度至少8个字符。 +2. 口令至少包含大写字母、小写字母、数字和特殊字符中的任意3种。 +3. 口令不能和账号一样。 +4. 口令不能使用字典词汇。 + - 查询字典 + 在已装好的openEuler环境中,可以通过如下命令导出字典库文件dictionary.txt,用户可以查询密码是否在该字典中。 + ``` + cracklib-unpacker /usr/share/cracklib/pw_dict > dictionary.txt + ``` + - 修改字典 + 1. 修改上面导出的字典文件,执行如下命令更新系统字典库。 + ``` + # create-cracklib-dict dictionary.txt + ``` + 2. 在原字典库基础上新增其他字典内容custom.txt。 + ``` + # create-cracklib-dict dictionary.txt custom.txt + ``` + + +根据提示两次输入新用户的密码,完成密码更改。过程如下: + +``` +# passwd userexample +Changing password for user userexample. +New password: +Retype new password: +passwd: all authentication tokens updated successfully. +``` + +>![](public_sys-resources/icon-note.gif) **说明:** +>若打印信息中出现“BAD PASSWORD: The password fails the dictionary check - it is too simplistic/sytematic”,表示设置的密码过于简单,建议设置复杂度较高的密码。 + +### 修改用户账号 + +#### 修改密码 + +普通用户可以用passwd修改自己的密码,只有管理员才能用passwd username为其他用户修改密码。 + +#### 修改用户shell设置 + +使用chsh命令可以修改自己的shell,只有管理员才能用chsh username为其他用户修改shell设置。 + +用户也可以使用usermod命令修改shell信息,在root权限下执行如下命令,其中 _new\_shell\_path_ 为目标shell路径,_username_ 为要修改用户的用户名,请根据实际情况修改: + +``` +usermod -s new_shell_path username +``` + +例如,将用户userexample的shell改为csh,命令如下: + +``` +# usermod -s /bin/csh userexample +``` + +#### 修改主目录 + +- 修改主目录,可以在root权限下执行如下命令,其中 _new\_home\_directory_ 为已创建的目标主目录的路径,_username_ 为要修改用户的用户名,请根据实际情况修改: + + ``` + usermod -d new_home_directory username + ``` + +- 如果想将现有主目录的内容转移到新的目录,应该使用-m选项,命令如下: + + ``` + usermod -d new_home_directory -m username + ``` + + +#### 修改UID + +修改用户ID,在root权限下执行如下命令,其中 _UID_ 代表目标用户ID,_username_ 代表用户名,请根据实际情况修改: + +``` +usermod -u UID username +``` + +该用户主目录中所拥有的文件和目录都将自动修改UID设置。但是,对于主目录外所拥有的文件,只能使用chown命令手动修改所有权。 + +#### 修改账号的有效期 + +如果使用了影子口令,则可以在root权限下,执行如下命令来修改一个账号的有效期,其中 _MM_ 代表月份,_DD_ 代表某天,_YY_ 代表年份,_username_ 代表用户名,请根据实际情况修改: + +``` +usermod -e MM/DD/YY username +``` + +### 删除用户 + +在root权限下,使用userdel命令可删除现有用户。 + +例如,删除用户Test,命令如下: + +``` +# userdel Test +``` + +如果想同时删除该用户的主目录以及其中所有内容,要使用-r参数递归删除。 + +>![](public_sys-resources/icon-note.gif) **说明:** +>不建议直接删除已经进入系统的用户,如果需要强制删除,请使用 userdel -f _Test_ 命令。 + +### 管理员账户授权 + +使用sudo命令可以允许普通用户执行管理员账户才能执行的命令。 + +sudo命令允许已经在/etc/sudoers文件中指定的用户运行管理员账户命令。例如,一个已经获得许可的普通用户可以运行如下命令: + +``` +sudo /usr/sbin/useradd newuserl +``` + +实际上,sudo的配置完全可以指定某个已经列入/etc/sudoers文件的普通用户可以做什么,不可以做什么。 + +/etc/sudoers的配置行如下所示。 + +- 空行或注释行(以\#字符打头):无具体功能的行。 +- 可选的主机别名行:用来创建主机列表的简称。必须以Host\_Alias关键词开头,列表中的主机必须用逗号隔开,如: + + ``` + Host_Alias linux=ted1,ted2 + ``` + + 其中ted1和ted2是两个主机名,可使用linux(别名)称呼它们。 + + +- 可选的用户别名行:用来创建用户列表的简称。用户别名行必须以User\_Alias关键词开头,列表中的用户名必须以逗号隔开。其格式同主机别名行。 +- 可选的命令别名行:用来创建命令列表的简称。必须以Cmnd\_Alias开头,列表中的命令必须用逗号隔开。 +- 可选的运行方式别名行:用来创建用户列表的简称。不同的是,使用这样的别名可以告诉sudo程序以列表中某一用户的身份来运行程序。 +- 必要的用户访问说明行。 + + 用户访问的说明语法如下: + + ``` + user host = [ run as user ] command list + ``` + + 在user处指定一个真正的用户名或定义过的别名,host也可以是一个真正的主机名或者定义过的主机别名。默认情况下,sudo执行的所有命令都是以root身份执行。如果您想使用其他身份可以指定。command list可以是以逗号分隔的命令列表,也可以是一个已经定义过的别名,如: + + ``` + ted1 ted2=/sbin/shutdown + ``` + + 这一句说明ted1可以在ted2主机上运行关机命令。 + + ``` + newuser1 ted1=(root) /usr/sbin/useradd,/usr/sbin/userdel + ``` + + 这一句说明ted1主机上的newuser1具有以root用户权限执行useradd,userdel命令的功能。 + + >![](public_sys-resources/icon-note.gif) **说明:** + >- 可以在一行定义多个别名,中间用冒号 \(:\) 隔开。 + >- 可在命令或命令别名之前加上感叹号 \(!\),使该命令或命令别名无效。 + >- 有两个关键词:ALL和NOPASSWD。ALL意味着“所有”(所有文件、所有主机或所有命令),NOPASSWD意味着不用密码。 + >- 通过修改用户访问,将普通用户的访问权限修改为同root一样,则可以给普通用户分配特权。 + + +下面是一个sudoers文件的例子: + +``` +#sudoers files +#User alias specification +User_Alias ADMIN=ted1:POWERUSER=globus,ted2 +#user privilege specification +ADMIN ALL=ALL +POWERUSER ALL=ALL,!/bin/su +``` + +其中: + +- User\_Alias ADMIN=ted1:POWERUSER=globus,ted2 + + 定义了两个别名ADMIN和POWERUSER + +- ADMIN ALL=ALL + + 说明在所有主机上,ADMIN用户都可以以root身份执行所有命令 + +- POWERUSER ALL=ALL,!/bin/su + + 给POWERUSER用户除了运行su命令外等同ADMIN的权限 + +## 管理用户组 + +### 增加用户组 + +#### groupadd命令 + +在root权限下,通过groupadd命令可以为系统添加新用户组信息,其中 _options_ 为相关参数, _groupname_ 为用户组名称。 + +``` +groupadd [options] groupname +``` + +#### 用户组信息文件 + +与用户组信息有关的文件如下: + +- /etc/gshadow:用户组信息加密文件。 +- /etc/group:组信息文件。 +- /etc/login.defs:系统广义设置文件。 + +#### 创建用户组实例 + +例如新建一个用户组名为groupexample的用户,在root权限下执行如下命令: + +``` +# groupadd groupexample +``` + +### 修改用户组 + +#### 修改GID + +修改用户组ID,在root权限下执行如下命令,其中 _GID_ 代表目标用户组ID, _groupname_ 代表用户组,请根据实际情况修改: + +``` +groupmod -g GID groupname +``` + + +#### 修改用户组名 + +修改用户组名,在root权限下执行如下命令,其中 _newgroupname_ 代表新用户组名, _oldgroupname_ 代表已经存在的待修改的用户组名,请根据实际情况修改: + +``` +groupmod -n newgroupname oldgroupname +``` + +### 删除用户组 + +在root权限下,使用groupdel命令可删除用户组。 + +例如,删除用户组Test,命令如下: + +``` +# groupdel Test +``` + +>![](public_sys-resources/icon-note.gif) **说明:** +>groupdel不能直接删除用户的主组,如果需要强制删除用户主组,请使用 groupdel -f _Test_ 命令。 + +### 将用户加入用户组或从用户组中移除 + +在root权限下,使用gpasswd命令将用户加入用户组或从用户组中移除。 + +例如,将用户 _userexample_ 加入用户组 _Test_ ,命令如下: + +``` +# gpasswd -a userexample Test +``` +例如,将用户 _userexample_ 从 _Test_ 用户组中移除,命令如下: + +``` +# gpasswd -d userexample Test +``` + +### 切换用户组 + +一个用户同时属于多个用户组时,则在用户登录后,使用newgrp命令可以切换到其他用户组,以便具有其他用户组的权限。 + +例如,将用户 _userexample_ 切换到 _Test_ 用户组,命令如下: + +``` +$ newgrp Test +``` + + diff --git "a/content/zh/docs/Administration/\347\256\241\347\220\206\350\277\233\347\250\213.md" "b/content/zh/docs/Administration/\347\256\241\347\220\206\350\277\233\347\250\213.md" index 5a796ed6192cf9da4b20f3fc6376e49b9e88789e..e966f9c0d46a438942975c562345ec3b1bc4d99b 100644 --- "a/content/zh/docs/Administration/\347\256\241\347\220\206\350\277\233\347\250\213.md" +++ "b/content/zh/docs/Administration/\347\256\241\347\220\206\350\277\233\347\250\213.md" @@ -26,7 +26,7 @@ who命令主要用于查看当前系统中的用户情况。如果用户想和 例如查看系统中的用户及其状态。使用如下: ``` -# who +$ who admin tty1 Jul 28 15:55 admin pts/0 Aug 5 15:46 (192.168.0.110) admin pts/2 Jul 29 19:52 (192.168.0.110) @@ -98,7 +98,7 @@ ps命令最常用的还是用来监控后台进程的工作情况,因为后台 例如显示系统中终端上的所有进行进程。命令如下: ``` -# ps -a +$ ps -a PID TTY TIME CMD 12175 pts/6 00:00:00 bash 24526 pts/0 00:00:00 vsftpd @@ -130,7 +130,7 @@ kill -l [信号] 其中进程号可以通过ps命令的输出得到。-s选项是给程序发送指定的信号,详细的信号可以用“kill -l”命令查看;-p选项只显示指定进程的ID号。 -杀死pid为1409的进程,示例如下: +杀死pid为1409的进程,在root权限下执行如下命令: ``` # kill -9 1409 @@ -139,7 +139,7 @@ kill -l [信号] 显示所有的信号及其编号对应关系,示例如下: ``` -# kill -l +$ kill -l 1) SIGHUP 2) SIGINT 3) SIGQUIT 4) SIGILL 5) SIGTRAP 6) SIGABRT 7) SIGBUS 8) SIGFPE 9) SIGKILL 10) SIGUSR1 11) SIGSEGV 12) SIGUSR2 13) SIGPIPE 14) SIGALRM 15) SIGTERM @@ -204,7 +204,7 @@ at允许使用一套相当复杂的时间指定方法,比如: 对于at命令来说,需要定时执行的命令是从标准输入或者使用-f选项指定的文件中读取并执行的。如果at命令是从一个使用su命令切换到用户shell中执行的,那么当前用户被认为是执行用户,所有的错误和输出结果都会送给这个用户。但是如果有邮件送出的话,收到邮件的将是原来的用户,也就是登录时shell的所有者。 -例如在6月8日上午10点执行slocate -u命令。命令如下: +例如在6月8日上午10点执行slocate -u命令。在root权限下执行命令如下: ``` # at 10:00 6/8/19 @@ -223,7 +223,7 @@ at> #### 运行机制 -首先cron命令会搜索/var/spool/cron目录,寻找以/etc/passwd文件中的用户名命名的crontab文件,被找到的这种文件将装入内存。比如一个用户名为globus的用户,对应的crontab文件应该是/var/spool/cron/globus,即以该用户命名的crontab文件存放在/var/spool/cron目录下面。 +首先cron命令会搜索/var/spool/cron目录,寻找以/etc/passwd文件中的用户名命名的crontab文件,被找到的这种文件将装入内存。比如一个用户名为userexample的用户,对应的crontab文件应该是/var/spool/cron/userexample,即以该用户命名的crontab文件存放在/var/spool/cron目录下面。 cron命令还将搜索/etc/crontab文件,这个文件是用不同的格式写成的。cron启动以后,它将首先检查是否有用户设置了crontab文件,如果没有就转入睡眠状态,释放系统资源。所以该后台进程占用资源极少,它每分钟被换醒一次,查看当前是否有需要运行的命令。 @@ -243,7 +243,7 @@ crontab命令的常用方法如下: 例如root查看自己的cron设置。命令如下: ``` -crontab -u root -l +# crontab -u root -l ``` #### crontab文件 @@ -308,17 +308,17 @@ minute hour day-of-month month-of-year day-of-week commands 每次编辑完某个用户的cron设置后,cron自动在/var/spool/cron下生成一个与此用户同名的文件。此用户的cron信息都记录在这个文件中,这个文件是不可以直接编辑的,只可以用crontab -e来编辑。用户也可以另外建立一个文件,使用“cron文件名”命令导入cron设置。 -假设有个用户名为globus,它需要为自己创建的一个crontab文件。步骤如下: +假设有个用户名为userexample,它需要为自己创建的一个crontab文件。步骤如下: -1. 首先可以使用任何文本编辑器建立一个新文件,并将向该文件加入需要运行的命令和要定期执行的时间,假设该文件为 \~/globus.cron。 -2. 然后使用crontab命令安装这个文件,使用crontab命令使之成为该用户的crontab文件。命令如下: +1. 首先可以使用任何文本编辑器建立一个新文件,并将向该文件加入需要运行的命令和要定期执行的时间,假设该文件为 \~/userexample.cron。 +2. 然后在root权限下使用crontab命令安装这个文件,使用crontab命令使之成为该用户的crontab文件。命令如下: ``` - crontab globus. ~/globus.cron + # crontab -u userexample ~/userexample.cron ``` -这样crontab文件就建立好了,可以转到/var/spool/cron目录下面查看,发现多了一个globus文件。这个文件就是所需的crontab文件。 +这样crontab文件就建立好了,可以转到/var/spool/cron目录下面查看,发现多了一个userexample文件。这个文件就是所需的crontab文件。 >![](public_sys-resources/icon-note.gif) **说明:** >cron启动后,每过一分钟读一次crontab文件,检查是否要执行里面的命令。因此该文件被修改后不需要重新启动cron服务。 diff --git "a/content/zh/docs/Administration/\351\205\215\347\275\256\347\275\221\347\273\234.md" "b/content/zh/docs/Administration/\351\205\215\347\275\256\347\275\221\347\273\234.md" index e8a94dc8d346d2d52a29025852fea74fa1bf4efb..9da7a61e63c1da6388f52e3dd4a2c1bd40172e65 100644 --- "a/content/zh/docs/Administration/\351\205\215\347\275\256\347\275\221\347\273\234.md" +++ "b/content/zh/docs/Administration/\351\205\215\347\275\256\347\275\221\347\273\234.md" @@ -42,7 +42,7 @@ nmcli是NetworkManager的一个命令行工具,它提供了使用命令行配 其中,OBJECT选项可以是general、networking、radio、connection或device等。在日常使用中,最常使用的是-t, \-\-terse(用于脚本)、-p, \-\-pretty选项(用于用户)及-h, \-\-help选项,用户可以使用“ nmcli help”获取更多参数及使用信息。 ``` -# nmcli help +$ nmcli help ``` 常用命令使用举例如下: @@ -50,33 +50,32 @@ nmcli是NetworkManager的一个命令行工具,它提供了使用命令行配 - 显示NetworkManager状态: ``` - nmcli general status + $ nmcli general status ``` - 显示所有连接: ``` - nmcli connection show + $ nmcli connection show ``` - 只显示当前活动连接,如下所示添加 -a, \-\-active: ``` - nmcli connection show --active + $ nmcli connection show --active ``` - 显示由NetworkManager识别到设备及其状态: ``` - nmcli device status + $ nmcli device status ``` -- 使用nmcli工具启动和停止网络接口,例如: +- 使用nmcli工具启动和停止网络接口,在root权限下执行如下命令: ``` - - nmcli connection up id enp3s0 - nmcli device disconnect enp3s0 + # nmcli connection up id enp3s0 + # nmcli device disconnect enp3s0 ``` @@ -85,7 +84,7 @@ nmcli是NetworkManager的一个命令行工具,它提供了使用命令行配 列出目前可用的网络连接: ``` -# nmcli con show +$ nmcli con show NAME UUID TYPE DEVICE @@ -100,7 +99,7 @@ virbr0 ba552da6-f014-49e3-91fa-ec9c388864fa bridge virbr0 添加一个网络连接会生成相应的配置文件,并与相应的设备关联。检查可用的设备,方法如下: ``` -# nmcli dev status +$ nmcli dev status DEVICE TYPE STATE CONNECTION enp3s0 ethernet connected enp3s0 @@ -121,7 +120,7 @@ virbr0-nic tun unmanaged -- nmcli connection add type ethernet con-name connection-name ifname interface-name ``` -例如创建名为net-test的动态连接配置文件,使用以下命令: +例如创建名为net-test的动态连接配置文件,在root权限下使用以下命令: ``` # nmcli connection add type ethernet con-name net-test ifname enp3s0 @@ -132,7 +131,7 @@ NetworkManager 会将参数 connection.autoconnect 设定为 yes,并将设置 ###### 激活连接并检查状态 -使用以下命令激活网络连接,使用以下命令: +在root权限下使用以下命令激活网络连接: ``` # nmcli con up net-test @@ -142,7 +141,7 @@ Connection successfully activated (D-Bus active path:/org/freedesktop/NetworkMan 检查这些设备及连接的状态,使用以下命令: ``` -# nmcli device status +$ nmcli device status DEVICE TYPE STATE CONNECTION enp4s0 ethernet connected enp4s0 @@ -165,7 +164,7 @@ nmcli connection add type ethernet con-name connection-name ifname interface-nam >![](public_sys-resources/icon-note.gif) **说明:** >如果要添加 IPv6 地址和网关信息,使用 ip6 和 gw6 选项。 -例如创建名为 net-static的静态连接配置文件,使用以下命令: +例如创建名为 net-static的静态连接配置文件,在root权限下使用以下命令: ``` # nmcli con add type ethernet con-name net-static ifname enp3s0 ip4 192.168.0.10/24 gw4 192.168.0.254 @@ -180,13 +179,13 @@ Connection 'net-static' (63aa2036-8665-f54d-9a92-c3035bad03f7) successfully adde NetworkManager 会将其内部参数 ipv4.method 设定为 manual,将 connection.autoconnect 设定为yes,并将设置写入 /etc/sysconfig/network-scripts/ifcfg-my-office 文件,其中会将对应 BOOTPROTO 设定为 none,将 ONBOOT 设定为 yes。 -设定两个 IPv4 DNS 服务器地址,使用以下命令: +设定两个 IPv4 DNS 服务器地址,在root权限下使用以下命令: ``` # nmcli con mod net-static ipv4.dns "*.*.*.* *.*.*.*" ``` -设置两个 IPv6 DNS 服务器地址,使用以下命令: +设置两个 IPv6 DNS 服务器地址,在root权限下使用以下命令: ``` # nmcli con mod net-static ipv6.dns "2001:4860:4860::**** 2001:4860:4860::****" @@ -194,7 +193,7 @@ NetworkManager 会将其内部参数 ipv4.method 设定为 manual,将 connecti ###### 激活连接并检查状态 -激活新的网络连接,使用以下命令: +激活新的网络连接,在root权限下使用以下命令: ``` # nmcli con up net-static ifname enp3s0 @@ -204,7 +203,7 @@ Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkMa 检查这些设备及连接的状态,使用以下命令: ``` -# nmcli device status +$ nmcli device status DEVICE TYPE STATE CONNECTION enp4s0 ethernet connected enp4s0 @@ -217,7 +216,7 @@ virbr0-nic tun unmanaged -- 查看配置的连接详情,使用以下命令(使用 -p, \-\-pretty 选项在输出结果中添加标题和分段): ``` -# nmcli -p con show net-static +$ nmcli -p con show net-static =============================================================================== Connection profile details (net-static ) =============================================================================== @@ -251,26 +250,26 @@ connection.llmnr: -1 (default) 使用以下命令查看可用 Wi-Fi 访问点: ``` -# nmcli dev wifi list +$ nmcli dev wifi list ``` 使用以下命令生成使用的静态 IP 配置,但允许自动 DNS 地址分配的 Wi-Fi 连接: ``` -# nmcli con add con-name Wifi ifname wlan0 type wifi ssid MyWifi ip4 192.168.100.101/24 gw4 192.168.100.1 +$ nmcli con add con-name Wifi ifname wlan0 type wifi ssid MyWifi ip4 192.168.100.101/24 gw4 192.168.100.1 ``` 请使用以下命令设定 WPA2 密码,例如 “answer”: ``` -# nmcli con modify Wifi wifi-sec.key-mgmt wpa-psk -# nmcli con modify Wifi wifi-sec.psk answer +$ nmcli con modify Wifi wifi-sec.key-mgmt wpa-psk +$ nmcli con modify Wifi wifi-sec.psk answer ``` 使用以下命令更改 Wi-Fi 状态: ``` -# nmcli radio wifi [ on | off ] +$ nmcli radio wifi [ on | off ] ``` ##### 更改属性 @@ -278,20 +277,20 @@ connection.llmnr: -1 (default) 请使用以下命令检查具体属性,比如 mtu: ``` -# nmcli connection show id 'Wifi ' | grep mtu +$ nmcli connection show id 'Wifi ' | grep mtu 802-11-wireless.mtu: auto ``` 使用如下命令更改设置的属性: ``` -# nmcli connection modify id 'Wifi ' 802-11-wireless.mtu 1350 +$ nmcli connection modify id 'Wifi ' 802-11-wireless.mtu 1350 ``` 使用如下命令确认更改: ``` -# nmcli connection show id 'Wifi ' | grep mtu +$ nmcli connection show id 'Wifi ' | grep mtu 802-11-wireless.mtu: 1350 ``` @@ -300,14 +299,14 @@ connection.llmnr: -1 (default) - 使用nmcli命令为网络连接配置静态路由,使用命令如下: ``` - # nmcli connection modify enp3s0 +ipv4.routes "192.168.122.0/24 10.10.10.1" + $ nmcli connection modify enp3s0 +ipv4.routes "192.168.122.0/24 10.10.10.1" ``` - 使用编辑器配置静态路由,使用如下命令: ``` - # nmcli con edit type ethernet con-name enp3s0 + $ nmcli con edit type ethernet con-name enp3s0 ===| nmcli interactive connection editor |=== Adding a new '802-3-ethernet' connection Type 'help' or '?' for available commands. @@ -345,7 +344,7 @@ ip addr [ add | del ] address dev interface-name # ip address add 192.168.0.10/24 dev enp3s0 ``` -查看配置结果,使用如下命令: +查看配置结果,在root权限使用如下命令: ``` # ip addr show dev enp3s0 @@ -360,7 +359,7 @@ ip addr [ add | del ] address dev interface-name ``` ##### 配置多个地址 -ip 命令支持为同一接口分配多个地址,可重复多次使用 ip 命令实现分配多个地址。使用示例如下: +ip 命令支持为同一接口分配多个地址,可在root权限下重复多次使用 ip 命令实现分配多个地址。使用示例如下: ``` # ip address add 192.168.2.223/24 dev enp4s0 @@ -387,7 +386,7 @@ ip 命令支持为同一接口分配多个地址,可重复多次使用 ip 命 ip route [ add | del | change | append | replace ] destination-address ``` -使用 ip route 命令显示当前的 IP 路由表。示例如下: +在root权限下使用 ip route 命令显示当前的 IP 路由表。示例如下: ``` # ip route @@ -407,7 +406,7 @@ ip route add 192.168.2.1 via 10.0.0.1 [dev interface-name] 其中 192.168.2.1 是用点分隔的十进制符号中的 IP 地址,10.0.0.1 是下一个跃点,_interface-name_ 是进入下一个跃点的退出接口。 -要在网络中添加一个静态路由,即代表 IP 地址范围的 IP 地址,请作为 root 运行以下命令格式: +要在网络中添加一个静态路由,即代表 IP 地址范围的 IP 地址,请在root权限下运行以下命令格式: ``` ip route add 192.168.2.0/24 via 10.0.0.1 [dev interface-name] @@ -418,11 +417,11 @@ ip route add 192.168.2.0/24 via 10.0.0.1 [dev interface-name] ### 通过ifcfg文件配置网络 >![](public_sys-resources/icon-note.gif) **说明:** ->通过ifcfg文件配置的网络配置不会立即生效,需要执行**systemctl reload NetworkManager**命令以重启网络服务后才生效。 +>通过ifcfg文件配置的网络配置不会立即生效,需要在root权限下执行**systemctl reload NetworkManager**命令以重启网络服务后才生效。 #### 配置静态网络 -以enp4s0网络接口进行静态网络设置为例,通过修改ifcfg文件实现,在/etc/sysconfig/network-scripts/目录中生成名为ifcfg-enp4s0的文件中,修改参数配置,示例如下: +以enp4s0网络接口进行静态网络设置为例,通过在root权限下修改ifcfg文件实现,在/etc/sysconfig/network-scripts/目录中生成名为ifcfg-enp4s0的文件中,修改参数配置,示例如下: ``` TYPE=Ethernet @@ -446,7 +445,7 @@ ONBOOT=yes #### 配置动态网络 -要通过ifcfg文件为名为em1的接口配置动态网络,请按照如下操作在/etc/sysconfig/network-scripts/目录中生成名为 ifcfg-em1 的文件,示例如下: +要通过ifcfg文件为em1接口配置动态网络,请按照如下操作在/etc/sysconfig/network-scripts/目录中生成名为 ifcfg-em1 的文件,示例如下: ``` DEVICE=em1 @@ -501,7 +500,7 @@ hostname有三种类型:static、transient和pretty。 查看当前的主机名,使用如下命令: ``` -# hostnamectl status +$ hostnamectl status ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -541,7 +540,7 @@ hostname有三种类型:static、transient和pretty。 其中 "" 是空白字符串,option是\-\-pretty、\-\-static和\-\-transient中的一个或多个选项。 #### 远程更改主机名 -在远程系统中运行hostnamectl命令时,要使用-H,\-\-host 选项,使用如下命令: +在远程系统中运行hostnamectl命令时,要使用-H,\-\-host 选项,在root权限下使用如下命令: ``` # hostnamectl set-hostname -H [username]@hostname new_hostname @@ -554,7 +553,7 @@ hostname有三种类型:static、transient和pretty。 查询static主机名,使用如下命令: ``` -# nmcli general hostname +$ nmcli general hostname ``` 在root权限下,将static主机名设定为host-server,使用如下命令: @@ -577,38 +576,38 @@ hostname有三种类型:static、transient和pretty。 - 创建名为mybond0的绑定,使用示例如下: ``` - # nmcli con add type bond con-name mybond0 ifname mybond0 mode active-backup + $ nmcli con add type bond con-name mybond0 ifname mybond0 mode active-backup ``` - 添加从属接口,使用示例如下: ``` - # nmcli con add type bond-slave ifname enp3s0 master mybond0 + $ nmcli con add type bond-slave ifname enp3s0 master mybond0 ``` 要添加其他从属接口,重复上一个命令,并在命令中使用新的接口,使用示例如下: ``` - # nmcli con add type bond-slave ifname enp4s0 master mybond0 + $ nmcli con add type bond-slave ifname enp4s0 master mybond0 Connection 'bond-slave-enp4s0' (05e56afc-b953-41a9-b3f9-0791eb49f7d3) successfully added. ``` - 要启动绑定,则必须首先启动从属接口,使用示例如下: ``` - # nmcli con up bond-slave-enp3s0 + $ nmcli con up bond-slave-enp3s0 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14) ``` ``` - # nmcli con up bond-slave-enp4s0 + $ nmcli con up bond-slave-enp4s0 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15) ``` 现在可以启动绑定,使用示例如下: ``` - # nmcli con up bond-mybond0 + $ nmcli con up mybond0 Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16) ``` @@ -619,23 +618,23 @@ hostname有三种类型:static、transient和pretty。 #### 检查是否已安装Bonding内核模块 -在系统中默认已加载相应模块。在root权限下,要载入绑定模块,可使用如下命令: +在系统中默认已加载相应模块。要载入绑定模块,可在root权限下使用如下命令: ``` # modprobe --first-time bonding ``` -显示该模块的信息,可使用如下命令: +显示该模块的信息,可在root权限下使用如下命令: ``` # modinfo bonding ``` -更多命令请使用modprobe \-\-help查看。 +更多命令请在root权限下使用modprobe \-\-help查看。 #### 创建频道绑定接口 -要创建绑定接口,可通过在 /etc/sysconfig/network-scripts/ 目录中创建名为 ifcfg-bondN 的文件(使用接口号码替换 N,比如 0)。 +要创建绑定接口,可在root权限下通过在 /etc/sysconfig/network-scripts/ 目录中创建名为 ifcfg-bondN 的文件(使用接口号码替换 N,比如 0)。 根据要绑定接口类型的配置文件来编写相应的内容,比如网络接口。接口配置文件示例如下: @@ -702,7 +701,7 @@ Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkMa # nmcli con load /etc/sysconfig/network-scripts/ifcfg-device ``` -查看绑定接口的状态,请运行以下命令: +查看绑定接口的状态,请在root权限下运行以下命令: ``` # ip link show @@ -761,7 +760,8 @@ IPv6场景中会发现整个路由路径中的最小mtu的值作为当前链接 ##### 设置接口设备的mtu -如果在配置了IPv6地址的接口上设置mtu的值小于1280(IPv6 PMTU设置的最小值),则会导致该接口的IPv6地址被删除。并且无法再次添加IPv6地址。所以在IPv6场景中,对接口设备的mtu的配置一定要大于等于1280。具体现象如下: +如果在配置了IPv6地址的接口上设置mtu的值小于1280(IPv6 PMTU设置的最小值),则会导致该接口的IPv6地址被删除。并且无法再次添加IPv6地址。所以在IPv6场景中,对接口设备的mtu的配置一定要大于等于1280。 +请在root权限下运行如下命令查看具体现象: ``` # ip addr show enp3s0 @@ -811,7 +811,7 @@ RTNETLINK answers: No buffer space available ##### 概述 -IPv6与IPv4都可以通过DHCP的方式获得IP地址。IPv6地址有两种配置方式:无状态自动配置和有状态自动配置。 +IPv6与IPv4都可以在root权限下通过DHCP的方式获得IP地址。IPv6地址有两种配置方式:无状态自动配置和有状态自动配置。 - 无状态自动配置 @@ -970,6 +970,8 @@ PERSISTENT_DHCLIENT=yes|no|1|0 由于IPv4和IPv6是两个不同的协议标准,iproute相关命令在使用方法上存在一定的差异。本章节主要梳理iproute包中用户经常使用到命令在IPv4和IPv6使用方面的差异,从而可以更好地指导用户使用iproute包中相关命令。 +iproute相关命令均需要在root权限下运行。 + ##### IPv6地址的生命周期 @@ -1319,7 +1321,7 @@ rsyslog客户端配置文件同时配置IPv4和IPv6地址,且端口配置相 ##### 解决方法 -可通过配置Direct模式,关闭缓冲队列机制解决该问题。在rsyslog远程传输服务端的/etc/rsyslog.d目录下新增的远程传输配置文件中,最开头增加如下配置: +可在root权限下通过配置Direct模式,关闭缓冲队列机制解决该问题。在rsyslog远程传输服务端的/etc/rsyslog.d目录下新增的远程传输配置文件中,最开头增加如下配置: ``` $ActionQueueType Direct diff --git "a/content/zh/docs/ApplicationDev/\344\275\277\347\224\250GCC\347\274\226\350\257\221.md" "b/content/zh/docs/ApplicationDev/\344\275\277\347\224\250GCC\347\274\226\350\257\221.md" index c15b6bb206c20bfc8507f0d899675c1a3e677840..6a987cb35038cf518d4e999e0a4a6844171d61a6 100644 --- "a/content/zh/docs/ApplicationDev/\344\275\277\347\224\250GCC\347\274\226\350\257\221.md" +++ "b/content/zh/docs/ApplicationDev/\344\275\277\347\224\250GCC\347\274\226\350\257\221.md" @@ -238,7 +238,7 @@ GCC是一个功能强大的编译器,其 _options_ 参数取值很多,但有 示例:将test1.c和tes2.c分别编译后链接成test可执行文件。 ``` - gcc test1.c test2.c -o test + $ gcc test1.c test2.c -o test ``` - 分别编译各个源文件,之后对编译后输出的目标文件链接。编译时只重新编译修改的文件,未修改的文件不用重新编译。 @@ -246,9 +246,9 @@ GCC是一个功能强大的编译器,其 _options_ 参数取值很多,但有 示例:分别编译test1.c,test2.c,在将二者的目标文件test1.o,test2.o链接成test可执行文件。 ``` - gcc -c test1.c - gcc -c test2.c - gcc -o test1.o test2.o -o test + $ gcc -c test1.c + $ gcc -c test2.c + $ gcc -o test1.o test2.o -o test ``` @@ -284,14 +284,14 @@ GCC是一个功能强大的编译器,其 _options_ 参数取值很多,但有 示例1:从源文件生成动态链接库。 ``` -gcc -fPIC -shared test.c -o libtest.so +$ gcc -fPIC -shared test.c -o libtest.so ``` 示例2:从目标文件生成动态链接库。 ``` -gcc -fPIC -c test.c -o test.o -gcc -shared test.o -o libtest.so +$ gcc -fPIC -c test.c -o test.o +$ gcc -shared test.o -o libtest.so ``` 将一个动态库链接到可执行文件,需要在命令行中列出动态库的名称。 @@ -299,7 +299,7 @@ gcc -shared test.o -o libtest.so 示例:将main.c和libtest.so一起编译成 app.out,当 app.out 运行时,会动态地加载链接库 libtest.so。 ``` -gcc main.c libtest.so -o app.out +$ gcc main.c libtest.so -o app.out ``` 这种方式是直接指定使用当前目录下的libtest.so文件。 @@ -309,7 +309,7 @@ gcc main.c libtest.so -o app.out - 将动态库保存在标准目录下,例如 /usr/lib。 - 把动态库所在路径libaryDIR增加到环境变量LD\_LIBRARY\_PATH中 - export LD\_LIBRARY\_PATH=libraryDIR:$LD\_LIBRARY\_PATH + $ export LD\_LIBRARY\_PATH=libraryDIR:$LD\_LIBRARY\_PATH >![](public_sys-resources/icon-note.gif) **说明:** >LD\_LIBRARY\_PATH为动态库的环境变量。当运行动态库时,若动态库不在缺省文件夹(/lib 和/usr/lib)下,则需要指定环境变量LD\_LIBRARY\_PATH。 @@ -317,8 +317,8 @@ gcc main.c libtest.so -o app.out - 把动态库所在路径libaryDIR增加 /etc/ld.so.conf中然后执行ldconfig或者以动态库所在路径libaryDIR为参数执行ldconfig。 ``` -gcc main.c -L libraryDIR -ltest -o app.out -export LD_LIBRARY_PATH=libraryDIR:$LD_LIBRARY_PATH +$ gcc main.c -L libraryDIR -ltest -o app.out +$ export LD_LIBRARY_PATH=libraryDIR:$LD_LIBRARY_PATH ``` ### 静态链接库 @@ -328,8 +328,8 @@ export LD_LIBRARY_PATH=libraryDIR:$LD_LIBRARY_PATH 示例:将源文件test1.c,test2.c,test3.c编译并打包成静态库。 ``` -gcc -c test1.c test2.c test3.c -ar rcs libtest.a test1.o test2.o test3.o +$ gcc -c test1.c test2.c test3.c +$ ar rcs libtest.a test1.o test2.o test3.o ``` 其中ar是一个备份压缩命令,可以将多个文件打包成一个备份文件(也叫归档文件),也可以从备份文件中提取成员文件。ar最常见的用法是将目标文件打包为静态链接库。 @@ -347,7 +347,7 @@ ar rcs _Sllfilename_ _Targetfilelist_ 示例:创建一个main.c文件来使用静态库 ``` -gcc main.c -L libraryDIR -ltest -o test.out +$ gcc main.c -L libraryDIR -ltest -o test.out ``` 其中libraryDIR为libtest.a库的路径。 @@ -357,16 +357,16 @@ gcc main.c -L libraryDIR -ltest -o test.out ### 使用GCC编译C程序示例 -1. cd到代码目录,此处以用户“/home/code”进行举例。如下所示: +1. cd到代码目录,此处以用户“~/code”进行举例。如下所示: ``` - cd /home/code + $ cd ~/code ``` 2. 编写Hello World程序,保存为helloworld.c,此处以编译Hello World程序进行举例说明。示例如下: ``` - vi helloworld.c + $ vi helloworld.c ``` 代码内容示例: @@ -383,7 +383,7 @@ gcc main.c -L libraryDIR -ltest -o test.out 3. 在代码目录,执行编译,使用命令: ``` - gcc helloworld.c -o helloworld + $ gcc helloworld.c -o helloworld ``` 编译执行未报错,表明执行通过。 @@ -391,28 +391,26 @@ gcc main.c -L libraryDIR -ltest -o test.out 4. 编译完成后,会生成helloworld文件,查看编译结果,示例如下: ``` - # ./helloworld + $ ./helloworld Hello World! ``` ### 使用GCC创建和使用动态链接库示例 -1. cd到代码目录,此处以用户“/home/code”进行举例。并在该目录下创建src,lib,include子目录,分别用于存放源文件,动态库文件和头文件。 +1. cd到代码目录,此处以用户“~/code”进行举例。并在该目录下创建src,lib,include子目录,分别用于存放源文件,动态库文件和头文件。 ``` - cd /home/code - mkdir src - mkdir lib - mkdir include + $ cd ~/code + $ mkdir src lib include ``` - -2. cd到/home/code/src目录,创建2个函数add.c、sub.c,分别实现加、减。 + +2. cd到~/code/src目录,创建2个函数add.c、sub.c,分别实现加、减。 ``` - cd /home/code/src - vi add.c - vi sub.c + $ cd ~/code/src + $ vi add.c + $ vi sub.c ``` add.c代码内容示例: @@ -435,17 +433,17 @@ gcc main.c -L libraryDIR -ltest -o test.out } ``` -3. 将add.c、sub.c源文件创建为动态库libmath.so,并将该动态库存放在/home/code/lib目录。 +3. 将add.c、sub.c源文件创建为动态库libmath.so,并将该动态库存放在~/code/lib目录。 ``` - gcc -fPIC -shared add.c sub.c -o /home/code/lib/libmath.so + $ gcc -fPIC -shared add.c sub.c -o ~/code/lib/libmath.so ``` -4. cd到/home/code/include目录,创建1个头文件math.h,声明函数的头文件。 +4. cd到~/code/include目录,创建1个头文件math.h,声明函数的头文件。 ``` - cd /home/code/include - vi math.h + $ cd ~/code/include + $ vi math.h ``` math.h代码内容示例: @@ -458,11 +456,11 @@ gcc main.c -L libraryDIR -ltest -o test.out #endif ``` -5. cd到/home/code/src目录,创建一个调用add\(\)和sub\(\)的main.c函数。 +5. cd到~/code/src目录,创建一个调用add\(\)和sub\(\)的main.c函数。 ``` - cd /home/code/src - vi main.c + $ cd ~/code/src + $ vi main.c ``` math.c代码内容示例: @@ -484,19 +482,19 @@ gcc main.c -L libraryDIR -ltest -o test.out 6. 将main.c和libmath.so一起编译成math.out。 ``` - gcc main.c -I /home/code/include -L /home/code/lib -lmath -o math.out + $ gcc main.c -I ~/code/include -L ~/code/lib -lmath -o math.out ``` 7. 将动态链接库所在的路径加入到环境变量中。 ``` - export LD_LIBRARY_PATH=/home/code/lib:$LD_LIBRARY_PATH + $ export LD_LIBRARY_PATH=~/code/lib:$LD_LIBRARY_PATH ``` 8. 执行math.out。 ``` - ./math.out + $ ./math.out ``` 执行结果如下所示: @@ -511,21 +509,19 @@ gcc main.c -L libraryDIR -ltest -o test.out ### 使用GCC创建和使用静态链接库示例 -1. cd到代码目录,此处以用户“/home/code”进行举例。并在该目录下创建src,lib,include子目录,分别用于存放源文件,静态库文件和头文件。 +1. cd到代码目录,此处以用户“~/code”进行举例。并在该目录下创建src,lib,include子目录,分别用于存放源文件,静态库文件和头文件。 ``` - cd /home/code - mkdir src - mkdir lib - mkdir include + $ cd ~/code + $ mkdir src lib include ``` - -2. cd到/home/code/src目录,创建2个函数add.c、sub.c,分别实现加、减。 + +2. cd到~/code/src目录,创建2个函数add.c、sub.c,分别实现加、减。 ``` - cd /home/code/src - vi add.c - vi sub.c + $ cd ~/code/src + $ vi add.c + $ vi sub.c ``` add.c代码内容示例: @@ -551,20 +547,20 @@ gcc main.c -L libraryDIR -ltest -o test.out 3. 将add.c、sub.c源文件编译为目标文件add.o、sub.o。 ``` - gcc -c add.c sub.c + $ gcc -c add.c sub.c ``` -4. 将add.o、sub.o目标文件通过ar命令打包成静态库libmath.a,并将该动态库存放在/home/code/lib目录。 +4. 将add.o、sub.o目标文件通过ar命令打包成静态库libmath.a,并将该动态库存放在~/code/lib目录。 ``` - ar rcs /home/code/lib/libmath.a add.o sub.o + $ ar rcs ~/code/lib/libmath.a add.o sub.o ``` -5. cd到/home/code/include目录,创建1个头文件math.h,声明函数的头文件。 +5. cd到~/code/include目录,创建1个头文件math.h,声明函数的头文件。 ``` - cd /home/code/include - vi math.h + $ cd ~/code/include + $ vi math.h ``` math.h代码内容示例: @@ -577,11 +573,11 @@ gcc main.c -L libraryDIR -ltest -o test.out #endif ``` -6. cd到/home/code/src目录,创建一个调用add\(\)和sub\(\)的main.c函数。 +6. cd到~/code/src目录,创建一个调用add\(\)和sub\(\)的main.c函数。 ``` - cd /home/code/src - vi main.c + $ cd ~/code/src + $ vi main.c ``` math.c代码内容示例: @@ -603,13 +599,13 @@ gcc main.c -L libraryDIR -ltest -o test.out 7. 将main.c和libmath.a一起编译成math.out。 ``` - gcc main.c -I /home/code/include -L /home/code/lib -lmath -o math.out + $ gcc main.c -I ~/code/include -L ~/code/lib -lmath -o math.out ``` 8. 执行math.out。 ``` - ./math.out + $ ./math.out ``` 执行结果如下所示: diff --git "a/content/zh/docs/ApplicationDev/\344\275\277\347\224\250JDK\347\274\226\350\257\221.md" "b/content/zh/docs/ApplicationDev/\344\275\277\347\224\250JDK\347\274\226\350\257\221.md" index d08a464eb8304b2b54be54bae1199b5c84af299a..04b393703e35a00edab3461e7a81d8c154137dd6 100644 --- "a/content/zh/docs/ApplicationDev/\344\275\277\347\224\250JDK\347\274\226\350\257\221.md" +++ "b/content/zh/docs/ApplicationDev/\344\275\277\347\224\250JDK\347\274\226\350\257\221.md" @@ -397,16 +397,16 @@ java类库是以包的形式实现的,包是类和接口的集合。java编译 ### 编译不带包的java程序示例 -1. cd到代码目录,此处以用户“/home/code”进行举例。如下所示: +1. cd到代码目录,此处以用户“~/code”进行举例。如下所示: ``` - # cd /home/code + $ cd ~/code ``` 2. 编写Hello World程序,保存为HelloWorld.java,此处以编译Hello World程序进行举例说明。示例如下: ``` - # vi HelloWorld.java + $ vi HelloWorld.java ``` 代码内容示例: @@ -422,7 +422,7 @@ java类库是以包的形式实现的,包是类和接口的集合。java编译 3. 在代码目录,执行编译,使用命令: ``` - # javac HelloWorld.java + $ javac HelloWorld.java ``` 编译执行未报错,表明执行通过。 @@ -430,28 +430,27 @@ java类库是以包的形式实现的,包是类和接口的集合。java编译 4. 编译完成后,会生成 HelloWorld.class 文件,通过java命令可执行查看结果,示例如下: ``` - # java HelloWorld + $ java HelloWorld Hello World ``` ### 编译带包的java程序示例 -1. cd到代码目录,此处以用户“/home/code”进行举例。并在该目录下创建“/home/code/Test/my/example”、“/home/code/Hello/world/developers”、“/home/code/Hi/openos/openeuler”子目录,分别用于存放源文件。 +1. cd到代码目录,此处以用户“~/code”进行举例。并在该目录下创建“~/code/Test/my/example”、“~/code/Hello/world/developers”、“~/code/Hi/openos/openeuler”子目录,分别用于存放源文件。 ``` - cd /home/code - - mkdir -p Test/my/example - mkdir -p Hello/world/developers - mkdir -p Hi/openos/openeuler + $ cd ~/code + $ mkdir -p Test/my/example + $ mkdir -p Hello/world/developers + $ mkdir -p Hi/openos/openeuler ``` - -2. cd到/home/code/Test/my/example目录,创建Test.java。 + +2. cd到~/code/Test/my/example目录,创建Test.java。 ``` - cd /home/code/Test/my/example - vi Test.java + $ cd ~/code/Test/my/example + $ vi Test.java ``` Test.java代码内容示例: @@ -470,11 +469,11 @@ java类库是以包的形式实现的,包是类和接口的集合。java编译 } ``` -3. cd到/home/code/Hello/world/developers目录,创建Hello.java。 +3. cd到~/code/Hello/world/developers目录,创建Hello.java。 ``` - cd /home/code/Hello/world/developers - vi Hello.java + $ cd ~/code/Hello/world/developers + $ vi Hello.java ``` Hello.java代码内容示例: @@ -488,11 +487,11 @@ java类库是以包的形式实现的,包是类和接口的集合。java编译 } ``` -4. cd到/home/code/Hi/openos/openeuler目录,创建Hi.java。 +4. ~/code/Hi/openos/openeuler目录,创建Hi.java。 ``` - cd /home/code/Hi/openos/openeuler - vi Hi.java + $ cd ~/code/Hi/openos/openeuler + $ vi Hi.java ``` Hi.java代码内容示例: @@ -506,20 +505,20 @@ java类库是以包的形式实现的,包是类和接口的集合。java编译 } ``` -5. cd到/home/code,使用javac编译源文件。 +5. cd到~/code,使用javac编译源文件。 ``` - cd /home/code - javac -classpath Hello:Hi Test/my/example/Test.java + $ cd ~/code + $ javac -classpath Hello:Hi Test/my/example/Test.java ``` - 执行完命令后,会在“/home/code/Test/my/example”、“/home/code/Hello/world/developers”、“/home/code/Hi/openos/openeuler”目录下分别生成Test.class、Hello.class、Hi.class文件。 + 执行完命令后,会在“~/code/Test/my/example”、“~/code/Hello/world/developers”、“~/code/Hi/openos/openeuler”目录下分别生成Test.class、Hello.class、Hi.class文件。 -6. cd到/home/code,使用java运行Test程序。 +6. cd到~/code,使用java运行Test程序。 ``` - cd /home/code - java -classpath Test:Hello:Hi my/example/Test + $ cd ~/code + $ java -classpath Test:Hello:Hi my/example/Test ``` 执行结果如下所示: diff --git "a/content/zh/docs/ApplicationDev/\344\275\277\347\224\250make\347\274\226\350\257\221.md" "b/content/zh/docs/ApplicationDev/\344\275\277\347\224\250make\347\274\226\350\257\221.md" index f10d9cc1e071a35e4ae2eb80c084ed1542172efb..69fbf68deb5a3186bad0d84062e2255e7d1d8607 100644 --- "a/content/zh/docs/ApplicationDev/\344\275\277\347\224\250make\347\274\226\350\257\221.md" +++ "b/content/zh/docs/ApplicationDev/\344\275\277\347\224\250make\347\274\226\350\257\221.md" @@ -277,16 +277,18 @@ Makefile文件结构表明了输出的目标,输出目标的依赖对象和生 ### 使用Makefile实现编译的示例 -1. cd到代码目录,此处以用户“/home/code”进行举例。 +1. cd到代码目录,此处以用户“~/code”进行举例。 ``` - cd /home/code + $ cd ~/code ``` -2. 创建1个头文件hello.h和2个函数hello.c、main.c。 +2. 创建1个头文件hello.h和2个函数hello.c、main.c。 ``` - cd /home/code/ + $ vi hello.h + $ vi hello.c + $ vi main.c ``` hello.h代码内容示例: @@ -328,7 +330,7 @@ Makefile文件结构表明了输出的目标,输出目标的依赖对象和生 3. 创建Makefile文件。 ``` - vi Makefile + $ vi Makefile ``` Makefile文件内容示例: @@ -347,7 +349,7 @@ Makefile文件结构表明了输出的目标,输出目标的依赖对象和生 4. 执行make命令。 ``` - make + $ make ``` 命令执行后,会打印Makefile中执行的命令。如果不需要打印该信息,可以在执行make命令是加上参数-s。 @@ -361,7 +363,7 @@ Makefile文件结构表明了输出的目标,输出目标的依赖对象和生 5. 执行./main目标。 ``` - ./main + $ ./main ``` 命令执行后,打印如下信息: diff --git "a/content/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" "b/content/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" index 141b209c3c6aef4cf24e0640d9c308ad203b2352..5b157833da29b925e048feaa15f7fe8835521ae1 100644 --- "a/content/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" +++ "b/content/zh/docs/ApplicationDev/\345\274\200\345\217\221\347\216\257\345\242\203\345\207\206\345\244\207.md" @@ -129,13 +129,13 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 1. 进入到yum源目录。 ``` - cd /etc/yum.repos.d + $ cd /etc/yum.repos.d ``` -2. 新建local.repo文件并编辑local.repo,将repo源文件配置为yum源。 +2. 在root权限下新建local.repo文件并编辑local.repo,将repo源文件配置为yum源。 ``` - vi local.repo + # vi local.repo ``` 编辑local.repo文件的内容如下: @@ -148,8 +148,15 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 enabled=1 - gpgcheck=0 + gpgcheck=1 + gpgkey=http://repo.openeuler.org/openEuler-20.03-LTS/OS/aarch64/RPM-GPG-KEY-openEuler + + + **** + >![](public_sys-resources/icon-note.gif) **说明:** + >- gpgcheck可设置为1或0,1表示进行gpg(GNU Private Guard)校验,0表示不进行gpg校验,gpgcheck可以确定rpm包的来源是有效和安全的。 + >- gpgkey为验证签名用的公钥。 ### 通过挂载ISO的方式配置repo源 @@ -170,10 +177,10 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 6. 单击“aarch64”。 7. 单击“openEuler-20.03-LTS-aarch64-dvd.iso”,将openEuler发布包下载到本地。 8. 单击“openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum”,将openEuler校验文件下载到本地。 - 9. 登录openEuler操作系统,新建用于存放发布包和检验文件的目录,如“/home/iso”。 + 9. 登录openEuler操作系统,新建用于存放发布包和检验文件的目录,如“~/iso”。 ``` - mkdir /home/iso + $ mkdir ~/iso ``` 10. 使用跨平台文件传输工具(如WinSCP)将本地的openEuler发布包和校验文件上传到openEuler操作系统。 @@ -191,18 +198,18 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 6. 单击“aarch64”。 7. 右键单击“openEuler-20.03-LTS-aarch64-dvd.iso”,单击“复制链接地址”,将openEuler发布包地址记录好。 8. 右键单击“openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum”,单击“复制链接地址”,将openEuler校验文件地址记录好。 - 9. 登录openEuler操作系统,新建用于存放发布包和检验文件的目录,如“/home/iso”,并切换到该目录。 + 9. 登录openEuler操作系统,新建用于存放发布包和检验文件的目录,如“~/iso”,并切换到该目录。 ``` - mkdir /home/iso - cd /home/iso + $ mkdir ~/iso + $ cd ~/iso ``` 10. 使用**wget**命令远程下载发布包和检验文件,命令中的 _ipaddriso_ 和 _ipaddrisosum_ 分别为[1.g](#li62369349505)和[1.h](#li9236203405015)中记录的地址。 ``` - wget ipaddriso - wget ipaddrisosum + $ wget ipaddriso + $ wget ipaddrisosum ``` @@ -210,13 +217,13 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 1. 获取校验文件中的校验值。 ``` - cat openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum + $ cat openEuler-20.03-LTS-aarch64-dvd.iso.sha256sum ``` 2. 计算openEuler发布包的sha256校验值。 ``` - sha256sum openEuler-20.03-LTS-aarch64-dvd.iso + $ sha256sum openEuler-20.03-LTS-aarch64-dvd.iso ``` 命令执行完成后,输出校验值。 @@ -227,7 +234,7 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 3. 挂载ISO并配置为repo源。 - 使用mount命令挂载镜像文件。 + 在root权限下使用mount命令挂载镜像文件。 示例如下: @@ -265,12 +272,7 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 gpgcheck=1 gpgkey=file:///mnt/RPM-GPG-KEY-openEuler ``` - - **** - - >![](public_sys-resources/icon-note.gif) **说明:** - >- gpgcheck可设置为1或0,1表示进行gpg(GNU Private Guard)校验,0表示不进行gpg校验,gpgcheck可以确定rpm包的来源是有效和安全的。 - >- gpgkey为签名公钥的存放路径。 + ## 安装软件包 @@ -283,7 +285,7 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 1. 执行**dnf list installed | grep jdk** 查询JDK软件是否已安装。 ``` - dnf list installed | grep jdk + $ dnf list installed | grep jdk ``` 查看命令打印信息,若打印信息中包含“jdk”,表示该软件已经安装了,则不需要再安装。若无任何打印信息,则表示该软件未安装。 @@ -291,33 +293,33 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 2. 清除缓存。 ``` - dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - dnf makecache + $ dnf makecache ``` 4. 查询可安装的JDK软件包。 ``` - dnf search jdk | grep jdk + $ dnf search jdk | grep jdk ``` 查看命令打印信息,选择安装java-x.x.x-openjdk-devel.aarch64软件包。其中x.x.x为版本号。 -5. 安装JDK软件包,以安装java-1.8.0-openjdk-devel软件包为例。 +5. 在root权限下安装JDK软件包,以安装java-1.8.0-openjdk-devel软件包为例。 ``` - dnf install java-1.8.0-openjdk-devel.aarch64 + # dnf install java-1.8.0-openjdk-devel.aarch64 ``` 6. 查询JDK软件版本。 ``` - java -version + $ java -version ``` 查看打印信息,若打印信息中包括“openjdk version "1.8.0\_232"”信息,表示已正确安装,其中1.8.0\_232为版本号。 @@ -328,7 +330,7 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 1. 执行**dnf list installed | grep rpm-build** 查询rpm-build软件是否已安装。 ``` - dnf list installed | grep rpm-build + $ dnf list installed | grep rpm-build ``` 查看命令打印信息,若打印信息中包含“rpm-build”,表示该软件已经安装了,则不需要再安装。若无任何打印信息,则表示该软件未安装。 @@ -336,25 +338,25 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 2. 清除缓存。 ``` - dnf clean all + $ dnf clean all ``` 3. 创建缓存。 ``` - dnf makecache + $ dnf makecache ``` -4. 安装rpm-build软件包。 +4. 在root权限下安装rpm-build软件包。 ``` - dnf install rpm-build + # dnf install rpm-build ``` 5. 查询rpm-build软件版本。 ``` - rpmbuild --version + $ rpmbuild --version ``` @@ -381,35 +383,35 @@ MobaXterm是一款非常优秀的SSH客户端,其自带X Server,可以轻松 查看java路径,命令如下: ``` -# which java +$ which java /usr/bin/java ``` 查看软链接的实际指向目录,命令如下: ``` -# ls -la /usr/bin/java +$ ls -la /usr/bin/java lrwxrwxrwx. 1 root root 22 Mar 6 20:28 /usr/bin/java -> /etc/alternatives/java -# ls -la /etc/alternatives/java +$ ls -la /etc/alternatives/java lrwxrwxrwx. 1 root root 83 Mar 6 20:28 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64/jre/bin/java ``` 发现JDK的真实路径为/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64,设置JAVA\_HOME和PATH,命令如下: ``` -# export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64 -# export PATH=$JAVA_HOME/bin:$PATH +$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.h2.aarch64 +$ export PATH=$JAVA_HOME/bin:$PATH ``` ### 下载安装GTK库 -请确认您具有root权限后,运行如下命令: +运行如下命令: ``` -# dnf list installed | grep gtk +$ dnf list installed | grep gtk ``` -如果显示gtk2或者gtk3,则表示您已安装该库,可以直接跳过进入下一步,否则运行如下命令自动下载安装gtk库。 +如果显示gtk2或者gtk3,则表示您已安装该库,可以直接跳过进入下一步,否则在root权限西下运行如下命令自动下载安装gtk库。 ``` # dnf -y install gtk2 libXtst libXrender xauth @@ -420,13 +422,13 @@ lrwxrwxrwx. 1 root root 83 Mar 6 20:28 /etc/alternatives/java -> /usr/lib/jvm/j 切换到sshd配置目录 ``` -# cd ~/.ssh +$ cd ~/.ssh ``` 如果该目录不存在,则创建目录后再进行切换,创建目录命令如下: ``` -# mkdir ~/.ssh +$ mkdir ~/.ssh ``` 然后在.ssh目录下编辑config文件并保存: @@ -434,7 +436,7 @@ lrwxrwxrwx. 1 root root 83 Mar 6 20:28 /etc/alternatives/java -> /usr/lib/jvm/j 1. 使用vim打卡config文件 ``` - # vim config + $ vim config ``` 2. 将以下内容添加到文件末尾并保存: @@ -451,12 +453,12 @@ lrwxrwxrwx. 1 root root 83 Mar 6 20:28 /etc/alternatives/java -> /usr/lib/jvm/j 在执行如上环境配置后,您就可以下载使用IntelliJ IDEA了。鉴于最新版的IntelliJ IDEA和openEuler系统在部分功能上有兼容性问题,建议您从此[链接](https://www.jetbrains.com/idea/download/other.html)下载2018版本linux压缩包。下载好后把压缩包移到您想要安装该软件的目录,对压缩包进行解压: ``` -# tar xf ideaIC-2018.3.tar.gz +$ tar xf ideaIC-2018.3.tar.gz ``` 解压后切换到IntelliJ IDEA的目录下并运行。 ``` -# cd ./idea-IC-183.4284.148 -# bin/idea.sh & +$ cd ./idea-IC-183.4284.148 +$ bin/idea.sh & ``` diff --git "a/content/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" "b/content/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" index 6518e0def9388cfe6dc423ffd7b972086a6d9ec2..e8251e05948a8ccce8c978014fc84e26a71ca12c 100644 --- "a/content/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" +++ "b/content/zh/docs/ApplicationDev/\346\236\204\345\273\272RPM\345\214\205.md" @@ -24,13 +24,13 @@ RPM打包的时候需要编译源码,需要把编译好的配置文件、二进制命令文件等放到合适的位置,还要根据需要对RPM的包进行测试,这些都需要先有一个“工作空间”。rpmbuild命令使用一套标准化的“工作空间”: ``` -# rpmdev-setuptree +$ rpmdev-setuptree ``` rpmdev-setuptree这个命令就是安装 rpmdevtools 带来的。可以看到运行了这个命令之后,在“/root“目录(非root用户为“/home/用户名“目录)下多了一个 rpmbuild 的文件夹,目录结构如下: ``` -# tree rpmbuild +$ tree rpmbuild rpmbuild ├── BUILD ├── RPMS @@ -378,7 +378,7 @@ rpmbuild命令格式为:rpmbuild \[_option_...\] ### 创建Hello World RPM包 -这里以GNU“Hello World” 项目的打包过程作为示例,包含了典型的FOSS(Free and Open Source Software) 软件项目相关的最常用的外围组件,其中包括配置/编译/安装环境、文档、国际化等等。 +这里以GNU “Hello World” 项目的打包过程作为示例,包含了典型的FOSS(Free and Open Source Software) 软件项目相关的最常用的外围组件,其中包括配置/编译/安装环境、文档、国际化等等。 #### 下载源码 @@ -386,16 +386,17 @@ rpmbuild命令格式为:rpmbuild \[_option_...\] 我们直接下载官方例子的源码,使用如下命令: ``` -# cd ~/rpmbuild/SOURCES -# wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz +$ cd ~/rpmbuild/SOURCES +$ wget http://ftp.gnu.org/gnu/hello/hello-2.10.tar.gz ``` #### 编辑SPEC文件 -新建spec文件,参考命令如下: +在**~/rpmbuild/SPECS**目录下新建spec文件,参考命令如下: ``` -# vi hello.spec +$ cd ~/rpmbuild/SPECS +$ vi hello.spec ``` 在文件中写入对应内容后保存文件。文件内容示例如下,请根据实际情况修改相应字段。 @@ -468,13 +469,13 @@ fi 构建源码、二进制和包含调试信息的软件包,在spec文件所在目录执行如下命令: ``` -# rpmbuild -ba hello.spec +$ rpmbuild -ba hello.spec ``` 执行成功后,查看结果,使用如下命令: ``` -# tree ~/rpmbuild/*RPMS +$ tree ~/rpmbuild/*RPMS /home/testUser/rpmbuild/RPMS └── aarch64 @@ -515,7 +516,7 @@ OBS使用工程组织软件包。基础的权限控制、相关的存仓库和 使用OBS网页端,修改已有软件的源代码,并将修改后的源文件构建为RPM软件包的操作方法如下: -1. 登录OBS界面,地址为:[http://openeuler-build.huawei.com/](http://openeuler-build.huawei.com/)。 +1. 登录OBS界面,地址为:[https://build.openeuler.org/](https://build.openeuler.org/)。 2. 单击“All Projects”进入所有工程页面。 3. 单击需要修改的对应工程,进入该工程的详情页面,例如单击“openEuler:Mainline”。 4. 在工程详情页面的搜索框查找需要修改的软件包,然后单击该软件包包名,进入该软件包详请页面。 @@ -636,16 +637,15 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 1. 打开\~/.oscrc,命令如下: ``` - # vi ~/.oscrc + $ vi ~/.oscrc ``` - 2. 在\~/.oscrc中添加user和pass字段,如下所示,它们的取值 _userName_ 和 _passWord_ 分别是用户在OBS网页([http://openeuler-build.huawei.com/](http://openeuler-build.huawei.com/))上已经注册的账号和密码。 + 2. 在\~/.oscrc中添加user和pass字段,如下所示,它们的取值 _userName_ 和 _passWord_ 分别是用户在OBS网页([https://build.openeuler.org/](https://build.openeuler.org/))上已经注册的账号和密码。 ``` [general] - apiurl = http://openeuler-build.huawei.com/ - no_verify = 1 - [http://openeuler-build.huawei.com/] + apiurl = https://build.openeuler.org/ + [https://build.openeuler.org/] user=userName pass=passWord ``` @@ -658,7 +658,7 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 1. 通过拷贝已有工程,创建属于用户自己的子工程。例如将openEuler:Mainline工程下的zlib软件包到新分支,参考命令如下: ``` - # osc branch openEuler:Mainline zlib + $ osc branch openEuler:Mainline zlib ``` 回显如下所示,说明在用户testUser下创建了新的分支工程home:testUser:branches:openEuler:Mainline。 @@ -671,7 +671,7 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 2. 将需要修改软件包的相关配置文件(例如\_service)下载到本地当前路径。其中 _testUser_ 为\~/.oscrc配置文件中配置的账户名称,请根据实际情况修改。 ``` - # osc co home:testUser:branches:openEuler:Mainline/zlib + $ osc co home:testUser:branches:openEuler:Mainline/zlib ``` 回显如下所示: @@ -685,8 +685,8 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 3. 进入本地子工程目录,并将软件包远程代码同步到本地。 ``` - # cd home:testUser:branches:openEuler:Mainline/zlib - # osc up -S + $ cd home:testUser:branches:openEuler:Mainline/zlib + $ osc up -S ``` 回显如下所示: @@ -707,26 +707,26 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 1. 重命名源文件,然后将重命名后的源文件添加到OBS暂存中。 ``` - # rm -f _service;for file in `ls | grep -v .osc`;do new_file=${file##*:};mv $file $new_file;done - # osc addremove * + $ rm -f _service;for file in `ls | grep -v .osc`;do new_file=${file##*:};mv $file $new_file;done + $ osc addremove * ``` 2. 修改源代码和spec文件,并将对应软件包的所有修改同步到OBS服务器。参考命令如下,-m参数后的信息为提交记录。 ``` - # osc ci -m "commit log" + $ osc ci -m "commit log" ``` 3. 获取当前工程的仓库名称和架构,参考命令如下: ``` - # osc repos home:testUser:branches:openEuler:Mainline + $ osc repos home:testUser:branches:openEuler:Mainline ``` 4. 修改提交成功后,OBS会自动开始编译软件包。可以通过如下命令,查看对应仓库的编译日志,其中 _standard_aarch64_ 、 _aarch64_ 分别为查询所得仓库名称和架构。 ``` - # osc buildlog standard_aarch64 aarch64 + $ osc buildlog standard_aarch64 aarch64 ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -742,22 +742,22 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 1. 根据新增软件包的依赖情况,基于合适的工程,创建属于用户自己的个人工程。例如基于 _openEuler:Mainline_ 工程的 zlib 创建工程的参考命令如下,zlib 为工程下的任一软件包。 ``` - # osc branch openEuler:Mainline zlib + $ osc branch openEuler:Mainline zlib ``` 2. 删除创建工程时新增的无用软件包。例如删除zlib软件包的参考命令如下: ``` - # cd home:testUser:branches:openEuler:Mainline - # osc rm zlib - # osc commit -m "commit log" + $ cd home:testUser:branches:openEuler:Mainline + $ osc rm zlib + $ osc commit -m "commit log" ``` 3. 在个人工程下创建新增的软件包。例如新增软件包 my-first-obs-package命令如下: ``` - # mkdir my-first-obs-package - # cd my-first-obs-package + $ mkdir my-first-obs-package + $ cd my-first-obs-package ``` @@ -767,22 +767,22 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 2. 修改源代码和spec文件,并将对应软件包的所有文件上传到OBS服务器。参考命令如下,-m 参数后的信息为提交记录。 ``` - # cd home:testUser:branches:openEuler:Mainline - # osc add my-first-obs-package - # osc ci -m "commit log" + $ cd home:testUser:branches:openEuler:Mainline + $ osc add my-first-obs-package + $ osc ci -m "commit log" ``` 3. 获取当前工程的仓库名称和架构,参考命令如下: ``` - # osc repos home:testUser:branches:openEuler:Mainline + $ osc repos home:testUser:branches:openEuler:Mainline ``` 4. 修改提交成功后,OBS会自动开始编译软件包。可以通过如下命令,查看对应仓库的编译日志,其中 _standard_aarch64_ 、 _aarch64_ 分别为查询所得仓库名称和架构。 ``` - # cd home:testUser:branches:openEuler:Mainline/my-first-obs-package - # osc buildlog standard_aarch64 aarch64 + $ cd home:testUser:branches:openEuler:Mainline/my-first-obs-package + $ osc buildlog standard_aarch64 aarch64 ``` >![](public_sys-resources/icon-note.gif) **说明:** @@ -794,7 +794,7 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 RPM软件包构建完成后,使用osc获取对应RPM软件包的命令如下: ``` -# osc getbinaries home:testUser:branches:openEuler:Mainline my-first-obs-package standard_aarch64 aarch64 +$ osc getbinaries home:testUser:branches:openEuler:Mainline my-first-obs-package standard_aarch64 aarch64 ``` 命令中的各参数含义如下,请用户根据实际情况修改: diff --git "a/content/zh/docs/Container/\345\212\250\346\200\201\345\212\240\350\275\275\345\206\205\346\240\270\346\250\241\345\235\227.md" "b/content/zh/docs/Container/\345\212\250\346\200\201\345\212\240\350\275\275\345\206\205\346\240\270\346\250\241\345\235\227.md" index 2e5edd1d0676a69525e188fe02f6473164d81b8a..d5c65f9e4ea5c4b5047863f2acaba8ff08772c0e 100644 --- "a/content/zh/docs/Container/\345\212\250\346\200\201\345\212\240\350\275\275\345\206\205\346\240\270\346\250\241\345\235\227.md" +++ "b/content/zh/docs/Container/\345\212\250\346\200\201\345\212\240\350\275\275\345\206\205\346\240\270\346\250\241\345\235\227.md" @@ -2,7 +2,7 @@ ## 功能描述 -容器内业务可能依赖某些内核模块,可通过设置环境变量的方式,在系统容器启动前动态加载容器中业务需要的内核模块到宿主机,此特性需要配合isulad-hooks一起使用,具体使用可参看"容器资源动态管理(syscontainer-tools)"章节。 +容器内业务可能依赖某些内核模块,可通过设置环境变量的方式,在系统容器启动前动态加载容器中业务需要的内核模块到宿主机,此特性需要配合syscontainer-hooks一起使用,具体使用可参看"容器资源动态管理(syscontainer-tools)"章节。 ## 参数说明 @@ -28,7 +28,7 @@ ## 约束限制 - 如果加载的内核模块是未经过验证的,或者跟宿主机已有模块冲突的场景,会导致宿主机出现不可预知问题,在做加载内核模块时需要谨慎操作。 -- 动态加载内核模块通过将需要加载的内核模块传递给容器,此功能是依靠isulad-tools捕获到容器启动的环境变量实现,依赖isulad-tools的正确安装部署。 +- 动态加载内核模块通过将需要加载的内核模块传递给容器,此功能是依靠syscontainer-tools捕获到容器启动的环境变量实现,依赖syscontainer-tools的正确安装部署。 - 加载的内核模块需要手动进行删除。 ## 使用示例 @@ -37,7 +37,7 @@ ``` [root@localhost ~]# lsmod | grep ip_vs -[root@localhost ~]# isula run -tid -e KERNEL_MODULES=ip_vs,ip_vs_wrr --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/myrootfs none init +[root@localhost ~]# isula run -tid -e KERNEL_MODULES=ip_vs,ip_vs_wrr --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/myrootfs none init ae18c4281d5755a1e153a7bff6b3b4881f36c8e528b9baba8a3278416a5d0980 [root@localhost ~]# lsmod | grep ip_vs ip_vs_wrr 16384 0 @@ -48,6 +48,6 @@ libcrc32c 16384 3 nf_conntrack,nf_nat,ip_vs ``` >![](public_sys-resources/icon-note.gif) **说明:** ->- 宿主机需要安装isulad-tools。 ->- 需要指定--hooks-spec为isulad hooks。 +>- 宿主机需要安装syscontainer-tools。 +>- 需要指定--hooks-spec为syscontainer hooks。 diff --git "a/content/zh/docs/Container/\345\256\211\345\205\250\346\200\247\345\222\214\351\232\224\347\246\273\346\200\247.md" "b/content/zh/docs/Container/\345\256\211\345\205\250\346\200\247\345\222\214\351\232\224\347\246\273\346\200\247.md" index 7f85248df59155c1513a9a2710587011cde4a13b..200736c81e65491a747287f965ca92f53ea6ff4d 100644 --- "a/content/zh/docs/Container/\345\256\211\345\205\250\346\200\247\345\222\214\351\232\224\347\246\273\346\200\247.md" +++ "b/content/zh/docs/Container/\345\256\211\345\205\250\346\200\247\345\222\214\351\232\224\347\246\273\346\200\247.md" @@ -213,12 +213,12 @@ exit ### 接口说明 -系统容器对外提供两个工具包:一个是lxcfs软件,另外一个是配合lxcfs一起使用的lxcfs-toolkit工具。其中lxcfs作为宿主机daemon进程常驻,lxcfs-toolkit通过hook机制将宿主机的lxcfs文件系统绑定挂载到容器。 +系统容器对外提供两个工具包:一个是lxcfs软件,另外一个是配合lxcfs一起使用的lxcfs-tools工具。其中lxcfs作为宿主机daemon进程常驻,lxcfs-tools通过hook机制将宿主机的lxcfs文件系统绑定挂载到容器。 -lxcfs-toolkit命令行格式如下: +lxcfs-tools命令行格式如下: ``` -lxcfs-toolkit [OPTIONS] COMMAND [COMMAND_OPTIONS] +lxcfs-tools [OPTIONS] COMMAND [COMMAND_OPTIONS] ``` @@ -283,10 +283,10 @@ lxcfs-toolkit [OPTIONS] COMMAND [COMMAND_OPTIONS] ### 使用示例 -1. 首先需要安装lxcfs和lxcfs-toolkit这两个包,并启动lxcfs服务。 +1. 首先需要安装lxcfs和lxcfs-tools这两个包,并启动lxcfs服务。 ``` - [root@localhost ~]# yum install lxcfs lxcfs-toolkit + [root@localhost ~]# yum install lxcfs lxcfs-tools [root@localhost ~]# systemctl start lxcfs ``` diff --git "a/content/zh/docs/Container/\345\256\211\350\243\205\346\214\207\345\257\274.md" "b/content/zh/docs/Container/\345\256\211\350\243\205\346\214\207\345\257\274.md" index 204899cbec0479b6a9d747f10defded621a4584d..fbcd663a6015c6b18d9b3b7e887ac5b045549b08 100644 --- "a/content/zh/docs/Container/\345\256\211\350\243\205\346\214\207\345\257\274.md" +++ "b/content/zh/docs/Container/\345\256\211\350\243\205\346\214\207\345\257\274.md" @@ -12,7 +12,7 @@ 2. 安装系统容器依赖包。 ``` - # yum install isulad-tools authz isulad-lxcfs-toolkit lxcfs + # yum install syscontainer-tools authz lxcfs-tools lxcfs ``` 3. 查看iSulad是否已经启动。 diff --git "a/content/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\345\212\250\346\200\201\347\256\241\347\220\206.md" "b/content/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\345\212\250\346\200\201\347\256\241\347\220\206.md" index 720cb8835ac73b4abf167a95cce048457d011151..c09fa4af20f3643963297e7a371796c88cf78262 100644 --- "a/content/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\345\212\250\346\200\201\347\256\241\347\220\206.md" +++ "b/content/zh/docs/Container/\345\256\271\345\231\250\350\265\204\346\272\220\345\212\250\346\200\201\347\256\241\347\220\206.md" @@ -19,12 +19,12 @@ ### 功能描述 -isulad-tools支持将宿主机上的块设备(比如磁盘、LVM)或字符设备(比如GPU、binner、fuse)添加到容器中。在容器中使用该设备,例如可以对磁盘进行fdisk格式化,写入fs等操作。在容器不需要设备时,isulad-tools可以将设备从容器中删除,归还宿主机。 +syscontainer-tools支持将宿主机上的块设备(比如磁盘、LVM)或字符设备(比如GPU、binner、fuse)添加到容器中。在容器中使用该设备,例如可以对磁盘进行fdisk格式化,写入fs等操作。在容器不需要设备时,syscontainer-tools可以将设备从容器中删除,归还宿主机。 ### 命令格式 ``` -isulad-tools [COMMADN][OPTIONS] [ARG...] +syscontainer-tools [COMMADN][OPTIONS] [ARG...] ``` 其中: @@ -104,16 +104,16 @@ ARG:命令对应的参数。 - 添加/删除设备的时机可以是容器实例非运行状态,完成操作后启动容器,容器内会有体现;也可以在容器运行时(running)动态添加。 - 不能在容器内和host上并发进行fdisk对磁盘的格式化写入,会影响容器磁盘使用。 -- add-device将磁盘添加到容器的特定目录时,如果容器内的父目录为多级目录(比如/dev/a/b/c/d/e...)且目录层级不存在,则isulad-tools会自动在容器内创建对应目录;当删除时,不会将创建的父目录删除。如果用户下一次add-device到该父目录,则会提示已经存在无法添加成功。 +- add-device将磁盘添加到容器的特定目录时,如果容器内的父目录为多级目录(比如/dev/a/b/c/d/e...)且目录层级不存在,则syscontainer-tools会自动在容器内创建对应目录;当删除时,不会将创建的父目录删除。如果用户下一次add-device到该父目录,则会提示已经存在无法添加成功。 - add-device添加磁盘、更新磁盘参数时,配置磁盘Qos;当配置磁盘Qos的read/write bps、read/write IOPS值时,不建议配置值过小,当设置过小时,会造成磁盘表现为不可读(实际原因是速度过慢),最终影响业务功能。 - 使用--blkio-weight-device来限制指定块设备的权重,如果当前块设备仅支持BFQ模式,可能会报错,提示用户检查当前OS环境是否支持BFQ块设备权重值设置。 ### 使用示例 -- 启动一个系统容器,指定hook spec为isulad hook执行配置脚本 +- 启动一个系统容器,指定hook spec为syscontainer hook执行配置脚本 ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init eed1096c8c7a0eca6d92b1b3bc3dd59a2a2adf4ce44f18f5372408ced88f8350 ``` @@ -121,7 +121,7 @@ ARG:命令对应的参数。 - 添加一个块设备到容器 ``` - [root@localhost ~]# isulad-tools add-device ee /dev/sdb:/dev/sdb123 + [root@localhost ~]# syscontainer-tools add-device ee /dev/sdb:/dev/sdb123 Add device (/dev/sdb) to container(ee,/dev/sdb123) done. [root@localhost ~]# isula exec ee fdisk -l /dev/sdb123 Disk /dev/sdb123: 50 GiB, 53687091200 bytes, 104857600 sectors @@ -139,14 +139,14 @@ ARG:命令对应的参数。 - 更新设备信息 ``` - [root@localhost ~]# isulad-tools update-device --device-read-bps /dev/sdb:10m ee + [root@localhost ~]# syscontainer-tools update-device --device-read-bps /dev/sdb:10m ee Update read bps for device (/dev/sdb,10485760) done. ``` - 删除设备 ``` - [root@localhost ~]# isulad-tools remove-device ee /dev/sdb:/dev/sdb123 + [root@localhost ~]# syscontainer-tools remove-device ee /dev/sdb:/dev/sdb123 Remove device (/dev/sdb) from container(ee,/dev/sdb123) done. Remove read bps for device (/dev/sdb) done. ``` @@ -156,12 +156,12 @@ ARG:命令对应的参数。 ### 功能描述 -isulad-tools支持将宿主机上的物理网卡或虚拟网卡插入到容器,在不使用网卡的时候从容器中删除归还给宿主机,并且可以动态修改网卡配置。插入物理网卡即把宿主机上一块网卡直接添加到容器中,插入虚拟网卡则需要先创建一对veth pair,之后将一端插入到容器中。 +syscontainer-tools支持将宿主机上的物理网卡或虚拟网卡插入到容器,在不使用网卡的时候从容器中删除归还给宿主机,并且可以动态修改网卡配置。插入物理网卡即把宿主机上一块网卡直接添加到容器中,插入虚拟网卡则需要先创建一对veth pair,之后将一端插入到容器中。 ### 命令格式 ``` -isulad-tools [COMMADN][OPTIONS] +syscontainer-tools [COMMADN][OPTIONS] ``` 其中: @@ -223,18 +223,18 @@ container\_id:容器id。 - 支持添加物理网卡(eth)和虚拟网卡(veth)两种类型。 - 在添加网卡时可以同时对网卡进行配置,参数包括--ip/--mac/--bridge/--mtu/--qlen。 - 支持最多添加8个物理网卡到容器。 -- 使用isulad-tools add-nic向容器添加eth网卡后,如果不加hook,在容器退出前必须手工将nic删除,否则在host上的eth网卡的名字会被更改成容器内的名字。 +- 使用syscontainer-tools add-nic向容器添加eth网卡后,如果不加hook,在容器退出前必须手工将nic删除,否则在host上的eth网卡的名字会被更改成容器内的名字。 - 对于物理网卡(1822 vf网卡除外),add-nic必须使用原mac地址,update-nic禁止修改mac地址,容器内也不允许修改mac地址。 -- 使用isulad-tools add-nic时,设置mtu值,设置范围跟具体的网卡型号有关。 -- 使用isulad-tools向容器添加网卡和路由时,建议先执行add-nic添加网卡,然后执行add-route添加路由;使用isulad-tools从容器删除网卡和路由时,建议先执行remove-route删除路由,然后执行remove-nic删除网卡。 -- 使用isulad-tools添加网卡时,一块网卡只能添加到一个容器中。 +- 使用syscontainer-tools add-nic时,设置mtu值,设置范围跟具体的网卡型号有关。 +- 使用syscontainer-tools向容器添加网卡和路由时,建议先执行add-nic添加网卡,然后执行add-route添加路由;使用syscontainer-tools从容器删除网卡和路由时,建议先执行remove-route删除路由,然后执行remove-nic删除网卡。 +- 使用syscontainer-tools添加网卡时,一块网卡只能添加到一个容器中。 ### 使用示例 -- 启动一个系统容器,指定hook spec为isulad hook执行配置脚本: +- 启动一个系统容器,指定hook spec为syscontainer hook执行配置脚本: ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init 2aaca5c1af7c872798dac1a468528a2ccbaf20b39b73fc0201636936a3c32aa8 ``` @@ -242,14 +242,14 @@ container\_id:容器id。 - 添加一个虚拟网卡到容器 ``` - [root@localhost ~]# isulad-tools add-nic --type "veth" --name abc2:bcd2 --ip 172.17.28.5/24 --mac 00:ff:48:13:xx:xx --bridge docker0 2aaca5c1af7c + [root@localhost ~]# syscontainer-tools add-nic --type "veth" --name abc2:bcd2 --ip 172.17.28.5/24 --mac 00:ff:48:13:xx:xx --bridge docker0 2aaca5c1af7c Add network interface to container 2aaca5c1af7c (bcd2,abc2) done ``` - 添加一个物理网卡到容器 ``` - [root@localhost ~]# isulad-tools add-nic --type "eth" --name eth3:eth1 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 2aaca5c1af7c + [root@localhost ~]# syscontainer-tools add-nic --type "eth" --name eth3:eth1 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 2aaca5c1af7c Add network interface to container 2aaca5c1af7c (eth3,eth1) done ``` @@ -261,12 +261,12 @@ container\_id:容器id。 ### 功能描述 -isulad-tools工具可以对系统容器进行动态添加/删除路由表。 +syscontainer-tools工具可以对系统容器进行动态添加/删除路由表。 ### 命令格式 ``` -isulad-tools [COMMADN][OPTIONS] [ARG...] +syscontainer-tools [COMMADN][OPTIONS] [ARG...] ``` 其中: @@ -333,31 +333,31 @@ ARG:命令对应的参数。 ### 约束限制 -- 使用isulad-tools向容器添加网卡和路由时,建议先执行add-nic添加网卡,然后执行add-route添加路由;使用isulad-tools从容器删除网卡和路由时,建议先执行remove-route删除路由,然后执行remove-nic删除网卡。 +- 使用syscontainer-tools向容器添加网卡和路由时,建议先执行add-nic添加网卡,然后执行add-route添加路由;使用syscontainer-tools从容器删除网卡和路由时,建议先执行remove-route删除路由,然后执行remove-nic删除网卡。 - 向容器内添加路由规则时,需确保所添加的路由规则与容器内现有的路由规则不会产生冲突。 ### 使用示例 -- 启动一个系统容器,指定hook spec为isulad hook执行配置脚本: +- 启动一个系统容器,指定hook spec为syscontainer hook执行配置脚本: ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init 0d2d68b45aa0c1b8eaf890c06ab2d008eb8c5d91e78b1f8fe4d37b86fd2c190b ``` -- isulad-tools向系统容器添加一块物理网卡: +- syscontainer-tools向系统容器添加一块物理网卡: ``` - [root@localhost ~]# isulad-tools add-nic --type "eth" --name enp4s0:eth123 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 0d2d68b45aa0 + [root@localhost ~]# syscontainer-tools add-nic --type "eth" --name enp4s0:eth123 --ip 172.17.28.6/24 --mtu 1300 --qlen 2100 0d2d68b45aa0 Add network interface (enp4s0) to container (0d2d68b45aa0,eth123) done ``` -- isulad-tools添加一条路由规则到系统容器,注意格式需按照'\[\{"dest":"default", "gw":"192.168.10.1"\},\{"dest":"192.168.0.0/16","dev":"eth0","src":"192.168.1.2"\}\]'来配置。如果dest为空会自动填成default。 +- syscontainer-tools添加一条路由规则到系统容器,注意格式需按照'\[\{"dest":"default", "gw":"192.168.10.1"\},\{"dest":"192.168.0.0/16","dev":"eth0","src":"192.168.1.2"\}\]'来配置。如果dest为空会自动填成default。 ``` - [root@localhost ~]# isulad-tools add-route 0d2d68b45aa0 '[{"dest":"172.17.28.0/32", "gw":"172.17.28.5","dev":"eth123"}]' + [root@localhost ~]# syscontainer-tools add-route 0d2d68b45aa0 '[{"dest":"172.17.28.0/32", "gw":"172.17.28.5","dev":"eth123"}]' Add route to container 0d2d68b45aa0, route: {dest:172.17.28.0/32,src:,gw:172.17.28.5,dev:eth123} done ``` @@ -376,12 +376,12 @@ ARG:命令对应的参数。 ### 功能描述 -普通容器仅支持在创建时指定--volume参数将宿主机的目录/卷挂载到容器实现资源共享,但是无法在容器运行时将挂载到容器中的目录/卷卸载掉,也不支持将宿主机的目录/卷挂载到容器。系统容器可以通过isulad-tools工具实现动态将宿主机的目录/卷挂载到容器,以及将容器中的目录/卷进行卸载。 +普通容器仅支持在创建时指定--volume参数将宿主机的目录/卷挂载到容器实现资源共享,但是无法在容器运行时将挂载到容器中的目录/卷卸载掉,也不支持将宿主机的目录/卷挂载到容器。系统容器可以通过syscontainer-tools工具实现动态将宿主机的目录/卷挂载到容器,以及将容器中的目录/卷进行卸载。 ### 命令格式 ``` -isulad-tools [COMMADN][OPTIONS] [ARG...] +syscontainer-tools [COMMADN][OPTIONS] [ARG...] ``` 其中: @@ -455,18 +455,18 @@ ARG:命令对应的参数。 ### 使用示例 -- 启动一个系统容器,指定hook spec为isulad hook执行配置脚本: +- 启动一个系统容器,指定hook spec为syscontainer hook执行配置脚本: ``` - [root@localhost ~]# isula run -tid --hook-spec /etc/isulad-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init + [root@localhost ~]# isula run -tid --hook-spec /etc/syscontainer-tools/hookspec.json --system-container --external-rootfs /root/root-fs none init e45970a522d1ea0e9cfe382c2b868d92e7b6a55be1dd239947dda1ee55f3c7f7 ``` -- isulad-tools将宿主机某个目录挂载到容器,实现资源共享: +- syscontainer-tools将宿主机某个目录挂载到容器,实现资源共享: ``` - [root@localhost ~]# isulad-tools add-path e45970a522d1 /home/test123:/home/test123 + [root@localhost ~]# syscontainer-tools add-path e45970a522d1 /home/test123:/home/test123 Add path (/home/test123) to container(e45970a522d1,/home/test123) done. ``` @@ -479,10 +479,10 @@ ARG:命令对应的参数。 hello world ``` -- isulad-tools将挂载目录从容器内删除: +- syscontainer-tools将挂载目录从容器内删除: ``` - [root@localhost ~]# isulad-tools remove-path e45970a522d1 /home/test123:/home/test123 + [root@localhost ~]# syscontainer-tools remove-path e45970a522d1 /home/test123:/home/test123 Remove path (/home/test123) from container(e45970a522d1,/home/test123) done [root@localhost ~]# isula exec e45970a522d1 bash [root@localhost /]# ls /home/test123/helloworld diff --git "a/content/zh/docs/Virtualization/\347\256\241\347\220\206\350\256\276\345\244\207.md" "b/content/zh/docs/Virtualization/\347\256\241\347\220\206\350\256\276\345\244\207.md" index b214eaf8925cfcbc6f67be97ad2a0e67fe95cdf1..25ef2a6f90419de67d48c8d3e6558b9f61cdf146 100644 --- "a/content/zh/docs/Virtualization/\347\256\241\347\220\206\350\256\276\345\244\207.md" +++ "b/content/zh/docs/Virtualization/\347\256\241\347\220\206\350\256\276\345\244\207.md" @@ -285,7 +285,7 @@ PCI直通是指将host上的物理PCI设备直接呈现给一台虚拟机,供 >![](public_sys-resources/icon-note.gif) **说明:** >VFIO直通方式的最小直通单位是iommu\_group,host根据硬件上的ACS位,来划分iommu\_group。同一个iommu\_group中的设备只允许直通给同一台虚拟机(一个PCI设备上的若干个function,如果属于同一个iommu\_group,只允许直通给一个虚拟机使用)。 -### SR-IOV直通">SR-IOV直通 +### SR-IOV直通 #### 概述 @@ -455,6 +455,29 @@ SR-IOV(Single Root I/O Virtualizaiton)是一种基于硬件的虚拟化解 >echo 0 > /sys/class/net/eth0/device/sriov_numvfs >``` +#### HPRE加速器SR-IOV直通 + +加速器引擎是TaiShan 200服务器基于Kunpeng 920服务器提供的硬件加速解决方案。HPRE加速器用于加速SSL/TLS应用,可以显著降低处理器消耗,提高处理器效率。 +在鲲鹏服务器上,需要把主机Host上的HPRE加速器的VF直通给虚拟机,供虚拟机内部业务使用。 + +**表 1** HPRE加速器说明 + +| | 说明 | +|-------------|-----------------------------------------------------------------------------------------------------| +| 设备名称 | Hi1620 on-chip RSA/DH security algorithm accelerator (HPRE engine) | +| 功能 | 模幂运算、RSA密钥对运算、DH计算、部分大数辅助运算(模幂、模乘、取模、乘法、模逆、素数测试、互质测试) | +| VendorID | 0x19E5 | +| PF DeviceID | 0xA258 | +| VF DeviceID | 0xA259 | +| 最大VF数量 | 一个HPRE PF最多支持创建63个VF | + + +>![](public_sys-resources/icon-note.gif) **说明:** +>当虚拟机正在使用VF设备时,不允许卸载Host上的驱动,加速器不支持热插拔。 +>VF操作(VFNUMS为0表示关闭VF,hpre_num用来标识具体的加速器设备): +>``` +>echo $VFNUMS > /sys/class/uacce/hisi_hpre-$hpre_num/device/sriov_numvfs +>``` ## 管理虚拟机USB diff --git a/content/zh/menu/index.md b/content/zh/menu/index.md index 4b1c195a18c344d72dd390c26c49672fa0cc6d9b..d6780444537daf3f432c737de71cc763c97e8b85 100644 --- a/content/zh/menu/index.md +++ b/content/zh/menu/index.md @@ -26,7 +26,7 @@ headless: true - [管理员指南]({{< relref "./docs/Administration/administration.md" >}}) - [查看系统信息]({{< relref "./docs/Administration/查看系统信息.md" >}}) - [基础配置]({{< relref "./docs/Administration/基础配置.md" >}}) - - [管理用户]({{< relref "./docs/Administration/管理用户.md" >}}) + - [管理用户和用户组]({{< relref "./docs/Administration/管理用户和用户组.md" >}}) - [使用DNF管理软件包]({{< relref "./docs/Administration/使用DNF管理软件包.md" >}}) - [管理服务]({{< relref "./docs/Administration/管理服务.md" >}}) - [管理进程]({{< relref "./docs/Administration/管理进程.md" >}})