From 966caf6c4c87cd98a5c9636c964f5b648484e2cc Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 8 Aug 2017 18:36:05 +0800 Subject: [PATCH 01/27] PRF&PUB:20170801 Deploy Kubernetes cluster for Linux containers.md @rieonke --- ...Kubernetes cluster for Linux containers.md | 47 +++++++++---------- 1 file changed, 21 insertions(+), 26 deletions(-) rename {translated/tech => published}/20170801 Deploy Kubernetes cluster for Linux containers.md (74%) diff --git a/translated/tech/20170801 Deploy Kubernetes cluster for Linux containers.md b/published/20170801 Deploy Kubernetes cluster for Linux containers.md similarity index 74% rename from translated/tech/20170801 Deploy Kubernetes cluster for Linux containers.md rename to published/20170801 Deploy Kubernetes cluster for Linux containers.md index 827449b302..43f16c816a 100644 --- a/translated/tech/20170801 Deploy Kubernetes cluster for Linux containers.md +++ b/published/20170801 Deploy Kubernetes cluster for Linux containers.md @@ -1,38 +1,38 @@ -Deploy Kubernetes cluster for Linux containers -部署Kubernetes 容器集群 +在 Azure 中部署 Kubernetes 容器集群 ============================================================ -在这个快速入门教程中,我们使用 Azure CLI 创建 Kubernetes 集群。 然后在集群上部署并运行由 Web 前端和 Redis 实例组成的多容器应用程序。 一旦部署完成,应用程序可以通过互联网访问。 +在这个快速入门教程中,我们使用 Azure CLI 创建一个 Kubernetes 集群,然后在集群上部署运行由 Web 前端和 Redis 实例组成的多容器应用程序。一旦部署完成,应用程序可以通过互联网访问。 + ![示例应用截图](https://docs.microsoft.com/en-us/azure/container-service/kubernetes/media/container-service-kubernetes-walkthrough/azure-vote.png) -这个快速入门教程假设你已经基本了解了Kubernetes 的概念,有关 Kubernetes 的详细信息,请参阅[ Kubernetes 文档][3]。 +这个快速入门教程假设你已经基本了解了 Kubernetes 的概念,有关 Kubernetes 的详细信息,请参阅 [Kubernetes 文档][3]。 -如果您没有 Azure 账号订阅,请在开始之前创建一个[免费帐户][4]。 +如果您没有 Azure 账号,请在开始之前创建一个[免费帐户][4]。 -### 登陆Azure 云控制台 +### 登录 Azure 云控制台 -Azure 云控制台是一个免费的 Bash shell ,你可以直接在 Azure 网站上运行。 它已经在你的账户中预先配置好了, 单击[ Azure 门户][5]右上角菜单上的 “Cloud Shell” 按钮; +Azure 云控制台是一个免费的 Bash shell,你可以直接在 Azure 网站上运行。它已经在你的账户中预先配置好了, 单击 [Azure 门户][5]右上角菜单上的 “Cloud Shell” 按钮; - [![Cloud Shell](https://docs.microsoft.com/en-us/azure/includes/media/cloud-shell-try-it/cloud-shell-menu.png)][6] +[![Cloud Shell](https://docs.microsoft.com/en-us/azure/includes/media/cloud-shell-try-it/cloud-shell-menu.png)][6] - 该按钮启动一个交互式 shell,您可以使用它来运行本教程中的所有操作步骤。 +该按钮会启动一个交互式 shell,您可以使用它来运行本教程中的所有操作步骤。 - [![ Cloud Shell 截图](https://docs.microsoft.com/en-us/azure/includes/media/cloud-shell-try-it/cloud-shell-safari.png)][7] +[![ Cloud Shell 截图](https://docs.microsoft.com/en-us/azure/includes/media/cloud-shell-try-it/cloud-shell-safari.png)][7] -此快速入门教程所用的 Azure CLI 的版本最低要求为 2.0.4 。如果您选择在本地安装和使用 CLI 工具,请运行 `az --version` 来检查已安装的版本。 如果您需要安装或升级请参阅[安装 Azure CLI 2.0 ][8]。 +此快速入门教程所用的 Azure CLI 的版本最低要求为 2.0.4。如果您选择在本地安装和使用 CLI 工具,请运行 `az --version` 来检查已安装的版本。 如果您需要安装或升级请参阅[安装 Azure CLI 2.0 ][8]。 ### 创建一个资源组 -使用 [az group create][9] 命令创建一个资源组,一个 Azure 资源组是 Azure 资源部署和管理的逻辑组。 +使用 [az group create][9] 命令创建一个资源组,一个 Azure 资源组是指 Azure 资源部署和管理的逻辑组。 -以下示例在 _eastus_ 位置中创建名为 _myResourceGroup_ 的资源组。 +以下示例在 _eastus_ 区域中创建名为 _myResourceGroup_ 的资源组。 ``` az group create --name myResourceGroup --location eastus ``` -输出: +输出: ``` @@ -53,23 +53,21 @@ az group create --name myResourceGroup --location eastus 使用 [az acs create][10] 命令在 Azure 容器服务中创建 Kubernetes 集群。 以下示例使用一个 Linux 主节点和三个 Linux 代理节点创建一个名为 _myK8sCluster_ 的集群。 -Azure CLICopyTry It ``` az acs create --orchestrator-type=kubernetes --resource-group myResourceGroup --name=myK8sCluster --generate-ssh-keys ``` -几分钟后,命令将完成并返回有关该集群的json格式的信息。 +几分钟后,命令将完成并返回有关该集群的 json 格式的信息。 ### 连接到 Kubernetes 集群 要管理 Kubernetes 群集,可以使用 Kubernetes 命令行工具 [kubectl][11]。 -如果您使用 Azure CloudShell ,则已经安装了 kubectl 。 如果要在本地安装,可以使用 [az acs kubernetes install-cli][12] 命令。 +如果您使用 Azure CloudShell ,则已经安装了 kubectl 。如果要在本地安装,可以使用 [az acs kubernetes install-cli][12] 命令。 要配置 kubectl 连接到您的 Kubernetes 群集,请运行 [az acs kubernetes get-credentials][13] 命令下载凭据并配置 Kubernetes CLI 以使用它们。 - ``` az acs kubernetes get-credentials --resource-group=myResourceGroup --name=myK8sCluster @@ -83,7 +81,7 @@ kubectl get nodes ``` -输出: +输出: ``` @@ -171,7 +169,7 @@ kubectl create -f azure-vote.yaml ``` -输出: +输出: ``` @@ -188,15 +186,13 @@ service "azure-vote-front" created 要监控这个进程,使用 [kubectl get service][17] 命令时加上 `--watch` 参数。 -Azure CLICopyTry It ``` kubectl get service azure-vote-front --watch ``` -Initially the EXTERNAL-IP for the  _azure-vote-front_  service appears as  _pending_ . Once the EXTERNAL-IP address has changed from  _pending_  to an  _IP address_ , use `CTRL-C` to stop the kubectl watch process. -最初,_azure-vote-front_ 服务的 EXTERNAL-IP 显示为 _pending_ 。 一旦 EXTERNAL-IP 地址从 _pending_ 变成一个具体的IP地址,请使用 “CTRL-C” 来停止 kubectl 监视进程。 +最初,_azure-vote-front_ 服务的 EXTERNAL-IP 显示为 _pending_ 。 一旦 EXTERNAL-IP 地址从 _pending_ 变成一个具体的 IP 地址,请使用 “CTRL-C” 来停止 kubectl 监视进程。 ``` azure-vote-front 10.0.34.242 80:30676/TCP 7s @@ -204,7 +200,6 @@ azure-vote-front 10.0.34.242 52.179.23.131 80:30676/TCP 2m ``` -You can now browse to the external IP address to see the Azure Vote App. 现在你可以通过这个外网 IP 地址访问到 Azure Vote 这个应用了。 ![浏览 Azure Vote 应用截图 ](https://docs.microsoft.com/en-us/azure/container-service/kubernetes/media/container-service-kubernetes-walkthrough/azure-vote.png) @@ -234,9 +229,9 @@ az group delete --name myResourceGroup --yes --no-wait via: https://docs.microsoft.com/en-us/azure/container-service/kubernetes/container-service-kubernetes-walkthrough -作者:[neilpeterson ][a],[mmacy][b] +作者:[neilpeterson][a],[mmacy][b] 译者:[rieonke](https://github.com/rieonke) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 85fbb5cc2e5616561a52b53e639ad569604c4a59 Mon Sep 17 00:00:00 2001 From: wxy Date: Tue, 8 Aug 2017 18:47:06 +0800 Subject: [PATCH 02/27] PRF&PUB:20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md @geekpi --- ...nstall Zabbix on an Ubuntu 16.04 Server.md | 36 +++++++++++-------- 1 file changed, 22 insertions(+), 14 deletions(-) rename {translated/tech => published}/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md (87%) diff --git a/translated/tech/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md b/published/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md similarity index 87% rename from translated/tech/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md rename to published/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md index 090d8b2289..7add8b0583 100644 --- a/translated/tech/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md +++ b/published/20170705 Monitoring Server Install Zabbix on an Ubuntu 16.04 Server.md @@ -1,12 +1,11 @@ -监控服务器:在 Ubuntu 16.04 Server 上安装 Zabbix +在 Ubuntu 16.04 Server 上安装 Zabbix ============================================================ [![Zabbix logo](https://www.unixmen.com/wp-content/uploads/2017/06/zabbix_logo.png "zabbix_logo")][3] ### 监控服务器 - 什么是 Zabbix -[Zabbix][2] 是企业级开源分布式监控服务器解决方案。该软件能监控网络的不同参数以及服务器的完整性,还允许为任何事件配置基于电子邮件的警报。Zabbix 根据存储在数据库(例如 MySQL)中的数据提供报告和数据可视化功能。软件收集的每个测量可以通过基于 Web 的界面访问。 - +[Zabbix][2] 是企业级开源分布式监控服务器解决方案。该软件能监控网络的不同参数以及服务器的完整性,还允许为任何事件配置基于电子邮件的警报。Zabbix 根据存储在数据库(例如 MySQL)中的数据提供报告和数据可视化功能。软件收集的每个测量指标都可以通过基于 Web 的界面访问。 Zabbix 根据 GNU 通用公共许可证版本 2(GPLv2)的条款发布,完全免费。 @@ -19,6 +18,7 @@ Zabbix 根据 GNU 通用公共许可证版本 2(GPLv2)的条款发布,完 ``` # apt-get install php7.0-bcmath php7.0-xml php7.0-mbstring ``` + Ubuntu 仓库中提供的 Zabbix 软件包已经过时了。使用官方 Zabbix 仓库安装最新的稳定版本。 通过执行以下命令来安装仓库软件包: @@ -28,11 +28,12 @@ $ wget http://repo.zabbix.com/zabbix/3.2/ubuntu/pool/main/z/zabbix-release/zabbi # dpkg -i zabbix-release_3.2-1+xenial_all.deb ``` -然后更新 `apt` 包源码: +然后更新 `apt` 包源: ``` # apt-get update ``` + 现在可以安装带有 MySQL 支持和 PHP 前端的 Zabbix 服务器。执行命令: ``` @@ -166,18 +167,19 @@ DBPassword=usr_strong_pwd ![Zabbix monitoring server Frontend Setup](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot1.png) -点击  _**Next step**_ +点击  **Next step** ![snapshot2](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot2.png) -确保所有的值都是 **Ok**,然后再次单击 _**Next step** _ 。 +确保所有的值都是 **Ok**,然后再次单击 **Next step** 。 ![Zabbix MySQL configuration](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot3.png) -输入 MySQL **zabbix** 的用户密码,然后点击 _ **Next step** _。 + +输入 MySQL **zabbix** 的用户密码,然后点击 **Next step**。 ![Zabbix server details](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot4.png) -单击 _**Next step**_ ,安装程序将显示具有所有配置参数的页面。再次检查以确保一切正确。 +单击 **Next step** ,安装程序将显示具有所有配置参数的页面。再次检查以确保一切正确。 ![Zabbix pre-installation details](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot5.png) @@ -192,18 +194,24 @@ DBPassword=usr_strong_pwd ![Zabbix login interface](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot7.png) 使用上述凭证登录后,我们将看到 Zabbix 面板: + ![zabbix dashboard](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot8.png) -前往 _Administration -> Users_,了解已启用帐户的概况 +前往 **Administration -> Users**,了解已启用帐户的概况: + ![Zabbix users](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot9.png) -通过点击 _**Create user**_ 创建一个新帐户。 +通过点击 **Create user** 创建一个新帐户。 + ![Zabbix User Creation](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot10.png) -点击 **Groups** 中的 **Add**,然后选择一个组 +点击 **Groups** 中的 **Add**,然后选择一个组: + ![snapshot11](https://www.unixmen.com/wp-content/uploads/2017/06/snapshot11.png) -保存新用户凭证,它将显示在 _Administration -> Users_ 面板中。**请注意,在 Zabbix 中,主机的访问权限分配给用户组,而不是单个用户。** +保存新用户凭证,它将显示在 **Administration -> Users** 面板中。 + +**请注意,在 Zabbix 中,主机的访问权限分配给用户组,而不是单个用户。** ### 总结 @@ -213,9 +221,9 @@ DBPassword=usr_strong_pwd via: https://www.unixmen.com/monitoring-server-install-zabbix-ubuntu-16-04/ -作者:[Giuseppe Molica ][a] +作者:[Giuseppe Molica][a] 译者:[geekpi](https://github.com/geekpi) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 4609fcaf05aa538c70baa2ee9774942f16e62d49 Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 9 Aug 2017 08:26:03 +0800 Subject: [PATCH 03/27] translated --- ...to Samba4 AD from Commandline – Part 14.md | 299 ------------------ ...to Samba4 AD from Commandline – Part 14.md | 297 +++++++++++++++++ 2 files changed, 297 insertions(+), 299 deletions(-) delete mode 100644 sources/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md create mode 100644 translated/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md diff --git a/sources/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md b/sources/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md deleted file mode 100644 index 9affa013ed..0000000000 --- a/sources/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md +++ /dev/null @@ -1,299 +0,0 @@ -translting----geekpi - -Integrate CentOS 7 to Samba4 AD from Commandline – Part 14 -============================================================ - -This guide will show you how you can integrate a CentOS 7 Server with no Graphical User Interface to [Samba4 Active Directory Domain Controller][3] from command line using Authconfig software. - -This type of setup provides a single centralized account database held by Samba and allows the AD users to authenticate to CentOS server across the network infrastructure. - -#### Requirements - -1. [Create an Active Directory Infrastructure with Samba4 on Ubuntu][1] - -2. [CentOS 7.3 Installation Guide][2] - -### Step 1: Configure CentOS for Samba4 AD DC - -1. Before starting to join CentOS 7 Server into a Samba4 DC you need to assure that the network interface is properly configured to query domain via DNS service. - -Run [ip address][4] command to list your machine network interfaces and choose the specific NIC to edit by issuing nmtui-edit command against the interface name, such as ens33 in this example, as illustrated below. - -``` -# ip address -# nmtui-edit ens33 -``` - [![List Network Interfaces](https://www.tecmint.com/wp-content/uploads/2017/07/List-Network-Interfaces.jpg)][5] - -List Network Interfaces - -2. Once the network interface is opened for editing, add the static IPv4 configurations best suited for your LAN and make sure you setup Samba AD Domain Controllers IP addresses for the DNS servers. - -Also, append the name of your domain in search domains filed and navigate to OK button using [TAB] key to apply changes. - -The search domains filed assures that the domain counterpart is automatically appended by DNS resolution (FQDN) when you use only a short name for a domain DNS record. - - [![Configure Network Interface](https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Network-Interface.png)][6] - -Configure Network Interface - -3. Finally, restart the network daemon to apply changes and test if DNS resolution is properly configured by issuing series of ping commands against the domain name and domain controllers short names as shown below. - -``` -# systemctl restart network.service -# ping -c2 tecmint.lan -# ping -c2 adc1 -# ping -c2 adc2 -``` - [![Verify DNS Resolution on Domain](https://www.tecmint.com/wp-content/uploads/2017/07/Verify-DNS-Resolution-on-Domain.png)][7] - -Verify DNS Resolution on Domain - -4. Also, configure your machine hostname and reboot the machine to properly apply the settings by issuing the following commands. - -``` -# hostnamectl set-hostname your_hostname -# init 6 -``` - -Verify if hostname was correctly applied with the below commands. - -``` -# cat /etc/hostname -# hostname -``` - -5. Finally, sync local time with Samba4 AD DC by issuing the below commands with root privileges. - -``` -# yum install ntpdate -# ntpdate domain.tld -``` - [![Sync Time with Samba4 AD DC](https://www.tecmint.com/wp-content/uploads/2017/07/Sync-Time-with-Samba4-AD-DC.png)][8] - -Sync Time with Samba4 AD DC - -### Step 2: Join CentOS 7 Server to Samba4 AD DC - -6. To join CentOS 7 server to Samba4 Active Directory, first install the following packages on your machine from an account with root privileges. - -``` -# yum install authconfig samba-winbind samba-client samba-winbind-clients -``` - -7. In order to integrate CentOS 7 server to a domain controller run authconfig-tui graphical utility with root privileges and use the below configurations as described below. - -``` -# authconfig-tui -``` - -At the first prompt screen choose: - -* On User Information: - * Use Winbind - -* On Authentication tab select by pressing [Space] key: - * Use Shadow Password - - * Use Winbind Authentication - - * Local authorization is sufficient - - [![Authentication Configuration](https://www.tecmint.com/wp-content/uploads/2017/07/Authentication-Configuration.png)][9] - -Authentication Configuration - -8. Hit Next to continue to the Winbind Settings screen and configure as illustrated below: - -* Security Model: ads - -* Domain = YOUR_DOMAIN (use upper case) - -* Domain Controllers = domain machines FQDN (comma separated if more than one) - -* ADS Realm = YOUR_DOMAIN.TLD - -* Template Shell = /bin/bash - - [![Winbind Settings](https://www.tecmint.com/wp-content/uploads/2017/07/Winbind-Settings.png)][10] - -Winbind Settings - -9. To perform domain joining navigate to Join Domain button using [tab] key and hit [Enter] key to join domain. - -At the next screen prompt, add the credentials for a Samba4 AD account with elevated privileges to perform the machine account joining into AD and hit OK to apply settings and close the prompt. - -Be aware that when you type the user password, the credentials won’t be shown in the password screen. On the remaining screen hit OK again to finish domain integration for CentOS 7 machine. - - [![Join Domain to Samba4 AD DC](https://www.tecmint.com/wp-content/uploads/2017/07/Join-Domain-to-Samba4-AD-DC.png)][11] - -Join Domain to Samba4 AD DC - - [![Confirm Winbind Settings](https://www.tecmint.com/wp-content/uploads/2017/07/Confirm-Winbind-Settings.png)][12] - -Confirm Winbind Settings - -To force adding a machine into a specific Samba AD Organizational Unit, get your machine exact name using hostname command and create a new Computer object in that OU with the name of your machine. - -The best way to add a new object into a Samba4 AD is by using ADUC tool from a Windows machine integrated into the domain with [RSAT tools installed][13] on it. - -Important: An alternate method of joining a domain is by using authconfig command line which offers extensive control over the integration process. - -However, this method is prone to errors do to its numerous parameters as illustrated on the below command excerpt. The command must be typed into a single long line. - -``` -# authconfig --enablewinbind --enablewinbindauth --smbsecurity ads --smbworkgroup=YOUR_DOMAIN --smbrealm YOUR_DOMAIN.TLD --smbservers=adc1.yourdomain.tld --krb5realm=YOUR_DOMAIN.TLD --enablewinbindoffline --enablewinbindkrb5 --winbindtemplateshell=/bin/bash--winbindjoin=domain_admin_user --update --enablelocauthorize --savebackup=/backups -``` - -10. After the machine has been joined to domain, verify if winbind service is up and running by issuing the below command. - -``` -# systemctl status winbind.service -``` - -11. Then, check if CentOS machine object has been successfully created in Samba4 AD. Use AD Users and Computers tool from a Windows machine with RSAT tools installed and navigate to your domain Computers container. A new AD computer account object with name of your CentOS 7 server should be listed in the right plane. - -12. Finally, tweak the configuration by opening samba main configuration file (/etc/samba/smb.conf) with a text editor and append the below lines at the end of the [global]configuration block as illustrated below: - -``` -winbind use default domain = true -winbind offline logon = true -``` - [![Configure Samba](https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Samba.jpg)][14] - -Configure Samba - -13. In order to create local homes on the machine for AD accounts at their first logon run the below command. - -``` -# authconfig --enablemkhomedir --update -``` - -14. Finally, restart Samba daemon to reflect changes and verify domain joining by performing a logon on the server with an AD account. The home directory for the AD account should be automatically created. - -``` -# systemctl restart winbind -# su - domain_account -``` - [![Verify Domain Joining](https://www.tecmint.com/wp-content/uploads/2017/07/Verify-Domain-Joining.jpg)][15] - -Verify Domain Joining - -15. List the domain users or domain groups by issuing one of the following commands. - -``` -# wbinfo -u -# wbinfo -g -``` - [![List Domain Users and Groups](https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Users-and-Groups.png)][16] - -List Domain Users and Groups - -16. To get info about a domain user run the below command. - -``` -# wbinfo -i domain_user -``` - [![List Domain User Info](https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-User-Info.jpg)][17] - -List Domain User Info - -17. To display summary domain info issue the following command. - -``` -# net ads info -``` - [![List Domain Summary](https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Summary.jpg)][18] - -List Domain Summary - -### Step 3: Login to CentOS with a Samba4 AD DC Account - -18. To authenticate with a domain user in CentOS, use one of the following command line syntaxes. - -``` -# su - ‘domain\domain_user’ -# su - domain\\domain_user -``` - -Or use the below syntax in case winbind use default domain = true parameter is set to samba configuration file. - -``` -# su - domain_user -# su - domain_user@domain.tld -``` - -19. In order to add root privileges for a domain user or group, edit sudoers file using visudocommand and add the following lines as illustrated on the below screenshot. - -``` -YOUR_DOMAIN\\domain_username ALL=(ALL:ALL) ALL #For domain users -%YOUR_DOMAIN\\your_domain\ group ALL=(ALL:ALL) ALL #For domain groups -``` - -Or use the below excerpt in case winbind use default domain = true parameter is set to samba configuration file. - -``` -domain_username ALL=(ALL:ALL) ALL #For domain users -%your_domain\ group ALL=(ALL:ALL) ALL #For domain groups -``` - [![Grant Root Privileges on Domain Users](https://www.tecmint.com/wp-content/uploads/2017/07/Grant-Root-Privileges-on-Domain-Users.jpg)][19] - -Grant Root Privileges on Domain Users - -20. The following series of commands against a Samba4 AD DC can also be useful for troubleshooting purposes: - -``` -# wbinfo -p #Ping domain -# wbinfo -n domain_account #Get the SID of a domain account -# wbinfo -t #Check trust relationship -``` - -21. To leave the domain run the following command against your domain name using a domain account with elevated privileges. After the machine account has been removed from the AD, reboot the machine to revert changes before the integration process. - -``` -# net ads leave -w DOMAIN -U domain_admin -# init 6 -``` - -That’s all! Although this procedure is mainly focused on joining a CentOS 7 server to a Samba4 AD DC, the same steps described here are also valid for integrating a CentOS server into a Microsoft Windows Server 2012 Active Directory. - --------------------------------------------------------------------------------- - -作者简介: - -Matei Cezar -I'am a computer addicted guy, a fan of open source and linux based system software, have about 4 years experience with Linux distributions desktop, servers and bash scripting. - ------------------- - -via: https://www.tecmint.com/integrate-centos-7-to-samba4-active-directory/ - -作者:[Matei Cezar ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://www.tecmint.com/author/cezarmatei/ -[1]:https://www.tecmint.com/install-samba4-active-directory-ubuntu/ -[2]:https://www.tecmint.com/centos-7-3-installation-guide/ -[3]:https://www.tecmint.com/install-samba4-active-directory-ubuntu/ -[4]:https://www.tecmint.com/ip-command-examples/ -[5]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Network-Interfaces.jpg -[6]:https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Network-Interface.png -[7]:https://www.tecmint.com/wp-content/uploads/2017/07/Verify-DNS-Resolution-on-Domain.png -[8]:https://www.tecmint.com/wp-content/uploads/2017/07/Sync-Time-with-Samba4-AD-DC.png -[9]:https://www.tecmint.com/wp-content/uploads/2017/07/Authentication-Configuration.png -[10]:https://www.tecmint.com/wp-content/uploads/2017/07/Winbind-Settings.png -[11]:https://www.tecmint.com/wp-content/uploads/2017/07/Join-Domain-to-Samba4-AD-DC.png -[12]:https://www.tecmint.com/wp-content/uploads/2017/07/Confirm-Winbind-Settings.png -[13]:https://www.tecmint.com/manage-samba4-ad-from-windows-via-rsat/ -[14]:https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Samba.jpg -[15]:https://www.tecmint.com/wp-content/uploads/2017/07/Verify-Domain-Joining.jpg -[16]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Users-and-Groups.png -[17]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-User-Info.jpg -[18]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Summary.jpg -[19]:https://www.tecmint.com/wp-content/uploads/2017/07/Grant-Root-Privileges-on-Domain-Users.jpg -[20]:https://www.tecmint.com/author/cezarmatei/ -[21]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ -[22]:https://www.tecmint.com/free-linux-shell-scripting-books/ diff --git a/translated/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md b/translated/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md new file mode 100644 index 0000000000..3c8c3e581a --- /dev/null +++ b/translated/tech/20170714 Integrate CentOS 7 to Samba4 AD from Commandline – Part 14.md @@ -0,0 +1,297 @@ +Samba 系列(十四):在命令行中将 CentOS 7 与 Samba4 AD 集成 +============================================================ + +本指南将向你介绍如何使用 Authconfig 在命令行中将无图形界面的 CentOS 7 服务器集成到[ Samba4 AD 域控制器][3]中。 + +这类设置提供了由 Samba 持有的单一集中式帐户数据库,允许 AD 用户通过网络基础设施对 CentOS 服务器进行身份验证。 + +#### 要求 + +1. [在 Ubuntu 上使用 Samba4 创建 AD 基础架构][1] + +2. [CentOS 7.3 安装指南][2] + +### 步骤 1:为 Samba4 AD DC 配置 CentOS + +1. 在开始将 CentOS 7 服务器加入 Samba4 DC 之前,你需要确保网络接口被正确配置为通过 DNS 服务查询域。 + +运行 [ip address][4] 命令列出你机器网络接口,选择要编辑的特定网卡,通过针对接口名称运行 nmtui-edit 命令(如本例中的 ens33),如下所示。 + +``` +# ip address +# nmtui-edit ens33 +``` + [![List Network Interfaces](https://www.tecmint.com/wp-content/uploads/2017/07/List-Network-Interfaces.jpg)][5] + +列出网络接口 + +2. 打开网络接口进行编辑后,添加最适合 LAN 的静态 IPv4 配置,并确保为 DNS 服务器设置 Samba AD 域控制器 IP 地址。 + +另外,在搜索域中追加你的域的名称,并使用 [TAB] 键跳到确定按钮来应用更改。 + +当你仅对域 dns 记录使用短名称时, 已提交的搜索域保证域对应项会自动追加到 dns 解析 (FQDN) 中。 + + [![Configure Network Interface](https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Network-Interface.png)][6] + +配置网络接口 + +3.最后,重启网络守护进程以应用更改,并通过对域名和域控制器 ping 来测试 DNS 解析是否正确配置,如下所示。 + +``` +# systemctl restart network.service +# ping -c2 tecmint.lan +# ping -c2 adc1 +# ping -c2 adc2 +``` + [![Verify DNS Resolution on Domain](https://www.tecmint.com/wp-content/uploads/2017/07/Verify-DNS-Resolution-on-Domain.png)][7] + +验证域上的 DNS 解析 + +4. 另外,使用下面的命令配置你的计算机主机名并重启机器应用更改。 + +``` +# hostnamectl set-hostname your_hostname +# init 6 +``` + +使用以下命令验证主机名是否正确配置。 + +``` +# cat /etc/hostname +# hostname +``` + +5. 最后,使用 root 权限运行以下命令,与 Samba4 AD DC 同步本地时间。 + +``` +# yum install ntpdate +# ntpdate domain.tld +``` + [![Sync Time with Samba4 AD DC](https://www.tecmint.com/wp-content/uploads/2017/07/Sync-Time-with-Samba4-AD-DC.png)][8] + +与 Samba4 AD DC 同步时间 + +### 步骤 2:将 CentOS 7 服务器加入到 Samba4 AD DC + +6. 要将 CentOS 7 服务器加入到 Samba4 AD 中,请先用具有 root 权限的帐户在计算机上安装以下软件包。 + +``` +# yum install authconfig samba-winbind samba-client samba-winbind-clients +``` + +7. 为了将 CentOS 7 服务器与域控制器集成,可以使用 root 权限运行 authconfig-tui,并使用下面的配置。 + +``` +# authconfig-tui +``` + +首屏选择: + +* 在 User Information 中: + * Use Winbind + +* 在 Authentication 中使用[空格键]选择: + * Use Shadow Password + + * Use Winbind Authentication + + * Local authorization is sufficient + + [![Authentication Configuration](https://www.tecmint.com/wp-content/uploads/2017/07/Authentication-Configuration.png)][9] + +验证配置 + +8. 点击 Next 进入 Winbind 设置界面并配置如下: + +* Security Model: ads + +* Domain = YOUR_DOMAIN (use upper case) + +* Domain Controllers = domain machines FQDN (comma separated if more than one) + +* ADS Realm = YOUR_DOMAIN.TLD + +* Template Shell = /bin/bash + + [![Winbind Settings](https://www.tecmint.com/wp-content/uploads/2017/07/Winbind-Settings.png)][10] + +Winbind 设置 + +9. 要加入域,使用 [tab] 键跳到 “Join Domain” 按钮,然后按[回车]键加入域。 + +在下一个页面,添加具有提升权限的 Samba4 AD 帐户的凭据,以将计算机帐户加入 AD,然后单击 “OK” 应用设置并关闭提示。 + +请注意,当你输入用户密码时,凭据将不会显示在屏幕中。在下面再次点击 OK,完成 CentOS 7 的域集成。 + + [![Join Domain to Samba4 AD DC](https://www.tecmint.com/wp-content/uploads/2017/07/Join-Domain-to-Samba4-AD-DC.png)][11] + +加入域到 Samba4 AD DC + + [![Confirm Winbind Settings](https://www.tecmint.com/wp-content/uploads/2017/07/Confirm-Winbind-Settings.png)][12] + +确认 Winbind 设置 + +要强制将机器添加到特定的 Samba AD OU 中,请使用 hostname 命令获取计算机的完整名称,并使用机器名称在该 OU 中创建一个新的计算机对象。 + +将新对象添加到 Samba4 AD 中的最佳方法是已经集成到[安装了 RSAT 工具][13]的域的 Wubdows 机器上使用 ADUC 工具。 + +重要:加入域的另一种方法是使用 authconfig 命令行,它可以对集成过程进行广泛的控制。 + +但是,这种方法很容易因为其众多参数造成错误,如下所示。该命令必须输入一条长命令行。 + +``` +# authconfig --enablewinbind --enablewinbindauth --smbsecurity ads --smbworkgroup=YOUR_DOMAIN --smbrealm YOUR_DOMAIN.TLD --smbservers=adc1.yourdomain.tld --krb5realm=YOUR_DOMAIN.TLD --enablewinbindoffline --enablewinbindkrb5 --winbindtemplateshell=/bin/bash--winbindjoin=domain_admin_user --update --enablelocauthorize --savebackup=/backups +``` + +10. 机器加入域后,通过使用以下命令验证 winbind 服务是否正常运行。 + +``` +# systemctl status winbind.service +``` + +11. 接着检查是否在 Samba4 AD 中成功创建了 CentOS 机器对象。从安装了 RSAT 工具的 Windows 机器使用 AD 用户和计算机工具,并进入到你的域计算机容器。一个名为 CentOS 7 Server 的新 AD 计算机帐户对象应该在右边的列表中。 + +12. 最后,使用文本编辑器打开 samba 主配置文件(/etc/samba/smb.conf)来调整配置,并在 [global] 配置块的末尾附加以下行,如下所示: + +``` +winbind use default domain = true +winbind offline logon = true +``` + [![Configure Samba](https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Samba.jpg)][14] + +配置 Samba + +13. 为了在 AD 帐户首次登录时在机器上创建本地家目录,请运行以下命令 + +``` +# authconfig --enablemkhomedir --update +``` + +14. 最后,重启 Samba 守护进程使更改生效,并使用一个 AD 账户登陆验证域加入。AD 帐户的家目录应该会自动创建。 + +``` +# systemctl restart winbind +# su - domain_account +``` + [![Verify Domain Joining](https://www.tecmint.com/wp-content/uploads/2017/07/Verify-Domain-Joining.jpg)][15] + +验证域加入 + +15. 通过以下命令之一列出域用户或域组。 + +``` +# wbinfo -u +# wbinfo -g +``` + [![List Domain Users and Groups](https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Users-and-Groups.png)][16] + +列出域用户和组 + +16. 要获取有关域用户的信息,请运行以下命令。 + +``` +# wbinfo -i domain_user +``` + [![List Domain User Info](https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-User-Info.jpg)][17] + +列出域用户信息 + +17. 要显示域摘要信息,请使用以下命令。 + +``` +# net ads info +``` + [![List Domain Summary](https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Summary.jpg)][18] + +列出域摘要 + +### 步骤 3:使用 Samba4 AD DC 帐号登录CentOS + +18. 要在 CentOS 中与域用户进行身份验证,请使用以下命令语法之一。 + +``` +# su - ‘domain\domain_user’ +# su - domain\\domain_user +``` + +或者使用下面的语法来防止 winbind 使用 default domain = true 参数来设置 samba 配置文件。 + +``` +# su - domain_user +# su - domain_user@domain.tld +``` + +19. 要为域用户或组添加 root 权限,请使用 visudocommand 编辑 sudoers 文件,并添加以下截图所示的行。 + +``` +YOUR_DOMAIN\\domain_username ALL=(ALL:ALL) ALL #For domain users +%YOUR_DOMAIN\\your_domain\ group ALL=(ALL:ALL) ALL #For domain groups +``` + +如果 winbind 使用 default domain = true 参数设置 samba 配置文件,那么使用下面的配置。 + +``` +domain_username ALL=(ALL:ALL) ALL #For domain users +%your_domain\ group ALL=(ALL:ALL) ALL #For domain groups +``` + [![Grant Root Privileges on Domain Users](https://www.tecmint.com/wp-content/uploads/2017/07/Grant-Root-Privileges-on-Domain-Users.jpg)][19] + +授予域用户 root 权限 + +20. 针对 Samba4 AD DC 的以下一系列命令也可用于故障排除: + +``` +# wbinfo -p #Ping domain +# wbinfo -n domain_account #Get the SID of a domain account +# wbinfo -t #Check trust relationship +``` + +21. 要离开该域, 请使用具有提升权限的域帐户对你的域名运行以下命令。从 AD 中删除计算机帐户后, 重启计算机以在集成进程之前还原更改。 + +``` +# net ads leave -w DOMAIN -U domain_admin +# init 6 +``` + +就是这样了!尽管此过程主要集中在将 CentOS 7 服务器加入到 Samba4 AD DC 中,但这里描述的相同步骤也适用于将 CentOS 服务器集成到 Microsoft Windows Server 2012 AD 中。 + +-------------------------------------------------------------------------------- + +作者简介: + +Matei Cezar +我是一个电脑上瘾的家伙,开源和基于 linux 的系统软件的粉丝,在 Linux 发行版桌面、服务器和 bash 脚本方面拥有大约 4 年的经验。 + +------------------ + +via: https://www.tecmint.com/integrate-centos-7-to-samba4-active-directory/ + +作者:[Matei Cezar ][a] +译者:[geekpi](https://github.com/geekpi) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://www.tecmint.com/author/cezarmatei/ +[1]:https://www.tecmint.com/install-samba4-active-directory-ubuntu/ +[2]:https://www.tecmint.com/centos-7-3-installation-guide/ +[3]:https://www.tecmint.com/install-samba4-active-directory-ubuntu/ +[4]:https://www.tecmint.com/ip-command-examples/ +[5]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Network-Interfaces.jpg +[6]:https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Network-Interface.png +[7]:https://www.tecmint.com/wp-content/uploads/2017/07/Verify-DNS-Resolution-on-Domain.png +[8]:https://www.tecmint.com/wp-content/uploads/2017/07/Sync-Time-with-Samba4-AD-DC.png +[9]:https://www.tecmint.com/wp-content/uploads/2017/07/Authentication-Configuration.png +[10]:https://www.tecmint.com/wp-content/uploads/2017/07/Winbind-Settings.png +[11]:https://www.tecmint.com/wp-content/uploads/2017/07/Join-Domain-to-Samba4-AD-DC.png +[12]:https://www.tecmint.com/wp-content/uploads/2017/07/Confirm-Winbind-Settings.png +[13]:https://www.tecmint.com/manage-samba4-ad-from-windows-via-rsat/ +[14]:https://www.tecmint.com/wp-content/uploads/2017/07/Configure-Samba.jpg +[15]:https://www.tecmint.com/wp-content/uploads/2017/07/Verify-Domain-Joining.jpg +[16]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Users-and-Groups.png +[17]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-User-Info.jpg +[18]:https://www.tecmint.com/wp-content/uploads/2017/07/List-Domain-Summary.jpg +[19]:https://www.tecmint.com/wp-content/uploads/2017/07/Grant-Root-Privileges-on-Domain-Users.jpg +[20]:https://www.tecmint.com/author/cezarmatei/ +[21]:https://www.tecmint.com/10-useful-free-linux-ebooks-for-newbies-and-administrators/ +[22]:https://www.tecmint.com/free-linux-shell-scripting-books/ From 1f27925a39a167e91e345a5bfb41db8e0e81998a Mon Sep 17 00:00:00 2001 From: geekpi Date: Wed, 9 Aug 2017 08:31:29 +0800 Subject: [PATCH 04/27] translating --- ...8 How modelling helps you avoid getting a stuck OpenStack.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md b/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md index bf0eea18bf..ab05f37142 100644 --- a/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md +++ b/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md @@ -1,3 +1,5 @@ +translating---geekpi + How modelling helps you avoid getting a stuck OpenStack ============================================================ From 69ab92dc6eb9f5cdd20cd33dc722ca58d505be59 Mon Sep 17 00:00:00 2001 From: toyijiu <309378714@qq.com> Date: Wed, 9 Aug 2017 15:21:01 +0800 Subject: [PATCH 05/27] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E4=B8=AD=20by=20toyiji?= =?UTF-8?q?u=20=E4=B9=8B=E5=89=8D=E9=80=89=E7=9A=84=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=A4=AA=E9=95=BF=EF=BC=8C=E8=80=8C=E4=B8=94?= =?UTF-8?q?=E4=B8=8D=E6=98=AF=E5=96=9C=E6=AC=A2=E7=9A=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E5=B8=8C=E6=9C=9B=E6=8D=A2=E4=B8=80=E4=B8=AA=E7=9F=AD?= =?UTF-8?q?=E4=B8=80=E7=82=B9=E7=9A=84=EF=BC=8C=E6=AF=94=E8=BE=83=E6=84=9F?= =?UTF-8?q?=E5=85=B4=E8=B6=A3=E7=9A=84=E6=96=87=E7=AB=A0=E7=BF=BB=E8=AF=91?= =?UTF-8?q?=EF=BC=8C=E8=BF=98=E6=9C=9B=E6=89=B9=E5=87=86~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sources/talk/20170320 Education of a Programmer.md | 2 -- ...22 The What Why and Wow Behind the CoreOS Container Linux.md | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/sources/talk/20170320 Education of a Programmer.md b/sources/talk/20170320 Education of a Programmer.md index 5672a26b38..5690c0fd5c 100644 --- a/sources/talk/20170320 Education of a Programmer.md +++ b/sources/talk/20170320 Education of a Programmer.md @@ -1,5 +1,3 @@ -翻译中 by WuXiao(toyijiu) - Education of a Programmer ============================================================ diff --git a/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md b/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md index 9f79c35776..8398c07aaf 100644 --- a/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md +++ b/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md @@ -1,3 +1,4 @@ +translated by toyijiu The What, Why and Wow! Behind the CoreOS Container Linux ============================================================ From 76a64f2e9f0feea14fae04e6fcc7f59ab0d4dc4d Mon Sep 17 00:00:00 2001 From: polebug Date: Wed, 9 Aug 2017 16:37:57 +0800 Subject: [PATCH 06/27] polebug is translating --- ...ing the move from Scala to Go and why were not going back.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170124 Making the move from Scala to Go and why were not going back.md b/sources/tech/20170124 Making the move from Scala to Go and why were not going back.md index 61283e4986..cef21ffece 100644 --- a/sources/tech/20170124 Making the move from Scala to Go and why were not going back.md +++ b/sources/tech/20170124 Making the move from Scala to Go and why were not going back.md @@ -1,3 +1,5 @@ +polebug is translating + Making the move from Scala to Go, and why we’re not going back ============================================================ From 53c422bb76031a6384afed26a9f7059702e6da0e Mon Sep 17 00:00:00 2001 From: wxy Date: Wed, 9 Aug 2017 17:11:37 +0800 Subject: [PATCH 07/27] PRF&PUB:20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @rieonke 翻译的很好,流畅而达意! --- ...CONTAINER INITIATIVE OCI SPECIFICATIONS.md | 44 ++++++++----------- 1 file changed, 19 insertions(+), 25 deletions(-) rename {translated/tech => published}/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md (50%) diff --git a/translated/tech/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md b/published/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md similarity index 50% rename from translated/tech/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md rename to published/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md index c8b79a054e..fde82f0023 100644 --- a/translated/tech/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md +++ b/published/20170719 DEMYSTIFYING THE OPEN CONTAINER INITIATIVE OCI SPECIFICATIONS.md @@ -1,73 +1,67 @@ 解密开放容器计划(OCI)规范 ============================================================ - -开放容器计划(OCI)宣布本周完成容器运行时和镜像的第一版规范。OCI 在是 Linux 基金会(Linux Foundation)支持下的容器解决方案标准化的成果。两年来,为了[建立这些规范][12]已经付出了大量的努力。 由此,让我们一起来回顾过去两年中出现的一些误区。 +开放容器计划Open Container Initiative(OCI)宣布本周完成了容器运行时和镜像的第一版规范。OCI 在是 Linux 基金会Linux Foundation支持下的容器解决方案标准化的成果。两年来,为了[建立这些规范][12]已经付出了大量的努力。 由此,让我们一起来回顾过去两年中出现的一些误区。 ![OCI](https://i1.wp.com/blog.docker.com/wp-content/uploads/logo_oci.png?resize=800%2C180&ssl=1) -**误区:OCI 是 Docker 的替代品** +### 误区:OCI 是 Docker 的替代品 -诚然标准非常重要,但它们远非一个完整的生产平台。 以万维网为例,它25年来一路演进,建立在诸如 TCP/IP ,HTTP 和 HTML 等核心可靠的标准之上。再以 TCP/IP 为例,当企业将 TCP/IP 合并为一种通用协议时,它推动了路由器行业,尤其是思科的发展。 然而,思科通过专注于在其路由平台上提供差异化的功能,而成为市场的领导者。我们认为 OCI 规范和 Docker 也是类似这样并行存在的。 +诚然标准非常重要,但它们远非一个完整的生产平台。 以万维网为例,它 25 年来一路演进,建立在诸如 TCP/IP 、HTTP 和 HTML 等可靠的核心标准之上。再以 TCP/IP 为例,当企业将 TCP/IP 合并为一种通用协议时,它推动了路由器行业,尤其是思科的发展。 然而,思科通过专注于在其路由平台上提供差异化的功能,而成为市场的领导者。我们认为 OCI 规范和 Docker 也是类似这样并行存在的。 [Docker 是一个完整的生产平台][13],提供了基于容器的开发、分发、安全、编排的一体化解决方案。Docker 使用了 OCI 规范,但它大约只占总代码的 5%,而且 Docker 平台只有一小部分涉及容器的运行时行为和容器镜像的布局。 -**误区:产品和项目已经通过了 OCI 规范认证** +### 误区:产品和项目已经通过了 OCI 规范认证 -运行时和镜像规范本周刚发布1.0的版本。 而且 OCI 认证计划仍在开发阶段,所以企业在认证正式推出之前(今年晚些时候),没法要求容器产品的合规性,一致性或兼容性。 +运行时和镜像规范本周刚发布 1.0 的版本。 而且 OCI 认证计划仍在开发阶段,所以企业在该认证正式推出之前(今年晚些时候),没法要求容器产品的合规性、一致性或兼容性。 -OCI [认证工作组][14] 目前正在制定标准,使容器产品和开源项目能够符合规范的要求。标准和规范对于实施解决方案的工程师很重要,但正式认证是向客户保证其正在使用的技术真正符合标准的唯一方式。 +OCI [认证工作组][14]目前正在制定标准,使容器产品和开源项目能够符合规范的要求。标准和规范对于实施解决方案的工程师很重要,但正式认证是向客户保证其正在使用的技术真正符合标准的唯一方式。 -**误区:Docker不支持 OCI 规范的工作** +### 误区:Docker 不支持 OCI 规范的工作 Docker 很早就开始为 OCI 做贡献。 我们向 OCI 贡献了大部分的代码,作为 OCI 项目的维护者,为 OCI 运行时和镜像规范定义提供了积极有益的帮助。Docker 运行时和镜像格式在 2013 年开源发布之后,便迅速成为事实上的标准,我们认为将代码捐赠给中立的管理机构,对于避免容器行业的碎片化和鼓励行业创新将是有益的。我们的目标是提供一个可靠和标准化的规范,因此 Docker 提供了一个简单的容器运行时 runc 作为运行时规范工作的基础,后来又贡献了 Docker V2 镜像规范作为 OCI 镜像规范工作的基础。 Docker 的开发人员如 Michael Crosby 和 Stephen Day 从一开始就是这项工作的关键贡献者,确保能将 Docker 的托管和运行数十亿个容器镜像的经验带给 OCI。等认证工作组完成(制定认证规范的)工作后,Docker 将通过 OCI 认证将其产品展示出来,以证明 OCI 的一致性。 -**误区:OCI 仅用于 Linux 容器技术** +### 误区:OCI 仅用于 Linux 容器技术 -因为 OCI 是由 Linux 基金会 (Linux Foundation) 负责制定的,所以很容易让人误解为 OCI 仅适用于 Linux 容器技术。 而实际上并非如此,尽管 Docker 技术源于 Linux 世界,但 Docker 也一直在与微软合作,将我们的容器技术、平台和工具带到 Windows Server 的世界。 此外,Docker 向 OCI 贡献的基础技术广泛适用于包括 Linux ,Windows 和 Solaris 在内的多种操作系统环境,涵盖了 x86,ARM 和 IBM zSeries 等多种架构环境。 +因为 OCI 是由 Linux 基金会Linux Foundation 负责制定的,所以很容易让人误解为 OCI 仅适用于 Linux 容器技术。 而实际上并非如此,尽管 Docker 技术源于 Linux 世界,但 Docker 也一直在与微软合作,将我们的容器技术、平台和工具带到 Windows Server 的世界。 此外,Docker 向 OCI 贡献的基础技术广泛适用于包括 Linux 、Windows 和 Solaris 在内的多种操作系统环境,涵盖了 x86、ARM 和 IBM zSeries 等多种架构环境。 -**误区:Docker 仅仅是OCI的众多贡献者之一** +### 误区:Docker 仅仅是 OCI 的众多贡献者之一 -OCI 作为一个支持成员众多的开放组织,代表了容器行业的广度。 也就是说,它是一个小而专业的个人技术专家组,为制作初始规范的工作贡献了大量的时间和技术。 Docker 是 OCI 的创始成员,贡献了初始代码库,构成了运行时规范的基础,后来引入了参考实现。 同样地,Docker 也将 Docker V2 镜像规范贡献给 OCI 作为镜像规范的基础。 +OCI 作为一个支持成员众多的开放组织,代表了容器行业的广度。 也就是说,它是一个小而专业的个人技术专家组,为制作初始规范的工作贡献了大量的时间和技术。 Docker 是 OCI 的创始成员,贡献了初始代码库,构成了运行时规范的基础和后来的参考实现。 同样地,Docker 也将 Docker V2 镜像规范贡献给 OCI 作为镜像规范的基础。 -**误区:CRI-O 是 OCI 项目** +### 误区:CRI-O 是 OCI 项目 -CRI-O 是云计算基金会(CNCF)Kubernetes 孵化器的开源项目 -- 它不是 OCI 项目。 它基于早期版本的 Docker 体系结构,而 containerd 是一个直接的 CNCF 项目,它是一个包括 runc 参考实现的更大的容器运行时。 containerd 负责镜像传输和存储,容器运行和监控,以及支持存储和网络附件等底层功能。 Docker 在五个最大的云提供商(阿里云,AWS,Google Cloud Platform (GCP),IBM Softlayer 和 Microsoft Azure)的支持下,将 containerd 捐赠给了云计算基金会(CNCF),作为多个容器平台和编排系统的核心容器运行时。 +CRI-O 是云计算基金会Cloud Native Computing Foundation(CNCF)的 Kubernetes 孵化器的开源项目 -- 它不是 OCI 项目。 它基于早期版本的 Docker 体系结构,而 containerd 是一个直接的 CNCF 项目,它是一个包括 runc 参考实现的更大的容器运行时。 containerd 负责镜像传输和存储、容器运行和监控,以及支持存储和网络附件等底层功能。 Docker 在五个最大的云提供商(阿里云、AWS、Google Cloud Platform(GCP)、IBM Softlayer 和 Microsoft Azure)的支持下,将 containerd 捐赠给了云计算基金会(CNCF),作为多个容器平台和编排系统的核心容器运行时。 -**误区:OCI 规范现在已经完成了** +### 误区:OCI 规范现在已经完成了 -虽然首版容器运行时和镜像格式规范的发布是一个重要的里程碑,但还有许多工作有待完成。 OCI 的一开始着眼于定义一个狭窄的规范:开发人员可以依赖于容器的运行时行为,防止容器行业碎片化,并且仍然允许在不断变化的容器域中进行创新。之后才将含容器镜像规范囊括其中。 +虽然首版容器运行时和镜像格式规范的发布是一个重要的里程碑,但还有许多工作有待完成。 OCI 一开始着眼于定义一个狭窄的规范:开发人员可以依赖于容器的运行时行为,防止容器行业碎片化,并且仍然允许在不断变化的容器域中进行创新。之后才将含容器镜像规范囊括其中。 随着工作组完成运行时行为和镜像格式的第一个稳定规范,新的工作考量也已经同步展开。未来的新特性将包括分发和签名等。 然而,OCI 的下一个最重要的工作是提供一个由测试套件支持的认证过程,因为第一个规范已经稳定了。 **在 Docker 了解更多关于 OCI 和开源的信息:** -* 阅读关于[OCI v1.0 版本的运行时和镜像格式规范]的博文[1] - +* 阅读关于 [OCI v1.0 版本的运行时和镜像格式规范]的博文[1] * 访问 [OCI 的网站][2] - * 访问 [Moby 项目网站][3] - * 参加 [DockerCon Europe 2017][4] - * 参加 [Moby Summit LA][5]  -------------------------------------------------------------------------------- 作者简介: -Stephen 是 Docker 开源项目总监。 他曾在 Hewlett-Packard Enterprise (惠普企业)担任董事和杰出技术专家。他的关于开源软件和商业的博客 “再次违约”(http://stephesblog.blogs.com) 和网站 opensource.com。 - +Stephen 是 Docker 开源项目总监。 他曾在 Hewlett-Packard Enterprise (惠普企业)担任董事和杰出技术专家。他的关于开源软件和商业的博客发布在 “再次违约”(http://stephesblog.blogs.com) 和网站 opensource.com 上。 ----------------- via: https://blog.docker.com/2017/07/demystifying-open-container-initiative-oci-specifications/ -作者:[Stephen ][a] +作者:[Stephen][a] 译者:[rieonke](https://github.com/rieonke) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 6efc68f4740a85b763cad7b93854a87db5c1c5bd Mon Sep 17 00:00:00 2001 From: toyijiu <309378714@qq.com> Date: Wed, 9 Aug 2017 22:07:56 +0800 Subject: [PATCH 08/27] =?UTF-8?q?=E7=BF=BB=E8=AF=91=E5=AE=8C=E6=88=90-2017?= =?UTF-8?q?0622=20The=20What=20Why=20and=20Wow=20Behind=20the=20CoreOS=20C?= =?UTF-8?q?ontainer=20Linux.md?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...d Wow Behind the CoreOS Container Linux.md | 95 ------------------- ...d Wow Behind the CoreOS Container Linux.md | 90 ++++++++++++++++++ 2 files changed, 90 insertions(+), 95 deletions(-) delete mode 100644 sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md create mode 100644 translated/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md diff --git a/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md b/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md deleted file mode 100644 index 8398c07aaf..0000000000 --- a/sources/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md +++ /dev/null @@ -1,95 +0,0 @@ -translated by toyijiu -The What, Why and Wow! Behind the CoreOS Container Linux -============================================================ - - -![](https://cdn-images-1.medium.com/max/1600/1*znkOJQnw5_8Ko8VMEpRlpg.png) - -#### Latest Linux distro automatically updates kernel software and gives full configuration control across clusters. - -The usual debate over server Linux distributions begins with: - - _Do you use a _ [_Red Hat Enterprise Linux (RHEL)_][1] _-based distribution, such as _ [_CentOS_][2] _ or _ [_Fedora_][3] _; a _ [_Debian_][4] _-based Linux like _ [_Ubuntu_][5] _; or _ [_SUSE_][6] _?_ - -But now, [CoreOS Container Linux][7] joins the fracas. [CoreOS, recently offered by Linode on its servers][8], takes an entirely different approach than its more conventional, elder siblings. - -So, you may be asking yourself: “Why should I bother, when there are so many other solid Linux distros?” Well, I’ll let Greg Kroah-Hartman, the kernel maintainer for the Linux-stable branch and CoreOS advisor, start the conversation: - -> (CoreOS) handles distro updates (based on the ChromeOS code) combined with Docker and potentially checkpoint/restore, (which) means that you might be [able to update the distro under your application without stopping/starting the process/container.][9] I’ve seen it happen in testing, and it’s scary [good].” - -And that assessment came when CoreOS was in alpha. Back then, [CoreOS was being developed in — believe it or not — a Silicon Valley garage][10]. While CoreOS is no Apple or HPE, it’s grown considerably in the last four years. - -When I checked in on them at 2017’s [CoreOS Fest][11] in San Francisco, CoreOS had support from Google Cloud, IBM, Amazon Web Services, and Microsoft. The project itself now has over a thousand contributors. They think they’re on to something good, and I agree. - -Why? Because, CoreOS is a lightweight Linux designed from the get-go for running containers. It started as a [Docker][12] platform, but over time CoreOS has taken its own path to containers. It now supports both its own take on containers, [rkt][13] (pronounced rocket), and Docker. - -Unlike most Linux distributions, CoreOS doesn’t have a package manager. Instead it takes a page from Google’s ChromeOS and automates software updates to ensure better security and reliability of machines and containers running on clusters. Both operating system updates and security patches are regularly pushed to CoreOS Container Linux machines without sysadmin intervention. - -You control how often patches are pushed using [CoreUpdate, with its web-based interface][14]. This enables you to control when your machines update, and how quickly an update is rolled out across your cluster. - -Specifically, CoreOS does this with the the distributed configuration service [etcd][15]. This is an open-source, distributed key value store based on [YAML][16]. Etcd provides shared configuration and service discovery for Container Linux clusters. - -This service runs on each machine in a cluster. When one server goes down, say to update, it handles the leader election so that the overall Linux system and containerized applications keep running as each server is updated. - -To handle cluster management, [CoreOS used to use fleet][17]. This ties together [systemd][18] and etcd into a distributed init system. While fleet is still around, CoreOS has joined etcd with [Kubernetes][19] container orchestration to form an even more powerful management tool. - -CoreOS also enables you to declaratively customize other operating system specifications, such as network configuration, user accounts, and systemd units, with [cloud-config][20]. - -Put it all together and you have a Linux that’s constantly self-updating to the latest patches while giving you full control over its configuration from individual systems to thousand of container instances. Or, as CoreOS puts it, “You’ll never have to run [Chef ][21]on every machine in order to change a single config value ever again.” - -Let’s say you want to expand your DevOps control even further. [CoreOS helps you there, too, by making it easy to deploy Kubernetes][22]. - -So, what does all this mean? CoreOS is built from the ground-up to make it easy to deploy, manage and run containers. Yes, other Linux distributions, such as the Red Hat family with [Project Atomic][23], also enable you to do this, but for these distributions, it’s an add-on. CoreOS was designed from day one for containers. - -If you foresee using containers in your business — and you’d better because [Docker and containers are fast becoming  _The Way_  to develop and run business applications][24] — then you must consider CoreOS Container Linux, no matter whether you’re running on bare-metal, virtual machines, or the cloud. - -* * * - - _Please feel free to share below any comments or insights about your experience with or questions about CoreOS. And if you found this blog useful, please consider sharing it through social media._ - -* * * - - _About the blogger: Steven J. Vaughan-Nichols is a veteran IT journalist whose estimable work can be found on a host of channels, including _ [_ZDNet.com_][25] _, _ [_PC Magazine_][26] _, _ [_InfoWorld_][27] _, _ [_ComputerWorld_][28] _, _ [_Linux Today_][29] _ and _ [_eWEEK_][30] _. Steven’s IT expertise comes without parallel — he has even been a Jeopardy! clue. And while his views and cloud situations are solely his and don’t necessarily reflect those of Linode, we are grateful for his contributions. He can be followed on Twitter (_ [_@sjvn_][31] _)._ - --------------------------------------------------------------------------------- - -via: https://medium.com/linode-cube/the-what-why-and-wow-behind-the-coreos-container-linux-fa7ceae5593c - -作者:[Steven J. Vaughan-Nichols ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://medium.com/linode-cube/the-what-why-and-wow-behind-the-coreos-container-linux-fa7ceae5593c -[1]:https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux -[2]:https://www.centos.org/ -[3]:https://getfedora.org/ -[4]:https://www.debian.org/ -[5]:https://www.ubuntu.com/ -[6]:https://www.suse.com/ -[7]:https://coreos.com/os/docs/latest -[8]:https://www.linode.com/docs/platform/use-coreos-container-linux-on-linode -[9]:https://plus.google.com/+gregkroahhartman/posts/YvWFmPa9kVf -[10]:https://www.wired.com/2013/08/coreos-the-new-linux/ -[11]:https://coreos.com/fest/ -[12]:https://www.docker.com/ -[13]:https://coreos.com/rkt -[14]:https://coreos.com/products/coreupdate/ -[15]:https://github.com/coreos/etcd -[16]:http://yaml.org/ -[17]:https://github.com/coreos/fleet -[18]:https://www.freedesktop.org/wiki/Software/systemd/ -[19]:https://kubernetes.io/ -[20]:https://coreos.com/os/docs/latest/cloud-config.html -[21]:https://insights.hpe.com/articles/what-is-chef-a-primer-for-devops-newbies-1704.html -[22]:https://blogs.dxc.technology/2017/06/08/coreos-moves-in-on-cloud-devops-with-kubernetes/ -[23]:http://www.projectatomic.io/ -[24]:http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/ -[25]:http://www.zdnet.com/meet-the-team/us/steven-j-vaughan-nichols/ -[26]:http://www.pcmag.com/author-bio/steven-j.-vaughan-nichols -[27]:http://www.infoworld.com/author/Steven-J.-Vaughan_Nichols/ -[28]:http://www.computerworld.com/author/Steven-J.-Vaughan_Nichols/ -[29]:http://www.linuxtoday.com/author/Steven+J.+Vaughan-Nichols/ -[30]:http://www.eweek.com/cp/bio/Steven-J.-Vaughan-Nichols/ -[31]:http://www.twitter.com/sjvn diff --git a/translated/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md b/translated/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md new file mode 100644 index 0000000000..d9d87d78ba --- /dev/null +++ b/translated/tech/20170622 The What Why and Wow Behind the CoreOS Container Linux.md @@ -0,0 +1,90 @@ +CoreOS,一款新的 Linux 发行版的相关介绍 +============================================================ + +![](https://cdn-images-1.medium.com/max/1600/1*znkOJQnw5_8Ko8VMEpRlpg.png) + +#### CoreOS,一款最新的 Linux 发行版本,支持自动升级内核软件,提供各集群间的全部配置操作控制。 + +关于使用哪个版本的 Linux 系统,我们常常会引发相关的讨论: +你是喜欢基于 [_Red Hat Enterprise Linux (RHEL)_][1] 的 [_CentOS_][2] 或者 [_Fedora_][3],还是基于 [_Debian_][4] 的 [_Ubuntu_][5] 和 [_SUSE_][6] 呢? + +但是现在,一款名叫 [CoreOS Container Linux][7] 的 Linux 发行版进入了我们的视野。和它的老前辈比起来,它使用了完全不同的实现方法,并且最近已经正式被部署到一家名叫 Linode 的美国 VPS 提供商的服务器上,为其提供[相关服务][8]。 + +你可能会感到不解,这里有这么多成熟的 Linux 发行版本,为什么要选择用 CoreOS ?借用 Linux 主干分支的维护人员,也是 CoreOS 的顾问的 Greg Kroah-Hartman 先生的一句话: + +> CoreOS 的发行版升级基于 ChromeOS 代码,不用断开 Docker,支持潜在的修复和核对,这意味着不用停止或者重启你的相关进程,就可以[在线升级][9], 测试版本已经支持此功能,这是史无前例的。 + +当 Greg Kroah-Hartman 做出这段评价时,CoreOS 还处于 α 的版本阶段,当时[开发团队正在硅谷的一个车库中紧锣密鼓地开发此产品][10],但 CoreOS 不像最开始的苹果或者惠普,在过去的四年当中一直稳步发展。 + +当我参加在旧金山举办的 [2017 CoreOS 大会][11]时,CoreOS 已经支持谷歌云、IBM、亚马逊和微软的相关服务。现在有超过 1000 位开发人员参与到这个项目中,并为能够成为这个伟大产品的一员而感到高兴。 + +究其原因,CoreOS 是基于 get-go 的轻量级容器化 Linux 发行版,最初基于 [Docker][12] 平台,随着版本的更新,现在除了 Docker ,也支持 [rkt][13] 和 自己的容器。 + +不像大多数其他的 Linux 发行版,CoreOS 没有包管理器,取而代之的是通过 Google ChromeOS 的页面自动进行软件升级,这样能提高在集群上运行的机器/容器的安全性和可靠性。不用通过系统管理员的干涉,操作系统升级组件和安全补丁可以定期自动地上传到 CoreOS 容器进行升级。 + +你可以通过 [CoreUpdate 接口][14]来修改周期上传的时间,这样你就可以控制软件升级的时间和速率。 + +CoreOS 通过一种叫做 [etcd][15] 的分布式配置服务来进行升级,etcd 基于 [YAML][16],是一个开源的分布式哈希表存储系统,它可以为 Linux 集群容器提供服务搜索和共享配置等功能。 + +此服务可作用于集群上的所有服务器,当其中一台服务器需要升级时,可通过集群选举算法来升级,而其他机器则照常运行。 + +对于集群管理,CoreOS 之前采用的是 [fleet][17] 方法,这将 etcd 和 [systemd][18] 强耦合到分布式初始化系统中。当 fleet 仍然在运行时,CoreOS 结合 etcd 和 [Kubernetes][19] 容器编制来构成一个更加强有力的管理工具。 + +CoreOS 也可以让你以声明的方式定义其他操作系统的相关规格,比如用[云配置][20]的方式管理网络配置,用户账号和系统网元等。 + +综上所述,CoreOS 可以自动升级到最新版本,能让你获得从单独系统到集群等各种场景的完全控制,你再也不用为了改变一个单独的配置而在每一个集群的机器上运行 [Chef][21] 配置了。 + +所以说,对于运维工程师来说,[CoreOS能够更加快速有效地帮助你部署各种平台系统][22]。 + +通过CoreOS自下而上的构建,运维人员能够更加容易地部署、管理和运行系统。当然有[原子计画的红帽][23]等其他 Linux 发行版本也可以达到类似的效果,但它是在后续版本中才扩展的附加组件,而 CoreOS 从它诞生的第一天就有了。 + +当前[基于容器和 Docker 的框架已经逐渐成为商业系统的主流][24],如果在可预见的未来,你要在工作中使用容器,你最好考虑下 CoreOS,不管你的系统是在云上、虚拟机还是裸机硬件上跑。 + +* * * +如果有任何关于 CoreOS 的观点或者问题,还请在评论栏中留言。如果你觉得这篇博客还算有用的话,还请分享一下~ +* * * + +关于博主:Steven J. Vaughan-Nichols 是一位经验丰富的 IT 记者,许多网站中都刊登有他的文章,包括 [_ZDNet.com_][25] _, _ [_PC Magazine_][26] _, _ [_InfoWorld_][27] _, _ [_ComputerWorld_][28] _, _ [_Linux Today_][29] 和 [_eWEEK_][30] 等. 他拥有丰富的 IT 知识 - 而且他曾参加过智力竞赛节目 Jeopardy !他的相关观点都是自身思考的结果,并不代表 Linode 公司,我们对他做出的贡献致以最真诚的感谢。如果想知道他更多的信息,可以关注他的 Twitter [_@sjvn_][31]. + +-------------------------------------------------------------------------------- + +via: https://medium.com/linode-cube/the-what-why-and-wow-behind-the-coreos-container-linux-fa7ceae5593c + +作者:[Steven J. Vaughan-Nichols ][a] +译者:[吴霄/toyijiu](https://github.com/toyijiu) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://medium.com/linode-cube/the-what-why-and-wow-behind-the-coreos-container-linux-fa7ceae5593c +[1]:https://www.redhat.com/en/technologies/linux-platforms/enterprise-linux +[2]:https://www.centos.org/ +[3]:https://getfedora.org/ +[4]:https://www.debian.org/ +[5]:https://www.ubuntu.com/ +[6]:https://www.suse.com/ +[7]:https://coreos.com/os/docs/latest +[8]:https://www.linode.com/docs/platform/use-coreos-container-linux-on-linode +[9]:https://plus.google.com/+gregkroahhartman/posts/YvWFmPa9kVf +[10]:https://www.wired.com/2013/08/coreos-the-new-linux/ +[11]:https://coreos.com/fest/ +[12]:https://www.docker.com/ +[13]:https://coreos.com/rkt +[14]:https://coreos.com/products/coreupdate/ +[15]:https://github.com/coreos/etcd +[16]:http://yaml.org/ +[17]:https://github.com/coreos/fleet +[18]:https://www.freedesktop.org/wiki/Software/systemd/ +[19]:https://kubernetes.io/ +[20]:https://coreos.com/os/docs/latest/cloud-config.html +[21]:https://insights.hpe.com/articles/what-is-chef-a-primer-for-devops-newbies-1704.html +[22]:https://blogs.dxc.technology/2017/06/08/coreos-moves-in-on-cloud-devops-with-kubernetes/ +[23]:http://www.projectatomic.io/ +[24]:http://www.zdnet.com/article/what-is-docker-and-why-is-it-so-darn-popular/ +[25]:http://www.zdnet.com/meet-the-team/us/steven-j-vaughan-nichols/ +[26]:http://www.pcmag.com/author-bio/steven-j.-vaughan-nichols +[27]:http://www.infoworld.com/author/Steven-J.-Vaughan_Nichols/ +[28]:http://www.computerworld.com/author/Steven-J.-Vaughan_Nichols/ +[29]:http://www.linuxtoday.com/author/Steven+J.+Vaughan-Nichols/ +[30]:http://www.eweek.com/cp/bio/Steven-J.-Vaughan-Nichols/ +[31]:http://www.twitter.com/sjvn From 8ec5a349f2c6541ca3a9a8109fee2f2c04333102 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 Aug 2017 08:41:05 +0800 Subject: [PATCH 09/27] translated --- ...lps you avoid getting a stuck OpenStack.md | 78 ------------------- ...lps you avoid getting a stuck OpenStack.md | 76 ++++++++++++++++++ 2 files changed, 76 insertions(+), 78 deletions(-) delete mode 100644 sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md create mode 100644 translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md diff --git a/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md b/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md deleted file mode 100644 index ab05f37142..0000000000 --- a/sources/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md +++ /dev/null @@ -1,78 +0,0 @@ -translating---geekpi - -How modelling helps you avoid getting a stuck OpenStack -============================================================ - - -### Share or save - -![](https://insights.ubuntu.com/wp-content/uploads/bd5d/airbus.jpg) - - _Lego model of an Airbus A380-800\. Airbus run OpenStack_ - -A “StuckStack” is a deployment of OpenStack that usually, for technical but sometimes business reasons, is unable to be upgraded without significant disruption, time and expense. In the last post on this topic we discussed how many of these clouds became stuck and how the decisions made at the time were consistent with much of the prevailing wisdom of the day. Now, with OpenStack being 7 years old, the recent explosion of growth in container orchestration systems and more businesses starting to make use of cloud platforms, both public and private, OpenStack are under pressure. - -### No magic solution - -If you are still searching for a solution to upgrade your existing StuckStack in place without issues, then I have bad news for you: there are no magic solutions and you are best focusing your energy on building a standardised platform that can be operated efficiently and upgraded easily. - -The low cost airlines industry has shown that whilst flyers may aspire to best of breed experience and sit in first or business class sipping champagne with plenty of space to relax, most will choose to fly in the cheapest seat as ultimately the value equation doesn’t warrant them paying more. Workloads are the same. Long term, workloads will run on the platform where it is most economic to run them as the business really doesn’t benefit from running on premium priced hardware or software. - -Amazon, Microsoft, Google and other large scale public cloud players know this which is why they have built highly efficient data centres and used models to build, operate and scale their infrastructure. Enterprises have long followed a policy of using best of breed hardware and software infrastructure that is designed, built, marketed, priced, sold and implemented as first class experiences. The reality may not have always lived up to the promise but it matters not now anyway, as the cost model cannot survive in today’s world. Some organisations have tried to tackle this by switching to free software alternatives yet without a change in their own behaviour. Thus find that they are merely moving cost from software acquisition to software operation.The good news is that the techniques used by the large operators, who place efficient operations above all else, are available to organisations of all types now. - -### What is a software model? - -Whilst for many years software applications have been comprised of many objects, processes and services, in recent years it has become far more common for applications to be made up of many individual services that are highly distributed across servers in a data centre and across different data centres themselves. - -![](https://insights.ubuntu.com/wp-content/uploads/f881/OpenStack-graphic.png) - - _A simple representation of OpenStack Services_ - -Many services means many pieces of software to configure, manage and keep track of over many physical machines. Doing this at scale in a cost efficient way requires a model of how all the components are connected and how they map to physical resources. To build the model we need to have a library of software components, a means of defining how they connect with one another and a way to deploy them onto a platform, be it physical or virtual. At Canonical we recognised this several years ago and built [Juju][2], a generic software modelling tool that enables operators to compose complex software applications with flexible topologies, architectures and deployment targets from a catalogue of 100s of common software services. - -![](https://insights.ubuntu.com/wp-content/uploads/7790/jjuju.png) - - _Juju modelling OpenStack Services_ - -In Juju, software services are defined in something called a Charm. Charms are pieces of code, typically written in python or bash that give information about the service – the interfaces declared, how the service is installed, what other services it can connect to etc. - -Charms can be simple or complex depending on the level of intelligence you wish to give them. For OpenStack, Canonical, with help from the upstream OpenStack community, has developed a full set of Charms for the primary OpenStack services. The Charms represents the instructions for the model such that it can be deployed, operated scaled and replicated with ease. The Charms also define how to upgrade themselves including, where needed, the sequence in which to perform the upgrade and how to gracefully pause and resume services when required. By connecting Juju to a bare metal provisioning system such as [Metal As A Service (MAAS)][3] the logical model of OpenStack can is deployed to physical hardware. By default, the Charms will deploy services in LXC containers which gives greater flexibility to relocate services as required based on the cloud behaviour. Config is defined in the Charms or injected at deploy time by a 3rd party tool such as Puppet or Chef. - -There are 2 distinct benefits from this approach: 1 – by creating a model we have abstracted each of the cloud services from the underlying hardware and 2: we have the means to compose new architectures through iterations using the standardised components from a known source. This consistency is what enables us to deploy very different cloud architectures using the same tooling, safe in the knowledge that we will be able to operate and upgrade them easily. - -With hardware inventory being managed with a fully automated provisioning tool and software applications modelled, operators can scale infrastructure much more efficiently than using legacy enterprise techniques or building a bespoke system that deviates from core. Valuable development resources can be focused on innovating in the application space, bringing new software services online faster rather than altering standard, commodity infrastructure in a way which will create compatibility problems further down the line. - -In the next post I’ll highlight some of the best practises for deploying a fully modelled OpenStack and how you can get going quickly. If you have an existing StuckStack then whilst we aren’t going to be able to rescue it that easily, we will be able to get you on a path to fully supported, efficient infrastructure with operations cost that compares to public cloud. - -### Upcoming webinar - -If you are stuck on an old version of OpenStack and want to upgrade your OpenStack cloud easily and without downtime, watch our [on-demand webinar][4] with live demo of an upgrade from Newton to Ocata. - -### Contact us - -If you would like to learn more about migrating to a Canonical OpenStack cloud, [get in touch][5]. - --------------------------------------------------------------------------------- - -作者简介: - -Cloud Product Manager focused on Ubuntu OpenStack. Previously at MySQL and Red Hat. Likes motorcycles and meeting people who do interesting stuff with Ubuntu and OpenStack - - ------- - - -via: https://insights.ubuntu.com/2017/07/18/stuckstack-how-modelling-helps-you-avoid-getting-a-stuck-openstack/ - -作者:[Mark Baker ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://insights.ubuntu.com/author/markbaker/ -[1]:https://insights.ubuntu.com/author/markbaker/ -[2]:https://www.ubuntu.com/cloud/juju -[3]:https://www.ubuntu.com/server/maas -[4]:http://ubunt.eu/Bwe7kQ -[5]:http://ubunt.eu/3OYs5s diff --git a/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md b/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md new file mode 100644 index 0000000000..5cad8ffe47 --- /dev/null +++ b/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md @@ -0,0 +1,76 @@ +如何建模可以帮助你避免在 OpenStack 中遇到问题 +============================================================ + + +### 分享或保存 + +![](https://insights.ubuntu.com/wp-content/uploads/bd5d/airbus.jpg) + + _乐高的空客 A380-800模型。空客运行 OpenStack_ + +“StuckStack” 是 OpenStack 的一种部署方式,通常由于技术上但有时是商业上的原因,它无法在没有明显中断、时间和费用的情况下升级。在关于这个话题的最后一篇文章中,我们讨论了这些云中有多少陷入僵局,当时的决定与当今大部分的智慧是一致的。现在 OpenStack 已经有 7 年了,最近随着容器编排系统的增长以及更多企业开始利用公共和私有的云平台,OpenStack 正面临着压力。 + + +### 没有魔法解决方案 + +如果你仍在寻找一个解决方案来没有任何问题地升级你现有的 StuckStack, 那么我有坏消息给你: 有没有魔法解决方案, 你最好集中精力建立一个标准化的平台, 它可以有效地操作和升级。 + +低成本航空业已经表明, 虽然乘客可能渴望最好的体验, 可以坐在头等舱或者商务舱喝香槟, 有足够的空间放松, 但是大多数人会选择乘坐最便宜的, 最终价值等式不保证他们付出更多的代价。工作负载是相同的。长期而言, 工作负载将运行在最经济的平台上, 因为在高价硬件或软件上运行的业务实际上并没有受益。 + +Amazon、Microsoft、Google 等大型公共云企业都知道,这就是为什么他们建立了高效的数据中心, 并使用模型来构建、操作和扩展基础设施。长期以来,企业一直奉行以设计、制造、市场、定价、销售,实施为一体的最优秀的硬件和软件基础设施。现实可能并不总是符合承诺,但由于成本模式在当今世界无法生存,所以现在还不重要。一些组织试图通过改用免费软件替代, 而不改变自己的行为来解决这一问题。因此, 他们发现, 他们只是将成本从软件获取变到软件操作。好消息是,那些高效运营的大型运营商使用的技术,现在可用于所有类型的组织。 + +### 什么是软件模型? + +虽然许多年来, 软件程序由许多对象、进程和服务组成, 但近年来, 程序是普遍由许多单独的服务组成, 它们高度分布式地分布在数据中心的不同服务器以及跨越数据中心的服务器上。 + +![](https://insights.ubuntu.com/wp-content/uploads/f881/OpenStack-graphic.png) + + _OpenStack 服务的简单演示_ + +许多服务意味着许多软件需要配置、管理并跟踪许多物理机器。以成本效益的方式规模化地进行这一工作需要一个模型,即所有组件如何连接以及它们如何映射到物理资源。为了构建模型,我们需要有一个软件组件库,这是一种定义它们如何彼此连接以及将其部署到平台上的方法,无论是物理还是虚拟。在 Canonical 公司,我们几年前就认识到这一点,并建立了一个通用的软件建模工具 [Juju][2],使得运营商能够从 100 个通用软件服务目录中组合灵活的拓扑结构、架构和部署目标。 + +![](https://insights.ubuntu.com/wp-content/uploads/7790/jjuju.png) + + _Juju 建模 OpenStack 服务_ + +在 Juju 中,软件服务被定义为一种叫做 Charm 的东西。 Charms 是代码片段,它通常用 python 或 bash 编写,其中提供有关服务的信息 - 声明的接口、服务的安装方式、可连接的其他服务等。 + +Charms 可以简单或者复杂,具体取决于你想要赋予的功能。对于 OpenStack,Canonical 在上游 OpenStack 社区的帮助下,为主要 OpenStack 服务开发了一套完整的 Charms。Charms 代表了模型的说明,使其可以轻松地部署、操作扩展和复制。Charms 还定义了如何升级自身,包括在需要时执行升级的顺序以及如何在需要时优雅地暂停和恢复服务。通过将 Juju 连接到诸如[裸机即服务(MAAS)][3]这样的裸机配置系统,其中 OpenStack 的逻辑模型可以部署到物理硬件上。默认情况下,Charms 将在 LXC 容器中部署服务,从而根据云行为的需要, 提供更大的灵活性来重新定位服务。配置在 Charms 中定义,或者在部署时由第三方工具(如 Puppet 或 Chef)注入。 + +这种方法有两个不同的好处:1 - 通过创建一个模型,我们从底层硬件抽象出每个云服务。2 - 使用已知来源的标准化组件,通过迭代组合新的架构。这种一致性使我们能够使用相同的工具部署非常不同的云架构,运行和升级这些工具是安全的。 + +通过全面自动化的配置工具和软件程序来管理硬件库存,运营商可以比使用传统企业技术或构建偏离核心的定制系统更有效地扩展基础架构。有价值的开发资源可以集中在创新应用领域,使新的软件服务更快上线,而不是改变标准的商品基础设施, 这将会导致进一步的兼容性问题。 + +在下一篇文章中,我将介绍部署完全建模的 OpenStack 的一些最佳实践,以及如何快速地进行操作。如果你有一个现有的 StuckStack, 那么虽然我们不能很容易地拯救它, 但是与公有云相比,我们将能够让你走上一条完全支持的、高效的基础架构以及运营成本的道路。 + +### 即将举行的网络研讨会 + +如果你在旧版本的 OpenStack 中遇到问题,并且想要轻松升级 OpenStack 云并且无需停机,请观看我们的[在线点播研讨会][4],从 Newton 升级到 Ocata 的现场演示。 + +### 联系我们 + +如果你想了解有关迁移到 Canonical OpenStack 云的更多信息,请[联系][5]。 + +-------------------------------------------------------------------------------- + +作者简介: + +专注于 Ubuntu OpenStack 的云产品经理。以前在 MySQL 和 Red Hat 工作。喜欢摩托车,遇见使用 Ubuntu 和 Openstack 做有趣事的人。 + +------ + + +via: https://insights.ubuntu.com/2017/07/18/stuckstack-how-modelling-helps-you-avoid-getting-a-stuck-openstack/ + +作者:[Mark Baker ][a] +译者:[译者ID](https://github.com/译者ID) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://insights.ubuntu.com/author/markbaker/ +[1]:https://insights.ubuntu.com/author/markbaker/ +[2]:https://www.ubuntu.com/cloud/juju +[3]:https://www.ubuntu.com/server/maas +[4]:http://ubunt.eu/Bwe7kQ +[5]:http://ubunt.eu/3OYs5s From f6464ce07f5f20644003f24e0872df4695bb5363 Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 Aug 2017 08:42:21 +0800 Subject: [PATCH 10/27] translated --- ...8 How modelling helps you avoid getting a stuck OpenStack.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md b/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md index 5cad8ffe47..c9076ec50f 100644 --- a/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md +++ b/translated/tech/20170718 How modelling helps you avoid getting a stuck OpenStack.md @@ -63,7 +63,7 @@ Charms 可以简单或者复杂,具体取决于你想要赋予的功能。对 via: https://insights.ubuntu.com/2017/07/18/stuckstack-how-modelling-helps-you-avoid-getting-a-stuck-openstack/ 作者:[Mark Baker ][a] -译者:[译者ID](https://github.com/译者ID) +译者:[geekpi](https://github.com/geekpi) 校对:[校对者ID](https://github.com/校对者ID) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 2be2f3ca1a7b99dd4fa1ecde65d49c00ddbc3cff Mon Sep 17 00:00:00 2001 From: geekpi Date: Thu, 10 Aug 2017 08:45:50 +0800 Subject: [PATCH 11/27] translating --- .../20170117 The Age of the Unikernel- 10 Projects to Know.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sources/tech/20170117 The Age of the Unikernel- 10 Projects to Know.md b/sources/tech/20170117 The Age of the Unikernel- 10 Projects to Know.md index 45cf389712..fdda74b4e7 100644 --- a/sources/tech/20170117 The Age of the Unikernel- 10 Projects to Know.md +++ b/sources/tech/20170117 The Age of the Unikernel- 10 Projects to Know.md @@ -1,3 +1,5 @@ +translating---geekpi + The Age of the Unikernel: 10 Projects to Know ============================================================ From 31e744876b3f7191ab9062cdd98002b4f2329fa3 Mon Sep 17 00:00:00 2001 From: dimple <786796696@qq.com> Date: Thu, 10 Aug 2017 10:03:54 +0800 Subject: [PATCH 12/27] 20170705 Two great uses for the cp command (#5916) * translated * Update 20170705 Two great uses for the cp command.md * Update 20170705 Two great uses for the cp command.md * Update 20170705 Two great uses for the cp command.md --- ...70705 Two great uses for the cp command.md | 206 ------------------ ...70705 Two great uses for the cp command.md | 188 ++++++++++++++++ 2 files changed, 188 insertions(+), 206 deletions(-) delete mode 100644 sources/tech/20170705 Two great uses for the cp command.md create mode 100644 translated/tech/20170705 Two great uses for the cp command.md diff --git a/sources/tech/20170705 Two great uses for the cp command.md b/sources/tech/20170705 Two great uses for the cp command.md deleted file mode 100644 index c7d9eda069..0000000000 --- a/sources/tech/20170705 Two great uses for the cp command.md +++ /dev/null @@ -1,206 +0,0 @@ -【big_dimple翻译中】 -Two great uses for the cp command -============================================================ - -### Linux's copy command makes quick work of making specialized backups. - - -![Two great uses for the cp command](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/car-penguin-drive-linux-yellow.png?itok=ueZE5mph "Two great uses for the cp command") -Image by :  - -Internet Archive [Book][10] [Images][11]. Modified by Opensource.com. CC BY-SA 4.0 - -The point-and-click graphical user interface available on Linux is a wonderful thing... but if your favorite interactive development environment consists of the terminal window, Bash, Vim, and your favorite language compiler, then, like me, you use the terminal  _a lot_ . - -But even people who generally avoid the terminal can benefit by being more aware of the riches that its environment offers. A case in point – the **cp** command. [According to Wikipedia][12], the **cp** (or copy) command was part of Version 1 of [Unix][13]. Along with a select group of other commands—**ls**, **mv**, **cd**, **pwd**, **mkdir**, **vi**, **sh**, **sed**, and **awk** come to mind—**cp** was one of my first few steps in System V Unix back in 1984\. The most common use of **cp** is to make a copy of a file, as in: - -``` -cp sourcefile destfile -``` - -More Linux resources - -* [What is Linux?][1] - -* [What are Linux containers?][2] - -* [Download Now: Linux commands cheat sheet][3] - -* [Advanced Linux commands cheat sheet][4] - -* [Our latest Linux articles][5] - -issued at the command prompt in a terminal session. The above command copies the file named **sourcefile** to the file named **destfile**. If **destfile** doesn't exist before the command is issued, it's created; if it does exist, it's overwritten. - -I don't know how many times I've used this command (maybe I don't want to know), but I do know that I often use it when I'm writing and testing code and I have a working version of something that I want to retain as-is before I move on. So, I have probably typed something like this: - -``` -cp test1.py test1.bak -``` - -at a command prompt at least a zillion times over the past 30+ years. Alternatively, I might have decided to move on to version 2 of my test program, in which case I may have typed: - -``` -cp test1.py test2.py -``` - -to accomplish the first step of that move. - -This is such a common and simple thing to do that I have rarely ever looked at the reference documentation for **cp**. But, while backing up my Pictures folder (using the Files application in my GUI environment), I started thinking, "I wonder if there is an option to have **cp** copy over only new files or those that have changed?" And sure enough, there is! - -### Great use #1: Updating a second copy of a folder - -Let's say I have a folder on my computer that contains a collection of files. Furthermore, let's say that from time to time I put a new file into that collection. Finally, let's say that from time to time I might edit one of those files in some way. An example of such a collection might be the photos I download from my cellphone or my music files. - -Assuming that this collection of files has some enduring value to me, I might occasionally want to make a copy of it—a kind of "snapshot" of it—to preserve it on some other media. Of course, there are many utility programs that exist for doing backups, but maybe I want to have this exact structure duplicated on a removable device that I generally store offline or even connect to another computer. - -The **cp** command offers a dead-easy way to do this. Here's an example. - -In my **Pictures** folder, I have a sub-folder called **Misc**. For illustrative purposes, I'm going to make a copy of it on a USB memory stick. Here we go! - -``` -me@desktop:~/Pictures$ cp -r Misc /media/clh/4388-D5FE -me@desktop:~/Pictures$ -``` - -The above lines are copied as-is from my terminal window. For those who might not be fully comfortable with that environment, it's worth noting that **me @mydesktop:~/Pictures$** is the command prompt provided by the terminal before every command is entered and executed. It identifies the user (**me**), the computer (**mydesktop**), and the current working directory, in this case, **~/Pictures**, which is shorthand for **/home/me/Pictures**, that is, the **Pictures** folder in my home directory. - -The command I've entered and executed, **cp -r Misc /media/clh/4388-D5FE**, copies the folder **Misc** and all its contents (the **-r**, or "recursive," option indicates the contents as well as the folder or file itself) into the folder **/media/clh/4388-D5FE**, which is where my USB stick is mounted. - -Executing the command returned me to the original prompt. Like with most commands inherited from Unix, if the command executes without detecting any kind of anomalous result, it won't print out a message like "execution succeeded" before terminating. People who would like more feedback can use the **-v** option to make execution "verbose." - -Below is an image of my new copy of **Misc** on the USB drive. There are nine JPEG files in the directory. - -### [cp1_file_structure.png][6] - -![Image of the new copy of Misc on the USB drive](https://opensource.com/sites/default/files/u128651/cp1_file_structure.png "Image of the new copy of Misc on the USB drive") - -Suppose I add a few new files to the master copy of the directory **~/Pictures/Misc**, so now it looks like this: - -### [cp2_new_files.png][7] - -![New files added to the master directory](https://opensource.com/sites/default/files/u128651/cp2_new_files.png "New files added to the master directory") - -Now I want to copy over only the new files to my memory stick. For this I'll use the "update" and "verbose" options to **cp**: - -``` -me@desktop:~/Pictures$ cp -r -u -v Misc /media/clh/4388-D5FE -'Misc/asunder.png' -> '/media/clh/4388-D5FE/Misc/asunder.png' -'Misc/editing tags guayadeque.png' -> '/media/clh/4388-D5FE/Misc/editing tags guayadeque.png' -'Misc/misc on usb.png' -> '/media/clh/4388-D5FE/Misc/misc on usb.png' -me@desktop:~/Pictures$ -``` - -The first line above shows the **cp** command and its options (**-r** for "recursive", **-u** for "update," and **-v** for "verbose"). The next three lines show the files that are copied across. The last line shows the command prompt again. - -Generally speaking, options such as **-r** can also be given in a more verbose fashion, such as **--recursive**. In brief form, they can also be combined, such as **-ruv**. - -### Great use #2 – Making versioned backups - -Returning to my initial example of making periodic backups of working versions of code in development, another really useful **cp** option I discovered while learning about update is backup. - -Suppose I'm setting out to write a really useful Python program. Being a fan of iterative development, I might do so by getting a simple version of the program working first, then successively adding more functionality to it until it does the job. Let's say my first version just prints the string "hello world" using the Python print command. This is a one-line program that looks like this: - -``` -print 'hello world' -``` - -and I've put that string in the file **test1.py**. I can run it from the command line as follows: - -``` -me@desktop:~/Test$ python test1.py -hello world -me@desktop:~/Test$ -``` - -Now that the program is working, I want to make a backup of it before adding the next component. I decide to use the backup option with numbering, as follows: - -``` -clh@vancouver:~/Test$ cp --force --backup=numbered test1.py test1.py -clh@vancouver:~/Test$ ls -test1.py  test1.py.~1~ -clh@vancouver:~/Test$ -``` - -So, what does this all mean? - -First, the **--backup=numbered** option says, "I want to do a backup, and I want successive backups to be numbered." So the first backup will be number 1, the second 2, and so on. - -Second, note that the source file and destination file are the same. Normally, if we try to use the **cp** command to copy a file onto itself, we will receive a message like: - -``` -cp: 'test1.py' and 'test1.py' are the same file -``` - -In the special case where we are doing a backup and we want the same source and destination, we use the **--force** option. - -Third, I used the **ls** (or "list") command to show that we now have a file called **test1.py**, which is the original, and another called **test1.py.~1~**, which is the backup file. - -Suppose now that the second bit of functionality I want to add to the program is another print statement that prints the string "Kilroy was here." Now the program in file **test1.py**looks like this: - -``` -print 'hello world' -print 'Kilroy was here' -``` - -See how simple Python programming is? Anyway, if I again execute the backup step, here's what happens: - -``` -clh@vancouver:~/Test$ cp --force --backup=numbered test1.py test1.py -clh@vancouver:~/Test$ ls -test1.py test1.py.~1~ test1.py.~2~ -clh@vancouver:~/Test$ -``` - -Now we have two backup files: **test1.py.~1~**, which contains the original one-line program, and **test1.py.~2~**, which contains the two-line program, and I can move on to adding and testing some more functionality. - -This is such a useful thing to me that I am considering making a shell function to make it simpler. - -### Three points to wrap this up - -First, the Linux manual pages, installed by default on most desktop and server distros, provide details and occasionally useful examples of commands like **cp**. At the terminal, enter the command: - -``` -man cp -``` - -Such explanations can be dense and obscure to users just trying to learn how to use a command in the first place. For those inclined to persevere nevertheless, I suggest creating a test directory and files and trying the command and options out there. - -Second, if a tutorial is of greater interest, the search string "linux shell tutorial" typed into your favorite search engine brings up a lot of interesting and useful resources. - -Third, if you're wondering, "Why bother when the GUI typically offers the same functionality with point-and-click ease?" I have two responses. The first is that "point-and-click" isn't always that easy, especially when it disrupts another workflow and requires a lot of points and a lot of clicks to make it work. The second is that repetitive tasks can often be easily streamlined through the use of shell scripts, shell functions, and shell aliases. - -Are you using the **cp** command in new or interesting ways? Let us know about them in the comments. - --------------------------------------------------------------------------------- - -作者简介: - -Chris Hermansen - Engaged in computing since graduating from the University of British Columbia in 1978, I have been a full-time Linux user since 2005 and a full-time Solaris, SunOS and UNIX System V user before that. On the technical side of things, I have spent a great deal of my career doing data analysis; especially spatial data analysis. I have a substantial amount of programming experience in relation to data analysis, using awk, Python, PostgreSQL, PostGIS and lately Groovy. - - -via: https://opensource.com/article/17/7/two-great-uses-cp-command - -作者:[ Chris Hermansen ][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:https://opensource.com/users/clhermansen -[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent -[6]:https://opensource.com/file/360601 -[7]:https://opensource.com/file/360606 -[8]:https://opensource.com/article/17/7/two-great-uses-cp-command?rate=87TiE9faHZRes_f4Gj3yQZXhZ-x7XovYhnhjrk3SdiM -[9]:https://opensource.com/user/37806/feed -[10]:https://www.flickr.com/photos/internetarchivebookimages/14746482994/in/photolist-ot6zCN-odgbDq-orm48o-otifuv-otdyWa-ouDjnZ-otGT2L-odYVqY-otmff7-otGamG-otnmSg-rxnhoq-orTmKf-otUn6k-otBg1e-Gm6FEf-x4Fh64-otUcGR-wcXsxg-tLTN9R-otrWYV-otnyUE-iaaBKz-ovcPPi-ovokCg-ov4pwM-x8Tdf1-hT5mYr-otb75b-8Zk6XR-vtefQ7-vtehjQ-xhhN9r-vdXhWm-xFBgtQ-vdXdJU-vvTH6R-uyG5rH-vuZChC-xhhGii-vvU5Uv-vvTNpB-vvxqsV-xyN2Ai-vdXcFw-vdXuNC-wBMhes-xxYmxu-vdXxwS-vvU8Zt -[11]:https://www.flickr.com/photos/internetarchivebookimages/14774719031/in/photolist-ovAie2-otPK99-xtDX7p-tmxqWf-ow3i43-odd68o-xUPaxW-yHCtWi-wZVsrD-DExW5g-BrzB7b-CmMpC9-oy4hyF-x3UDWA-ow1m4A-x1ij7w-tBdz9a-tQMoRm-wn3tdw-oegTJz-owgrs2-rtpeX1-vNN6g9-owemNT-x3o3pX-wiJyEs-CGCC4W-owg22q-oeT71w-w6PRMn-Ds8gyR-x2Aodm-owoJQm-owtGp9-qVxppC-xM3Gw7-owgV5J-ou9WEs-wihHtF-CRmosE-uk9vB3-wiKdW6-oeGKq3-oeFS4f-x5AZtd-w6PNuv-xgkofr-wZx1gJ-EaYPED-oxCbFP -[12]:https://en.wikipedia.org/wiki/Cp_(Unix) -[13]:https://en.wikipedia.org/wiki/Unix -[14]:https://opensource.com/users/clhermansen -[15]:https://opensource.com/users/clhermansen -[16]:https://opensource.com/article/17/7/two-great-uses-cp-command#comments diff --git a/translated/tech/20170705 Two great uses for the cp command.md b/translated/tech/20170705 Two great uses for the cp command.md new file mode 100644 index 0000000000..48fb8224a7 --- /dev/null +++ b/translated/tech/20170705 Two great uses for the cp command.md @@ -0,0 +1,188 @@ +【big_dimple翻译完成】 +# cp命令两个高效的用法 + +============================================================ + +### Linux中高效的备份拷贝命令 + + +![Two great uses for the cp command](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/car-penguin-drive-linux-yellow.png?itok=ueZE5mph "Two great uses for the cp command") + +图像来自于:Opensource.com + +在Linux上能使用图形化界面是一件很美妙的事...但是如果你像我一样,喜欢的开发交互环境和编译器是终端窗口,Bash 和 Vim,那你将会经常和终端打交道。 + +即使是不经常使用终端的人,也能通过终端提供的环境来获取很多有用的知识。举个例子—**cp**命令,通过[Wiki百科][12]的解释,**cp** (或者copy)命令是[Unix][13]系统第一个版本中的一部分。以及其他的一组命令 **ls**, **mv**, **cd**, **pwd**, **mkdir**, **vi**, **sh**, **sed**, 和 **awk** 还有我们所说的 **cp** 都是在 1984 年构造Unix系统第一个版本中最初的几步。**cp** 命令最常见的用法是复制文件。像这样: + +``` +cp sourcefile destfile +``` +在终端中执行此命令,上述命令将名为 **sourcefile** 的文件复制到名为 **destfile** 的文件中。如果在执行命令之前 **destfile** 文件不存在,那将会创建此文件,如果已经存在,那就会覆盖此文件。 + +这个命令我不知道自己用了多少次了(或许我不想知道),但是我知道在我测试代码的时候,我经常用,为了保留当前版本,而且又能继续修改,我会输入这个命令: + +``` +cp test1.py test1.bak +``` +在过去的30多年里,我使用了无数次这个命令。另外,当我决定编写我的第二版测试程序时,我会输入这个命令: + +``` +cp test1.py test2.py +``` +这样就完成了修改程序版本的第一步。 + +我通常很少查看 **cp** 命令的参考文档,但是当我在备份我的图片文件夹的时候(在GUI环境下使用文件应用),我开始思考“在 **cp** 命令中是否有个参数支持只复制新文件或者是修改过的文件。”果然,真的有! + +### 高效用法1:更新你的文件夹 +比如说在我的电脑上有一个存放各种文件的文件夹,另外我要不时的往里面添加一些新文件,而且我会不时地修改一些文件,例如我手机里下载的照片或者是音乐。 + +假设我收集的这些文件对我而言都很有价值,我有时候会想做个拷贝,就像是“快照”一样将文件保存在其它媒体。当然目前有很多程序都支持备份,但是我想更为精确的将目录结构复制到可移动设备中,方便于我经常使用这些离线设备或者连接到其它电脑上。 + + **cp** 命令提供了一个易如反掌的方法。例子如下: + +在我的 **Pictures** 文件夹下,我有这样一个文件夹名字为 **Misc**。为了方便说明,我把文件拷贝到USB存储设备上。让我们开始吧! + +``` +me@desktop:~/Pictures$ cp -r Misc /media/clh/4388-D5FE +me@desktop:~/Pictures$ +``` +上面的命令是我从按照终端窗口中完整复制下来的。对于有些人来说这种环境可能不是很舒服,在我们输入命令或者执行命令之前,需要注意的是 **me@mydesktop:~/Pictures** 这个前缀,(**me**)这个是当前用户,(**mydesktop**)这是电脑名称,(**~/Pictures**)这个是当前工作目录,是(**/home/me/Pictures**)完整路径的缩写。 + +我输入这个命令并执行后(**cp -r Misc /media/clh/4388-D5FE**),拷贝 **Misc** 目录下所有文件(这个 **-r**参数,全称“recursive”,递归处理,意思为本目录下所有文件及子目录一起处理)到我的USB设备的挂载目录 **/media/clh/4388-D5FE**。 + +执行命令后回到之前的提示,大多数命令继承了Unix的特性,在命令执行后,如果没有任何异常什么都不显示,在任务结束之前不会显示像“execution succeeded“这样的提示符。如果想获取更多的反馈,就使用 **-v** 参数让执行结果更详细。 + +下图中是我的USB设备中刚刚拷贝过来的文件夹 **Misc** ,里面总共有 9 张图片。 + +### [cp1_file_structure.png][6] + +![Image of the new copy of Misc on the USB drive](https://opensource.com/sites/default/files/u128651/cp1_file_structure.png "Image of the new copy of Misc on the USB drive") + +假设我要在原始拷贝路径下 **~/Pictures/Misc** 下添加一些新文件,就像这样: + +### [cp2_new_files.png][7] + +![New files added to the master directory](https://opensource.com/sites/default/files/u128651/cp2_new_files.png "New files added to the master directory") + +现在我想只拷贝新的文件到我的存储设备上,我就使用 **cp** 的“update”和“verbose”选项。 + +``` +me@desktop:~/Pictures$ cp -r -u -v Misc /media/clh/4388-D5FE +'Misc/asunder.png' -> '/media/clh/4388-D5FE/Misc/asunder.png' +'Misc/editing tags guayadeque.png' -> '/media/clh/4388-D5FE/Misc/editing tags guayadeque.png' +'Misc/misc on usb.png' -> '/media/clh/4388-D5FE/Misc/misc on usb.png' +me@desktop:~/Pictures$ +``` +上面的第一行中是 **cp** 命令和具体的参数(**-r** 是“recursive”, **-u** 是“update”,**-v** 是“verbose”)。接下来的三行显示被复制文件的信息,最后一行显示命令行前缀。 + +通常来说,参数 **-r** 也可用用更详细的方式使用 **--recursive**。但是以简短的方式,也可以这么用 **-ruv**。 + +###高效用法2:版本备份 + +回到一开始的例子中,我在开发的时候定期给我的代码版本进行备份。然后我找到了另一种更好用的 **cp** 参数。 + +假设我正在编写一个非常有用的Python程序,作为一个喜欢不断修改代码的开发者,我会在一开始定义一个程序简单版本,然后不停的忘里面添加各种功能直到它能成功的运行起来。比方说我的第一个版本就是用Python程序打印出“hello world”。这只有一行代码的程序就像这样: + +``` +print 'hello world' +``` + +然后我将这个代码保存成文件命名为 **test1.py**。我可以这么运行它: + +``` +me@desktop:~/Test$ python test1.py +hello world +me@desktop:~/Test$ +``` + +现在程序可以运行了,我想在添加新的内容之前进行备份。我决定使用带编号的备份选项,如下: + +``` +clh@vancouver:~/Test$ cp --force --backup=numbered test1.py test1.py +clh@vancouver:~/Test$ ls +test1.py  test1.py.~1~ +clh@vancouver:~/Test$ +``` + +所以,上面的做法是什么意思呢? + +第一,这个 **--backup=numbered** 参数意思为“我要做个备份,而且是带编号的连续备份”。所以一个备份就是 1 号,第二个就是 2 号,等等。 + +第二,如果源文件和目标文件名字是一样的。通常我们使用 **cp** 命令去拷贝成自己,会得到这样的报错信息: + +``` +cp: 'test1.py' and 'test1.py' are the same file +``` + +在特殊情况下,如果我们想备份的源文件和目标文件名字相同,我们使用 **--force** 参数。 + +第三,我使用 **ls** (或者是“list”)命令来显示现在目录下的文件,名字为 **test1.py** 的是原始文件,名字为 **test1.py.~1~** 的是备份文件 + +假如现在我要加上第二个功能,在程序里加上另一行代码,可以打印“Kilroy was here.”。现在程序文件 **test1.py** 的内容如下: + +``` +print 'hello world' +print 'Kilroy was here' +``` + +看到Python代码如此简单了吗?不管怎样,如果我再次执行备份的步骤,结果如下: + + +``` +clh@vancouver:~/Test$ cp --force --backup=numbered test1.py test1.py +clh@vancouver:~/Test$ ls +test1.py test1.py.~1~ test1.py.~2~ +clh@vancouver:~/Test$ +``` +现在我有有两个备份文件: **test1.py.~1~** 包含了一行代码的程序,和 **test1.py.~2~** 包含两行代码的程序。 + +这个很好用的功能,让我在进行shell编程的时候变得更为简单。 + +###最后总结 + +第一,Linux手册页,默认安装在大多数桌面和服务器发行版,它提供了更为详细的使用方法和例子,就像 **cp** 命令,在终端中输入如下命令: + +``` +man cp +``` + +对于那些想学习如何使用这些命令,但不清楚如何使用的用户应该首先看一下这些说明,然后我建议创建一个测试目录和文件来尝试使用命令和选项。 + +第二,兴趣是最好的老师。在你最喜欢的搜索引擎中搜索“linux shell tutorial”,你会获得很多有趣和有用的资源。 + +第三,你是不是在想,“为什么我要用这么麻烦的方法,图形化界面中有相同的功能,只用点击几下岂不是更简单?”,关于这个问题我有两个理由。首先,在我们工作中需要中断其他工作流程以及大量使用点击动作时,点击动作可就不简单了。其次,如果我们要完成流水线般的重复性工作,通过使用shell脚本和shell函数以及shell重命名等功能就能很轻松的实现。 + +你还知道关于 **cp** 命令其他更棒的使用方式吗?请在留言中积极回复哦~ + +-------------------------------------------------------------------------------- + +作者简介: + +Chris Hermansen - 1978 年毕业于英国哥伦比亚大学后一直从事计算机相关职业,我从2005年开始一直使用Linux,Solaris, SunOS,在那之前我就是Unix系统管理员了,在技术方面,我花了大量的职业生涯做数据分析,尤其是空间数据分析,我有大量的编程经验与数据分析经验,熟练使用awk,Python,PostgreSQL,PostGIS和Groovy。 + + +原文: https://opensource.com/article/17/7/two-great-uses-cp-command + +作者:[ Chris Hermansen ][a] +译者:[bigdimple](https://github.com/bigdimple) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:https://opensource.com/users/clhermansen +[1]:https://opensource.com/resources/what-is-linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[2]:https://opensource.com/resources/what-are-linux-containers?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[3]:https://developers.redhat.com/promotions/linux-cheatsheet/?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[4]:https://developers.redhat.com/cheat-sheet/advanced-linux-commands-cheatsheet?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[5]:https://opensource.com/tags/linux?intcmp=70160000000h1jYAAQ&utm_source=intcallout&utm_campaign=linuxcontent +[6]:https://opensource.com/file/360601 +[7]:https://opensource.com/file/360606 +[8]:https://opensource.com/article/17/7/two-great-uses-cp-command?rate=87TiE9faHZRes_f4Gj3yQZXhZ-x7XovYhnhjrk3SdiM +[9]:https://opensource.com/user/37806/feed +[10]:https://www.flickr.com/photos/internetarchivebookimages/14746482994/in/photolist-ot6zCN-odgbDq-orm48o-otifuv-otdyWa-ouDjnZ-otGT2L-odYVqY-otmff7-otGamG-otnmSg-rxnhoq-orTmKf-otUn6k-otBg1e-Gm6FEf-x4Fh64-otUcGR-wcXsxg-tLTN9R-otrWYV-otnyUE-iaaBKz-ovcPPi-ovokCg-ov4pwM-x8Tdf1-hT5mYr-otb75b-8Zk6XR-vtefQ7-vtehjQ-xhhN9r-vdXhWm-xFBgtQ-vdXdJU-vvTH6R-uyG5rH-vuZChC-xhhGii-vvU5Uv-vvTNpB-vvxqsV-xyN2Ai-vdXcFw-vdXuNC-wBMhes-xxYmxu-vdXxwS-vvU8Zt +[11]:https://www.flickr.com/photos/internetarchivebookimages/14774719031/in/photolist-ovAie2-otPK99-xtDX7p-tmxqWf-ow3i43-odd68o-xUPaxW-yHCtWi-wZVsrD-DExW5g-BrzB7b-CmMpC9-oy4hyF-x3UDWA-ow1m4A-x1ij7w-tBdz9a-tQMoRm-wn3tdw-oegTJz-owgrs2-rtpeX1-vNN6g9-owemNT-x3o3pX-wiJyEs-CGCC4W-owg22q-oeT71w-w6PRMn-Ds8gyR-x2Aodm-owoJQm-owtGp9-qVxppC-xM3Gw7-owgV5J-ou9WEs-wihHtF-CRmosE-uk9vB3-wiKdW6-oeGKq3-oeFS4f-x5AZtd-w6PNuv-xgkofr-wZx1gJ-EaYPED-oxCbFP +[12]:https://en.wikipedia.org/wiki/Cp_(Unix) +[13]:https://en.wikipedia.org/wiki/Unix +[14]:https://opensource.com/users/clhermansen +[15]:https://opensource.com/users/clhermansen +[16]:https://opensource.com/article/17/7/two-great-uses-cp-command#comments From 3dd42073bb041a9fddaab688b787d3a78530974c Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 10 Aug 2017 13:47:44 +0800 Subject: [PATCH 13/27] PRF:20170705 Two great uses for the cp command.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @bigdimple 恭喜你完成了第一篇翻译,翻译的不错。不过要适当注意标点符号的使用。具体你可以参考我校对的版本(做版本对比) 你的 LCTT 个人专页是: https://linux.cn/lctt/bigdimple --- ...70705 Two great uses for the cp command.md | 97 +++++++++---------- 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/translated/tech/20170705 Two great uses for the cp command.md b/translated/tech/20170705 Two great uses for the cp command.md index 48fb8224a7..d9aaca8c7c 100644 --- a/translated/tech/20170705 Two great uses for the cp command.md +++ b/translated/tech/20170705 Two great uses for the cp command.md @@ -1,70 +1,66 @@ -【big_dimple翻译完成】 -# cp命令两个高效的用法 - +cp 命令两个高效的用法 ============================================================ -### Linux中高效的备份拷贝命令 - +> Linux 中高效的备份拷贝命令 ![Two great uses for the cp command](https://opensource.com/sites/default/files/styles/image-full-size/public/images/life/car-penguin-drive-linux-yellow.png?itok=ueZE5mph "Two great uses for the cp command") -图像来自于:Opensource.com +在 Linux 上能使用鼠标点来点去的图形化界面是一件很美妙的事……但是如果你喜欢的开发交互环境和编译器是终端窗口、Bash 和 Vim,那你应该像我一样*经常*和终端打交道。 -在Linux上能使用图形化界面是一件很美妙的事...但是如果你像我一样,喜欢的开发交互环境和编译器是终端窗口,Bash 和 Vim,那你将会经常和终端打交道。 - -即使是不经常使用终端的人,也能通过终端提供的环境来获取很多有用的知识。举个例子—**cp**命令,通过[Wiki百科][12]的解释,**cp** (或者copy)命令是[Unix][13]系统第一个版本中的一部分。以及其他的一组命令 **ls**, **mv**, **cd**, **pwd**, **mkdir**, **vi**, **sh**, **sed**, 和 **awk** 还有我们所说的 **cp** 都是在 1984 年构造Unix系统第一个版本中最初的几步。**cp** 命令最常见的用法是复制文件。像这样: +即使是不经常使用终端的人,如果对终端环境深入了解也能获益良多。举个例子—— `cp` 命令,据 [维基百科][12] 的解释,`cp` (意即 copy)命令是第一个版本的 [Unix][13] 系统的一部分。连同一组其它的命令 `ls`、`mv`、`cd`、`pwd`、`mkdir`、`vi`、`sh`、`sed` 和 `awk` ,还有提到的 `cp` 都是我在 1984 年接触 System V Unix 系统时所学习的命令之一。`cp` 命令最常见的用法是制作文件副本。像这样: ``` cp sourcefile destfile ``` -在终端中执行此命令,上述命令将名为 **sourcefile** 的文件复制到名为 **destfile** 的文件中。如果在执行命令之前 **destfile** 文件不存在,那将会创建此文件,如果已经存在,那就会覆盖此文件。 -这个命令我不知道自己用了多少次了(或许我不想知道),但是我知道在我测试代码的时候,我经常用,为了保留当前版本,而且又能继续修改,我会输入这个命令: +在终端中执行此命令,上述命令将名为 `sourcefile` 的文件复制到名为 `destfile` 的文件中。如果在执行命令之前 `destfile` 文件不存在,那将会创建此文件,如果已经存在,那就会覆盖此文件。 + +这个命令我不知道自己用了多少次了(我也不想知道),但是我知道在我编写测试代码的时候,我经常用,为了保留当前正常的版本,而且又能继续修改,我会输入这个命令: ``` cp test1.py test1.bak ``` -在过去的30多年里,我使用了无数次这个命令。另外,当我决定编写我的第二版测试程序时,我会输入这个命令: + +在过去的30多年里,我使用了无数次这个命令。另外,当我决定编写我的第二个版本的测试程序时,我会输入这个命令: ``` cp test1.py test2.py ``` -这样就完成了修改程序版本的第一步。 -我通常很少查看 **cp** 命令的参考文档,但是当我在备份我的图片文件夹的时候(在GUI环境下使用文件应用),我开始思考“在 **cp** 命令中是否有个参数支持只复制新文件或者是修改过的文件。”果然,真的有! +这样就完成了修改程序的第一步。 + +我通常很少查看 `cp` 命令的参考文档,但是当我在备份我的图片文件夹的时候(在 GUI 环境下使用 “file” 应用),我开始思考“在 `cp` 命令中是否有个参数支持只复制新文件或者是修改过的文件。”果然,真的有! + +### 高效用法 1:更新你的文件夹 -### 高效用法1:更新你的文件夹 比如说在我的电脑上有一个存放各种文件的文件夹,另外我要不时的往里面添加一些新文件,而且我会不时地修改一些文件,例如我手机里下载的照片或者是音乐。 假设我收集的这些文件对我而言都很有价值,我有时候会想做个拷贝,就像是“快照”一样将文件保存在其它媒体。当然目前有很多程序都支持备份,但是我想更为精确的将目录结构复制到可移动设备中,方便于我经常使用这些离线设备或者连接到其它电脑上。 - **cp** 命令提供了一个易如反掌的方法。例子如下: + `cp` 命令提供了一个易如反掌的方法。例子如下: -在我的 **Pictures** 文件夹下,我有这样一个文件夹名字为 **Misc**。为了方便说明,我把文件拷贝到USB存储设备上。让我们开始吧! +在我的 `Pictures` 文件夹下,我有这样一个文件夹名字为 `Misc`。为了方便说明,我把文件拷贝到 USB 存储设备上。让我们开始吧! ``` me@desktop:~/Pictures$ cp -r Misc /media/clh/4388-D5FE me@desktop:~/Pictures$ ``` -上面的命令是我从按照终端窗口中完整复制下来的。对于有些人来说这种环境可能不是很舒服,在我们输入命令或者执行命令之前,需要注意的是 **me@mydesktop:~/Pictures** 这个前缀,(**me**)这个是当前用户,(**mydesktop**)这是电脑名称,(**~/Pictures**)这个是当前工作目录,是(**/home/me/Pictures**)完整路径的缩写。 -我输入这个命令并执行后(**cp -r Misc /media/clh/4388-D5FE**),拷贝 **Misc** 目录下所有文件(这个 **-r**参数,全称“recursive”,递归处理,意思为本目录下所有文件及子目录一起处理)到我的USB设备的挂载目录 **/media/clh/4388-D5FE**。 +上面的命令是我从按照终端窗口中完整复制下来的。对于有些人来说不是很适应这种环境,在我们输入命令或者执行命令之前,需要注意的是 `me@mydesktop:~/Pictures` 这个前缀,`me` 这个是当前用户,`mydesktop` 这是电脑名称,`~/Pictures` 这个是当前工作目录,是 `/home/me/Pictures` 完整路径的缩写。 -执行命令后回到之前的提示,大多数命令继承了Unix的特性,在命令执行后,如果没有任何异常什么都不显示,在任务结束之前不会显示像“execution succeeded“这样的提示符。如果想获取更多的反馈,就使用 **-v** 参数让执行结果更详细。 +我输入这个命令 `cp -r Misc /media/clh/4388-D5FE` 并执行后 ,拷贝 `Misc` 目录下所有文件(这个 `-r` 参数,全称 “recursive”,递归处理,意思为本目录下所有文件及子目录一起处理)到我的 USB 设备的挂载目录 `/media/clh/4388-D5FE`。 -下图中是我的USB设备中刚刚拷贝过来的文件夹 **Misc** ,里面总共有 9 张图片。 +执行命令后回到之前的提示,大多数命令继承了 Unix 的特性,在命令执行后,如果没有任何异常什么都不显示,在任务结束之前不会显示像 “execution succeeded” 这样的提示消息。如果想获取更多的反馈,就使用 `-v` 参数让执行结果更详细。 -### [cp1_file_structure.png][6] +下图中是我的 USB 设备中刚刚拷贝过来的文件夹 `Misc` ,里面总共有 9 张图片。 ![Image of the new copy of Misc on the USB drive](https://opensource.com/sites/default/files/u128651/cp1_file_structure.png "Image of the new copy of Misc on the USB drive") -假设我要在原始拷贝路径下 **~/Pictures/Misc** 下添加一些新文件,就像这样: - -### [cp2_new_files.png][7] +假设我要在原始拷贝路径下 `~/Pictures/Misc` 下添加一些新文件,就像这样: ![New files added to the master directory](https://opensource.com/sites/default/files/u128651/cp2_new_files.png "New files added to the master directory") -现在我想只拷贝新的文件到我的存储设备上,我就使用 **cp** 的“update”和“verbose”选项。 +现在我想只拷贝新的文件到我的存储设备上,我就使用 `cp` 的“更新”和“详细”选项。 ``` me@desktop:~/Pictures$ cp -r -u -v Misc /media/clh/4388-D5FE @@ -73,21 +69,21 @@ me@desktop:~/Pictures$ cp -r -u -v Misc /media/clh/4388-D5FE 'Misc/misc on usb.png' -> '/media/clh/4388-D5FE/Misc/misc on usb.png' me@desktop:~/Pictures$ ``` -上面的第一行中是 **cp** 命令和具体的参数(**-r** 是“recursive”, **-u** 是“update”,**-v** 是“verbose”)。接下来的三行显示被复制文件的信息,最后一行显示命令行前缀。 +上面的第一行中是 `cp` 命令和具体的参数(`-r` 是“递归”, `-u` 是“更新”,`-v` 是“详细”)。接下来的三行显示被复制文件的信息,最后一行显示命令行提示符。 -通常来说,参数 **-r** 也可用用更详细的方式使用 **--recursive**。但是以简短的方式,也可以这么用 **-ruv**。 +通常来说,参数 `-r` 也可用更详细的风格 `--recursive`。但是以简短的方式,也可以这么连用 `-ruv`。 -###高效用法2:版本备份 +### 高效用法 2:版本备份 -回到一开始的例子中,我在开发的时候定期给我的代码版本进行备份。然后我找到了另一种更好用的 **cp** 参数。 +回到一开始的例子中,我在开发的时候定期给我的代码版本进行备份。然后我找到了另一种更好用的 `cp` 参数。 -假设我正在编写一个非常有用的Python程序,作为一个喜欢不断修改代码的开发者,我会在一开始定义一个程序简单版本,然后不停的忘里面添加各种功能直到它能成功的运行起来。比方说我的第一个版本就是用Python程序打印出“hello world”。这只有一行代码的程序就像这样: +假设我正在编写一个非常有用的 Python 程序,作为一个喜欢不断修改代码的开发者,我会在一开始编写一个程序简单版本,然后不停的往里面添加各种功能直到它能成功的运行起来。比方说我的第一个版本就是用 Python 程序打印出 “hello world”。这只有一行代码的程序就像这样: ``` print 'hello world' ``` -然后我将这个代码保存成文件命名为 **test1.py**。我可以这么运行它: +然后我将这个代码保存成文件命名为 `test1.py`。我可以这么运行它: ``` me@desktop:~/Test$ python test1.py @@ -106,26 +102,26 @@ clh@vancouver:~/Test$ 所以,上面的做法是什么意思呢? -第一,这个 **--backup=numbered** 参数意思为“我要做个备份,而且是带编号的连续备份”。所以一个备份就是 1 号,第二个就是 2 号,等等。 +第一,这个 `--backup=numbered` 参数意思为“我要做个备份,而且是带编号的连续备份”。所以一个备份就是 1 号,第二个就是 2 号,等等。 -第二,如果源文件和目标文件名字是一样的。通常我们使用 **cp** 命令去拷贝成自己,会得到这样的报错信息: +第二,如果源文件和目标文件名字是一样的。通常我们使用 `cp` 命令去拷贝成自己,会得到这样的报错信息: ``` cp: 'test1.py' and 'test1.py' are the same file ``` -在特殊情况下,如果我们想备份的源文件和目标文件名字相同,我们使用 **--force** 参数。 +在特殊情况下,如果我们想备份的源文件和目标文件名字相同,我们使用 `--force` 参数。 -第三,我使用 **ls** (或者是“list”)命令来显示现在目录下的文件,名字为 **test1.py** 的是原始文件,名字为 **test1.py.~1~** 的是备份文件 +第三,我使用 `ls` (意即 “list”)命令来显示现在目录下的文件,名字为 `test1.py` 的是原始文件,名字为 `test1.py.~1~` 的是备份文件 -假如现在我要加上第二个功能,在程序里加上另一行代码,可以打印“Kilroy was here.”。现在程序文件 **test1.py** 的内容如下: +假如现在我要加上第二个功能,在程序里加上另一行代码,可以打印 “Kilroy was here.”。现在程序文件 `test1.py` 的内容如下: ``` print 'hello world' print 'Kilroy was here' ``` -看到Python代码如此简单了吗?不管怎样,如果我再次执行备份的步骤,结果如下: +看到 Python 编程多么简单了吗?不管怎样,如果我再次执行备份的步骤,结果如下: ``` @@ -134,13 +130,13 @@ clh@vancouver:~/Test$ ls test1.py test1.py.~1~ test1.py.~2~ clh@vancouver:~/Test$ ``` -现在我有有两个备份文件: **test1.py.~1~** 包含了一行代码的程序,和 **test1.py.~2~** 包含两行代码的程序。 +现在我有有两个备份文件: `test1.py.~1~` 包含了一行代码的程序,和 `test1.py.~2~` 包含两行代码的程序。 -这个很好用的功能,让我在进行shell编程的时候变得更为简单。 +这个很好用的功能,我考虑做个 shell 函数让它变得更简单。 -###最后总结 +### 最后总结 -第一,Linux手册页,默认安装在大多数桌面和服务器发行版,它提供了更为详细的使用方法和例子,就像 **cp** 命令,在终端中输入如下命令: +第一,Linux 手册页,它在大多数桌面和服务器发行版都默认安装了,它提供了更为详细的使用方法和例子,对于 `cp` 命令,在终端中输入如下命令: ``` man cp @@ -148,24 +144,27 @@ man cp 对于那些想学习如何使用这些命令,但不清楚如何使用的用户应该首先看一下这些说明,然后我建议创建一个测试目录和文件来尝试使用命令和选项。 -第二,兴趣是最好的老师。在你最喜欢的搜索引擎中搜索“linux shell tutorial”,你会获得很多有趣和有用的资源。 +第二,兴趣是最好的老师。在你最喜欢的搜索引擎中搜索 “linux shell tutorial”,你会获得很多有趣和有用的资源。 -第三,你是不是在想,“为什么我要用这么麻烦的方法,图形化界面中有相同的功能,只用点击几下岂不是更简单?”,关于这个问题我有两个理由。首先,在我们工作中需要中断其他工作流程以及大量使用点击动作时,点击动作可就不简单了。其次,如果我们要完成流水线般的重复性工作,通过使用shell脚本和shell函数以及shell重命名等功能就能很轻松的实现。 +第三,你是不是在想,“为什么我要用这么麻烦的方法,图形化界面中有相同的功能,只用点击几下岂不是更简单?”,关于这个问题我有两个理由。首先,在我们工作中需要中断其他工作流程以及大量使用点击动作时,点击动作可就不简单了。其次,如果我们要完成流水线般的重复性工作,通过使用 shell 脚本和 shell 函数以及 shell 重命名等功能就能很轻松的实现。 -你还知道关于 **cp** 命令其他更棒的使用方式吗?请在留言中积极回复哦~ +你还知道关于 `cp` 命令其他更棒的使用方式吗?请在留言中积极回复哦~ + +(题图:Opensource.com) -------------------------------------------------------------------------------- 作者简介: -Chris Hermansen - 1978 年毕业于英国哥伦比亚大学后一直从事计算机相关职业,我从2005年开始一直使用Linux,Solaris, SunOS,在那之前我就是Unix系统管理员了,在技术方面,我花了大量的职业生涯做数据分析,尤其是空间数据分析,我有大量的编程经验与数据分析经验,熟练使用awk,Python,PostgreSQL,PostGIS和Groovy。 +Chris Hermansen - 1978 年毕业于英国哥伦比亚大学后一直从事计算机相关职业,我从 2005 年开始一直使用 Linux、Solaris、SunOS,在那之前我就是 Unix 系统管理员了,在技术方面,我的大量的职业生涯都是在做数据分析,尤其是空间数据分析,我有大量的编程经验与数据分析经验,熟练使用 awk、Python、PostgreSQL、PostGIS 和 Groovy。 +--- -原文: https://opensource.com/article/17/7/two-great-uses-cp-command +via: https://opensource.com/article/17/7/two-great-uses-cp-command -作者:[ Chris Hermansen ][a] +作者:[Chris Hermansen][a] 译者:[bigdimple](https://github.com/bigdimple) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 From 699218a6029785d4e7e5503ac30c430d0eacb316 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 10 Aug 2017 13:48:21 +0800 Subject: [PATCH 14/27] PUB:20170705 Two great uses for the cp command.md @bigdimple https://linux.cn/article-8766-1.html --- .../20170705 Two great uses for the cp command.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170705 Two great uses for the cp command.md (100%) diff --git a/translated/tech/20170705 Two great uses for the cp command.md b/published/20170705 Two great uses for the cp command.md similarity index 100% rename from translated/tech/20170705 Two great uses for the cp command.md rename to published/20170705 Two great uses for the cp command.md From f61e217521b4626e6eec661228e3906c9e9f76c4 Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 10 Aug 2017 17:10:55 +0800 Subject: [PATCH 15/27] PRF:20170711 Ubuntu Core Making a factory image with private snaps.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Snaplee 恭喜你,完成了第一篇贡献!你的 LCTT 专页是: https://linux.cn/lctt/Snaplee 文中有一处翻译你有质疑,我看了,其实原文没错,它说的 snapd ,那个确实也是 apt 安装的,我校对修改了。 另外,文中的图片,都不需要另外做本地化处理。我发布文章时候,会自动本地化到 LINUX.CN 上了。 --- ...king a factory image with private snaps.md | 108 ++++++++++-------- 1 file changed, 60 insertions(+), 48 deletions(-) diff --git a/translated/tech/20170711 Ubuntu Core Making a factory image with private snaps.md b/translated/tech/20170711 Ubuntu Core Making a factory image with private snaps.md index efe9af6af6..d625de186c 100644 --- a/translated/tech/20170711 Ubuntu Core Making a factory image with private snaps.md +++ b/translated/tech/20170711 Ubuntu Core Making a factory image with private snaps.md @@ -1,13 +1,16 @@ -# Ubuntu Core: 制作包含私有 snaps 的工厂镜像 ---- -这篇帖子是有关 [ROS prototype to production on Ubuntu Core][1] 系列的补充,用来回答我接收到的一个问题: “如何在不公开发布 snaps 的情况下制作一个工厂镜像?” 当然,问题和回答都不只是针对于机器人技术。在这篇帖子中,我将会通过两种方法来回答这个问题。 +Ubuntu Core:制作包含私有 snap 的工厂镜像 +======== + +这篇帖子是有关 [在 Ubuntu Core 开发 ROS 原型到成品][1] 系列的补充,用来回答我收到的一个问题: “我想做一个工厂镜像,但我不想使我的 snap 公开” 当然,这个问题和回答都不只是针对于机器人技术。在这篇帖子中,我将会通过两种方法来回答这个问题。 -开始之前,你需要了解一些制作 Ubuntu Core 镜像的背景知识,如果你已经看过 [ROS prototype to production on Ubuntu Core][3] 系列文章(具体是第 5 部分),你就已经有了需要的背景知识,如果没有看过的话,可以查看有关 [制作你的 Ubuntu Core 镜像][5] 的教程。 +开始之前,你需要了解一些制作 Ubuntu Core 镜像的背景知识,如果你已经看过 [在 Ubuntu Core 开发 ROS 原型到成品[3] 系列文章(具体是第 5 部分),你就已经有了需要的背景知识,如果没有看过的话,可以查看有关 [制作你的 Ubuntu Core 镜像][5] 的教程。 -如果你已经了解了最新的情况并且当我说 “模型定义” 或者 “模型断言” 时知道我在谈论什么,那就让我们开始通过不同的方法使用私有 sanps 来制作 Ubuntu Core 镜像吧。 +如果你已经了解了最新的情况,并且当我说 “模型定义” 或者 “模型断言” 时知道我在谈论什么,那就让我们开始通过不同的方法使用私有 sanps 来制作 Ubuntu Core 镜像吧。 + +### 方法 1: 不要上传你的 snap 到商店 + +这是最简单的方法了。首先看一下这个有关模型定义的例子——`amd64-model.json`: -### 方法 1: 无需上传你的 snap 到商店 -这是最简单的方法了。首先看一下这个有关模型定义的例子——**amd64-model.json**: ``` { "type": "model", @@ -21,16 +24,20 @@ "timestamp": "2017-06-23T21:03:24+00:00", "required-snaps": ["kyrofa-test-snap"] } -``` -让我们将它转换成模型断言 +``` + +让我们将它转换成模型断言: + ``` $ cat amd64-model.json | snap sign -k my-key-name > amd64.model You need a passphrase to unlock the secret key for user: "my-key-name" 4096-bit RSA key, ID 0B79B865, created 2016-01-01 ... -``` -获得模型断言:**amd64.model** 后,如果你现在就把它交给 **ubuntu-image** 使用,你将会碰钉子: +``` + +获得模型断言:`amd64.model` 后,如果你现在就把它交给 `ubuntu-image` 使用,你将会碰钉子: + ``` $ sudo ubuntu-image -c stable amd64.model Fetching core @@ -40,7 +47,9 @@ Fetching kyrofa-test-snap error: cannot find snap "kyrofa-test-snap": snap not found COMMAND FAILED: snap prepare-image --channel=stable amd64.model /tmp/tmp6p453gk9/unpack ``` -实际上商店中并没有名为 **kyrofa-test-snap** 的 snap。这里需要重点说明的是:模型定义(以及转换后的断言)会包含一列 snap 的名字。如果你在本地有个名字相同的 snap,即使它没有存在于商店中,你也可以通过 **--extra-snaps** 选项告诉 **ubuntu-image** 在断言中增加这个名字来使用它: + +实际上商店中并没有名为 `kyrofa-test-snap` 的 snap。这里需要重点说明的是:模型定义(以及转换后的断言)只包含了一系列的 snap 的名字。如果你在本地有个那个名字的 snap,即使它没有存在于商店中,你也可以通过 `--extra-snaps` 选项告诉 `ubuntu-image` 在断言中匹配这个名字来使用它: + ``` $ sudo ubuntu-image -c stable \ --extra-snaps /path/to/kyrofa-test-snap_0.1_amd64.snap \ @@ -54,30 +63,35 @@ WARNING: "kyrofa-test-snap" were installed from local snaps disconnected from a store and cannot be refreshed subsequently! Partition size/offset need to be a multiple of sector size (512). The size/offset will be rounded up to the nearest sector. -``` -现在,在 snap 并没有上传到商店的情况下,你已经获得一个预装了私有 snap 的 Ubuntu Core 镜像(名为 pc.img)。但是这样做有一个很大的问题,ubuntu-image 会提示一个警告:不通过连接商店预装 snap 意味着你没有办法在烧录了这些镜像的设备上更新它。你只能通过制作新的镜像并重新烧录到设备的方式来更新它。 +``` -### 方法 2: 使用品牌商店 -当你注册了一个商店账号并访问 [dashboard.snapcraft.io][6] 时,你其实是在标准的 Ubuntu 商店中查看你的 snaps。如果你在系统中安装 snap(原文是:If you install snapd fresh on your system,但是 snapd 并不是从 Ubuntu 商城安装的,而是通过 apt-get 命令 安装的),默认会从这个商店下载。虽然你可以在 Ubuntu 商店中发布私有的 snaps,但是你 [不能将它们预装到镜像中][7],因为只有你(以及你添加的合作者)才有权限去使用它。在这种情况下制作镜像的唯一方式就是公开发布你的 snaps,然而这并不符合这篇帖子的目的(原文是:which defeats the whole purpose of this post)。 +现在,在 snap 并没有上传到商店的情况下,你已经获得一个预装了私有 snap 的 Ubuntu Core 镜像(名为 `pc.img`)。但是这样做有一个很大的问题,ubuntu-image 会提示一个警告:不通过连接商店预装 snap 意味着你没有办法在烧录了这些镜像的设备上更新它。你只能通过制作新的镜像并重新烧录到设备的方式来更新它。 -对于这种用例,我们有所谓的 **[品牌商店][8]**。品牌商店仍然在 Ubuntu 商店里托管,但是它们是针对于某一特定公司或设备的一个可定制的策划(curated)版本。品牌商店可以继承或者不继承标准的 Ubuntu 商店,品牌商店也可以选择开放给所有的开发者或者将其限制在一个特定的组内(保持私有正是我们想要的)。 +### 方法 2: 使用品牌商店 + +当你注册了一个商店账号并访问 [dashboard.snapcraft.io][6] 时,你其实是在标准的 Ubuntu 商店中查看你的 snap。如果你是在系统中新安装的 snapd,默认会从这个商店下载。虽然你可以在 Ubuntu 商店中发布私有的 snap,但是你[不能将它们预装到镜像中][7],因为只有你(以及你添加的合作者)才有权限去使用它。在这种情况下制作镜像的唯一方式就是公开发布你的 snap,然而这并不符合这篇帖子的目的。 -请注意,这是一个付费功能。你需要 [申请一个品牌商店][9]。请求通过后,你将可以通过访问用户名下的“stores you can access” 看到你的新商店。 -![图片.png-78.9kB][10] +对于这种用例,我们有所谓的 [品牌商店][8]。品牌商店仍然托管在 Ubuntu 商店里,但是它们是针对于某一特定公司或设备的一个定制的、专门的版本。品牌商店可以继承或者不继承标准的 Ubuntu 商店,品牌商店也可以选择开放给所有的开发者或者将其限制在一个特定的组内(保持私有正是我们想要的)。 -在那里你可以看到多个有权使用的商店。最少的情况下也会有两个: 标准的 Ubuntu 商店以及你的新的品牌商店。选择品牌商店(红色矩形),进去后记录下你的商店 ID(蓝色矩形):等下你将会用到它。 -![图片.png-43.9kB][11] +请注意,这是一个付费功能。你需要 [申请一个品牌商店][9]。请求通过后,你将可以通过访问用户名下的 “stores you can access” 看到你的新商店。 + +![](https://insights.ubuntu.com/wp-content/uploads/1a62/stores_you_can_access.jpg) +在那里你可以看到多个有权使用的商店。最少的情况下也会有两个:标准的 Ubuntu 商店以及你的新的品牌商店。选择品牌商店(红框),进去后记录下你的商店 ID(蓝框):等下你将会用到它。 -在品牌商店里注册名字或者上传 snaps 和标准的商店使用的方法是一样的,只是它们现在是上传到你的品牌商店而不是标准的那个。如果你没有将品牌商店列出来,那么这些 snaps 对外部用户是不可见。但是这里需要注意的是第一次上传 snap 的时候需要通过web界面来操作。在那之后,你可以继续像往常一样使用 Snapcraft 。 +![](https://insights.ubuntu.com/wp-content/uploads/b10c/Screenshot-from-2017-07-06-15-16-32.png) + +在品牌商店里注册名字或者上传 snap 和标准的商店使用的方法是一样的,只是它们现在是上传到你的品牌商店而不是标准的那个。如果你将品牌商店放在 unlisted 里面,那么这些 snap 对外部用户是不可见。但是这里需要注意的是第一次上传 snap 的时候需要通过 web 界面来操作。在那之后,你可以继续像往常一样使用 Snapcraft 来操作。 + +那么这些是如何改变的呢?我的 “kyrofal-store” 从 Ubuntu 商店继承了 snap,并且还包含一个发布在稳定通道中的 “kyrofa-bran-test-snap” 。这个 snap 在 Ubuntu 商店里是使用不了的,如果你去搜索它,你是找不到的: -那么这些是如何改变的呢?我的 “kyrofal-store” 从 Ubuntu 商店继承了 snaps,并且还包含一个发布在稳定通道中的 “kyrofa-bran-test-snap” 。这个 snap 在 Ubuntu 商店里是使用不了的,如果你去搜索它,你是找不到的: ``` $ snap find kyrofa-branded The search "kyrofa-branded" returned 0 snaps ``` -但是使用我们前面记录的商店 ID,我们可以创建一个从品牌商店而不是 Ubuntu 商店下载 snaps 的模型断言。我们只需要将 “store” 键添加到 JSON 文件中,就像这样: +但是使用我们前面记录的商店 ID,我们可以创建一个从品牌商店而不是 Ubuntu 商店下载 snap 的模型断言。我们只需要将 “store” 键添加到 JSON 文件中,就像这样: + ``` { "type": "model", @@ -92,8 +106,10 @@ The search "kyrofa-branded" returned 0 snaps "required-snaps": ["kyrofa-branded-test-snap"], "store": "kyek" } -``` -使用方法 1 中的方式对它签名,然后我们就可以像这样很简单的制作一个预装有我们品牌商店私有 snap 的 Ubuntu Core 镜像: +``` + +使用方法 1 中的方式对它签名,然后我们就可以像这样很简单的制作一个预装有我们品牌商店私有 snap 的 Ubuntu Core 镜像: + ``` $ sudo ubuntu-image -c stable amd64.model Fetching core @@ -102,8 +118,9 @@ Fetching pc Fetching kyrofa-branded-test-snap Partition size/offset need to be a multiple of sector size (512). The size/offset will be rounded up to the nearest sector. -``` -现在,和方法 1 的最后一样,你获得了一个为工厂准备的 pc.img。并且使用这种方法制作的镜像中的所有 snaps 都从商店下载的,这意味着它们将能像平常一样自动更新。 +``` + +现在,和方法 1 的最后一样,你获得了一个为工厂准备的 `pc.img`。并且使用这种方法制作的镜像中的所有 snap 都从商店下载的,这意味着它们将能像平常一样自动更新。 ### 结论 @@ -113,35 +130,30 @@ The size/offset will be rounded up to the nearest sector. 希望能帮助到您! - --- + 关于作者 -Kyle 的图片 - -![Kyle_Fazzari.jpg-12kB][13] Kyle 是 Snapcraft 团队的一员,也是 Canonical 公司的常驻机器人专家,他专注于 snaps 和 snap 开发实践,以及 snaps 和 Ubuntu Core 的机器人技术实现。 -- - - +--- + via: https://insights.ubuntu.com/2017/07/11/ubuntu-core-making-a-factory-image-with-private-snaps/ 作者:[Kyle Fazzari][a] 译者:[Snaplee](https://github.com/Snaplee) -校对:[校对者ID](https://github.com/校对者ID) +校对:[wxy](https://github.com/wxy) 本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出 - [1]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ - [2]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ - [3]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ - [4]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ - [5]: https://tutorials.ubuntu.com/tutorial/create-your-own-core-image - [6]: https://dashboard.snapcraft.io/dev/snaps/ - [7]: https://forum.snapcraft.io/t/unable-to-create-an-image-that-uses-private-snaps - [8]: https://docs.ubuntu.com/core/en/build-store/index?_ga=2.103787520.1269328701.1501772209-778441655.1499262639 - [9]: https://docs.ubuntu.com/core/en/build-store/create - [10]: http://static.zybuluo.com/apollomoon/hzffexclyv4srqsnf52a9udc/%E5%9B%BE%E7%89%87.png - [11]: http://static.zybuluo.com/apollomoon/9gevrgmq01s3vdtp5qfa8tp7/%E5%9B%BE%E7%89%87.png - [12]: https://forum.snapcraft.io/t/unable-to-create-an-image-that-uses-private-snaps/1115 - [13]: http://static.zybuluo.com/apollomoon/xaxxjof19s7cbgk00xntgmqa/Kyle_Fazzari.jpg - [14]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ +[1]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ +[2]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ +[3]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ +[4]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ +[5]: https://tutorials.ubuntu.com/tutorial/create-your-own-core-image +[6]: https://dashboard.snapcraft.io/dev/snaps/ +[7]: https://forum.snapcraft.io/t/unable-to-create-an-image-that-uses-private-snaps +[8]: https://docs.ubuntu.com/core/en/build-store/index?_ga=2.103787520.1269328701.1501772209-778441655.1499262639 +[9]: https://docs.ubuntu.com/core/en/build-store/create +[12]: https://forum.snapcraft.io/t/unable-to-create-an-image-that-uses-private-snaps/1115 +[14]: https://insights.ubuntu.com/2017/04/06/from-ros-prototype-to-production-on-ubuntu-core/ From 859c471b652e6e6a873e2e84bbec4a1e259db67a Mon Sep 17 00:00:00 2001 From: wxy Date: Thu, 10 Aug 2017 17:11:50 +0800 Subject: [PATCH 16/27] PUB:20170711 Ubuntu Core Making a factory image with private snaps.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @Snaplee 难怪你以这篇为第一篇,原来你就是 snap 啊~ 发布地址: https://linux.cn/article-8767-1.html --- ...70711 Ubuntu Core Making a factory image with private snaps.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename {translated/tech => published}/20170711 Ubuntu Core Making a factory image with private snaps.md (100%) diff --git a/translated/tech/20170711 Ubuntu Core Making a factory image with private snaps.md b/published/20170711 Ubuntu Core Making a factory image with private snaps.md similarity index 100% rename from translated/tech/20170711 Ubuntu Core Making a factory image with private snaps.md rename to published/20170711 Ubuntu Core Making a factory image with private snaps.md From bdc7fabbcc1ac4647203598b936d108f80ee7572 Mon Sep 17 00:00:00 2001 From: MonkeyDEcho <863626156@qq.com> Date: Thu, 10 Aug 2017 19:27:10 +0800 Subject: [PATCH 17/27] translated --- ...220 TypeScript the missing introduction.md | 427 ++++++++++++++++++ 1 file changed, 427 insertions(+) create mode 100644 translated/tech/20161220 TypeScript the missing introduction.md diff --git a/translated/tech/20161220 TypeScript the missing introduction.md b/translated/tech/20161220 TypeScript the missing introduction.md new file mode 100644 index 0000000000..53c7e84782 --- /dev/null +++ b/translated/tech/20161220 TypeScript the missing introduction.md @@ -0,0 +1,427 @@ +简洁的介绍TypeScript +============================================================= + + +**下文是James Henry([@MrJamesHenry][8])所编辑的内容。我是ESLint核心团队的一员,也是TypeScript的热衷者和发扬者。我和Todd合作在[UltimateAngular][9]平台上发布Angular和TypeScript的精品课程。** + +> 本文的主旨是为了介绍我们对TypeScript的思考和在JavaScript开发当中的更好的使用。 +> +> 我们将给出编译和关键字准确的定义 + +TypeScript强大之处远远不止这些,本篇文章无法涵盖,想要了解更多请阅读官方文档[official document][15],或者查阅[TypeScript courses over on UltimateAngular][16]UltimateAngular平台的TypeScript精品课程-从初学者到TypeScript高手 + +### [目录][17] + +* [背景][10] +* [关键知识的掌握][11] + * [JavaScript解释型语言还是编译型语言][1] + * [运行时间 VS 编译时间][2] + * [TypeScript编译器][3] + * [动态类型 VS 静态类型][4] +* [TypeScript在我们JavaScript工作流程中的作用][12] + * [我们的源文件是我们的文档,TypeScript是我们的拼写检查][5] +* [TypeScript是一种可以启动其它工具的工具][13] + * [什么是抽象语法树(AST)?][6] + * [示例:在VS中重命名符号][7] +* [总结][14] + +### [背景][18] + +TypeScript是很容易掌握的强大开发工具 + +然而,TypeScript可能比JavaScript要更为复杂,因为TypeScript可能同时向我们介绍以前没有考虑到的JavaScript程序相关的一些列技术概念。 + +每当我们谈论到类型、编译器等这些概念的时候。事情就会变的非常麻烦和不知所云起来。 + +这篇文章就是为了你在学习过程中你需要知道的许许多多不知所云的概念解答的,来帮助你TypeScript入门的,让你轻松自如的应对这些概念。 + +### [关键知识的掌握][19] + +有时候运行我们的代码是在Web浏览器中运行,和我们平常运行代码有不同的感觉,它是怎样运行自己书写的代码的?“没有经过编译的,是正确的吗?”。“我敢肯定没有类型的...” + +情况变的更有趣了,当我们知道通过前后程序的定义来判断语法的正确与否 + +首先我们要作的是 + +#### [JavaScript 解释型语言还是编译型语言][20] + +传统意义上,程序员经常将自己的程序编译之后运行出结果就认为这种语言是编译型语言。 + +> 从初学者的角度来说,编译的过程就是将我们自己编辑好的高级语言程序转换成机器实际运行过程中能够看懂的格式(一般是二进制文件格式)。 + +就像GO语言,可以使用go build的命令行工具编译.go的文件格式,将其编译成较低级的语言,可以直接运行的格式。(译者没有使用过GO语言,不清楚GO编译过程的机制,试着用C语言的方式说明) + +``` +# We manually compile our .go file into something we can run +# using the command line tool "go build" +go build ultimate-angular.go +# ...then we execute it! +./ultimate-angular +``` + +我们在日常使用JavaScript开发的时候并没有编译的这一步,这是JavaScript忽略了我们程序员对新一代构建工具和模块加载程序的热爱。 + +我们编写JavaScript代码在浏览器的