0%

导出
sqlite3 db.sqlite3 .dump > link.sql

执行语句
mysql -h192.168.1.60 -P3306 -uroot -proot -e "SELECT * FROM user \G"

改密码
mysqladmin -uroot -p123456 password 123 

建数据库
CREATE DATABASE `mydb` CHARACTER SET utf8 COLLATE utf8_general_ci;

\G 垂直显示
SELECT report_id FROM `weekly_report_content` WHERE report_id IN (381395,381437,380576,381359,381472)\G

#备份
#备份某个库(cmdb)某些表(cmdb_cluster_hosts,多个空格隔开)的数据
mysqldump -h192.168.3.97 -t cmdb -u root -proot --tables cmdb_cluster_hosts > /root/cmdb_cluster_hosts.sql
-P是端口

#导入
mysql -uroot -p test < test.sql

#格式化时间
FROM_UNIXTIME(v.visit_time, '%Y-%m-%d') AS visit_time
select request_data, FROM_UNIXTIME(create_time, '%Y-%m-%d %H:%i:%s') AS c_time from mytable order by id desc limit 10;

查总数是COUNT,但总和是 SUM !!! 

xhs@xhs:~$ sudo composer create-project symfony/website-skeleton symfony_web
[sudo] password for xhs: 
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Installing symfony/website-skeleton (v4.1.6.3)
  - Installing symfony/website-skeleton (v4.1.6.3): Downloading (100%)         
Created project in symfony_web
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/framework-bundle v4.1.6 -> satisfiable by symfony/framework-bundle[v4.1.6].
    - symfony/framework-bundle v4.1.6 requires ext-xml * -> the requested PHP extension xml is missing from your system.
  Problem 2
    - Installation request for symfony/security-bundle v4.1.6 -> satisfiable by symfony/security-bundle[v4.1.6].
    - symfony/security-bundle v4.1.6 requires ext-xml * -> the requested PHP extension xml is missing from your system.
  Problem 3
    - Installation request for facebook/webdriver 1.6.0 -> satisfiable by facebook/webdriver[1.6.0].
    - facebook/webdriver 1.6.0 requires ext-zip * -> the requested PHP extension zip is missing from your system.
  Problem 4
    - Installation request for symfony/debug-bundle v4.1.6 -> satisfiable by symfony/debug-bundle[v4.1.6].
    - symfony/debug-bundle v4.1.6 requires ext-xml * -> the requested PHP extension xml is missing from your system.
  Problem 5
    - symfony/framework-bundle v4.1.6 requires ext-xml * -> the requested PHP extension xml is missing from your system.
    - symfony/maker-bundle v1.8.0 requires symfony/framework-bundle ^3.4|^4.0 -> satisfiable by symfony/framework-bundle[v4.1.6].
    - Installation request for symfony/maker-bundle v1.8.0 -> satisfiable by symfony/maker-bundle[v1.8.0].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php/7.3/cli/php.ini
    - /etc/php/7.3/cli/conf.d/10-mysqlnd.ini
    - /etc/php/7.3/cli/conf.d/10-opcache.ini
    - /etc/php/7.3/cli/conf.d/10-pdo.ini
    - /etc/php/7.3/cli/conf.d/20-calendar.ini
    - /etc/php/7.3/cli/conf.d/20-ctype.ini
    - /etc/php/7.3/cli/conf.d/20-curl.ini
    - /etc/php/7.3/cli/conf.d/20-exif.ini
    - /etc/php/7.3/cli/conf.d/20-fileinfo.ini
    - /etc/php/7.3/cli/conf.d/20-ftp.ini
    - /etc/php/7.3/cli/conf.d/20-gettext.ini
    - /etc/php/7.3/cli/conf.d/20-iconv.ini
    - /etc/php/7.3/cli/conf.d/20-json.ini
    - /etc/php/7.3/cli/conf.d/20-mbstring.ini
    - /etc/php/7.3/cli/conf.d/20-mysqli.ini
    - /etc/php/7.3/cli/conf.d/20-pdo_mysql.ini
    - /etc/php/7.3/cli/conf.d/20-phar.ini
    - /etc/php/7.3/cli/conf.d/20-posix.ini
    - /etc/php/7.3/cli/conf.d/20-readline.ini
    - /etc/php/7.3/cli/conf.d/20-shmop.ini
    - /etc/php/7.3/cli/conf.d/20-sockets.ini
    - /etc/php/7.3/cli/conf.d/20-sysvmsg.ini
    - /etc/php/7.3/cli/conf.d/20-sysvsem.ini
    - /etc/php/7.3/cli/conf.d/20-sysvshm.ini
    - /etc/php/7.3/cli/conf.d/20-tokenizer.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
