From 72b673dd547819748d821aa4592bfc5795a5571f Mon Sep 17 00:00:00 2001 From: fhxing168 Date: Tue, 26 May 2020 20:24:55 +0800 Subject: [PATCH 1/3] Modfiy the root user. --- .../Administration/configuring-the-network.md | 125 +++++++++--------- ...15\347\275\256\347\275\221\347\273\234.md" | 108 +++++++-------- 2 files changed, 118 insertions(+), 115 deletions(-) diff --git a/content/en/docs/Administration/configuring-the-network.md b/content/en/docs/Administration/configuring-the-network.md index 2f73c57f0..370ae8c6a 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/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 e8a94dc8d..8c476a94f 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 @@ -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 -- Gitee From a331aaabbed922b949a860ddecc34b3de6d1c94f Mon Sep 17 00:00:00 2001 From: fhxing168 Date: Mon, 1 Jun 2020 19:00:46 +0800 Subject: [PATCH 2/3] Modify the root user. --- .../configuring-the-ftp-server.md | 58 ++-- .../configuring-the-repo-server.md | 140 ++++---- .../configuring-the-web-server.md | 62 ++-- .../managing-hard-disks-through-lvm.md | 105 +++--- .../setting-up-the-database-server.md | 300 ++++++++--------- ...41\347\220\206\347\241\254\347\233\230.md" | 105 +++--- ...TP\346\234\215\345\212\241\345\231\250.md" | 63 ++-- ...po\346\234\215\345\212\241\345\231\250.md" | 129 ++++---- ...eb\346\234\215\345\212\241\345\231\250.md" | 63 ++-- ...23\346\234\215\345\212\241\345\231\250.md" | 309 +++++++++--------- 10 files changed, 679 insertions(+), 655 deletions(-) diff --git a/content/en/docs/Administration/configuring-the-ftp-server.md b/content/en/docs/Administration/configuring-the-ftp-server.md index 17d2f87eb..98104b86e 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-repo-server.md b/content/en/docs/Administration/configuring-the-repo-server.md index 03a1ea003..72a12fc16 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,13 @@ 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 +112,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 openEuler; 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; @@ -142,7 +144,7 @@ Install openEuler OS and deploy the repo source using Nginx on openEuler OS. listen 80; server_name localhost; #Server name (URL) client_max_body_size 4G; - root /srv/repo; #Default service directory + root /home/openEuler/srv/repo; #Default service directory location / { autoindex on; # Enable the access to lower-layer files in the directory. @@ -158,17 +160,17 @@ 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. @@ -179,57 +181,57 @@ Install openEuler OS and deploy the repo source using Nginx on openEuler OS. - 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") - 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 to create the /home/openEuler/srv/repo directory specified in the Nginx configuration file /etc/nginx/nginx.conf: ``` - mkdir -p /srv/repo + $ mkdir -p /home/openEuler/srv/repo ``` -2. Set the SELinux working mode to the permissive mode: +2. Set the SELinux working mode to the permissive mode as the **root** user: ``` - setenforce permissive + # setenforce permissive ``` >![](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 +239,25 @@ 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 /home/openEuler/srv/repo directory: + - Copy related files in the image to the /home/openEuler/srv/repo directory. ``` - 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 /home/openEuler/srv/repo/ + $ cp -r /mnt/repodata /home/openEuler/srv/repo/ + $ cp -r /mnt/RPM-GPG-KEY-openEuler /home/openEuler/srv/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 /home/openEuler/srv/repo directory. ``` - ln -s /home/openEuler/os /srv/repo/os + $ ln -s /home/openEuler/os /home/openEuler/srv/repo/os ``` - /home/openEuler/os is the created repo source, and /srv/repo/os points to /home/openEuler/os. + /home/openEuler/os is the created repo source, and /home/openEuler/srv/repo/os points to /home/openEuler/os. @@ -266,7 +268,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,10 +277,10 @@ 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:** @@ -330,62 +332,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 0c74c8a3f..e4e375aa1 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 https://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_ + https://192.168.1.60_ If the port number is changed, enter the address in the following format: - https://_192.168.1.60: port number_ + https://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 ``` @@ -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 a8d5b7c57..45c63cd6e 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/setting-up-the-database-server.md b/content/en/docs/Administration/setting-up-the-database-server.md index d7ef2d753..d016c74c2 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 ``` @@ -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. @@ -1413,7 +1413,7 @@ In the preceding information: #### 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 ``` @@ -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: @@ -2157,7 +2157,7 @@ In the preceding information: #### 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/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 492d03b32..3add822aa 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/\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 37cf5cba2..f77d385e1 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 519808a7b..d46a7ee41 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 openEuler; 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 /home/openEuler/srv/repo; # 服务默认目录 location / { autoindex on; # 开启访问目录下层文件 @@ -152,17 +155,17 @@ 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服务启动成功 @@ -173,57 +176,57 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, - 若nginx服务启动失败,查看错误信息: ``` - systemctl status nginx.service --full + $ systemctl status nginx.service --full ``` **图 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. 创建nginx配置文件/etc/nginx/nginx.conf中指定的目录/home/openEuler/srv/repo: ``` - mkdir -p /srv/repo + $ mkdir -p /home/openEuler/srv/repo ``` -2. SELinux设置为宽容模式: +2. 在root权限下将SELinux设置为宽容模式: ``` - setenforce permissive + # setenforce permissive ``` >![](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 +234,25 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, **图 3** nginx部署成功 ![](figures/nginx部署成功.png "nginx部署成功") -5. 通过下面几种方式将repo源放入到/srv/repo下: - - 拷贝镜像中相关文件至在/srv/repo下 +5. 通过下面几种方式将repo源放入到/home/openEuler/srv/repo下: + - 拷贝镜像中相关文件至在/home/openEuler/srv/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 /home/openEuler/srv/repo/ + $ cp -r /mnt/repodata /home/openEuler/srv/repo/ + $ cp -r /mnt/RPM-GPG-KEY-openEuler /home/openEuler/srv/repo/ ``` openEuler-20.03-LTS-aarch64-dvd.iso存放在/home/openEuler目录下。 - - 在/srv/repo下创建repo源的软链接 + - 在/home/openEuler/srv/repo下创建repo源的软链接 ``` - ln -s /home/openEuler/os /srv/repo/os + $ ln -s /home/openEuler/os /home/openEuler/srv/repo/os ``` - /home/openEuler/os为已经创建好的repo源,/srv/repo/os将指向/home/openEuler/os。 + /home/openEuler/os为已经创建好的repo源,/home/openEuler/srv/repo/os将指向/home/openEuler/os。 @@ -258,7 +261,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,10 +270,10 @@ 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) **说明:** @@ -322,63 +325,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 e0b2fe793..3ed3aa10e 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_ + https://192.168.1.60_ 如果修改了端口号,输入地址格式如下: - https://_192.168.1.60:端口号_ + https://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 ``` @@ -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 fb17745d7..91a104f5c 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 ``` @@ -1344,7 +1345,7 @@ DROP SCHEMA是DROP DATABASE的同义词。 #### 备份数据库 -可以使用mysqldump命令备份数据库。 +可以在root权限下使用mysqldump命令备份数据库。 备份一个或多个表: @@ -1413,7 +1414,7 @@ mysqldump [options] -all-databases > outputfile #### 恢复数据库 -可以使用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 + #s ystemctl 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 ``` @@ -2091,7 +2092,7 @@ DROP SCHEMA是DROP DATABASE的同义词。 #### 备份数据库 -可以使用mysqldump命令备份数据库。 +可以在root权限下使用mysqldump命令备份数据库。 备份一个或多个表: @@ -2160,7 +2161,7 @@ mysqldump [options] -all-databases > outputfile #### 恢复数据库 -可以使用mysqldump命令恢复数据库。 +可以在root权限下使用mysql命令恢复数据库。 备份一个或多个表: -- Gitee From 9da19683d285cba02f4e0bff1ef0b387adfd818a Mon Sep 17 00:00:00 2001 From: fhxing168 Date: Tue, 2 Jun 2020 17:44:27 +0800 Subject: [PATCH 3/3] Modify the root user. --- .../ApplicationDev/building-an-rpm-package.md | 60 ++++----- content/en/docs/ApplicationDev/preparation.md | 80 ++++++------ .../using-gcc-for-compilation.md | 118 +++++++++--------- .../using-jdk-for-compilation.md | 55 ++++---- .../using-make-for-compilation.md | 16 +-- ...po\346\234\215\345\212\241\345\231\250.md" | 2 +- ...347\224\250GCC\347\274\226\350\257\221.md" | 118 +++++++++--------- ...347\224\250JDK\347\274\226\350\257\221.md" | 55 ++++---- ...47\224\250make\347\274\226\350\257\221.md" | 16 +-- ...57\345\242\203\345\207\206\345\244\207.md" | 80 ++++++------ ...346\236\204\345\273\272RPM\345\214\205.md" | 62 ++++----- 11 files changed, 328 insertions(+), 334 deletions(-) diff --git a/content/en/docs/ApplicationDev/building-an-rpm-package.md b/content/en/docs/ApplicationDev/building-an-rpm-package.md index 70e2262d7..5ab6079aa 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,8 +388,8 @@ 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 @@ -397,7 +397,7 @@ Run the following command to download the source code of the official example: Run the following command to create the .spec file: ``` -# vi hello.spec +$ 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 +470,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 @@ -639,7 +639,7 @@ 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/)\). @@ -660,7 +660,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**. @@ -673,7 +673,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: @@ -687,8 +687,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: @@ -709,26 +709,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:** @@ -744,22 +744,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 ``` @@ -769,22 +769,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:** @@ -796,7 +796,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 10db10bc8..826f07f00 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: @@ -172,10 +172,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. @@ -193,18 +193,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 ``` @@ -212,13 +212,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. @@ -229,7 +229,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: @@ -286,7 +286,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. @@ -294,33 +294,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. @@ -331,7 +331,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. @@ -339,25 +339,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 ``` @@ -384,35 +384,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 @@ -423,13 +423,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. @@ -437,7 +437,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: @@ -454,12 +454,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 eb596a947..173ff7bd2 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 be343ae87..4946b917d 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 9c2f7dc16..199f76d06 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/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 d46a7ee41..589f40478 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" @@ -114,7 +114,7 @@ Packages为rpm包所在的目录,repodata为repo源元数据所在的目录, >文档中的配置内容仅供参考,请用户根据实际情况(例如安全加固需要)进行配置。 ``` - user openEuler; + user nginx; worker_processes auto; # 建议设置为core-1 error_log /var/log/nginx/error.log warn; # log存放位置 pid /var/run/nginx.pid; 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 c15b6bb20..6a987cb35 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 d08a464eb..04b393703 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 f10d9cc1e..69fbf68de 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 4140f2ddb..c16154d6e 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文件的内容如下: @@ -171,10 +171,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操作系统。 @@ -192,18 +192,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 ``` @@ -211,13 +211,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 ``` 命令执行完成后,输出校验值。 @@ -228,7 +228,7 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 3. 挂载ISO并配置为repo源。 - 使用mount命令挂载镜像文件。 + 在root权限下使用mount命令挂载镜像文件。 示例如下: @@ -284,7 +284,7 @@ openEuler操作系统具体安装方法请参考《openEuler 20.03 LTS 安装指 1. 执行**dnf list installed | grep jdk** 查询JDK软件是否已安装。 ``` - dnf list installed | grep jdk + $ dnf list installed | grep jdk ``` 查看命令打印信息,若打印信息中包含“jdk”,表示该软件已经安装了,则不需要再安装。若无任何打印信息,则表示该软件未安装。 @@ -292,33 +292,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为版本号。 @@ -329,7 +329,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”,表示该软件已经安装了,则不需要再安装。若无任何打印信息,则表示该软件未安装。 @@ -337,25 +337,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 ``` @@ -382,35 +382,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 @@ -421,13 +421,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文件并保存: @@ -435,7 +435,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. 将以下内容添加到文件末尾并保存: @@ -452,12 +452,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 29f36c617..e77dab84c 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,8 +386,8 @@ 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文件 @@ -395,7 +395,7 @@ rpmbuild命令格式为:rpmbuild \[_option_...\] 新建spec文件,参考命令如下: ``` -# vi hello.spec +$ vi hello.spec ``` 在文件中写入对应内容后保存文件。文件内容示例如下,请根据实际情况修改相应字段。 @@ -468,13 +468,13 @@ fi 构建源码、二进制和包含调试信息的软件包,在spec文件所在目录执行如下命令: ``` -# rpmbuild -ba hello.spec +$ rpmbuild -ba hello.spec ``` 执行成功后,查看结果,使用如下命令: ``` -# tree ~/rpmbuild/*RPMS +$ tree ~/rpmbuild/*RPMS /home/testUser/rpmbuild/RPMS └── aarch64 @@ -636,7 +636,7 @@ 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/))上已经注册的账号和密码。 @@ -657,7 +657,7 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 1. 通过拷贝已有工程,创建属于用户自己的子工程。例如将openEuler:Mainline工程下的zlib软件包到新分支,参考命令如下: ``` - # osc branch openEuler:Mainline zlib + $ osc branch openEuler:Mainline zlib ``` 回显如下所示,说明在用户testUser下创建了新的分支工程home:testUser:branches:openEuler:Mainline。 @@ -670,7 +670,7 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 2. 将需要修改软件包的相关配置文件(例如\_service)下载到本地当前路径。其中 _testUser_ 为\~/.oscrc配置文件中配置的账户名称,请根据实际情况修改。 ``` - # osc co home:testUser:branches:openEuler:Mainline/zlib + $ osc co home:testUser:branches:openEuler:Mainline/zlib ``` 回显如下所示: @@ -684,8 +684,8 @@ RPM软件包构建完成后,通过网页端获取对应RPM软件包的方法 3. 进入本地子工程目录,并将软件包远程代码同步到本地。 ``` - # cd home:testUser:branches:openEuler:Mainline/zlib - # osc up -S + $ cd home:testUser:branches:openEuler:Mainline/zlib + $ osc up -S ``` 回显如下所示: @@ -706,26 +706,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) **说明:** @@ -741,22 +741,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 ``` @@ -766,22 +766,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) **说明:** @@ -793,7 +793,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 ``` 命令中的各参数含义如下,请用户根据实际情况修改: -- Gitee