From 43ada36603e35e1ffe45624cb70ab250bd471925 Mon Sep 17 00:00:00 2001 From: jackfrued Date: Thu, 21 Jun 2018 20:10:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BA=86Linux=E6=96=87?= =?UTF-8?q?=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...15\344\275\234\347\263\273\347\273\237.md" | 139 +++++++++++++++--- 1 file changed, 116 insertions(+), 23 deletions(-) diff --git "a/Day31-35/\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" "b/Day31-35/\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" index 1f674fa..faa71d8 100644 --- "a/Day31-35/\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" +++ "b/Day31-35/\347\216\251\350\275\254Linux\346\223\215\344\275\234\347\263\273\347\273\237.md" @@ -752,40 +752,133 @@ Linux系统的命令通常都是如下所示的格式: ### 软件安装和配置 -#### yum +#### 使用包管理工具 + +1. yum - Yellowdog Updater Modified。 + - `yum search`:搜索软件包,例如`yum search nginx`。 + - `yum list installed`:列出已经安装的软件包,例如`yum list installed | grep zlib`。 + - `yum install`:安装软件包,例如`yum install nginx`。 + - `yum remove`:删除软件包,例如`yum remove nginx`。 + - `yum update`:更新软件包,例如`yum update`可以更新所有软件包,而`yum update tar只会更新tar。 + - `yum check-update`:检查有哪些可以更新的软件包。 + - `yum info`:显示软件包的相关信息,例如`yum info nginx`。 +2. rpm - Redhat Package Manager。 + - 安装软件包:`rpm -ivh .rpm`。 + - 移除软件包:`rpm -e `。 + - 查询软件包:`rpm -qa`,例如可以用`rpm -qa | grep mysql`来检查是否安装了MySQL相关的软件包。 + +下面以Nginx为例,演示如何使用yum安装软件。 -- yum update -- yum install -- yum remove -- yum list -- yum search +```Shell -#### rpm +[root@iZwz97tbgo9lkabnat2lo8Z ~]# yum -y install nginx +... +Installed: + nginx.x86_64 1:1.12.2-2.el7 +Dependency Installed: + nginx-all-modules.noarch 1:1.12.2-2.el7 + nginx-mod-http-geoip.x86_64 1:1.12.2-2.el7 + nginx-mod-http-image-filter.x86_64 1:1.12.2-2.el7 + nginx-mod-http-perl.x86_64 1:1.12.2-2.el7 + nginx-mod-http-xslt-filter.x86_64 1:1.12.2-2.el7 + nginx-mod-mail.x86_64 1:1.12.2-2.el7 + nginx-mod-stream.x86_64 1:1.12.2-2.el7 +Complete! +[root@iZwz97tbgo9lkabnat2lo8Z ~]# nginx -v +nginx version: nginx/1.12.2 +``` -- rpm -ivh \-\-force \-\-nodeps -- rpm -e -- rpm -qa | grep +#### 下载解压配置环境变量 -#### 二进制安装程序(JDK) +下面以安装MongoDB为例,演示这类软件应该如何安装。 -- \.bin +```Shell -#### 配置环境变量(MongoDB) +[root@iZwz97tbgo9lkabnat2lo8Z ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz +--2018-06-21 18:32:53-- https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.5.tgz +Resolving fastdl.mongodb.org (fastdl.mongodb.org)... 52.85.83.16, 52.85.83.228, 52.85.83.186, ... +Connecting to fastdl.mongodb.org (fastdl.mongodb.org)|52.85.83.16|:443... connected. +HTTP request sent, awaiting response... 200 OK +Length: 100564462 (96M) [application/x-gzip] +Saving to: ‘mongodb-linux-x86_64-rhel70-3.6.5.tgz’ +100%[==================================================>] 100,564,462 630KB/s in 2m 9s +2018-06-21 18:35:04 (760 KB/s) - ‘mongodb-linux-x86_64-rhel70-3.6.5.tgz’ saved [100564462/100564462] +[root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip mongodb-linux-x86_64-rhel70-3.6.5.tgz +[root@iZwz97tbgo9lkabnat2lo8Z ~]# tar -xvf mongodb-linux-x86_64-rhel70-3.6.5.tar +mongodb-linux-x86_64-rhel70-3.6.5/README +mongodb-linux-x86_64-rhel70-3.6.5/THIRD-PARTY-NOTICES +mongodb-linux-x86_64-rhel70-3.6.5/MPL-2 +mongodb-linux-x86_64-rhel70-3.6.5/GNU-AGPL-3.0 +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongodump +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongorestore +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoexport +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoimport +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongostat +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongotop +mongodb-linux-x86_64-rhel70-3.6.5/bin/bsondump +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongofiles +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoreplay +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongoperf +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongod +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongos +mongodb-linux-x86_64-rhel70-3.6.5/bin/mongo +mongodb-linux-x86_64-rhel70-3.6.5/bin/install_compass +[root@iZwz97tbgo9lkabnat2lo8Z ~]# vim .bash_profile +... +PATH=$PATH:$HOME/bin:$HOME/mongodb-linux-x86_64-rhel70-3.6.5/bin +export PATH +... +[root@iZwz97tbgo9lkabnat2lo8Z ~]# source .bash_profile +[root@iZwz97tbgo9lkabnat2lo8Z ~]# mongod --version +db version v3.6.5 +git version: a20ecd3e3a174162052ff99913bc2ca9a839d618 +OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 +allocator: tcmalloc +modules: none +build environment: + distmod: rhel70 + distarch: x86_64 + target_arch: x86_64 +``` -- 下载软件 -- 解压缩 / 解归档 -- 配置环境变量 / 注册软链接 +> 说明:当然也可以通过yum来安装MongoDB,具体可以参照[官方网站](https://docs.mongodb.com/master/administration/install-on-linux/)上给出的说明。 -#### 源代码构建安装(Python 3.6.5 / Redis) +#### 源代码构建安装 -- Makefile -- make && make install +1. 安装Python 3.6。 -#### 实例 + ```Shell + + [root@iZwz97tbgo9lkabnat2lo8Z ~]# yum install gcc + [root@iZwz97tbgo9lkabnat2lo8Z ~]# wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz + [root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip Python-3.6.5.tgz + [root@iZwz97tbgo9lkabnat2lo8Z ~]# ar -xvf Python-3.6.5.tar + [root@iZwz97tbgo9lkabnat2lo8Z ~]# cd Python-3.6.5 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# ./configure --prefix=/usr/local/python36 --enable-optimizations + [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 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# make && make install + [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /usr/local/python36/bin/python3.6 /usr/bin/python3 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /usr/local/python36/bin/pip3 /usr/bin/pip3 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# ln -s /usr/local/python36/bin/2to3-3.6 /usr/bin/2to3 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# python3 --version + Python 3.6.5 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# python3 -m pip install -U pip + ``` + +2. 安装Redis-3.2.12。 -1. 安装MySQL。 -2. 安装Redis。 -3. 安装NginX。 + ```Shell + + [root@iZwz97tbgo9lkabnat2lo8Z ~]# wget http://download.redis.io/releases/redis-3.2.12.tar.gz + [root@iZwz97tbgo9lkabnat2lo8Z ~]# gunzip redis-3.2.12.tar.gz + [root@iZwz97tbgo9lkabnat2lo8Z ~]# tar -xvf redis-3.2.12.tar + [root@iZwz97tbgo9lkabnat2lo8Z ~]# cd redis-3.2.12 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# make && make install + [root@iZwz97tbgo9lkabnat2lo8Z ~]# redis-server --version + Redis server v=3.2.12 sha=00000000:0 malloc=jemalloc-4.0.3 bits=64 build=5bc5cd3c03d6ceb6 + [root@iZwz97tbgo9lkabnat2lo8Z ~]# redis-cli --version + redis-cli 3.2.12 + ``` ### 进程和性能 -- GitLab