xhs@xhs:~$ 
想安装 zip扩展
sudo apt install php7.3-zip
报
The following packages have unmet dependencies:
 php7.3-zip : Depends: libzip4 (>= 1.0) but it is not installable
E: Unable to correct problems, you have held broken packages.
那就先安装libzip4
sudo apt install libzip4
但sourcelist里没有
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package libzip4 is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'libzip4' has no installation candidate
没找到哪个源可以安装,就直接下载deb包安装了
http://security.ubuntu.com/ubuntu/pool/universe/libz/libzip/libzip4_1.1.2-1.1_amd64.deb
安装libzip4后就安装php7.3-zip
接着安装 php7.3-xml
sudo apt install php7.3-xml
ok
继续安装 symfony
xhs@xhs:~$ sudo composer create-project symfony/website-skeleton /var/www/html/symfony_web
最后有一段,暂时不知道是什么意思
Executing script cache:clear [KO]
 [KO]
Script cache:clear returned with error code 1
!!  
!!  In UnitOfWork.php line 2718:
!!                                                                                 
!!    Warning: "continue" targeting switch is equivalent to "break". Did you mean  
!!     to use "continue 2"?                                                        
!!                                                                                 
!!  
!!  
Script @auto-scripts was called via post-install-cmd
按官方的文档(可装可不装)
https://symfony.com/doc/current/setup.html
cd /var/wwwhtml/symfony_web/
sudo composer require symfony/web-server-bundle --dev
修改nginx配置
sudo /etc/nginx/conf.d/symfony.conf
server {
    listen 80;
    listen [::]:80;
    server_name symfony.cc;
    root /var/www/html/symfony_web/public;
    index index.html index.htm index.nginx-debian.html index.php;

    server_name _;

    location / {
        try_files $uri $uri/ =404;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
    }
}
检查语法后重启nginx
sudo nginx -t
sudo service nginx restart
访问http://192.168.3.187/
出现symfony的页面

Tue Oct  9 21:44:29 2018 (23730): Fatal Error Unable to create lock file: Bad file descriptor (9)
原因:
tmp目录权限问题
root用户执行 php -i 没报错
其他用户执行报错
通过root用户运行 php -i 找到了 php.ini文件
配置 upload_tmp_dir 为 /tmp/php7.1.7
然后给这个目录加777权限,解决

总结:
kill -USR2 123 // 平滑重启,fpm
找php, php-fpm位置
ps -aux | grep fpm
/usr/local/php-7.1.7
php 在 bin目录下
fpm 在 sbin目录下

PHP 命令行运行代码
php -r "echo 'asdf';"
打印某个配置变量的值
[root@iZ28v4cg1ydZ ~]# php -r "print_r(ini_get('upload_tmp_dir'));"
[root@iZ28v4cg1ydZ ~]# php -r "print_r(ini_get('upload_max_filesize'));"
打印upload_tmp_dir没有东西,为了确定方法是正确的,又打印upload_max_filesize的值
确定方法正确。

其他原因参考
https://anandarajpandey.com/2016/02/18/solved-fatal-error-unable-to-create-lock-file-bad-file-descriptor-9/

sudo apt update
sudo apt install curl php-cli php-mbstring git unzip
失败了
php -v
因为我装的是php7.3,,所以装php的扩展都应该带php7.3-
sudo apt install php7.3-curl
apt-cache search php7 | grep cli
sudo apt install php7.3-cli
sudo apt install php7.3-mbstring
安装git
sudo apt install git unzip
参考https://getcomposer.org/download/的 Command-line installation
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ls
php -r "if (hash_file('SHA384', 'composer-setup.php') === '93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
//php composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"

如果上面运行的是
php composer-setup.php,那就最好把composer.phar拷到/usr/local/bin,后面执行方便
sudo cp composer.phar /usr/local/bin/composer
运行composer -V 确认安装是否成功

参考https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-18-04

 $file) {
            preg_match($patterns, $file, $prefix[$key]);
        }
        $fileNum = [];
        if (!empty($prefix)) {
            foreach ($prefix as $key => $item) {
                if (!empty($item)) {
                    $fileNum[] = $item[0];
                }
            }
        }
        if (!empty($fileNum)) {
            $maxNumIndex = array_search(max($fileNum), $fileNum);
            $maxNum = $fileNum[$maxNumIndex];
        }
        $maxNum++;
    }
    return $maxNum;
}

