mirror of
https://github.com/LCTT/TranslateProject.git
synced 2024-12-26 21:30:55 +08:00
commit
1a5eeaaa77
@ -1,18 +1,22 @@
|
||||
5个有趣的Linux命令行技巧(第一部分)
|
||||
5个有趣的Linux命令行技巧
|
||||
================================================================================
|
||||
你有将Linux物尽其用吗?对很多Linux用户来说,有很多看起来是技巧的有用特性。有些时候你会需要这些技巧。本文会帮助你更好得使用一些命令,发挥其更强大的功能。
|
||||
|
||||
![5个命令行技巧](http://www.tecmint.com/wp-content/uploads/2015/03/5-Command-Line-Tips.jpg)
|
||||
图1:5个命令行技巧
|
||||
|
||||
*图1:5个命令行技巧*
|
||||
|
||||
我们开始一个新的系列,在这里我们还会写一些技巧,并且用尽量小的篇幅写清楚。
|
||||
|
||||
### 1. 我们可以使用[`history`命令][1]来查看曾经运行过的命令。这里是一个`history`命令的示例输出。 ###
|
||||
### 1. 我们可以使用[`history`命令][1]来查看曾经运行过的命令。 ###
|
||||
|
||||
这里是一个`history`命令的示例输出。
|
||||
|
||||
# history
|
||||
|
||||
![history命令例子](http://www.tecmint.com/wp-content/uploads/2015/03/history-command.gif)
|
||||
图2:history命令例子
|
||||
|
||||
*图2:history命令例子*
|
||||
|
||||
从`history`命令输出看,很明显,命令的执行时间没有被打出来。有解决方法吗?有的!运行如下命令:
|
||||
|
||||
@ -39,32 +43,39 @@
|
||||
- .bashrc – BASH以交互方式启动时运行的脚本文件
|
||||
|
||||
![history命令输出的日志](http://www.tecmint.com/wp-content/uploads/2015/03/History-Command-Logs.gif)
|
||||
图3:`history`命令输出的日志
|
||||
|
||||
*图3:`history`命令输出的日志*
|
||||
|
||||
### 2. 如何测试磁盘写入速度?一行`dd`命令脚本就可以实现。###
|
||||
### 2. 如何测试磁盘写入速度?###
|
||||
|
||||
一行`dd`命令脚本就可以实现。
|
||||
|
||||
# dd if=/dev/zero of=/tmp/output.img bs=8k count=256k conv=fdatasync; rm -rf /tmp/output.img
|
||||
|
||||
![dd命令例子](http://www.tecmint.com/wp-content/uploads/2015/03/dd-Command-Example.gif)
|
||||
图4:`dd`命令例子
|
||||
|
||||
*图4:`dd`命令例子*
|
||||
|
||||
命令和选项的解释:
|
||||
|
||||
- dd – 转换和复制文件
|
||||
- if=/dev/zero – 指定输入文件,默认为stdin(标准输入)
|
||||
- of=/tmp/output.img – 指定输出文件,默认为stdout(标准输出)
|
||||
- bs – 一次读和写的大小,最大可以以MB为单位
|
||||
- bs – 一次读和写的块大小,最大可以以MB为单位
|
||||
- count – 复制次数
|
||||
- conv – 使用逗号分隔的策略来转换文件(LCTT 译注:比如将大写字母转换成小写,echo AA | dd conv=lcase)
|
||||
- rm – 删除文件和目录
|
||||
- -rf – (-r) 递归地删除目录和其中的内容,(-f)强行删除而不输出确认信息
|
||||
|
||||
### 3. 你如何获取吃掉你磁盘空间的最大的6个文件?一个使用[`du`命令][2]的简单单行脚本即可实现,`du`命令主要用于获取文件的空间使用情况。###
|
||||
### 3. 你如何获取吃掉你磁盘空间的最大的6个文件?###
|
||||
|
||||
一个使用[`du`命令][2]的简单单行脚本即可实现,`du`命令主要用于获取文件的空间使用情况。
|
||||
|
||||
# du -hsx * | sort -rh | head -6
|
||||
|
||||
![获取磁盘空间使用情况的方法](http://www.tecmint.com/wp-content/uploads/2015/03/check-disk-space-usage.gif)
|
||||
图5:获取磁盘空间使用情况的方法
|
||||
|
||||
*图5:获取磁盘空间使用情况的方法*
|
||||
|
||||
命令和选项的解释:
|
||||
|
||||
@ -74,19 +85,25 @@
|
||||
- -rf – (-r)将比较的结果逆序输出,(-f)忽略大小写
|
||||
- head – 输出文件的头几行
|
||||
|
||||
### 4. 获取一个文件的详细状态信息,可以使用`stat`命令。 ###
|
||||
### 4. 获取一个文件的详细状态信息###
|
||||
|
||||
可以使用`stat`命令
|
||||
|
||||
# stat filename_ext (例如:stat abc.pdf)
|
||||
|
||||
![获取文件的详细信息](http://www.tecmint.com/wp-content/uploads/2015/03/Check-File-Statistics.gif)
|
||||
图6:获取文件的详细信息
|
||||
|
||||
*图6:获取文件的详细信息*
|
||||
|
||||
### 5. 最后一个技巧是为那些入门者准备的,如果你是有经验的用户,可能不需要它,除非你想从中寻找乐趣。入门者可能有Linux命令行恐惧症,下面的命令会随机显示一个man手册页。对入门者来说,好处是总会学到新的东西,而且不会厌倦。 ###
|
||||
### 5. 显示帮助 ###
|
||||
|
||||
最后一个技巧是为那些入门者准备的,如果你是有经验的用户,可能不需要它,除非你想从中寻找乐趣。入门者可能有Linux命令行恐惧症,下面的命令会随机显示一个man手册页。对入门者来说,好处是总会学到新的东西,而且不会厌倦。
|
||||
|
||||
# man $(ls /bin | shuf | head -1)
|
||||
|
||||
![查看随机的man手册页](http://www.tecmint.com/wp-content/uploads/2015/03/Generate-Random-Man-Pages.gif)
|
||||
图7:查看随机的man手册页
|
||||
![查看随机的man手册页](http://www.tecmint.com/wp-content/uploads/2015/03/Generate-Random-Man-Pages.gif)
|
||||
|
||||
*图7:查看随机的man手册页*
|
||||
|
||||
命令和选项的解释:
|
||||
|
||||
@ -96,9 +113,9 @@
|
||||
- shuf – 把输入内容按行随机打乱并输出
|
||||
- head – 输出文件的头几行
|
||||
|
||||
这就是所有的内容了。如果你知道任何类似的技巧,可以分享给我们,我们会用你的语言在Tecmint.com网站上发表出来。
|
||||
这就是所有的内容了。如果你知道任何类似的技巧,可以分享给我们,我们会用你的语言在网站上发表出来。
|
||||
|
||||
如果你想分享任何技巧,但不想写成文章,可以发到tecmint[dot]com[at]gmail[dot]com,我们会将其包含在我们的文章中。不要忘记在下边评论框中留下有价值的反馈。保持联系。可以点赞或者将本文分享来帮助我们更好地传播内容。
|
||||
不要忘记在下边评论框中留下有价值的反馈。保持联系。可以点赞或者将本文分享来帮助我们更好地传播内容。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -106,10 +123,10 @@ via: http://www.tecmint.com/5-linux-command-line-tricks/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[goreliu](https://github.com/goreliu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/avishek/
|
||||
[1]:http://www.tecmint.com/history-command-examples/
|
||||
[1]:https://linux.cn/article-1143-1.html
|
||||
[2]:http://www.tecmint.com/check-linux-disk-usage-of-files-and-directories/
|
@ -0,0 +1,100 @@
|
||||
如何交互式地创建一个Docker容器
|
||||
===============================================================================
|
||||
|
||||
大家好,今天我们来学习如何使用一个docker镜像交互式地创建一个Docker容器。当我们从镜像中启动一个Docker进程,Docker就会获取该镜像及其父镜像,并重复这个过程,直到到达基础镜像。然后联合文件系统(UFS)会在其顶层添加一个读写层。读写层被称之为容器,它包含了一些关于父镜像信息及一些其他的信息,如唯一ID,网络配置和资源限制等。容器是有状态的,其状态可以从 **运行态** 切换到 **退出态**。一个处于 **运行态**的容器包含了在CPU上面运行的进程树,于其它在该主机上运行的进程相隔离,而**退出态**是指文件系统的状态,并保留了其退出值。你可以使用它来启动,停止和重启一个容器。
|
||||
|
||||
Docker技术为IT界带来了巨大的改变,它使得云服务可以用来共享应用和工作流程自动化,使得应用可以用组件快速组合,消除了开发、品质保证、产品环境间的摩擦。在这篇文章中,我们将会建立CentOS环境,然后用Apache网络服务器提供一个网站服务。
|
||||
|
||||
这是一个快速且容易的教程,讨论我们怎样使用交互的shell,以交互的方式来创建一个容器。
|
||||
|
||||
### 1. 运行一个Docker实例 ###
|
||||
|
||||
Docker首先会尝试从本地取得并运行所需的镜像,如果在本地主机上没有发现,它就会从[Docker公共注册中心][1]拉取。这里,我们将会拉取镜像并在 Docker 容器中创建一个fedora实例,并连接到它的 tty 上的bash shell。
|
||||
|
||||
# docker run -i -t fedora bash
|
||||
|
||||
![Downloading Fedora Base Image](http://blog.linoxide.com/wp-content/uploads/2015/03/downloading-fedora-base-image.png)
|
||||
|
||||
### 2.安装Apache网络服务器 ###
|
||||
|
||||
现在,在我们的Fedora基本镜像实例准备好后,我们将会开始交互式地安装Apache网络服务器,而不是为它创建Dockerfile。为了做到这点,我们需要在终端或者shell运行以下命令。
|
||||
|
||||
# yum update
|
||||
|
||||
![Installing httpd](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-httpd2.png)
|
||||
|
||||
# yum install httpd
|
||||
|
||||
![Installing httpd](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-httpd2.png)
|
||||
|
||||
# exit
|
||||
|
||||
### 3.保存镜像 ###
|
||||
|
||||
现在,我们要去保存在Fedora实例里做的修改。要做到这个,我们首先需要知道实例的容器ID。而为了得到ID,我们又需要运行以下命令(LCTT 译注:在容器外执行该命令)。
|
||||
|
||||
# docker ps -a
|
||||
|
||||
![Docker Running Container](http://blog.linoxide.com/wp-content/uploads/2015/03/docker-running-container.png)
|
||||
|
||||
然后,我们会保存这些改变为一个新的镜像,请运行以下命令。
|
||||
|
||||
# docker commit c16378f943fe fedora-httpd
|
||||
|
||||
![committing fedora httpd](http://blog.linoxide.com/wp-content/uploads/2015/03/committing-fedora-httpd.png)
|
||||
|
||||
这里,修改已经通过使用容器ID保存起来了,镜像名字叫fedora-httpd。为了确认新的镜像是否在运行,我们将运行以下命令。
|
||||
|
||||
# docker images
|
||||
|
||||
![view docker images](http://blog.linoxide.com/wp-content/uploads/2015/03/view-docker-images.png)
|
||||
|
||||
### 4. 添加内容到新的镜像 ###
|
||||
|
||||
我们自己新的Fedora Apache镜像正成功的运行,现在我们想添加一些我们网站的网页内容到Apache网络服务器,使得网站能够开箱即用。为做到这点,我们需要创建一个新的Dockerfile,它会处理从复制网页内容到启用80端口的所有操作。要达到这样的目的,我们需要使用我们最喜欢的文本编辑器创建Dockerfile文件,像下面演示的一样。
|
||||
|
||||
# nano Dockerfile
|
||||
|
||||
现在,我们需要添加以下的命令行到文件中。
|
||||
|
||||
FROM fedora-httpd
|
||||
ADD mysite.tar /tmp/
|
||||
RUN mv /tmp/mysite/* /var/www/html
|
||||
EXPOSE 80
|
||||
ENTRYPOINT [ "/usr/sbin/httpd" ]
|
||||
CMD [ "-D", "FOREGROUND" ]
|
||||
|
||||
![configuring Dockerfile](http://blog.linoxide.com/wp-content/uploads/2015/03/configuring-Dockerfile.png)
|
||||
|
||||
这里,上述的Dockerfile中,放在mysite.tar里的网页内容会自动解压到/tmp/文件夹里。然后,整个站点会被移动到Apache的网页根目录/var/www/html/,命令expose 80会打开80端口,这样网站就能正常访问了。其次,入口点放在了/usr/sbin/https里面,保证Apache服务器能够执行。
|
||||
|
||||
### 5. 构建并运行一个容器 ###
|
||||
|
||||
现在,我们要用刚刚创建的Dockerfile创建我们的容器,以便将我们的网站添加到上面。为做到这,我们需要运行以下命令。
|
||||
|
||||
# docker build -rm -t mysite .
|
||||
|
||||
![Building mysite Image](http://blog.linoxide.com/wp-content/uploads/2015/03/building-mysite-image.png)
|
||||
|
||||
建立好我们的新容器后,我们需要要用下面的命令来运行容器。
|
||||
|
||||
# docker run -d -P mysite
|
||||
|
||||
![Running mysite Container](http://blog.linoxide.com/wp-content/uploads/2015/03/running-mysite-container.png)
|
||||
|
||||
### 总结 ###
|
||||
|
||||
最后,我们已经成功的以交互式的方式建立了一个Docker容器。在本节方法中,我们是直接通过交互的shell命令建立我们的容器和镜像。在建立与配置镜像与容器时,这种方法十分简单且快速。如果你有任何问题,建议和反馈,请在下方的评论框里写下来,以便我们可以提升或者更新我们的文章。谢谢!祝生活快乐 :-)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-how-to/interactively-create-docker-container/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[wi-cuckoo](https://github.com/wi-cuckoo)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
||||
[1]:https://registry.hub.docker.com/
|
@ -2,42 +2,45 @@
|
||||
================================================================================
|
||||
我们一直积极地提供有关 Linux 技巧的系列文章,如果你错过了这个系列的最新文章,你或许可以去访问下面的链接。
|
||||
|
||||
注:此篇文章做过原文
|
||||
- [Linux 中 5 个有趣的命令行技巧][1] (注:这篇文章还没有被翻译,在 20150316 选的题)
|
||||
- [Linux 中 5 个有趣的命令行技巧][1]
|
||||
|
||||
在这篇文章中,我们将分享一些有趣 Linux 技巧,内容是有关如何产生随机密码以及加密或解密这些经过加盐或没有加盐处理的密码。
|
||||
|
||||
安全是数字时代中的一个主要话题。在电脑,email,云端,手机,文档和其他的场合中,我们都会使用到密码。众所周知,选择密码的基本原则是 “易记,难猜”。考虑过使用基于机器自动生成的密码吗?相信我,Linux 非常擅长这方面的工作。
|
||||
|
||||
**1. 使用命令 `pwgen` 来生成一个长度为 10 个字符的唯一的随机密码。假如你还没有安装 pwgen,请使用 Apt 或 YUM 等包管理器来安装它。**
|
||||
**1. 使用命令 `pwgen` 来生成一个长度为 10 个字符的独特的随机密码。假如你还没有安装 pwgen,请使用 Apt 或 YUM 等包管理器来安装它。**
|
||||
|
||||
$ pwgen 10 1
|
||||
|
||||
![生成一个唯一的随机密码](http://www.tecmint.com/wp-content/uploads/2015/03/Generate-Random-Unique-Password-in-Linux.gif)
|
||||
生成一个唯一的随机密码
|
||||
![生成一个独特的随机密码](http://www.tecmint.com/wp-content/uploads/2015/03/Generate-Random-Unique-Password-in-Linux.gif)
|
||||
|
||||
*生成一个独特的随机密码*
|
||||
|
||||
一口气生成若干组长度为 50 个字符的唯一的随机密码!
|
||||
|
||||
$ pwgen 50
|
||||
|
||||
![生成多组随机密码](http://www.tecmint.com/wp-content/uploads/2015/03/Generate-Multiple-Random-Passwords.gif)
|
||||
生成多组随机密码
|
||||
|
||||
**2. 你还可以使用 `makepasswd` 来每次生成一个给定长度的唯一的随机密码。在你把玩 makepasswd 命令之前,请确保你已经安装了它。如若没有安装它,试试使用 Apt 或 YUM 包管理器来安装 `makepasswd`这个软件包。**
|
||||
*生成多组随机密码*
|
||||
|
||||
**2. 你还可以使用 `makepasswd` 来每次生成一个给定长度的独特的随机密码。在你把玩 makepasswd 命令之前,请确保你已经安装了它。如若没有安装它,试试使用 Apt 或 YUM 包管理器来安装 `makepasswd`这个软件包。**
|
||||
|
||||
生成一个长度为 10 个字符的随机密码。该命令产生的密码的长度默认为 10。
|
||||
|
||||
$ makepasswd
|
||||
|
||||
![使用 makepasswd 生成唯一的密码](http://www.tecmint.com/wp-content/uploads/2015/03/mkpasswd-generate-unique-password.gif)
|
||||
使用 makepasswd 生成唯一的密码
|
||||
![使用 makepasswd 生成独特的密码](http://www.tecmint.com/wp-content/uploads/2015/03/mkpasswd-generate-unique-password.gif)
|
||||
|
||||
*使用 makepasswd 生成独特的密码*
|
||||
|
||||
生成一个长度为 50 个字符的随机密码。
|
||||
|
||||
$ makepasswd --char 50
|
||||
|
||||
![生成长度为 50 的密码](http://www.tecmint.com/wp-content/uploads/2015/03/Random-Password-Generate.gif)
|
||||
生成长度为 50 的密码
|
||||
|
||||
*生成长度为 50 的密码*
|
||||
|
||||
生成 7 个长度为 20 个字符的随机密码。
|
||||
|
||||
@ -47,9 +50,7 @@
|
||||
|
||||
**3. 使用带“盐”的 Crypt(注:这里应该指的是一个函数,可以参考[这里](http://man7.org/linux/man-pages/man3/crypt.3.html) ) 来加密一个密码。提供手动或自动添加 “盐”。**
|
||||
|
||||
对于那些不清楚 **盐** 的意义的人,
|
||||
|
||||
这里的 “盐” 指的是一个随机数据,它作为密码生成函数的一个额外的输入, 目的是保护密码免受词典攻击。
|
||||
对于那些不清楚 **盐** 的意义的人,这里的 “盐” 指的是一个随机数据,它作为密码生成函数的一个额外的输入, 目的是保护密码免受词典攻击。
|
||||
|
||||
在执行下面的操作前,请确保你已经安装了 `mkpasswd`。
|
||||
|
||||
@ -58,46 +59,51 @@
|
||||
$ mkpasswd tecmint
|
||||
|
||||
![使用 Crypt 来加密密码](http://www.tecmint.com/wp-content/uploads/2015/03/Encrypt-Password-in-Linux.gif)
|
||||
使用 Crypt 来加密密码
|
||||
|
||||
*使用 Crypt 来加密密码*
|
||||
|
||||
现在让我们来手动定义 “盐” 的值。每次它将产生相同的结果。请注意你可以输入任何你想输入的值来作为 “盐” 的值。
|
||||
|
||||
$ mkpasswd tecmint -s tt
|
||||
|
||||
![带“盐”加密密码](http://www.tecmint.com/wp-content/uploads/2015/03/Encrypt-Password-Using-Salt.gif)
|
||||
带“盐”加密密码
|
||||
|
||||
*带“盐”加密密码*
|
||||
|
||||
另外, mkpasswd 还是交互式的,假如你在命令中没有提供密码,它将主动询问你来输入密码。
|
||||
|
||||
**4. 使用 aes-256-cbc 加密算法并使用密码(如 “tecmint”) 并带“盐” 加密一个字符串(如 “Tecmint-is-a-Linux-Community”)。**
|
||||
**4. 使用 aes-256-cbc 加密算法并使用带“盐”的密码(如 “tecmint”) 加密一个字符串(如 “Tecmint-is-a-Linux-Community”)。**
|
||||
|
||||
# echo Tecmint-is-a-Linux-Community | openssl enc -aes-256-cbc -a -salt -pass pass:tecmint
|
||||
|
||||
![在 Linux 中加密一个字符串](http://www.tecmint.com/wp-content/uploads/2015/03/Encrypt-A-String-in-Linux.gif)
|
||||
在 Linux 中加密一个字符串
|
||||
|
||||
在上面例子中, [echo 命令][2](注:此篇原文也做过,这里是链接 http://linux.cn/article-3948-1.html) 的输出通过管道传递给了 openssl 命令,使得该输出被 Cipher(enc) 所加密,这个过程中使用了 aes-256-cbc 加密算法,并附带了密码 (tecmint) 和 “盐” 。
|
||||
*在 Linux 中加密一个字符串*
|
||||
|
||||
在上面例子中, [echo 命令][2]的输出通过管道传递给了 openssl 命令,使得该输出通过加密编码方式(enc:Encoding with Cipher ) 所加密,这个过程中使用了 aes-256-cbc 加密算法,并附带了密码 (tecmint) 和 “盐” 。
|
||||
|
||||
**5. 使用 openssl 命令的 -aes-256-cbc 解密选项来解密上面的字符串。**
|
||||
|
||||
# echo U2FsdGVkX18Zgoc+dfAdpIK58JbcEYFdJBPMINU91DKPeVVrU2k9oXWsgpvpdO/Z | openssl enc -aes-256-cbc -a -d -salt -pass pass:tecmint
|
||||
|
||||
![在 Linux 中解密字符串](http://www.tecmint.com/wp-content/uploads/2015/03/Decrypt-String-in-Linux.gif)
|
||||
在 Linux 中解密字符串
|
||||
|
||||
现在就是这些内容了。假如你知道任何这类的技巧,请将你的技巧发送到 admin@tecmint.com 邮箱中,你的技巧将会以你的名义来发表,同时我们也将在我们将来的文章中把它包含进去。
|
||||
*在 Linux 中解密字符串*
|
||||
|
||||
现在就是这些内容了。
|
||||
|
||||
保持联系,保持连接,敬请关注。不要忘了在下面的评论中提供给我们您有价值的反馈。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.tecmint.com/generate-encrypt-decrypt-random-passwords-in-linux/
|
||||
|
||||
作者:[Avishek Kumar][a]
|
||||
译者:[FSSlc](https://github.com/FSSlc)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.tecmint.com/author/avishek/
|
||||
[1]:http://www.tecmint.com/5-linux-command-line-tricks/
|
||||
[2]:http://www.tecmint.com/echo-command-in-linux/
|
||||
[1]:https://linux.cn/article-5485-1.html
|
||||
[2]:http://linux.cn/article-3948-1.html
|
@ -1,4 +1,4 @@
|
||||
[已解决] Ubuntu下不能记住亮度设置问题
|
||||
如何解决 Ubuntu 下不能记住亮度设置的问题
|
||||
================================================================================
|
||||
![](http://itsfoss.itsfoss.netdna-cdn.com/wp-content/uploads/2015/04/Fix_Ubuntu_Brightness_Issue.jpg)
|
||||
|
||||
@ -22,7 +22,7 @@ via: http://itsfoss.com/ubuntu-mint-brightness-settings/
|
||||
|
||||
作者:[Abhishek][a]
|
||||
译者:[ZTinoZ](https://github.com/ZTinoZ)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
@ -1,22 +1,22 @@
|
||||
Docker 1.6 发布 - 如何在Fedora / CentOS上面升级
|
||||
如何在Fedora / CentOS上面升级Docker 1.6
|
||||
=============================================================================
|
||||
Docker,一个为软件打包的流行开源容器平台,有了新的发行版1.6,增加了许多新的特性。该版本在Docker注册,引擎,云集,组合和机器方面都有更新。这次发行旨在提升体验,开发者和系统管理员的经验(这里不太确定)。让我们来快速看看有哪些新特性吧。
|
||||
Docker,一个流行的将软件打包的开源容器平台,已经有了新的1.6版,增加了许多新的特性。该版本主要更新了Docker Registry、Engine、 Swarm、 Compose 和 Machine等方面。这次发布旨在提升性能、改善开发者和系统管理员的体验。让我们来快速看看有哪些新特性吧。
|
||||
|
||||
**Docker Registry (2.0)**是一项推送Docker镜像用于存储和分享的服务,经历过架构的改变,因为面临加载下的体验问题。它仍然向下兼容。Docker Registry的编写语言现在从Python改为Google的Go语言了,为了提升表现力。与Docker引擎1.6结合后,拉取镜像的能力更快了。早先的镜像被队列式地输送,而现在是并行的啦。
|
||||
**Docker Registry (2.0)**是一项推送Docker镜像用于存储和分享的服务,因为面临加载下的体验问题而经历了架构的改变。它仍然向后兼容。Docker Registry的编写语言现在从Python改为Google的Go语言了,以提升性能。与Docker Engine 1.6结合后,拉取镜像的能力更快了。早先的镜像是队列式输送的,而现在是并行的啦。
|
||||
|
||||
**Docker Engine (1.6)**相比之前的版本有很大的提高。目前支持容器与镜像标签。通过标签,你可以附加用户自定义的元数据到镜像和容器上,而镜像和容器反过来可以被其他工具使用。标签对正在运行的应用是不可见的,可以用来加速搜索容器和镜像。
|
||||
**Docker Engine (1.6)**相比之前的版本有很大的提高。目前支持容器与镜像的标签。通过标签,你可以附加用户自定义的元数据到镜像和容器上,而镜像和容器反过来可以被其他工具使用。标签对正在运行的应用是不可见的,可以用来加速搜索容器和镜像。
|
||||
|
||||
Windows版本的Docker客户端可以连接一个远程的运行linux的Docker引擎。
|
||||
Windows版本的Docker客户端可以连接到远程的运行在linux上的Docker Engine。
|
||||
|
||||
Docker目前支持日志驱动API,这允许我们发送容器日志给系统如Syslog,或者第三方。这将会使得系统管理员受益。
|
||||
|
||||
**Swarm (0.2)**是一个Docker集群工具,将一个Docker主机池转换为一个虚拟主机。在新特性里,容器甚至被放在了可用的节点上。通过添加更多的Docker命令,所有的努力都朝着支持完整的Docker API。将来,使用第三方驱动来集群会成为可能。
|
||||
**Swarm (0.2)**是一个Docker集群工具,可以将一个Docker主机池转换为一个虚拟主机。在新特性里,容器甚至被放在了可用的节点上。通过添加更多的Docker命令,努力支持完整的Docker API。将来,使用第三方驱动来集群会成为可能。
|
||||
|
||||
**Compose (1.2)** 是一个Docker里定义和运行复杂应用的工具, 也得到了升级。在新版本里,一个可以创建多个子文件,而不是一个没有结构的文件描述一个多容器应用。
|
||||
**Compose (1.2)** 是一个Docker里定义和运行复杂应用的工具, 也得到了升级。在新版本里,可以创建多个子文件,而不是用一个没有结构的文件描述一个多容器应用。
|
||||
|
||||
通过**Machine (0.2)**,我们可以很容易地在本地计算机,云和数据中心上搭建Docker主机。新的发行版为开发者提供了一个相对干净地驱动界面来写驱动。供应被Machine牢牢地掌握,而不是每个独立的驱动。新的命令被添加,可以用来生成主机的TLS证书,以提高安全性。
|
||||
通过**Machine (0.2)**,我们可以很容易地在本地计算机、云和数据中心上搭建Docker主机。新的发布版本为开发者提供了一个相对干净地驱动界面来编写驱动。Machine集中控制供给,而不是每个独立的驱动。增加了新的命令,可以用来生成主机的TLS证书,以提高安全性。
|
||||
|
||||
### 在Fedora / CentOS 上升级架构 ###
|
||||
### 在Fedora / CentOS 上的升级指导 ###
|
||||
|
||||
在这一部分里,我们将会学习如何在Fedora和CentOS上升级已有的docker到最新版本。请注意,目前的Docker仅运行在64位的架构上,Fedora和CentOS都源于RedHat,命令的使用是差不多相同的,除了在Fedora20和CentOS6.5里Docker包被叫做“docker-io”。
|
||||
|
||||
@ -28,7 +28,7 @@ Docker目前支持日志驱动API,这允许我们发送容器日志给系统
|
||||
|
||||
在升级之前,备份一下docker镜像和容器卷是个不错的主意。
|
||||
|
||||
参考[filesystem to a tar archive][1]与[volumes backups, restores or migrations options][2],获取更多信息。
|
||||
参考[“将文件系统打成 tar 包”][1]与[“卷备份、恢复或迁移”][2],获取更多信息。
|
||||
|
||||
目前,测试系统安装了Docker1.5。样例输出显示是来自一个Fedora20的系统。
|
||||
|
||||
@ -42,7 +42,7 @@ Docker目前支持日志驱动API,这允许我们发送容器日志给系统
|
||||
|
||||
[root@TestNode1 ~]# sudo systemctl stop docker
|
||||
|
||||
升级到最新版使用yum update。但是写这篇文章的时候,仓库并不是最新版本(1.6)。因此你需要使用二进制的升级方法。
|
||||
使用yum update升级到最新版,但是写这篇文章的时候,仓库并不是最新版本(1.6),因此你需要使用二进制的升级方法。
|
||||
|
||||
[root@TestNode1 ~]#sudo yum -y update docker-io
|
||||
|
||||
@ -66,7 +66,7 @@ Docker目前支持日志驱动API,这允许我们发送容器日志给系统
|
||||
|
||||
2015-04-19 13:40:50 (8.72 MB/s) - /usr/bin/docker saved
|
||||
|
||||
检查更新版本
|
||||
检查更新后的版本
|
||||
|
||||
[root@TestNode1 ~]#sudo docker -v
|
||||
|
||||
@ -88,7 +88,7 @@ Docker目前支持日志驱动API,这允许我们发送容器日志给系统
|
||||
|
||||
Hello World
|
||||
|
||||
CentOS安装时需要**注意**,在CentOS上安装完Docker后,当你试图启动Docker服务的时候,你可能会得到错误的信息,如下所示
|
||||
CentOS安装时需要**注意**,在CentOS上安装完Docker后,当你试图启动Docker服务的时候,你可能会得到错误的信息,如下所示:
|
||||
|
||||
docker.service - Docker Application Container Engine
|
||||
|
||||
@ -116,7 +116,7 @@ CentOS安装时需要**注意**,在CentOS上安装完Docker后,当你试图
|
||||
|
||||
Apr 20 03:24:24 centos7 systemd[1]: Unit docker.service entered failed state.
|
||||
|
||||
这是一个熟知的bug([https://bugzilla.redhat.com/show_bug.cgi?id=1207839][3]),需要一个设备映射的升级,到最新的水平。
|
||||
这是一个已知的bug([https://bugzilla.redhat.com/show_bug.cgi?id=1207839][3]),需要将设备映射升级到最新。
|
||||
|
||||
[root@centos7 ~]# rpm -qa device-mapper
|
||||
|
||||
@ -132,7 +132,7 @@ CentOS安装时需要**注意**,在CentOS上安装完Docker后,当你试图
|
||||
|
||||
### 总结 ###
|
||||
|
||||
尽管docker技术出现时间不长,当很快获得了流行。它使得开发者的生活变得容易,运维团队可以快速独立地创建和部署应用。通过公司发布快速的Docker更新,来提升产品质量,满足用户需求,未来对于Docker来说一片光明。
|
||||
尽管docker技术出现时间不长,但很快就变得非常流行了。它使得开发者的生活变得轻松,运维团队可以快速独立地创建和部署应用。通过该公司的发布,Docker的快速更新,产品质量的提升,满足用户需求,未来对于Docker来说一片光明。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -140,7 +140,7 @@ via: http://linoxide.com/linux-how-to/docker-1-6-features-upgrade-fedora-centos/
|
||||
|
||||
作者:[B N Poornima][a]
|
||||
译者:[wi-cuckoo](https://github.com/wi-cuckoo)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
@ -1,6 +1,6 @@
|
||||
Linux有问必答——nginx网络服务器上如何阻挡特定用户代理
|
||||
Linux有问必答:nginx网络服务器上如何阻止特定用户代理(UA)
|
||||
================================================================================
|
||||
> **问题**: 我注意到有一些机器人经常访问我nginx驱动的网站,并且进行一些攻击性的扫描,导致消耗掉了我的网络服务器的大量资源。我一直尝试着通过用户代理符串来阻挡这些机器人。我怎样才能在nginx网络服务器上阻挡掉特定的用户代理呢?
|
||||
> **问题**: 我注意到有一些机器人经常访问我的nginx驱动的网站,并且进行一些攻击性的扫描,导致消耗掉了我的网络服务器的大量资源。我一直尝试着通过用户代理符串来阻挡这些机器人。我怎样才能在nginx网络服务器上阻挡掉特定的用户代理呢?
|
||||
|
||||
现代互联网滋生了大量各种各样的恶意机器人和网络爬虫,比如像恶意软件机器人、垃圾邮件程序或内容刮刀,这些恶意工具一直偷偷摸摸地扫描你的网站,干些诸如检测潜在网站漏洞、收获电子邮件地址,或者只是从你的网站偷取内容。大多数机器人能够通过它们的“用户代理”签名字符串来识别。
|
||||
|
||||
@ -10,7 +10,7 @@ Linux有问必答——nginx网络服务器上如何阻挡特定用户代理
|
||||
|
||||
### 在Nginx中将特定用户代理列入黑名单 ###
|
||||
|
||||
要配置用户代理阻挡列表,请打开你的网站的nginx配置文件,找到服务器定义部分。该文件可能会放在不同的地方,这取决于你的nginx配置或Linux版本(如,/etc/nginx/nginx.conf,/etc/nginx/sites-enabled/<your-site>,/usr/local/nginx/conf/nginx.conf,/etc/nginx/conf.d/<your-site>)。
|
||||
要配置用户代理阻挡列表,请打开你的网站的nginx配置文件,找到`server`定义部分。该文件可能会放在不同的地方,这取决于你的nginx配置或Linux版本(如,`/etc/nginx/nginx.conf`,`/etc/nginx/sites-enabled/<your-site>`,`/usr/local/nginx/conf/nginx.conf`,`/etc/nginx/conf.d/<your-site>`)。
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
@ -20,19 +20,19 @@ Linux有问必答——nginx网络服务器上如何阻挡特定用户代理
|
||||
....
|
||||
}
|
||||
|
||||
在打开该配置文件并找到 server 部分后,添加以下 if 声明到该部分内的某个地方。
|
||||
在打开该配置文件并找到 `server` 部分后,添加以下 if 声明到该部分内的某个地方。
|
||||
|
||||
server {
|
||||
listen 80 default_server;
|
||||
server_name xmodulo.com;
|
||||
root /usr/share/nginx/html;
|
||||
|
||||
# case sensitive matching
|
||||
# 大小写敏感的匹配
|
||||
if ($http_user_agent ~ (Antivirx|Arian) {
|
||||
return 403;
|
||||
}
|
||||
|
||||
# case insensitive matching
|
||||
#大小写无关的匹配
|
||||
if ($http_user_agent ~* (netcrawl|npbot|malicious)) {
|
||||
return 403;
|
||||
}
|
||||
@ -41,7 +41,7 @@ Linux有问必答——nginx网络服务器上如何阻挡特定用户代理
|
||||
}
|
||||
|
||||
如你所想,这些 if 声明使用正则表达式匹配了任意不良用户字符串,并向匹配的对象返回403 HTTP状态码。
|
||||
$http_user_agent是HTTP请求的一个包含有用户代理字符串的变量。‘~’操作符针对用户代理字符串进行大小写敏感匹配,而‘~*’操作符则进行大小写不敏感匹配。‘|’操作符是逻辑或,因此,你可以在 if 声明中放入众多的用户代理关键字,然后将它们全部阻挡掉。
|
||||
`$http_user_agent`是HTTP请求中的一个包含有用户代理字符串的变量。‘~’操作符针对用户代理字符串进行大小写敏感匹配,而‘~*’操作符则进行大小写无关匹配。‘|’操作符是逻辑或,因此,你可以在 if 声明中放入众多的用户代理关键字,然后将它们全部阻挡掉。
|
||||
|
||||
在修改配置文件后,你必须重新加载nginx以激活阻挡:
|
||||
|
||||
@ -55,7 +55,7 @@ $http_user_agent是HTTP请求的一个包含有用户代理字符串的变量。
|
||||
|
||||
### 管理Nginx中的用户代理黑名单 ###
|
||||
|
||||
目前为止,我已经展示了在nginx中如何阻挡一些用户代理的HTTP请求。如果你有学多不同类型的网络爬虫机器人要阻挡,又该怎么办呢?
|
||||
目前为止,我已经展示了在nginx中如何阻挡一些用户代理的HTTP请求。如果你有许多不同类型的网络爬虫机器人要阻挡,又该怎么办呢?
|
||||
|
||||
由于用户代理黑名单会增长得很大,所以将它们放在nginx的server部分不是个好点子。取而代之的是,你可以创建一个独立的文件,在该文件中列出所有被阻挡的用户代理。例如,让我们创建/etc/nginx/useragent.rules,并定义以下面的格式定义所有被阻挡的用户代理的图谱。
|
||||
|
||||
@ -100,7 +100,7 @@ $http_user_agent是HTTP请求的一个包含有用户代理字符串的变量。
|
||||
|
||||
$ sudo /path/to/nginx -s reload
|
||||
|
||||
现在,任何包含有/etc/nginx/useragent.rules中列出的关键字的用户代理将被nginx自动禁止。
|
||||
现在,任何包含有`/etc/nginx/useragent.rules`中列出的关键字的用户代理将被nginx自动禁止。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
@ -108,7 +108,7 @@ via: http://ask.xmodulo.com/block-specific-user-agents-nginx-web-server.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[GOLinux](https://github.com/GOLinux)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
@ -0,0 +1,26 @@
|
||||
Microsoft Open-Sources The Windows Communication Foundation
|
||||
================================================================================
|
||||
Microsoft has today announced they've open-sourced the important WCF (Windows Communication Foundation) code that now targets .NET Core.
|
||||
|
||||
As described by [MSDN][1], "Windows Communication Foundation (WCF) is a framework for building service-oriented applications. Using WCF, you can send data as asynchronous messages from one service endpoint to another. A service endpoint can be part of a continuously available service hosted by IIS, or it can be a service hosted in an application. An endpoint can be a client of a service that requests data from a service endpoint. The messages can be as simple as a single character or word sent as XML, or as complex as a stream of binary data."
|
||||
|
||||
The [code on GitHub][2], "contains a subset of the full Windows Communication Foundation product available on the Windows desktop, and it supports the library profiles already available for building WCF apps for the Windows Store. These profiles are primarily client-based, making them suited for mobile devices or on mid-tier servers to communicate with existing WCF services."
|
||||
|
||||
More details on Microsoft opening up the Windows Communication Foundation can be found via the announcement posted this morning to the [dotNETFoundation.org blog][3].
|
||||
|
||||
Windows Communication Foundation sounds a bit like D-Bus on Linux for inter-process communication between programs/services.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.phoronix.com/scan.php?page=news_item&px=Microsoft-Open-Source-WCF
|
||||
|
||||
作者:[Michael Larabel][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.michaellarabel.com/
|
||||
[1]:https://msdn.microsoft.com/en-us/library/ms731082%28v=vs.110%29.aspx
|
||||
[2]:https://github.com/dotnet/wcf
|
||||
[3]:http://www.dotnetfoundation.org/blog/wcf-is-open-source
|
@ -0,0 +1,38 @@
|
||||
Will Ubuntu Linux Hit 200 Million Users This Year?
|
||||
================================================================================
|
||||
It's been four years and two weeks since Mark Shuttleworth expressed his goal of "200 million users of Ubuntu in 4 years." While Ubuntu's presence has continued to increase over the past four years, it doesn't look like that goal has been realized yet or will be by the end of the calendar year.
|
||||
|
||||
It was back at [UDS Budapest][1] in May of 2011 when Shuttleworth expressed a goal of 200 million Ubuntu users in four years.
|
||||
|
||||
![](http://www.phoronix.net/image.php?id=uds_budapest&image=budapest_phoronix_03_show&w=1920)
|
||||
|
||||
Last I heard there was "tens of millions" of Ubuntu Linux users, but haven't seen any reliable reports anywhere of the Ubuntu user-base being close to 200 million. The latest monthly statistics from Valve show [the Linux gaming population being below 1%][2] compared to Windows and OS X. Most usage statistics based on web metrics and other data tend to put the total Linux user-base at just a few percent.
|
||||
|
||||
Aside from desktop installations, Ubuntu at least has made substantial inroads with cloud and server deployments over the past four years and have proven to be a contender with Red Hat Enterprise Linux on such fronts. Ubuntu has also proven itself quite well on ARM hardware. When Mark was coming up with his goal in four years, he was probably thinking that Ubuntu Phone/Touch would be much further along than where it is now: just having one device available in the EU and [a second currently in China][3] and [the Ubuntu Touch software stack still maturing][4] with [major work on key apps still needed][5], etc.
|
||||
|
||||
![](http://www.phoronix.net/image.php?id=0x2015&image=shuttleworth_200_million_show&w=1920)
|
||||
|
||||
It's also been three years since the Canonical claim of [Ubuntu would soon ship on 5% of PCs][6]. The 5% claim was for worldwide PC shipments, but even three years later, I have a hard time believing that... At least in the US and Europe I still very rarely see Ubuntu preloads on systems within brick and mortar stores while the major Internet retailers / OEMs still tend to offer Linux on a few select PC models, sans Chrome OS / Android devices.
|
||||
|
||||
Another lofty, unrelated goal that went unreached by the open-source community was [GNOME owning 10% of the global desktop market by 2010][7]. Five years later, there's no indication they're even close to reaching that 10x10 milestone.
|
||||
|
||||
How large do you think the Ubuntu user-base is today? How large do you think the Ubuntu (or Linux) user-base will grow in the years to come? Share with us your thoughts by commenting on this article.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.phoronix.com/scan.php?page=news_item&px=2015-200-Million-Goal-Retro
|
||||
|
||||
作者:[Michael Larabel][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://www.michaellarabel.com/
|
||||
[1]:http://www.phoronix.com/vr.php?view=16002
|
||||
[2]:http://www.phoronix.com/scan.php?page=news_item&px=Steam-April-2015-1-Drop
|
||||
[3]:http://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-MX4-In-China
|
||||
[4]:http://www.phoronix.com/scan.php?page=news_item&px=Ubuntu-Calculator-Reboot
|
||||
[5]:http://www.phoronix.com/scan.php?page=news_item&px=MTgzOTM
|
||||
[6]:http://www.phoronix.com/scan.php?page=news_item&px=MTA5ODM
|
||||
[7]:https://www.phoronix.com/scan.php?page=news_item&px=Nzg1Mw
|
@ -1,254 +0,0 @@
|
||||
Translating by goreliu ...
|
||||
|
||||
How to set up server monitoring system with Monit
|
||||
================================================================================
|
||||
Many Linux admins rely on a centralized remote monitoring system (e.g., [Nagios][1] or [Cacti][2]) to check the health of their network infrastructure. While centralized monitoring makes an admin's life easy when dealing with many hosts and devices, a dedicated monitoring box obviously becomes a single point of failure; if the monitoring box goes down or becomes unreachable for whatever reason (e.g., bad hardware or network outage), you will lose visibility on your entire infrastructure.
|
||||
|
||||
One way to add redundancy to your monitoring system is to install standalone monitoring software (as a fallback) at least on any critical/core servers on your network. In case a centralized monitor is down, you will still be able to maintain visibility on your core servers from their backup monitor.
|
||||
|
||||
### What is Monit? ###
|
||||
|
||||
[Monit][3] is a cross-platform open-source tool for monitoring Unix/Linux systems (e.g., Linux, BSD, OSX, Solaris). Monit is extremely easy to install and reasonably lightweight (with only 500KB in size), and does not require any third-party programs, plugins or libraries. Yet, Monit lends itself to full-blown monitoring, capable of process status monitoring, filesystem change monitoring, email notification, customizable actions for core services, and so on. The combination of ease of setup, lightweight implementation and powerful features makes Monit an ideal candidate for a backup monitoring tool.
|
||||
|
||||
I have been using Monit for several years on multiple hosts, and I am very pleased how reliable it has been. Even as a full-blown monitoring system, Monit is very useful and powerful for any Linux admin. In this tutorial, let me demonstrate how to set up Monit on a local server (as a backup monitor) to monitor common services. With this setup, I will only scrach the surface of what Monit can do for us.
|
||||
|
||||
### Installation of Monit on Linux ###
|
||||
|
||||
Most Linux distributions already include Monit in their repositories.
|
||||
|
||||
Debian, Ubuntu or Linux Mint:
|
||||
|
||||
$ sudo aptitude install monit
|
||||
|
||||
Fedora or CentOS/RHEL:
|
||||
|
||||
On CentOS/RHEL, you must enable either [EPEL][4] or [Repoforge][5] repository first.
|
||||
|
||||
# yum install monit
|
||||
|
||||
Monit comes with a very well documented configuration file with a lots of examples. The main configuration file is located in /etc/monit.conf in Fedora/CentOS/RHEL, or /etc/monit/monitrc in Debian/Ubuntu/Mint. Monit configuration has two parts: "Global" and "Services" sections.
|
||||
|
||||
Gl### ###obal Configuration: Web Status Page
|
||||
|
||||
Monit can use several mail servers for notifications, and/or an HTTP/HTTPS status page. Let's start with the web status page with the following requirements.
|
||||
|
||||
- Monit listens on port 1966.
|
||||
- Access to the web status page is encrypted with SSL.
|
||||
- Login requires monituser/romania as user/password.
|
||||
- Login is permitted from localhost, myhost.mydomain.ro, and internal LAN (192.168.0.0/16) only.
|
||||
- Monit stores an SSL certificate in a pem format.
|
||||
|
||||
For subsequent steps, I will use a Red Hat based system. Similar steps will be applicable on a Debian based system.
|
||||
|
||||
First, generate and store a self-signed certificate (monit.pem) in /var/cert.
|
||||
|
||||
# mkdir /var/certs
|
||||
# cd /etc/pki/tls/certs
|
||||
# ./make-dummy-cert monit.pem
|
||||
# cp monit.pem /var/certs
|
||||
# chmod 0400 /var/certs/monit.pem
|
||||
|
||||
Now put the following snippet in the Monit's main configuration file. You can start with an empty configuration file or make a copy of the original file.
|
||||
|
||||
set httpd port 1966 and
|
||||
SSL ENABLE
|
||||
PEMFILE /var/certs/monit.pem
|
||||
allow monituser:romania
|
||||
allow localhost
|
||||
allow 192.168.0.0/16
|
||||
allow myhost.mydomain.ro
|
||||
|
||||
### Global Configuration: Email Notification ###
|
||||
|
||||
Next, let's set up email notification in Monit. We need at least one active [SMTP server][6] which can send mails from the Monit host. Something like the following will do (adjust it for your case):
|
||||
|
||||
- Mail server hostname: smtp.monit.ro
|
||||
- Sender email address used by monit (from): monit@monit.ro
|
||||
- Who will receive mail from monit daemon: guletz@monit.ro
|
||||
- SMTP port used by mail server: 587 (default is 25)
|
||||
|
||||
With the above information, email notification would be configured like this:
|
||||
|
||||
set mailserver smtp.monit.ro port 587
|
||||
set mail-format {
|
||||
from: monit@monit.ro
|
||||
subject: $SERVICE $EVENT at $DATE on $HOST
|
||||
message: Monit $ACTION $SERVICE $EVENT at $DATE on $HOST : $DESCRIPTION.
|
||||
|
||||
Yours sincerely,
|
||||
Monit
|
||||
|
||||
}
|
||||
|
||||
set alert guletz@monit.ro
|
||||
|
||||
As you can see, Monit offers several built-in variables ($DATE, $EVENT, $HOST, etc.), and you can customize your email message for your needs. If you want to send mails from the Monit host itself, you need a sendmail-compatible program (e.g., postfix or ssmtp) already installed.
|
||||
|
||||
### Global Configuration: Monit Daemon ###
|
||||
|
||||
The next part is setting up monit daemon. We will set it up as follows.
|
||||
|
||||
- Performs the first check after 120 seconds.
|
||||
- Checks services once every 3 minutes.
|
||||
- Use syslog for logging.
|
||||
|
||||
Place the following snippet to achieve the above setting.
|
||||
|
||||
set daemon 120
|
||||
with start delay 240
|
||||
set logfile syslog facility log_daemon
|
||||
|
||||
We must also define "idfile", a unique ID used by monit demon, and "eventqueue", a path where mails sent by monit but undelivered due to SMTP/network errors. Verifiy that path (/var/monit) already exists. The following configuration will do.
|
||||
|
||||
set idfile /var/monit/id
|
||||
set eventqueue
|
||||
basedir /var/monit
|
||||
|
||||
### Test Global Configuration ###
|
||||
|
||||
Now the "Global" section is finished. The Monit configuration file will look like this:
|
||||
|
||||
# Global Section
|
||||
|
||||
# status webpage and acl's
|
||||
set httpd port 1966 and
|
||||
SSL ENABLE
|
||||
PEMFILE /var/certs/monit.pem
|
||||
allow monituser:romania
|
||||
allow localhost
|
||||
allow 192.168.0.0/16
|
||||
allow myhost.mydomain.ro
|
||||
|
||||
# mail-server
|
||||
set mailserver smtp.monit.ro port 587
|
||||
# email-format
|
||||
set mail-format {
|
||||
from: monit@monit.ro
|
||||
subject: $SERVICE $EVENT at $DATE on $HOST
|
||||
message: Monit $ACTION $SERVICE $EVENT at $DATE on $HOST : $DESCRIPTION.
|
||||
|
||||
Yours sincerely,
|
||||
Monit
|
||||
|
||||
}
|
||||
|
||||
set alert guletz@monit.ro
|
||||
|
||||
# delay checks
|
||||
set daemon 120
|
||||
with start delay 240
|
||||
set logfile syslog facility log_daemon
|
||||
|
||||
# idfile and mail queue path
|
||||
set idfile /var/monit/id
|
||||
set eventqueue
|
||||
basedir /var/monit
|
||||
|
||||
Now it is time to check what we have done. You can test an existing configuration file (/etc/monit.conf) by running:
|
||||
|
||||
# monit -t
|
||||
|
||||
----------
|
||||
|
||||
Control file syntax OK
|
||||
|
||||
If Monit complains about any error, please review the configuration file again. Fortunately, error/warnings messages are informative. For example:
|
||||
|
||||
monit: Cannot stat the SSL server PEM file '/var/certs/monit.pem' -- No such file or directory
|
||||
/etc/monit/monitrc:10: Warning: hostname did not resolve 'smtp.monit.ro'
|
||||
|
||||
Once you verify the syntax of configuration, start monit daemon, and wait 2 to 3 minutes:
|
||||
|
||||
# service monit start
|
||||
|
||||
If you are using systemd, run:
|
||||
|
||||
# systemctl start monit
|
||||
|
||||
Now open a browser window, and go to https://<monit_host>:1966. Replace &<monit_host> with your Monit hostname or IP address.
|
||||
|
||||
Note that if you have a self-signed SSL certificate, you will see a warning message in your browser.
|
||||
|
||||
![](https://farm8.staticflickr.com/7596/16737206479_96b9f7dfdb_c.jpg)
|
||||
|
||||
After you have completed login, you must see the following page.
|
||||
|
||||
![](https://farm8.staticflickr.com/7594/16303369973_6019482dea_c.jpg)
|
||||
|
||||
In the rest of the tutorial, let me show how we can monitor a local server and common services. You will see a lot of useful examples on the [official wiki page][7]. Most of them are copy-and-pastable!
|
||||
|
||||
### Service Configuration: CPU/Memory Monitoring ###
|
||||
|
||||
Let start with monitoring a local server's CPU/memory usage. Copy the following snippet in the configuration file.
|
||||
|
||||
check system localhost
|
||||
if loadavg (1min) > 10 then alert
|
||||
if loadavg (5min) > 6 then alert
|
||||
if memory usage > 75% then alert
|
||||
if cpu usage (user) > 70% then alert
|
||||
if cpu usage (system) > 60% then alert
|
||||
if cpu usage (wait) > 75% then alert
|
||||
|
||||
You can easily interpret the above configuration. The above checks are performed on local host for every monitoring cycle (which is set to 120 seconds in the Global section). If any condition is met, monit daemon will send an alert with an email.
|
||||
|
||||
If certain properties do not need to be monitored for every cycle, you can use the following format. For example, this will monitor average load every other cycle (i.e., every 240 seconds).
|
||||
|
||||
if loadavg (1min) > 10 for 2 cycles then alert
|
||||
|
||||
### Service Configuration: SSH Service Monitoring ###
|
||||
|
||||
Let's check if we have sshd binary installed in /usr/sbin/sshd:
|
||||
|
||||
check file sshd_bin with path /usr/sbin/sshd
|
||||
|
||||
We also want to check if the init script for sshd exist:
|
||||
|
||||
check file sshd_init with path /etc/init.d/sshd
|
||||
|
||||
Finally, we want to check if sshd daemon is up an running, and listens on port 22:
|
||||
|
||||
check process sshd with pidfile /var/run/sshd.pid
|
||||
start program "/etc/init.d/sshd start"
|
||||
stop program "/etc/init.d/sshd stop"
|
||||
if failed port 22 protocol ssh then restart
|
||||
if 5 restarts within 5 cycles then timeout
|
||||
|
||||
More specifically, we can interpret the above configuration as follows. We check if a process named sshd and a pidfile (/var/run/sshd.pid) exist. If either one does not exist, we restart sshd demon using init script. We check if a process listening on port 22 can speak SSH protocol. If not, we restart sshd daemon. If there are at least 5 restarts within the last 5 monitoring cycles (i.e., 5x120 seconds), sshd daemon is declared non-functional, and we do not try to check again.
|
||||
|
||||
![](https://farm9.staticflickr.com/8685/16735725998_62c26a24bc_c.jpg)
|
||||
|
||||
### Service Configuration: SMTP Service Monitoring ###
|
||||
|
||||
Now let's set up a check on a remote SMTP mail server (e.g., 192.168.111.102). Let's assume that the SMTP server is running SMTP, IMAP and SSH on its LAN interface.
|
||||
|
||||
check host MAIL with address 192.168.111.102
|
||||
if failed icmp type echo within 10 cycles then alert
|
||||
if failed port 25 protocol smtp then alert
|
||||
else if recovered then exec "/scripts/mail-script"
|
||||
if failed port 22 protocol ssh then alert
|
||||
if failed port 143 protocol imap then alert
|
||||
|
||||
We check if the remote host responds to ICMP. If we haven't received ICMP response within 10 cycles, we send out an alert. If testing for SMTP protocol on port 25 fails, we send out an alert. If testing succeeds again after a failed test, we run a script (/scripts/mail-script). If testing for SSH and IMAP protocols fail on port 22 and 143, respectively, we send out an alert.
|
||||
|
||||
### Conclusion ###
|
||||
|
||||
In this tutorial, I demonstrate how to set up Monit on a local server. What I showed here is just the tip of the iceberg, as far as Monit's capabilities are concerned. Take your time and read the man page about Monit (a very good one). Monit can do a lot for any Linux admin with a very nice and easy to understand syntax. If you put together a centralized remote monitor and Monit to work for you, you will have a more reliable monitoring system. What is your thought on Monit?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/server-monitoring-system-monit.html
|
||||
|
||||
作者:[Iulian Murgulet][a]
|
||||
译者:[goreliu](https://github.com/goreliu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/iulian
|
||||
[1]:http://xmodulo.com/monitor-common-services-nagios.html
|
||||
[2]:http://xmodulo.com/monitor-linux-servers-snmp-cacti.html
|
||||
[3]:http://mmonit.com/monit/
|
||||
[4]:http://xmodulo.com/how-to-set-up-epel-repository-on-centos.html
|
||||
[5]:http://xmodulo.com/how-to-set-up-rpmforge-repoforge-repository-on-centos.html
|
||||
[6]:http://xmodulo.com/mail-server-ubuntu-debian.html
|
||||
[7]:http://mmonit.com/wiki/Monit/ConfigurationExamples
|
@ -1,66 +0,0 @@
|
||||
translating----geekpi
|
||||
|
||||
How to Use tmpfs on RHEL / CentOS 7.0
|
||||
================================================================================
|
||||
Today we will talk about tmpfs CentOS 7 a file system that will keep all files and folders in the virtual memory of the operating system as opposed to actually writing them to the disk. This means that all the content in tmpfs is temporary in the sense that it’s not permanently written to the disk and in case the tmpfs is unmounted, the system is rebooted or the power is cut all content will be lost. From a technical point of view tmpfs puts everything in the kernel internal cache and then grows or shrinks to accommodate the files it contains ans is able to swap unneeded pages out of swap space.
|
||||
|
||||
By default CentOS uses tmpfs for various things as you can see from the output of the df –h command:
|
||||
|
||||
# df –h
|
||||
|
||||
![df](http://blog.linoxide.com/wp-content/uploads/2015/05/tmpfs1.jpg)
|
||||
|
||||
/dev - directory contains the special device files for all the devices.
|
||||
/dev/shm – contains shared memory allocation
|
||||
/run - used for system logs
|
||||
/sys/fs/cgroup - used for cgroups, a kernel feature to limit, police and account the resource usage of certain processes
|
||||
|
||||
One use of tmpfs is to obviously use it as a /tmp folder, you can do this in 2 ways:
|
||||
|
||||
### Using systemctl to enable tmpfs in /tmp ###
|
||||
|
||||
You can use the systemctl command to enable tmpfs in the /tmp folder, first use the following command to check if this feature is not already enabled:
|
||||
|
||||
# systemctl is-enabled tmp.mount
|
||||
|
||||
Will show the current status of settings you can use the following command to enable it:
|
||||
|
||||
# systemctl enable tmp.mount
|
||||
|
||||
![systemctl](http://blog.linoxide.com/wp-content/uploads/2015/05/tmpfs3.jpg)
|
||||
|
||||
This will have the system controlling the /tmp folder and mount a tmpfs in it.
|
||||
|
||||
### Manually mounting a /tmp/fs ###
|
||||
|
||||
You can also manually add a tmpfs in /tmp by adding the following line to /etc/fstab:
|
||||
|
||||
tmpfs /tmp tmpfs size=512m 0 0
|
||||
|
||||
And then running the mount command like this:
|
||||
|
||||
# mount –a
|
||||
|
||||
![df](http://blog.linoxide.com/wp-content/uploads/2015/05/tmpfs2.jpg)
|
||||
|
||||
This should make the tmpfs show in df –h, also it will automatically mount it the next time you reboot.
|
||||
|
||||
### Creating a tmpfs on the fly ###
|
||||
|
||||
If for some reason you wish to create a tmpfs in a folder on the fly you can always use the following command:
|
||||
|
||||
# mount -t tmpfs -o size=1G tmpfs /mnt/mytmpfs
|
||||
|
||||
Of course you can specify any size you wish in the size option and any mount point you wish, just remember it must be a valid directory.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/file-system/use-tmpfs-rhel-centos-7-0/
|
||||
|
||||
作者:[Adrian Dinu][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/adriand/
|
@ -1,169 +0,0 @@
|
||||
translating---geekpi
|
||||
|
||||
How to compile and install wxWidgets on Ubuntu/Debian/Linux Mint
|
||||
================================================================================
|
||||
### wxWidgets ###
|
||||
|
||||
wxWidgets is an application development framework/library that allows developer to make cross platform GUI applications for Windows, Mac and Linux using the same codebase.
|
||||
|
||||
Its primarily written in C++ but has bindings for other languages as well like Python, Perl and Ruby.
|
||||
|
||||
In this tutorial I am going to show you how to compile and build wxwidgets 3.0+ on Debian based linux systems like Ubuntu and Linux Mint.
|
||||
|
||||
Compiling wxWidgets from source is not at all difficult as it might sound and takes only a few minutes to do.
|
||||
|
||||
The library can be compiled in different modes like static library or dynamic library.
|
||||
|
||||
### 1. Download wxWidgets ###
|
||||
|
||||
The first step would be to download the wxWidgets source files from [wxwidgets.org][1]
|
||||
|
||||
Once done, extract the files to a directory.
|
||||
|
||||
### 2. Setup build environment ###
|
||||
|
||||
To compile wxwidgets we would need some utility programs including the C++ compiler on Linux called g++. And all of it would be installed from the repositories using apt-get.
|
||||
|
||||
We also need the GTK development libraries which wxWidgets depend on.
|
||||
|
||||
$ sudo apt-get install libgtk-3-dev build-essential checkinstall
|
||||
|
||||
> The utility called checkinstall would allow us to create an installation package for wxwidgets, so that later on it can un-installed easily using package managers
|
||||
|
||||
### 3. Compile wxWidgets ###
|
||||
|
||||
Get inside the directory where wxWidgets is extracted. In order to keep things clean, create a directory where the compilation would be done.
|
||||
|
||||
$ mkdir gtk-build
|
||||
$ cd gtk-build/
|
||||
|
||||
Now run the configure and make commands one by one. Each one would take some time to finish.
|
||||
|
||||
$ ../configure --disable-shared --enable-unicode
|
||||
$ make
|
||||
|
||||
The "--disable-shared" option instructs wxwidgets to builds static libraries instead of shared/dynamic ones.
|
||||
|
||||
After the make command finishes, the compilation is done successfully. Its time to install the wxWidgets files to the correct location.
|
||||
|
||||
More information about compile options can be found in install.txt and readme.txt files that can be found in /docs/gtk/ inside the wxwidgets directory.
|
||||
|
||||
### 4. Install with checkinstall ###
|
||||
|
||||
Now instead of using the "make install" command, we shall use the checkinstall command to create a deb package for wxwidgets. Run the following command
|
||||
|
||||
$ sudo checkinstall
|
||||
|
||||
Checkinstall would ask few questions during the process and make sure to provide a version number when asked, otherwise it would fail.
|
||||
|
||||
Once the process is over, wxWidgets would be installed and also a deb file would be created in the same directory.
|
||||
|
||||
### 5. Track the installed files ###
|
||||
|
||||
If you wish to check where the files are installed, use the dpkg command followed by the name of the package provided during the checkinstall process.
|
||||
|
||||
$ dpkg -L package_name
|
||||
/.
|
||||
/usr
|
||||
/usr/local
|
||||
/usr/local/lib
|
||||
/usr/local/lib/libwx_baseu-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_propgrid-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_html-3.0.a
|
||||
/usr/local/lib/libwxscintilla-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_ribbon-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_stc-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_qa-3.0.a
|
||||
/usr/local/lib/libwx_baseu_net-3.0.a
|
||||
/usr/local/lib/libwxtiff-3.0.a
|
||||
|
||||
### 6. Compile the samples ###
|
||||
|
||||
After compiling wxWidgets, its time to compile the sample programs to see it in action. In the same directory where we compiled wxwidgets, a new subdirectory called samples would have been created.
|
||||
|
||||
Just enter it and run the make command
|
||||
|
||||
$ compile samples
|
||||
$ cd samples/
|
||||
$ make
|
||||
|
||||
After the make process finishes, get inside each sample sub directory and there should be an executable file that can be run right away to see the demo.
|
||||
|
||||
### 7. Compile your first program ###
|
||||
|
||||
After you are done with the demo programs, its time to write your own program and compile it. Again it is quite easy.
|
||||
|
||||
It is assumed that you are coding in C++ and for that you can use any good editor with syntax highlighting feature. For example gedit, kate, kwrite would do. Or you might want to try fully loaded IDEs like Geany, Codelite, Codeblocks etc.
|
||||
|
||||
However for your first program just use an ordinary text editor get it done quick.
|
||||
|
||||
Here it is
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class Simple : public wxFrame
|
||||
{
|
||||
public:
|
||||
Simple(const wxString& title)
|
||||
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
|
||||
{
|
||||
Centre();
|
||||
}
|
||||
};
|
||||
|
||||
class MyApp : public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit()
|
||||
{
|
||||
Simple *simple = new Simple(wxT("Simple"));
|
||||
simple->Show(true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
wxIMPLEMENT_APP(MyApp);
|
||||
|
||||
Now save the program somewhere and compile it with the following commands
|
||||
|
||||
# compile
|
||||
$ g++ basic.cpp `wx-config --cxxflags --libs std` -o program
|
||||
|
||||
# run
|
||||
$ ./program
|
||||
|
||||
#### Compiling with non standard libraries ####
|
||||
|
||||
The wx-config command shown above provides only the standard libraries by default. If you are using the Aui classes for example, then you need to specify additional libraries for it
|
||||
|
||||
$ g++ code.cpp `wx-config --cxxflags --libs std,aui` -o program
|
||||
|
||||
More information can be found [here][2].
|
||||
|
||||
### Resources ###
|
||||
|
||||
Download source and help files for wxWidgets
|
||||
[https://www.wxwidgets.org/downloads/][3]
|
||||
|
||||
wxWidgets wiki page on compile instructions
|
||||
[https://wiki.wxwidgets.org/Compiling_and_getting_started][4]
|
||||
|
||||
Notes on how to use the latest wxWidgets version (3.0+)
|
||||
[https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets][5]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.binarytides.com/install-wxwidgets-ubuntu/
|
||||
|
||||
作者:[Silver Moon][a]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117145272367995638274/posts
|
||||
[1]:https://www.wxwidgets.org/downloads/
|
||||
[2]:https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets#The_wx-config_script
|
||||
[3]:https://www.wxwidgets.org/downloads/
|
||||
[4]:https://wiki.wxwidgets.org/Compiling_and_getting_started
|
||||
[5]:https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets
|
@ -1,99 +0,0 @@
|
||||
如何交互式地创建一个Docker容器
|
||||
===============================================================================
|
||||
大家好,今天我们来学习如何使用一个docker镜像交互式地创建一个Docker容器。一旦我们从镜像中启动一个Docker进程,Docker就会在父镜像与子镜像间来回搬运,重复工作,直到到达子镜像。然后联合文件系统会在顶层添加一个读写层。读写层又叫一个 **Container** 包含一些信息,关于它的父镜像和一些其他的信息,如单独的ID,网络配置和资源限制。容器已经声明,他们可以从 **running** 切换到 **exited** 状态。一个处于 **running** 状态的容器包含了很多分支在CPU上面运行,独立于其他在主机上运行的进程,而主机上 **exited** 是文件系统的状态,它的退出变量值是保留的。你可以使用读写层来启动,停止和重启一个容器。
|
||||
|
||||
Docker技术为IT界带来了巨大的改变,它使得云服务可以用来共享应用和工作流程自动化,使得应用可以从组件快速组合,消除了开发与品质保证和产品环境间的摩擦。在这篇文章中,我们将会建立CentOS环境,然后维护一个网站,在Apache网络服务器下运行。
|
||||
|
||||
这是快速且容易的教程,讨论我们怎样使用一个交互的shell,以一个交互的方式来创建一个容器。
|
||||
|
||||
### 1. 运行一个Docker实例 ###
|
||||
|
||||
Docker一开始尝试从本地取得和运行所需的镜像,如果在本地主机上没有发现,它就会从[Docker公共注册中心][1]拉取。这里,我们将会在一个DOcker容器里取得并创建一个fedora实例,附加一个bash shell到tty
|
||||
|
||||
# docker run -i -t fedora bash
|
||||
|
||||
![Downloading Fedora Base Image](http://blog.linoxide.com/wp-content/uploads/2015/03/downloading-fedora-base-image.png)
|
||||
|
||||
### 2.安装Apache网络服务器 ###
|
||||
|
||||
现在,在我们的Fedora基本镜像准备好后,我们将会开始交互式地安装Apache网络服务器,而不必为它创建Dockerfile。为了做到这点,我们需要在终端或者shell运行以下命令。
|
||||
|
||||
# yum update
|
||||
|
||||
![Installing httpd](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-httpd2.png)
|
||||
|
||||
# yum install httpd
|
||||
|
||||
![Installing httpd](http://blog.linoxide.com/wp-content/uploads/2015/03/installing-httpd2.png)
|
||||
|
||||
# exit
|
||||
|
||||
### 3.Saving the Image ###
|
||||
|
||||
现在,我们要去保存在Fedora实例里做的修改。要做到这个,我们首先需要知道实例的容器ID。而为了得到ID,我们又需要运行以下命令。
|
||||
|
||||
# docker ps -a
|
||||
|
||||
![Docker Running Container](http://blog.linoxide.com/wp-content/uploads/2015/03/docker-running-container.png)
|
||||
|
||||
然后,我们会保存这些改变为一个新的镜像,请运行以下命令。
|
||||
|
||||
# docker commit c16378f943fe fedora-httpd
|
||||
|
||||
![committing fedora httpd](http://blog.linoxide.com/wp-content/uploads/2015/03/committing-fedora-httpd.png)
|
||||
|
||||
这里,修改已经通过使用容器ID保存起来了,镜像名字叫fedora-httpd。为了确认新的镜像时候在运行,我们将运行以下命令
|
||||
|
||||
# docker images
|
||||
|
||||
![view docker images](http://blog.linoxide.com/wp-content/uploads/2015/03/view-docker-images.png)
|
||||
|
||||
### 4. 添加内容到新的镜像 ###
|
||||
|
||||
我们自己新的Fedora Apache镜像正成功的运行,现在我们想添加一些网页内容到Apache网络服务器,包括我们的网站,使得网站能够脱离盒子正确运行。为做到这点,我们需要创建一个新的Dockerfile,它会处理从复制网页内容到使用80端口的所有操作。而为做到这,我们又需要使用我们最喜欢的文本编辑器创建Dockerfile文件,像下面演示的一样。
|
||||
|
||||
# nano Dockerfile
|
||||
|
||||
现在,我们需要添加以下的命令行到文件中。
|
||||
|
||||
FROM fedora-httpd
|
||||
ADD mysite.tar /tmp/
|
||||
RUN mv /tmp/mysite/* /var/www/html
|
||||
EXPOSE 80
|
||||
ENTRYPOINT [ "/usr/sbin/httpd" ]
|
||||
CMD [ "-D", "FOREGROUND" ]
|
||||
|
||||
![configuring Dockerfile](http://blog.linoxide.com/wp-content/uploads/2015/03/configuring-Dockerfile.png)
|
||||
|
||||
这里,运行Dockerfile,mysite.tar里的网页内容会自动解压到/temp/文件夹里。然后,整个文件会被转移到Apache网页根目录/var/www/html/,命令expose 80会打开80端口,这样网站就能正常访问。其次,入口点放在了/usr/sbin/https里面,保证Apache服务器能够执行。
|
||||
|
||||
### 5. 建立并运行一个容器 ###
|
||||
|
||||
现在,为了添加我们网站在上面,我们要用刚刚创建的Dockerfile创建我们的容器,为做到这,我们需要运行以下命令。
|
||||
|
||||
# docker build -rm -t mysite .
|
||||
|
||||
![Building mysite Image](http://blog.linoxide.com/wp-content/uploads/2015/03/building-mysite-image.png)
|
||||
|
||||
我们建立自己的容器后,我们想要用下面的命令来运行容器。
|
||||
|
||||
# docker run -d -P mysite
|
||||
|
||||
![Running mysite Container](http://blog.linoxide.com/wp-content/uploads/2015/03/running-mysite-container.png)
|
||||
|
||||
### 总结 ###
|
||||
|
||||
最后,我们已经成功的以交互式的方式建立了一个Docker容器。在本节方法中,我们是直接通过交互的shell命令建立我们的容器和镜像。这种方法十分简单且快速,在建立与配置镜像与容器方面。如果你有任何问题,建议和反馈,请在下方的评论框里写下来,以便我们可以提升或者更新我们的文章。谢谢!祝生活快乐 :-)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/linux-how-to/interactively-create-docker-container/
|
||||
|
||||
作者:[Arun Pyasi][a]
|
||||
译者:[wi-cuckoo](https://github.com/wi-cuckoo)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/arunp/
|
||||
[1]:https://registry.hub.docker.com/
|
250
translated/tech/20150326 How to set up server monitoring system with Monit.md
Executable file
250
translated/tech/20150326 How to set up server monitoring system with Monit.md
Executable file
@ -0,0 +1,250 @@
|
||||
如何使用Monit部署服务器监控系统
|
||||
================================================================================
|
||||
很多Linux系统管理员依赖一个集中式的远程监控系统(比如[Nagios][1]或者[Cacti][2])来检查他们网络基础设备的健康状况。虽然集中式监控让管理员的生活更简单了,然而处理很多机器和服务时,专用的监控中心显然成为了一个单点故障,如果监控中心挂了或者因为什么原因(比如硬件或者网络故障)不可访问了,你就会失去整个网络基础设备情况的任何信息。
|
||||
|
||||
一个给你的监控系统增加冗余度的方法是安装独立的监控软件(作为后备),至少在网络中的关键/核心服务器上。这样在集中式监控系统挂掉的情况,你还有能力通过后备的监控方式来获取核心服务器的运行状况。
|
||||
|
||||
### Monit是什么? ###
|
||||
|
||||
[Monit][3]是一个跨平台的用来监控Unix/linux系统(比如Linux、BSD、OSX、Solaris)的工具。Monit特别易于安装,而且非常轻量级(只有500KB大小),并且不依赖任何第三方程序、插件或者库。然而,Monit可以胜任全面监控、进程状态监控、文件系统变动监控、邮件通知和对核心服务的自定义回调等场景。易于安装、轻量级的实现以及强大的功能,让Monit成为一个理想的后备监控工具。
|
||||
|
||||
我已经在一些机器使用Monit几年了,而且我对它的可靠性非常满意。甚至作为全面的监控系统,对任何Linux系统管理员来说Monit也是非常有用和强大的。在这篇教程中,我会展示如何在一个本地服务器部署Monit(作为后备监控系统)来监控常见的服务。在部署过程中,我只会展示我们用到的部分。
|
||||
|
||||
### 在Linux安装Monit ###
|
||||
|
||||
Monit已经被包含在多数Linux发行版的软件仓库中了。
|
||||
|
||||
Debian、Ubuntu或者Linux Mint:
|
||||
|
||||
$ sudo aptitude install monit
|
||||
|
||||
Fedora或者CentOS/RHEL:
|
||||
|
||||
在CentOS/RHEL中,你必须首先启用[EPEL][4]或者[Repoforge][5]软件仓库.
|
||||
|
||||
# yum install monit
|
||||
|
||||
Monit自带一个文档完善的配置文件,其中包含了很多例子。主配置文件在/etc/monit.conf(Fedora/CentOS/RHEL),或者/etc/monit/monitrc(Debian/Ubuntu/Mint)。Monit配置文件有两部分:“Global”(全局)和“Services”(服务)。
|
||||
|
||||
### Global Configuration: Web Status Page (全局配置:Web状态页面。LCTT 译注:保留原文是因为和配置文件中的字段对应) ###
|
||||
|
||||
Monit可以使用邮件服务来发送通知,也可以使用HTTP/HTTPS页面来展示。我们先使用符合以下要求的web状态页面吧:
|
||||
|
||||
- Monit监听1966端口。
|
||||
- 对web状态页面的访问是通过SSL加密的。
|
||||
- 使用monituser/romania作为用户名/口令登录。
|
||||
- 只允许使用localhost、myhost.mydomain.ro和在局域网内部(192.168.0.0/16)访问。
|
||||
- Monit使用pem格式的SSL证书。
|
||||
|
||||
之后的步骤,我会使用一个基于Red Hat的系统。在基于Debian的系统中的步骤也是类似的。
|
||||
|
||||
首先,在/var/cert生成一个自签名的证书(monit.pem):
|
||||
|
||||
# mkdir /var/certs
|
||||
# cd /etc/pki/tls/certs
|
||||
# ./make-dummy-cert monit.pem
|
||||
# cp monit.pem /var/certs
|
||||
# chmod 0400 /var/certs/monit.pem
|
||||
|
||||
现在将下列代码片段放到Monit的主配置文件中。你可以创建一个空配置文件,或者基于自带的配置文件修改。
|
||||
|
||||
set httpd port 1966 and
|
||||
SSL ENABLE
|
||||
PEMFILE /var/certs/monit.pem
|
||||
allow monituser:romania
|
||||
allow localhost
|
||||
allow 192.168.0.0/16
|
||||
allow myhost.mydomain.ro
|
||||
|
||||
### Global Configuration: Email Notification (全局配置:邮件通知) ###
|
||||
|
||||
然后,我们来设置Monit的邮件通知。我们至少需要一个可用的[SMTP服务器][6]来让Monit发送邮件。这样就可以(按照你的实际情况修改):
|
||||
|
||||
- 邮件服务器的机器名:smtp.monit.ro
|
||||
- Monit使用的发件人:monit@monit.ro
|
||||
- 邮件的收件人:guletz@monit.ro
|
||||
- 邮件服务器使用的SMTP端口:587(默认是25)
|
||||
|
||||
有了以上信息,邮件通知就可以这样配置:
|
||||
|
||||
set mailserver smtp.monit.ro port 587
|
||||
set mail-format {
|
||||
from: monit@monit.ro
|
||||
subject: $SERVICE $EVENT at $DATE on $HOST
|
||||
message: Monit $ACTION $SERVICE $EVENT at $DATE on $HOST : $DESCRIPTION.
|
||||
|
||||
Yours sincerely,
|
||||
Monit
|
||||
|
||||
}
|
||||
|
||||
set alert guletz@monit.ro
|
||||
|
||||
就像你看到的,Monit会提供几个内部变量(`$DATE`、`$EVENT`、`$HOST`等),你可以按照你的需求自定义邮件内容。如果你想要从Monit所在机器发送邮件,就需要一个已经安装的与sendmail兼容的程序(如postfix或者ssmtp)。
|
||||
|
||||
### Global Configuration: Monit Daemon (全局配置:Monit守护进程)###
|
||||
|
||||
接下来就该配置Monit守护进程了。可以将其设置成这样:
|
||||
|
||||
- 在120秒后进行第一次检测。
|
||||
- 每3分钟检测一次服务。
|
||||
- 使用syslog来记录日志。
|
||||
|
||||
如下代码段可以满足上述需求。
|
||||
|
||||
set daemon 120
|
||||
with start delay 240
|
||||
set logfile syslog facility log_daemon
|
||||
|
||||
我们必须定义“idfile”,Monit守护进程的一个独一无二的ID文件;以及“eventqueue”,当monit的邮件因为SMTP或者网络故障发不出去,邮件会暂存在这里;以及确保/var/monit路径是存在的。然后使用下边的配置就可以了。
|
||||
|
||||
set idfile /var/monit/id
|
||||
set eventqueue
|
||||
basedir /var/monit
|
||||
|
||||
### 测试Global Configuration(全局配置) ###
|
||||
|
||||
现在“Global”部分就完成了。Monit配置文件看起来像这样:
|
||||
|
||||
# Global Section
|
||||
|
||||
# status webpage and acl's
|
||||
set httpd port 1966 and
|
||||
SSL ENABLE
|
||||
PEMFILE /var/certs/monit.pem
|
||||
allow monituser:romania
|
||||
allow localhost
|
||||
allow 192.168.0.0/16
|
||||
allow myhost.mydomain.ro
|
||||
|
||||
# mail-server
|
||||
set mailserver smtp.monit.ro port 587
|
||||
# email-format
|
||||
set mail-format {
|
||||
from: monit@monit.ro
|
||||
subject: $SERVICE $EVENT at $DATE on $HOST
|
||||
message: Monit $ACTION $SERVICE $EVENT at $DATE on $HOST : $DESCRIPTION.
|
||||
|
||||
Yours sincerely,
|
||||
Monit
|
||||
|
||||
}
|
||||
|
||||
set alert guletz@monit.ro
|
||||
|
||||
# delay checks
|
||||
set daemon 120
|
||||
with start delay 240
|
||||
set logfile syslog facility log_daemon
|
||||
|
||||
# idfile and mail queue path
|
||||
set idfile /var/monit/id
|
||||
set eventqueue
|
||||
basedir /var/monit
|
||||
|
||||
现在是时候验证我们的工作了,你可以通过运行如下命令来验证存在的配置文件(/etc/monit.conf):
|
||||
|
||||
# monit -t
|
||||
|
||||
Control file syntax OK
|
||||
|
||||
如果monit提示任何错误,请再检查下配置文件。幸运的是,错误/警告信息是可以帮助你发现问题的,比如:
|
||||
|
||||
monit: Cannot stat the SSL server PEM file '/var/certs/monit.pem' -- No such file or directory
|
||||
/etc/monit/monitrc:10: Warning: hostname did not resolve 'smtp.monit.ro'
|
||||
|
||||
一旦你确认配置文件没问题了,可以启动monit守护进程,然后等2到3分钟:
|
||||
|
||||
# service monit start
|
||||
|
||||
如果你使用的是systemd,运行:
|
||||
|
||||
# systemctl start monit
|
||||
|
||||
现在打开一个浏览器窗口,然后访问`https://<monit_host>:1966`。将`<monit_host>`替换成Monit所在机器的机器名或者IP地址。
|
||||
|
||||
如果你使用的是自签名的SSL证书,你会在浏览器中看到一个警告信息。
|
||||
|
||||
![](https://farm8.staticflickr.com/7596/16737206479_96b9f7dfdb_c.jpg)
|
||||
|
||||
你完成登录后,一定要看这个页面。
|
||||
|
||||
![](https://farm8.staticflickr.com/7594/16303369973_6019482dea_c.jpg)
|
||||
|
||||
在这个教程的其余部分,我们演示监控一个本地服务器和常见服务的方法。你会在[官方wiki页面][7]看到很多有用的例子。其中的多数是可以直接复制粘贴的!
|
||||
|
||||
### Service Configuration: CPU/Memory Monitoring (服务配置:CPU、内存监控) ###
|
||||
|
||||
我们先来监控本地服务器的CPU、内存占用。复制如下代码段到配置文件中。
|
||||
|
||||
check system localhost
|
||||
if loadavg (1min) > 10 then alert
|
||||
if loadavg (5min) > 6 then alert
|
||||
if memory usage > 75% then alert
|
||||
if cpu usage (user) > 70% then alert
|
||||
if cpu usage (system) > 60% then alert
|
||||
if cpu usage (wait) > 75% then alert
|
||||
|
||||
你可以很容易理解上边的配置。最上边的check是指每个监控周期(全局配置里设置的120秒)都对本机进行下面的操作。如果满足了任何条件,monit守护进程就会使用邮件发送一条报警。
|
||||
|
||||
如果某个监控项不需要每个周期都检查,可以使用如下格式,它会每240秒检查一次平均负载。
|
||||
|
||||
if loadavg (1min) > 10 for 2 cycles then alert
|
||||
|
||||
### Service Configuration: SSH Service Monitoring (服务配置:SSH服务监控) ###
|
||||
|
||||
先检查我们的sshd是否安装在/usr/sbin/sshd:
|
||||
|
||||
check file sshd_bin with path /usr/sbin/sshd
|
||||
|
||||
我们还想检查sshd的启动脚本是否存在:
|
||||
|
||||
check file sshd_init with path /etc/init.d/sshd
|
||||
|
||||
最后,我们还想检查sshd守护进程是否存活,并且在监听22端口:
|
||||
|
||||
check process sshd with pidfile /var/run/sshd.pid
|
||||
start program "/etc/init.d/sshd start"
|
||||
stop program "/etc/init.d/sshd stop"
|
||||
if failed port 22 protocol ssh then restart
|
||||
if 5 restarts within 5 cycles then timeout
|
||||
|
||||
我们可以这样解释上述配置。我们检查是否存在名为sshd的进程,并且有一个保存pid的文件存在(/var/run/sshd.pid)。如果任何一个不存在,我们就使用启动脚本重启sshd。我们检查是否有进程在监听22端口,并且使用的是SSH协议。如果没有,我们还是重启sshd。如果在最近的5个监控周期(5x120秒)至少重启5次了,sshd就被认为是不能用的,我们就不再检查了。
|
||||
|
||||
![](https://farm9.staticflickr.com/8685/16735725998_62c26a24bc_c.jpg)
|
||||
|
||||
### Service Configuration: SMTP Service Monitoring (服务配置:SMTP服务监控) ###
|
||||
|
||||
现在我们来设置一个检查远程SMTP服务器(如192.168.111.102)的监控。假定SMTP服务器运行着SMTP、IMAP、SSH服务。
|
||||
|
||||
check host MAIL with address 192.168.111.102
|
||||
if failed icmp type echo within 10 cycles then alert
|
||||
if failed port 25 protocol smtp then alert
|
||||
else if recovered then exec "/scripts/mail-script"
|
||||
if failed port 22 protocol ssh then alert
|
||||
if failed port 143 protocol imap then alert
|
||||
|
||||
我们检查远程主机是否响应ICMP协议。如果我们在10个周期内没有收到ICMP回应,就发送一条报警。如果监测到25端口上的SMTP协议是异常的,就发送一条报警。如果在一次监测失败后又监测成功了,就运行一个脚本(/scripts/mail-script)。如果检查22端口上的SSH或者143端口上的IMAP协议不正常,同样发送报警。
|
||||
|
||||
### 总结 ###
|
||||
|
||||
在这个教程,我演示了如何在本地服务器设置Monit,当然这只是Monit功能的冰山一角。你可以花些时间阅读Monit的man手册(写得很好)。Monit可以为任何Linux系统管理员做很多事情,并且具有非常优美和易于理解的语法。如果你将一个集中式的远程监控系统和Monit一同使用,你会得到一个更可靠的监控系统。你感觉Monit怎么样?
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://xmodulo.com/server-monitoring-system-monit.html
|
||||
|
||||
作者:[Iulian Murgulet][a]
|
||||
译者:[goreliu](https://github.com/goreliu)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](http://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://xmodulo.com/author/iulian
|
||||
[1]:http://xmodulo.com/monitor-common-services-nagios.html
|
||||
[2]:http://xmodulo.com/monitor-linux-servers-snmp-cacti.html
|
||||
[3]:http://mmonit.com/monit/
|
||||
[4]:http://xmodulo.com/how-to-set-up-epel-repository-on-centos.html
|
||||
[5]:http://xmodulo.com/how-to-set-up-rpmforge-repoforge-repository-on-centos.html
|
||||
[6]:http://xmodulo.com/mail-server-ubuntu-debian.html
|
||||
[7]:http://mmonit.com/wiki/Monit/ConfigurationExamples
|
@ -0,0 +1,64 @@
|
||||
如何在RHEL/CentOS 7.0中使用tmpfs
|
||||
================================================================================
|
||||
7中的tmpfs,这是一个将所有文件和文件夹写到虚拟内存中而不是实际写到磁盘中的虚拟文件系统。这意味中tmpfs中所有的内容都是临时的,在取消挂载、系统重启或者电源切断后内容都将会丢失。技术的角度上来说,tmpfs将搜有的内容放在内核内部缓存中并且会增大或者缩小来容纳文件并可从交换空间中交换处不需要的页。
|
||||
|
||||
CentOS默认使用tmpfs做的事可用df -h命令的输出来看:
|
||||
|
||||
# df –h
|
||||
|
||||
![df](http://blog.linoxide.com/wp-content/uploads/2015/05/tmpfs1.jpg)
|
||||
|
||||
/dev - 含有针对所有设备的设备文件的目录
|
||||
/dev/shm – 包含共享内存分配
|
||||
/run - 用于系统日志
|
||||
/sys/fs/cgroup - 用于cgrpups, 一个针对特定进程限制、管制和审计资源利用的内核特性
|
||||
|
||||
/tmp目录, 你可以用下面的两种方法来做到:
|
||||
|
||||
### 使用systemctl来在/tmp中启用tmpfs ###
|
||||
|
||||
你可以使用systemctl命令在tmp目录启用tmpfs, 首先用下面的命令来检查这个特性是否可用:
|
||||
|
||||
# systemctl is-enabled tmp.mount
|
||||
|
||||
这会显示当先的状态,你可以使用下面的命令来启用它:
|
||||
|
||||
# systemctl enable tmp.mount
|
||||
|
||||
![systemctl](http://blog.linoxide.com/wp-content/uploads/2015/05/tmpfs3.jpg)
|
||||
|
||||
这会控制/tmp目录并挂载tmpfs。
|
||||
|
||||
### 手动挂载/tmp/文件系统 ###
|
||||
|
||||
你可以在/etc/fstab中添加下面这行在/tmp挂载tmpfs。
|
||||
|
||||
tmpfs /tmp tmpfs size=512m 0 0
|
||||
|
||||
接着运行这条命令
|
||||
|
||||
# mount –a
|
||||
|
||||
![df](http://blog.linoxide.com/wp-content/uploads/2015/05/tmpfs2.jpg)
|
||||
|
||||
这应该就会在df -h中显示tmpfs了,同样也会在你下次重启是会自动挂载。
|
||||
|
||||
### 立即创建tmpfs ###
|
||||
|
||||
如果由于一些原因,你写昂立即创建tmpfs,你可以使用下面的命令:
|
||||
|
||||
# mount -t tmpfs -o size=1G tmpfs /mnt/mytmpfs
|
||||
|
||||
当然你可以在size选项中指定你希望的大小和希望的挂载点,只要记住是有效的目录就行了。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://linoxide.com/file-system/use-tmpfs-rhel-centos-7-0/
|
||||
|
||||
作者:[Adrian Dinu][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://linoxide.com/author/adriand/
|
@ -0,0 +1,167 @@
|
||||
如何在Ubuntu/Debian/Linux Mint中编译和安装wxWidgets
|
||||
================================================================================
|
||||
### wxWidgets ###
|
||||
|
||||
wxWidgets是一个程序开发框架/库, 允许你在Windows、Mac、Linux中使用相同的代码跨平台开发。
|
||||
|
||||
它主要用C++写成,但也可以与其他语言绑定比如Python、Perl、Ruby。
|
||||
|
||||
本教程中我将向你展示如何在基于Debian的linux中如Ubuntu和Linux Mint中编译wxwidgets 3.0+。
|
||||
|
||||
从源码编译wxWidgets并不困难,仅仅需要几分钟。
|
||||
|
||||
库可以按不同的方式来编译,比如静态或者动态库。
|
||||
|
||||
### 1. 下载 wxWidgets ###
|
||||
|
||||
第一步你需要从[wxwidgets.org][1]下载wxWidgets源码文件。
|
||||
|
||||
做完后,解压到目录。
|
||||
|
||||
### 2. 设置编译环境 ###
|
||||
|
||||
要编译wxwidgets,我们需要一些工具包括C++编译器, 在Linux上是g++。所有这些可以通过apt-get工具从仓库中安装。
|
||||
|
||||
我们还需要wxWidgets依赖的GTK开发库。
|
||||
|
||||
$ sudo apt-get install libgtk-3-dev build-essential checkinstall
|
||||
|
||||
>checkinstall工具允许我们为wxwidgets创建一个安装包,这样之后就可以轻松的使用包管理器来卸载。
|
||||
|
||||
### 3. 编译 wxWidgets ###
|
||||
|
||||
进入到wxWidgets解压后的目录。为了保持清洁,创建一个编译用的目录。
|
||||
|
||||
$ mkdir gtk-build
|
||||
$ cd gtk-build/
|
||||
|
||||
现在运行configure和make命令。每个将花费一些时间来完成。
|
||||
|
||||
$ ../configure --disable-shared --enable-unicode
|
||||
$ make
|
||||
|
||||
"--disable-shared"选项将会编译静态库而不是动态库。
|
||||
|
||||
make命令完成后,编译也成功了。是时候安装wxWidgets到正确的目录。
|
||||
|
||||
更多信息请参考install.txt和readme.txt,这可在wxwidgets中的/docs/gtk/目录下找到。
|
||||
|
||||
### 4. 安装 checkinstall ###
|
||||
|
||||
现在我们不使用"make install"命令,我们使用checkinstall命令来创建一个wxwidgets的deb安装包。运行命令:
|
||||
|
||||
$ sudo checkinstall
|
||||
|
||||
checkinstall会询问几个问题,请保证在提问后提供一个版本号,否则将会失败。
|
||||
|
||||
完成这一切后,wxWidgets就安装好了,deb文件也会创建在相同的目录下。
|
||||
|
||||
### 5. 追踪安装的文件 ###
|
||||
|
||||
如果你想要检查文件安装的位置,使用dpkg命令后面跟上checkinstall提供的报名。
|
||||
|
||||
$ dpkg -L package_name
|
||||
/.
|
||||
/usr
|
||||
/usr/local
|
||||
/usr/local/lib
|
||||
/usr/local/lib/libwx_baseu-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_propgrid-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_html-3.0.a
|
||||
/usr/local/lib/libwxscintilla-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_ribbon-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_stc-3.0.a
|
||||
/usr/local/lib/libwx_gtk3u_qa-3.0.a
|
||||
/usr/local/lib/libwx_baseu_net-3.0.a
|
||||
/usr/local/lib/libwxtiff-3.0.a
|
||||
|
||||
### 6. 编译示例 ###
|
||||
|
||||
编译wxWidgets完成后就可以马上编译示例程序了。在相同的目录下,一个新的sample目录已经创建了。
|
||||
|
||||
进入它并运行下面的命令
|
||||
|
||||
$ compile samples
|
||||
$ cd samples/
|
||||
$ make
|
||||
|
||||
make命令完成后,进入sampl子目录,这里就有一个可以马上运行的Demo程序了。
|
||||
|
||||
### 7. 编译你的第一个程序 ###
|
||||
|
||||
你完成编译demo程序后,可以写你自己的程序来编译了。这个也很简单。
|
||||
|
||||
假设你用的是C++这样你可以使用编辑器的高亮特性。比如gedit、kate、kwrite等等。或者用全功能的IDE像Geany、Codelite、Codeblocks等等。
|
||||
|
||||
然而你的第一个程序只需要用一个文本编辑器来快速完成。
|
||||
|
||||
这里就是
|
||||
|
||||
#include <wx/wx.h>
|
||||
|
||||
class Simple : public wxFrame
|
||||
{
|
||||
public:
|
||||
Simple(const wxString& title)
|
||||
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(250, 150))
|
||||
{
|
||||
Centre();
|
||||
}
|
||||
};
|
||||
|
||||
class MyApp : public wxApp
|
||||
{
|
||||
public:
|
||||
bool OnInit()
|
||||
{
|
||||
Simple *simple = new Simple(wxT("Simple"));
|
||||
simple->Show(true);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
wxIMPLEMENT_APP(MyApp);
|
||||
|
||||
现在保存并用下面的命令编译。
|
||||
|
||||
# compile
|
||||
$ g++ basic.cpp `wx-config --cxxflags --libs std` -o program
|
||||
|
||||
# run
|
||||
$ ./program
|
||||
|
||||
#### 和非标准的库一起编译 ####
|
||||
|
||||
面展示的wx-config命令默认只支持标准的库。如果你使用的是Aui库,那么你需要指定额外用到的库。
|
||||
|
||||
$ g++ code.cpp `wx-config --cxxflags --libs std,aui` -o program
|
||||
|
||||
更多的信息参考这里[这里][2]。
|
||||
|
||||
### 资源 ###
|
||||
|
||||
下载wxWidgets的源码和帮助
|
||||
[https://www.wxwidgets.org/downloads/][3]
|
||||
|
||||
wxWidgets编译的wiki页面
|
||||
[https://wiki.wxwidgets.org/Compiling_and_getting_started][4]
|
||||
|
||||
使用wxWidgets最新版本(3.0+)的事项
|
||||
[https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets][5]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://www.binarytides.com/install-wxwidgets-ubuntu/
|
||||
|
||||
作者:[Silver Moon][a]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:https://plus.google.com/117145272367995638274/posts
|
||||
[1]:https://www.wxwidgets.org/downloads/
|
||||
[2]:https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets#The_wx-config_script
|
||||
[3]:https://www.wxwidgets.org/downloads/
|
||||
[4]:https://wiki.wxwidgets.org/Compiling_and_getting_started
|
||||
[5]:https://wiki.wxwidgets.org/Updating_to_the_Latest_Version_of_wxWidgets
|
@ -0,0 +1,71 @@
|
||||
Linux 有问必答--如何在桌面版 Ubuntu 中用命令行更改系统代理设置
|
||||
================================================================================
|
||||
> **问题**: 我经常需要在桌面版 Ubuntu 中更改系统代理设置,但我不想通过繁琐的 GUI 菜单链:"系统设置" -> "网络" -> "网络代理"。在命令行中有更方便的方法更改桌面版的代理设置吗?
|
||||
|
||||
在桌面版 Ubuntu 中,它的桌面环境设置,包括系统代理设置,都存储在 DConf 数据库,这是简单的键值对存储。如果你想通过系统设置菜单修改桌面属性,更改会持久保存在后端的 DConf 数据库。在 Ubuntu 中更改 DConf 数据库有基于图像用户界面和非图形用户界面的两种方式。系统设置或者 dconf-editor 是访问 DConf 数据库的图形方法,而 gsettings 或 dconf 就是能更改数据库的命令行工具。
|
||||
|
||||
下面介绍如何用 gsettings 从命令行更改系统代理设置。
|
||||
|
||||
![](https://farm6.staticflickr.com/5460/17872782271_68e5267a4a_c.jpg)
|
||||
|
||||
gsetting 读写特定 Dconf 设置的基本用法如下:
|
||||
|
||||
更改 DConf 设置:
|
||||
|
||||
$ gsettings set <schema> <key> <value>
|
||||
|
||||
读取 DConf 设置:
|
||||
|
||||
$ gsettings get <schema> <key>
|
||||
|
||||
### 通过命令行更改系统代理设置为手动 ###
|
||||
|
||||
桌面版 Ubuntu 中下面的命令会更改 HTTP 代理设置为 "my.proxy.com:8000"。
|
||||
|
||||
$ gsettings set org.gnome.system.proxy.http host 'my.proxy.com'
|
||||
$ gsettings set org.gnome.system.proxy.http port 8000
|
||||
$ gsettings set org.gnome.system.proxy mode 'manual'
|
||||
|
||||
如果你还想更改 HTTPS/FTP 代理为手动,用这些命令:
|
||||
|
||||
$ gsettings set org.gnome.system.proxy.https host 'my.proxy.com'
|
||||
$ gsettings set org.gnome.system.proxy.https port 8000
|
||||
$ gsettings set org.gnome.system.proxy.ftp host 'my.proxy.com'
|
||||
$ gsettings set org.gnome.system.proxy.ftp port 8000
|
||||
|
||||
更改套接字主机设置为手动:
|
||||
|
||||
$ gsettings set org.gnome.system.proxy.socks host 'my.proxy.com'
|
||||
$ gsettings set org.gnome.system.proxy.socks port 8000
|
||||
|
||||
上面的更改都只适用于当前的桌面用户。如果你想在系统范围内使用代理设置更改,在 gsettings 命令面前添加 sudo。例如:
|
||||
|
||||
$ sudo gsettings set org.gnome.system.proxy.http host 'my.proxy.com'
|
||||
$ sudo gsettings set org.gnome.system.proxy.http port 8000
|
||||
$ sudo gsettings set org.gnome.system.proxy mode 'manual'
|
||||
|
||||
### 在命令行中更改系统代理设置为自动 ###
|
||||
|
||||
如果你正在使用 [自动配置代理][1] (proxy auto configuration,PAC),输入以下命令更改为 PAC。
|
||||
|
||||
$ gsettings set org.gnome.system.proxy mode 'auto'
|
||||
$ gsettings set org.gnome.system.proxy autoconfig-url http://my.proxy.com/autoproxy.pac
|
||||
|
||||
### 在命令行中清除系统代理设置 ###
|
||||
|
||||
最后,清除所有 手动/自动 代理设置,还原为无代理设置:
|
||||
|
||||
$ gsettings set org.gnome.system.proxy mode 'none'
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/change-system-proxy-settings-command-line-ubuntu-desktop.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:http://xmodulo.com/how-to-set-up-proxy-auto-config-on-ubuntu-desktop.html
|
@ -0,0 +1,42 @@
|
||||
Linux 有问必答--如何在桌面版 Ubuntu 中安装 Unity Tweak Tool
|
||||
================================================================================
|
||||
> **问题**: 我试着给刚安装的桌面版 Ubuntu 自定制桌面。我想使用 Unity Tweak Tool。我怎样才能在 Ubuntu 上安装 Unity Tweak Tool 呢?
|
||||
|
||||
[Unity Tweak Tool][1] 是个流行的 Unity 桌面自定制工具。顾名思义,该工具只适用于 Ubuntu 的默认桌面环境(例如,基于 Unity 的 GNOME 桌面)。这个多功能的工具允许你通过非常直观和简单易用的图形用户界面自定义多种 Unity 桌面特性。它的菜单看起来类似于 Ubuntu 的官方系统设置,但它的桌面自定制能力远远超过默认的系统设置。通过使用 Unity Tweak Tool,你可以自定制外观、行为以及很多桌面组件的配置,例如工作区、窗口、图标、主题、光标、字体、滑动、热键等等。如果你是 Unity 桌面用户,Unity Tweak Tool 一定是个必不可少的应用程序。
|
||||
|
||||
![](https://farm6.staticflickr.com/5463/17684020389_25dc7f0db2_b.jpg)
|
||||
|
||||
尽管 Unity Tweak Tool 是桌面版 Ubuntu 的重要工具,并没有在桌面版 Ubuntu 中预安装。为了能自定制 Unity 桌面,下面介绍一下如何在桌面版 Ubuntu 中安装 Unity Tweak Tool。
|
||||
|
||||
### 在 Ubuntu 13.04 或更高版本中安装 Unity Tweak Tool ###
|
||||
|
||||
从 Ubuntu 13.04 开始, Ubuntu 的基础库中就有 Unity Tweak Tool 了。因此它的安装非常简单:
|
||||
|
||||
$ sudo apt-get install unity-tweak-tool
|
||||
|
||||
启动 Unity Tweak Tool:
|
||||
|
||||
$ unity-tweak-tool
|
||||
|
||||
如果你想使用最新版本的 Unity Tweak Tool,你可以从它的 PPA 中安装(如下所述)。
|
||||
|
||||
### 在 Ubuntu 12.10 中安装 Unity Tweak Tool ###
|
||||
|
||||
注意,Unity Tweak Tool 要求 Ubuntu 12.10 或更高的版本。如果你想着 Ubuntu 上安装它,你可以安装下面方法使用 PPA。当你想测试最新的开发版的时候这个 PPA 库也非常有用。
|
||||
|
||||
$ sudo add-apt-repository ppa:freyja-dev/unity-tweak-tool-daily
|
||||
$ sudo apt-get update
|
||||
$ sudo apt-get install unity-tweak-tool
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: http://ask.xmodulo.com/install-unity-tweak-tool-ubuntu-desktop.html
|
||||
|
||||
作者:[Dan Nanni][a]
|
||||
译者:[ictlyh](https://github.com/ictlyh)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]:http://ask.xmodulo.com/author/nanni
|
||||
[1]:https://launchpad.net/unity-tweak-tool
|
Loading…
Reference in New Issue
Block a user