@@ -752,40 +752,133 @@ Linux系统的命令通常都是如下所示的格式:
752752
753753### 软件安装和配置 
754754
755- #### yum 
755+ #### 使用包管理工具 
756+ 
757+ 1. yum - Yellowdog Updater Modified。 
758+    - `yum search`:搜索软件包,例如`yum search nginx`。 
759+    - `yum list installed`:列出已经安装的软件包,例如`yum list installed | grep zlib`。 
760+    - `yum install`:安装软件包,例如`yum install nginx`。 
761+    - `yum remove`:删除软件包,例如`yum remove nginx`。 
762+    - `yum update`:更新软件包,例如`yum update`可以更新所有软件包,而`yum update tar只会更新tar。 
763+    - `yum check-update`:检查有哪些可以更新的软件包。 
764+    - `yum info`:显示软件包的相关信息,例如`yum info nginx`。 
765+ 2. rpm - Redhat Package Manager。 
766+    - 安装软件包:`rpm -ivh <packagename>.rpm`。 
767+    - 移除软件包:`rpm -e <packagename>`。 
768+    - 查询软件包:`rpm -qa`,例如可以用`rpm -qa | grep mysql`来检查是否安装了MySQL相关的软件包。 
769+ 
770+ 下面以Nginx为例,演示如何使用yum安装软件。 
756771
757- - yum update 
758- - yum install 
759- - yum remove 
760- - yum list 
761- - yum search 
772+ ```Shell 
762773
763- #### rpm 
774+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# yum -y install nginx 
775+ ... 
776+ Installed: 
777+   nginx.x86_64 1:1.12.2-2.el7 
778+ Dependency Installed: 
779+   nginx-all-modules.noarch 1:1.12.2-2.el7 
780+   nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7 
781+   nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7 
782+   nginx-mod-http-perl.x86_64 1:1.12.2-2.el7 
783+   nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7 
784+   nginx-mod-mail.x86_64 1:1.12.2-2.el7 
785+   nginx-mod-stream.x86_64 1:1.12.2-2.el7 
786+ Complete! 
787+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# nginx -v 
788+ nginx version: nginx/1.12.2 
789+ ``` 
764790
765- - rpm -ivh \-\-force \-\-nodeps 
766- - rpm -e  
767- - rpm -qa | grep 
791+ #### 下载解压配置环境变量 
768792
769- #### 二进制安装程序(JDK) 
793+ 下面以安装MongoDB为例,演示这类软件应该如何安装。 
770794
771- - \<filename\>.bin 
795+ ```Shell 
772796
773- #### 配置环境变量(MongoDB) 
797+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz 
798+ --2018-06-21 18:32:53--  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz 
799+ Resolving fastdl.mongodb.org (fastdl.mongodb.org)... 52.85.83.16, 52.85.83.228, 52.85.83.186, ... 
800+ Connecting to fastdl.mongodb.org (fastdl.mongodb.org)|52.85.83.16|:443... connected. 
801+ HTTP request sent, awaiting response... 200 OK 
802+ Length: 100564462 (96M) [application/x-gzip] 
803+ Saving to: ‘mongodb-linux-x86_64-rhel70-3.6.5.tgz’ 
804+ 100%[==================================================>] 100,564,462  630KB/s   in 2m 9s 
805+ 2018-06-21 18:35:04 (760 KB/s) - ‘mongodb-linux-x86_64-rhel70-3.6.5.tgz’ saved [100564462/100564462] 
806+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip mongodb-linux-x86_64-rhel70-3.6.5.tgz 
807+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# tar -xvf mongodb-linux-x86_64-rhel70-3.6.5.tar 
808+ mongodb-linux-x86_64-rhel70-3.6.5/README 
809+ mongodb-linux-x86_64-rhel70-3.6.5/THIRD-PARTY-NOTICES 
810+ mongodb-linux-x86_64-rhel70-3.6.5/MPL-2 
811+ mongodb-linux-x86_64-rhel70-3.6.5/GNU-AGPL-3.0 
812+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongodump 
813+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongorestore 
814+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoexport 
815+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoimport 
816+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongostat 
817+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongotop 
818+ mongodb-linux-x86_64-rhel70-3.6.5/bin/bsondump 
819+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongofiles 
820+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoreplay 
821+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoperf 
822+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongod 
823+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongos 
824+ mongodb-linux-x86_64-rhel70-3.6.5/bin/mongo 
825+ mongodb-linux-x86_64-rhel70-3.6.5/bin/install_compass 
826+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# vim .bash_profile 
827+ ... 
828+ PATH=$PATH:$HOME/bin:$HOME/mongodb-linux-x86_64-rhel70-3.6.5/bin 
829+ export PATH 
830+ ... 
831+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# source .bash_profile 
832+ [root@iZwz97tbgo9lkabnat2lo8Z ~]# mongod --version 
833+ db version v3.6.5 
834+ git version: a20ecd3e3a174162052ff99913bc2ca9a839d618 
835+ OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 
836+ allocator: tcmalloc 
837+ modules: none 
838+ build environment: 
839+     distmod: rhel70 
840+     distarch: x86_64 
841+     target_arch: x86_64 
842+ ``` 
774843
775- - 下载软件 
776- - 解压缩 / 解归档 
777- - 配置环境变量 / 注册软链接 
844+ > 说明:当然也可以通过yum来安装MongoDB,具体可以参照[官方网站](https://docs.mongodb.com/master/administration/install-on-linux/)上给出的说明。 
778845
779- #### 源代码构建安装(Python 3.6.5 / Redis)  
846+ #### 源代码构建安装 
780847
781- - Makefile 
782- - make && make install 
848+ 1. 安装Python 3.6。 
783849
784- #### 实例 
850+    ```Shell 
851+     
852+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# yum install gcc 
853+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz 
854+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip Python-3.6.5.tgz 
855+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ar -xvf Python-3.6.5.tar 
856+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cd Python-3.6.5 
857+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ./configure --prefix=/usr/local/python36 --enable-optimizations 
858+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel 
859+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# make && make install 
860+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /usr/local/python36/bin/python3.6 /usr/bin/python3 
861+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /usr/local/python36/bin/pip3 /usr/bin/pip3 
862+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /usr/local/python36/bin/2to3-3.6 /usr/bin/2to3 
863+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# python3 --version 
864+    Python 3.6.5 
865+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# python3 -m pip install -U pip 
866+    ``` 
867+ 
868+ 2. 安装Redis-3.2.12。 
785869
786- 1. 安装MySQL。 
787- 2. 安装Redis。 
788- 3. 安装NginX。 
870+    ```Shell 
871+     
872+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# wget http://download.redis.io/releases/redis-3.2.12.tar.gz 
873+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip redis-3.2.12.tar.gz 
874+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# tar -xvf redis-3.2.12.tar 
875+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# cd redis-3.2.12 
876+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# make && make install 
877+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# redis-server --version 
878+    Redis server v=3.2.12 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=5bc5cd3c03d6ceb6 
879+    [root@iZwz97tbgo9lkabnat2lo8Z ~]# redis-cli --version 
880+    redis-cli 3.2.12 
881+    ``` 
789882
790883### 进程和性能 
791884
0 commit comments