php实现了git命令的运行
安装 git 后,在git bash里运行

getBranch();
if ($branchName == GitCommand::MERGE_BRANCH) {
    exit('the two branch is same.');
}
if (!$branchName) {
    exit('can not get branch name');
}
$needToCommit = $gitCommand->needCommit();
$mergeBranch = GitCommand::MERGE_BRANCH;
if ($needToCommit) {
    echo 'Please commit before merge.' . PHP_EOL;
    exit;
}

//拉master
$command = GitCommand::ORIGIN_PULL . $mergeBranch;
exec($command, $pullOutput);
$haveConflict = GitCommand::haveConflict($pullOutput);
if ($haveConflict) {
    echo 'may have conflict, please solve it.' . PHP_EOL;
    exit;
}

GitCommand::checkout($mergeBranch);

//origin pull
$command = GitCommand::ORIGIN_PULL . $mergeBranch;
exec($command, $pullOutput);
$haveConflict = GitCommand::haveConflict($pullOutput);
if ($haveConflict) {
    echo 'may have conflict, please solve it.' . PHP_EOL;
    exit;
}

//merge
$command = GitCommand::MERGE . $branchName;
exec($command, $mergeOutput);
$haveConflict = GitCommand::haveConflict($mergeOutput);
if ($haveConflict) {
    echo 'may have conflict, please solve it.' . PHP_EOL;
    exit;
}

//tag
$lastTag = GitCommand::getTag();
if (!$lastTag) {
    exit('can not get the last tag.');
}

if (!$description) {
    $description = 'default description';
}
$addRes = $gitCommand->addTag($lastTag, $description);
if (!$addRes) {
    exit('add tag fail.');
}

$pushRes = GitCommand::pushToOrigin($mergeBranch, true);
if (!$pushRes) {
    exit('push to origin ' . $mergeBranch . ' fail.');
}

//回到原分支
GitCommand::checkout($branchName);

$response = 'success merge&push to origin ' . $mergeBranch;
$outputObj = new Output();
$outputObj->customEcho($response);

class GitCommand
{
    const PROJECT_ROOT = '/e/project';
    const MERGE_BRANCH = 'master';
    const BRANCH = "git branch ";
    const PULL = "git pull ";
    const ORIGIN_PULL = "git pull origin ";
    const PUSH = "git push ";
    const ORIGIN_PUSH = "git push origin ";
    const ORIGIN_PUSH_TAG = "git push origin BRANCH --tag";
    const CHECKOUT = "git checkout ";
    const STATUS = 'git status';
    const MERGE = 'git merge ';
    const FETCH_TAG = 'git fetch --tag';
    const TAG_TAIL = 'git tag | tail -1';
    const CONFIG_NAME = 'git config --global user.name';
    const ADD_TAG = 'git tag -a TAG -m "DESCRIPTION"';

    private $branch = null;
    private $needCommit = null;

    public function __construct()
    {
        exec(GitCommand::STATUS, $output);
        $branchName = '';
        $needToCommit = false;
        if ($output) {
            //匹配所在分支
            //"On branch watson-git"
            $branchNameRegex = '/^On branch ((\w|-){1,})$/';

            //有文件改了
            //有新文件
            //未commit
            $change = 'Changes to be committed:';
            $new = 'Changes not staged for commit:';

            foreach ($output as $item) {
                if (!$branchName) {
                    preg_match($branchNameRegex, $item, $match);
                    $branchName = $match[1];
                }
                if ((false !== strpos($item, $change)) || (false !== strpos($item, $new))) {
                    $needToCommit = true;
                    break;
                }
            }
        }
        $this->branch = $branchName;
        $this->needCommit = $needToCommit;
    }

    public static function checkout($branch)
    {
        $command = GitCommand::CHECKOUT . $branch;
        exec($command, $temp);
    }

    public static function toProjectDir()
    {
        exec('pwd', $dir);
        if (GitCommand::PROJECT_ROOT != $dir[0]) {
            exec('cd ' . GitCommand::PROJECT_ROOT, $cdLog);
        }
    }

    public function getBranch()
    {
        if (null === $this->branch) {
            exit('error, git status can not be resolved.');
        }
        return $this->branch;
    }

    public function needCommit()
    {
        if (null === $this->needCommit) {
            exit('error, git status can not be resolved.');
        }
        return $this->needCommit;
    }

    public static function haveConflict($output)
    {
        $res = false;
        if ($output) {
            $conflict = 'conflict';
            foreach ($output as $item) {
                if (strpos($item, $conflict) > 0 || strpos($item, $conflict) === 0) {
                    $res = true;
                }
            }
        }
        return $res;
    }

    public function addTag($lastTag, $tagDescription = '')
    {
        $name = $this->getAuthor();
        if (!$name) {
            return false;
        }
        //解析tag
        if (!$lastTag) {
            return false;
        }
        $tagArr = explode('-', $lastTag);
        $project = $tagArr[0];
        $versionStr = $tagArr[1];
        $time = date('YmdHi');
        $versionArr = explode('.', $versionStr);
        $versionNum = implode('', $versionArr);
        $versionNum++;
        $versionArr = str_split($versionNum);
        $versionStr = implode('.', $versionArr);
        if (!$project || !$versionStr || !$time || !$name) {
            return false;
        }
        $newTagArr = array($project, $versionStr, $time, $name);
        $newTag = implode('-', $newTagArr);
        $command = str_replace('TAG', $newTag, self::ADD_TAG);
        $command = str_replace('DESCRIPTION', $tagDescription, $command);
        exec($command, $addOutput);
        return true;
    }

    private function getAuthor()
    {
        $name = '';
        exec(self::CONFIG_NAME, $output);
        if ($output) {
            $fullName = $output[0];
            $arr = explode('.', $fullName);
            $name = $arr[0];
        }
        return $name;
    }

    public static function getTag()
    {
        exec(self::FETCH_TAG, $output);
        exec(self::TAG_TAIL, $output);
        $lastTag = '';
        if ($output) {
            $lastTag = array_pop($output);
        }
        return $lastTag;
    }

    public static function pushToOrigin($branch, $withTag = false)
    {
        if ($withTag) {
            $command = str_replace('BRANCH', $branch, GitCommand::ORIGIN_PUSH_TAG);
        } else {
            $command = GitCommand::ORIGIN_PUSH . $branch;
        }
        exec($command, $pushOutput);
        if ($pushOutput) {
            foreach ($pushOutput as $item) {
                $pos = strpos($item, 'hint');
                if ($pos > 0 || 0 === $pos) {
                    return false;
                }
            }
        }
        return true;
    }

}

class Output
{
    public function customEcho($str)
    {
        $middle = '****** ' . $str . ' ******';
        $len = strlen($middle);
        $this->printStar($len);
        echo $middle . PHP_EOL;
        $this->printStar($len);
    }

    private function printStar($len)
    {
        for ($i = 0; $i < $len; $i++) {
            echo "*";
        }
        echo PHP_EOL;
    }
}

sudo apt update 
sudo apt install nginx
ps -aux | grep nginx
nginx -v
sudo ufw allow 'Nginx HTTP'
sudo ufw status
curl localhost
sudo apt install mysql-server-5.7
sudo mysql_secure_installation

xhs@xhs:~$ sudo apt install php-fpm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package php-fpm

apt-cache search fpm
换成阿里云的源装了个php5-fpm
打算再换回官方的源装php7-mysql
转念一想,fpm或cgi都只是nginx和php的通讯工具,装哪个都可以
就还是装php7-cgi
sudo apt remove php5-fpm
转来转去,还是要安装 fpm
先添加源
add-apt-repository ppa:ondrej/php
apt update 后终于有php-fpm了
但依赖有点问题
xhs@xhs:/etc/nginx$ sudo apt install php7.2-fpm
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 php7.2-fpm : Depends: php7.2-common (= 7.2.9-1+ubuntu18.04.1+deb.sury.org+1) but 7.2.10-0ubuntu0.18.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.
先卸载之前的吧
dpkg -l | grep php
没理解提示信息,卸载了还是装不上,又update了一下
看到有php7.3版本的,试着安装
sudo apt install php7.3-fpm
可以了
xhs@xhs:/etc/nginx$ systemctl restart php7.3-fpm.service 
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to restart 'php7.3-fpm.service'.
Authenticating as: xhs
Password: 
==== AUTHENTICATION COMPLETE ===
xhs@xhs:/etc/nginx$ sudo netstat -pantu | grep 9000
xhs@xhs:/etc/nginx$ sudo netstat -pantu | grep 9000
xhs@xhs:/etc/nginx$ systemctl status php
php5-fpm.service         php7.3-fpm.service       php-fpm.service          phpsessionclean.service  phpsessionclean.timer    
xhs@xhs:/etc/nginx$ systemctl status php
php5-fpm.service         php7.3-fpm.service       php-fpm.service          phpsessionclean.service  phpsessionclean.timer    
xhs@xhs:/etc/nginx$ systemctl status php7.3-fpm.service 
● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2018-09-27 10:24:05 UTC; 33s ago
     Docs: man:php-fpm7.3(8)
 Main PID: 20140 (php-fpm7.3)
   Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
    Tasks: 3 (limit: 2322)
   CGroup: /system.slice/php7.3-fpm.service
           ├─20140 php-fpm: master process (/etc/php/7.3/fpm/php-fpm.conf)
           ├─20154 php-fpm: pool www
           └─20155 php-fpm: pool www

Sep 27 10:24:05 xhs systemd[1]: Stopped The PHP 7.3 FastCGI Process Manager.
Sep 27 10:24:05 xhs systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
Sep 27 10:24:05 xhs systemd[1]: Started The PHP 7.3 FastCGI Process Manager.
xhs@xhs:/etc/nginx$ 
启动fpm
systemctl restart php7.2-fpm #重启
其他相关命令
systemctl start php7.2-fpm #启动
systemctl stop php7.2-fpm #关闭
systemctl status php7.2-fpm #检查状态

接着修改nginx配置文件
ps -aux | grep 9000 查不到 fpm 9000 端口的开启信息
原来还有另一种方式连接,unix sock
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
    
        #With php-fpm (or other unix sockets):
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        #With php-cgi (or other tcp sockets):
        #fastcgi_pass 127.0.0.1:9000;
    }

LEMP 指的是 Linux,nginx,mysql, php
首先到官网下载centos7镜像,我选的是DVD发行版
在virtualbox安装完,网络选桥接模式
ip address发现没有IP
查了一下,发现要改下网卡配置
https://grokbase.com/t/centos/centos/147a5f3y9k/centos-7-in-virtualbox
cp /etc/sysconfig/network-scripts/ifcfg-enp0s3 ~/ifcfg-enp0s3.bak
vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
ONBOOT=yes
再 reboot
ip address
有ip了
安装nginx
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
curl http://localhost
nginx -v
sudo systemctl enable nginx
ip addr show enp0s3 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'
安装MySql
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation
sudo systemctl enable mariadb
安装php,发现默认安装的是php5.4,但我想装php7
sudo yum install php php-mysql php-fpm
php --version
所以又删除了
yum remove php-common
安装php7
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum install yum-utils
yum-config-manager --enable remi-php71
yum install php php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo
yum install php-fpm
php --version
改cgi.pathinfo配置
vi /etc/php.ini 
参考文章中让nginx和php用unix socket通讯,我懒得改了
vi /etc/php-fpm.d/www.conf 
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
加nginx配置文件
sudo vi /etc/nginx/nginx.conf
sudo vi /etc/nginx/conf.d/symfony.conf
没有vim,装个vim
yum install vim
sudo vim /etc/nginx/conf.d/symfony.conf
内容:
    server {
        listen       80;
        listen       [::]:80;
        server_name  symfony.cc;
        root         /usr/share/nginx/html/symfony;
        location / {
            index index.html index.htm;
        }

        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
    }    
检查语法
nginx -t

mkdir /usr/share/nginx/html/symfony
vim /usr/share/nginx/html/symfony/index.html
    hello, xhs
vim /usr/share/nginx/html/symfony/info.php
    


      
    

#查看进程类似ps,杀死进程
tasklist | findstr "18768"
taskkill /pid 18768 -f
#查看历史命令F7
#导出历史命令
doskey /history > cmdlist.txt
#查看端口占用
netstat -ano|findstr "40000"
netstat -闹 | 
#计算MD5
certutil -hashfile ubuntu-16.04-server-cloudimg-amd64.ova MD5
#打开服务
win+r , 输入 services.msc
#创建定时任务
#每日九点执行脚本daily.bat
SchTasks /Create /SC DAILY /TN "dailyTask" /TR "C:\Windows\System32\daily.bat" /ST 09:00
#删除定时任务
SchTasks /Delete /TN logTask

#
net stop http

查看当前系统情况
uname -r
cat /etc/issue
更新安装
yum update -y
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
cd /etc/yum.repos.d/
rpm -Uvh https://www.elrepo.org/elrepo-release-6-8.el6.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-lt -y
备份
cp /etc/grub.conf /etc/grub.conf.backup
修改,default=0
vim /etc/grub.conf 
重启
reboot
开机后再查看
uname -r
more /etc/issue
参考
https://www.cnblogs.com/ywqbj/p/5756746.html