<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:media="http://search.yahoo.com/mrss/"><channel><title><![CDATA[技术分享]]></title><description><![CDATA[技术分享]]></description><link>http://xj10.xyz/</link><image><url>http://xj10.xyz/favicon.png</url><title>技术分享</title><link>http://xj10.xyz/</link></image><generator>Ghost 2.6</generator><lastBuildDate>Tue, 24 Feb 2026 20:28:13 GMT</lastBuildDate><atom:link href="http://xj10.xyz/rss/" rel="self" type="application/rss+xml"/><ttl>60</ttl><item><title><![CDATA[linux 出现结构需要清理 (structure needs cleaning)]]></title><description><![CDATA[<ol>
<li>
<p>问题描述<br>
Linux服务器出现 <code>mount /dev/mapper/centos-root on /sysroot failed: Structure needs cleaning</code> 的问题<br>
<img src="http://xj10.xyz/content/images/2023/02/bd585cd39971c09a8a224550b52a946.png" alt="bd585cd39971c09a8a224550b52a946"></p>
</li>
<li>
<p>处理过程<br>
关健字“structure needs cleaning”，这是XFS文件系统（客户选用）在异常掉电后损坏，需要手动修复：<br>
在未挂载状态下使用这个命令：<br>
<code>shell&gt; xfs_repair /dev/mapper/centos-root</code><br>
如果提示log什么的有问题，则使用-L参数,这会重建log，然后再使用上面一条命令进行修复。<br>
<code>shell&gt;xfs_repair -L /dev/mapper/centos-root</code></p>
</li>
<li>
<p>ext4文件系统的处理方法<br>
<code>fsck.ext4 /dev/sda1</code></p>
</li>
</ol>]]></description><link>http://xj10.xyz/untitled/</link><guid isPermaLink="false">63f84a139c23410001a3e177</guid><category><![CDATA[linux]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Fri, 24 Feb 2023 05:38:26 GMT</pubDate><content:encoded><![CDATA[<ol>
<li>
<p>问题描述<br>
Linux服务器出现 <code>mount /dev/mapper/centos-root on /sysroot failed: Structure needs cleaning</code> 的问题<br>
<img src="http://xj10.xyz/content/images/2023/02/bd585cd39971c09a8a224550b52a946.png" alt="bd585cd39971c09a8a224550b52a946"></p>
</li>
<li>
<p>处理过程<br>
关健字“structure needs cleaning”，这是XFS文件系统（客户选用）在异常掉电后损坏，需要手动修复：<br>
在未挂载状态下使用这个命令：<br>
<code>shell&gt; xfs_repair /dev/mapper/centos-root</code><br>
如果提示log什么的有问题，则使用-L参数,这会重建log，然后再使用上面一条命令进行修复。<br>
<code>shell&gt;xfs_repair -L /dev/mapper/centos-root</code></p>
</li>
<li>
<p>ext4文件系统的处理方法<br>
<code>fsck.ext4 /dev/sda1</code></p>
</li>
</ol>
]]></content:encoded></item><item><title><![CDATA[WEB播放MP4,需要视频加载完成才能播放问题解决]]></title><description><![CDATA[<p>将MP4中Metadata信息移至文件头部<br>
mp4视频有metadata，通常在文件尾部，而web播放器读到这个metadata才开始播放，解决办法是用工具处理一下mp4，把它的metadata移至文件头部。<br>
推荐工具：<a href="http://www.videohelp.com/tools/mp4box">mp4box</a><br>
指令：<code>mp4box.exe -isma xx.mp4</code></p>]]></description><link>http://xj10.xyz/mp4box-exe-isma-xx-mp4/</link><guid isPermaLink="false">60ff95269c23410001a3e15c</guid><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Tue, 27 Jul 2021 05:14:38 GMT</pubDate><content:encoded><![CDATA[<p>将MP4中Metadata信息移至文件头部<br>
mp4视频有metadata，通常在文件尾部，而web播放器读到这个metadata才开始播放，解决办法是用工具处理一下mp4，把它的metadata移至文件头部。<br>
推荐工具：<a href="http://www.videohelp.com/tools/mp4box">mp4box</a><br>
指令：<code>mp4box.exe -isma xx.mp4</code></p>
]]></content:encoded></item><item><title><![CDATA[CentOS7关闭SELinux]]></title><description><![CDATA[<h2 id="-"><strong>查看</strong></h2><pre><code>[root@dev-server ~]# getenforce
Disabled
[root@dev-server ~]# /usr/sbin/sestatus -v
SELinux status:                 disabled</code></pre><h2 id="--1"><strong>临时关闭</strong></h2><pre><code>##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
setenforce 0</code></pre><h2 id="--2"><strong>永久关闭</strong></h2><pre><code>vi /etc/selinux/config</code></pre><p>将SELINUX=enforcing改为SELINUX=disabled<br>设置后需要重启才能生效</p>]]></description><link>http://xj10.xyz/centos7guan-bi-selinux-2/</link><guid isPermaLink="false">60c15f9c9c23410001a3e14f</guid><category><![CDATA[centos]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Thu, 10 Jun 2021 00:46:25 GMT</pubDate><content:encoded><![CDATA[<h2 id="-"><strong>查看</strong></h2><pre><code>[root@dev-server ~]# getenforce
Disabled
[root@dev-server ~]# /usr/sbin/sestatus -v
SELinux status:                 disabled</code></pre><h2 id="--1"><strong>临时关闭</strong></h2><pre><code>##设置SELinux 成为permissive模式
##setenforce 1 设置SELinux 成为enforcing模式
setenforce 0</code></pre><h2 id="--2"><strong>永久关闭</strong></h2><pre><code>vi /etc/selinux/config</code></pre><p>将SELINUX=enforcing改为SELINUX=disabled<br>设置后需要重启才能生效</p>]]></content:encoded></item><item><title><![CDATA[实现Highcharts 图表双击事件]]></title><description><![CDATA[<p>Highcharts 默认并没有提供图表双击事件接口，这里用很简单的方法实现，代码如下</p>
<pre><code>var clickDetected = false;
$(&quot;#container&quot;).highcharts({
    chart: {
        events: {
            click: function(e) {
                if (clickDetected) {
                    console.log(&quot;Double click&quot;);
                    console.log(e);
                } else {
                    clickDetected = true;
                    setTimeout(function() {
                        clickDetected = false;
                    }, 500);
                }
            }
        }
    }
});
</code></pre>]]></description><link>http://xj10.xyz/shi-xian-highcharts-tu-biao-shuang-ji-shi-jian/</link><guid isPermaLink="false">603319e09c23410001a3e125</guid><category><![CDATA[highcharts]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Sun, 12 Apr 2020 04:52:19 GMT</pubDate><content:encoded><![CDATA[<p>Highcharts 默认并没有提供图表双击事件接口，这里用很简单的方法实现，代码如下</p>
<pre><code>var clickDetected = false;
$(&quot;#container&quot;).highcharts({
    chart: {
        events: {
            click: function(e) {
                if (clickDetected) {
                    console.log(&quot;Double click&quot;);
                    console.log(e);
                } else {
                    clickDetected = true;
                    setTimeout(function() {
                        clickDetected = false;
                    }, 500);
                }
            }
        }
    }
});
</code></pre>
]]></content:encoded></item><item><title><![CDATA[MySQL开启binlog日志]]></title><description><![CDATA[<h3 id="mysqletcmycnfmysqld">编辑mysql配置文件 <code>/etc/my.cnf</code> 在<code>[mysqld]</code> 区块下</h3>
<pre><code>log-bin=mysql-bin
max_binlog_size = 1g
</code></pre>]]></description><link>http://xj10.xyz/mysqlkai-qi-binlogri-zhi/</link><guid isPermaLink="false">603319e09c23410001a3e124</guid><category><![CDATA[mysql]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Fri, 20 Mar 2020 14:47:25 GMT</pubDate><content:encoded><![CDATA[<h3 id="mysqletcmycnfmysqld">编辑mysql配置文件 <code>/etc/my.cnf</code> 在<code>[mysqld]</code> 区块下</h3>
<pre><code>log-bin=mysql-bin
max_binlog_size = 1g
</code></pre>
]]></content:encoded></item><item><title><![CDATA[CentOS安装MySQL详解]]></title><description><![CDATA[<p>一、YUM</p><p>0、删除已安装的MySQL检查MariaDB</p><pre><code>shell&gt; rpm -qa|grep mariadb
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
复制代码</code></pre><h5 id="-mariadb-">删除mariadb如果不存在（上面检查结果返回空）则跳过步骤</h5><pre><code>shell&gt; rpm -e --nodeps mariadb-server
shell&gt; rpm -e --nodeps mariadb
shell&gt; rpm</code></pre>]]></description><link>http://xj10.xyz/centosan-zhuang-mysqlxiang-jie/</link><guid isPermaLink="false">603319e09c23410001a3e123</guid><category><![CDATA[centos]]></category><category><![CDATA[mysql]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Thu, 19 Mar 2020 14:49:11 GMT</pubDate><content:encoded><![CDATA[<p>一、YUM</p><p>0、删除已安装的MySQL检查MariaDB</p><pre><code>shell&gt; rpm -qa|grep mariadb
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
复制代码</code></pre><h5 id="-mariadb-">删除mariadb如果不存在（上面检查结果返回空）则跳过步骤</h5><pre><code>shell&gt; rpm -e --nodeps mariadb-server
shell&gt; rpm -e --nodeps mariadb
shell&gt; rpm -e --nodeps mariadb-libs
复制代码</code></pre><p><em>其实yum方式安装是可以不用删除mariadb的，安装MySQL会覆盖掉之前已存在的mariadb</em>检查MySQL</p><pre><code>shell&gt; rpm -qa|grep mysql
复制代码</code></pre><h5 id="-mysql-">删除MySQL如果不存在（上面检查结果返回空）则跳过步骤</h5><pre><code>shell&gt; rpm -e --nodeps xxx
复制代码</code></pre><h3 id="1-mysql-yum-repository-centos-7-mariadb-yum-centos-7-yum-mysql-mariadb-mysql-mysql-mysql-yum-mysql-dev-mysql-com-downloads-r-">1、添加MySQL Yum Repository从CentOS 7开始，MariaDB成为Yum源中默认的数据库安装包。也就是说在CentOS 7及以上的系统中使用yum安装MySQL默认安装的会是MariaDB（MySQL的一个分支）。如果想安装官方MySQL版本，需要使用MySQL提供的Yum源。下载MySQL源官网地址：<a href="https://dev.mysql.com/downloads/repo/yum/" rel="nofollow noopener noreferrer">dev.mysql.com/downloads/r…</a>查看系统版本：</h3><pre><code>shell&gt; cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
复制代码</code></pre><p>选择对应的版本进行下载，例如CentOS 7当前在官网查看最新Yum源的下载地址为： <a href="https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm" rel="nofollow noopener noreferrer">dev.mysql.com/get/mysql80…</a></p><pre><code>shell&gt; wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
复制代码</code></pre><h5 id="-mysql--1">安装MySQL源</h5><pre><code>shell&gt; sudo rpm -Uvh platform-and-version-specific-package-name.rpm
复制代码</code></pre><p>例如CentOS7当前最新MySQL源安装：</p><pre><code>shell&gt; sudo rpm -Uvh mysql80-community-release-el7-3.noarch.rpm
复制代码</code></pre><h5 id="-etc-yum-repos-d-repo-mysql-community-repo-mysql-community-source-repo-yum-repolist-mysql-">检查是否安装成功执行成功后会在<code>/etc/yum.repos.d/</code>目录下生成两个repo文件<code>mysql-community.repo</code>及 <code>mysql-community-source.repo</code>并且通过<code>yum repolist</code>可以看到mysql相关资源</h5><pre><code>shell&gt; yum repolist enabled | grep "mysql.*-community.*"
!mysql-connectors-community/x86_64 MySQL Connectors Community                108
!mysql-tools-community/x86_64      MySQL Tools Community                      90
!mysql80-community/x86_64          MySQL 8.0 Community Server                113
复制代码</code></pre><h3 id="2-mysql-mysql-yum-repository-mysql-mysql-mysql-8-0-mysql5-7-mysql-yum-repository-mysql-">2、选择MySQL版本使用MySQL Yum Repository安装MySQL，默认会选择当前最新的稳定版本，例如通过上面的MySQL源进行安装的话，默安装会选择MySQL 8.0版本，如果就是想要安装该版本，可以直接跳过此步骤，如果不是，比如我这里希望安装MySQL5.7版本，就需要“切换一下版本”：查看当前MySQL Yum Repository中所有MySQL版本（每个版本在不同的子仓库中）</h3><pre><code>shell&gt; yum repolist all | grep mysql
复制代码</code></pre><h5 id="-">切换版本</h5><pre><code>shell&gt; sudo yum-config-manager --disable mysql80-community
shell&gt; sudo yum-config-manager --enable mysql57-community
复制代码</code></pre><p>若出现 yum-config-manager: command not found </p><p>这个是因为系统默认没有安装这个命令，这个命令在yum-utils 包里，可以通过命令yum -y install yum-utils 安装就可以了。<br></p><p>除了使用yum-config-manager之外，还可以直接编辑<code>/etc/yum.repos.d/mysql-community.repo</code>文件enabled=0禁用</p><pre><code>[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
复制代码</code></pre><p>enabled=1启用</p><pre><code># Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
复制代码</code></pre><h5 id="-mysql--2">检查当前启用的MySQL仓库</h5><pre><code>shell&gt; yum repolist enabled | grep mysql
复制代码</code></pre><p><em>如果同时启用了多个仓库，安装时会选择最新版本</em></p><p>3、安装MySQL</p><pre><code>shell&gt; sudo yum install mysql-community-server
复制代码</code></pre><p>该命令会安装MySQL服务器 (mysql-community-server) 及其所需的依赖、相关组件，包括mysql-community-client、mysql-community-common、mysql-community-libs等如果带宽不够，这个步骤时间会比较长，请耐心等待~</p><p>若安装过程出现以下问题：</p><pre><code>警告：/var/cache/yum/x86_64/7.6-4.el7.ns7.05.lic.adv/mysql57-community/packages/mysql-community-server-5.7.38-1.el7.x86_64.rpm: 头V4 RSA/SHA256 Signature, 密钥 ID 3a79bd29: NOKEY
从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥


源 &quot;MySQL 5.7 Community Server&quot; 的 GPG 密钥已安装，但是不适用于此软件包。请检查源的公钥 URL 是否配置正确。


 失败的软件包是：mysql-community-server-5.7.38-1.el7.x86_64
 GPG  密钥配置为：file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

</code></pre>
<p>运行以下命令解决：</p><p><code>sudo rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022</code></p>
<p>4、启动MySQL启动</p><pre><code>shell&gt; sudo systemctl start mysqld.service
复制代码</code></pre><p>CentOS 6：</p><pre><code>shell&gt; sudo service mysqld start
复制代码</code></pre><h5 id="--1">查看状态</h5><pre><code>shell&gt; sudo systemctl status mysqld.service
复制代码</code></pre><p>CentOS 6：</p><pre><code>shell&gt; sudo service mysqld status
复制代码</code></pre><h5 id="--2">停止</h5><pre><code>shell&gt; sudo systemctl stop mysqld.service
复制代码</code></pre><p>CentOS 6：</p><pre><code>shell&gt; sudo service mysqld stop
复制代码</code></pre><h5 id="--3">重启</h5><pre><code>shell&gt; sudo systemctl restart mysqld.service
复制代码</code></pre><p>CentOS 6：</p><pre><code>shell&gt; sudo service mysqld restart
复制代码</code></pre><h3 id="5-mysql-root-localhost-">5、修改密码初始密码MySQL第一次启动后会创建超级管理员账号<code>root@localhost</code>，初始密码存储在日志文件中：</h3><pre><code>shell&gt; sudo grep 'temporary password' /var/log/mysqld.log
复制代码</code></pre><h5 id="--4">修改默认密码</h5><pre><code>shell&gt; mysql -uroot -p
复制代码</code></pre><pre><code>mysql&gt; ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
复制代码</code></pre><p>出现上面的提示是因为密码太简单了，解决方法如下：使用复杂密码，MySQL默认的密码策略是要包含数字、字母及特殊字符；如果只是测试用，不想用那么复杂的密码，可以修改默认策略，即<code>validate_password_policy</code>（以及<code>validate_password_length</code>等相关参数），使其支持简单密码的设定，具体方法可以自行百度；修改配置文件<code>/etc/my.cnf</code>，添加<code>validate_password=OFF</code>，保存并重启MySQL</p><pre><code>mysql&gt; ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.00 sec)
复制代码</code></pre><h3 id="6-root-">6、允许root远程访问</h3><pre><code>mysql&gt; GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
mysql&gt; FLUSH PRIVILEGES;
复制代码</code></pre><h3 id="7-utf8-">7、设置编码为utf8查看编码</h3><pre><code>mysql&gt; SHOW VARIABLES LIKE 'character%';
复制代码</code></pre><h5 id="-etc-my-cnf-mysqld-">设置编码编辑/etc/my.cnf，[mysqld]节点增加以下代码：</h5><pre><code>[mysqld]
character_set_server=utf8
init-connect='SET NAMES utf8'
复制代码</code></pre><h3 id="8-">8、设置开机启动</h3><pre><code>shell&gt; systemctl enable mysqld
shell&gt; systemctl daemon-reload
复制代码</code></pre><h2 id="-rpm-yum-0-1-mysql-dev-mysql-com-downloads-m-">二、RPM除安装过程外，其他步骤和yum方式安装相同，不再赘述0、删除已旧版本略1、下载MySQL安装包下载地址：<a href="https://dev.mysql.com/downloads/mysql/" rel="nofollow noopener noreferrer">dev.mysql.com/downloads/m…</a>选择对应的版本： </h2><figure class="kg-card kg-image-card"><img src="https://user-gold-cdn.xitu.io/2019/6/18/16b66894c80e9b32?imageView2/0/w/1280/h/960/format/webp/ignore-error/1" class="kg-image"></figure><pre><code>shell&gt; wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
复制代码</code></pre><h3 id="2-mysql-">2、安装MySQL解压（解打包）</h3><pre><code>shell&gt; tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.26-1.el7.x86_64.rpm-bundle.tar
mysql-community-embedded-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-libs-5.7.26-1.el7.x86_64.rpm
mysql-community-embedded-5.7.26-1.el7.x86_64.rpm
mysql-community-test-5.7.26-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.26-1.el7.x86_64.rpm
mysql-community-common-5.7.26-1.el7.x86_64.rpm
mysql-community-devel-5.7.26-1.el7.x86_64.rpm
mysql-community-client-5.7.26-1.el7.x86_64.rpm
mysql-community-server-5.7.26-1.el7.x86_64.rpm
复制代码</code></pre><p>我们主要安装的是这四个（如果有需要也可以一并安装其它的）：</p><pre><code>mysql-community-libs-5.7.26-1.el7.x86_64.rpm
mysql-community-common-5.7.26-1.el7.x86_64.rpm
mysql-community-client-5.7.26-1.el7.x86_64.rpm
mysql-community-server-5.7.26-1.el7.x86_64.rpm
复制代码</code></pre><p>如果不想下载rpm-bundle，官网也提供单独的rpm下载链接安装各rpm包是有依赖关系的，所以需要按照一定顺序进行安装，安装期间如果提示缺少哪些依赖也要先安装相应的包：</p><pre><code>shell&gt; rpm -ivh mysql-community-common-5.7.26-1.el7.x86_64.rpm
shell&gt; rpm -ivh mysql-community-libs-5.7.26-1.el7.x86_64.rpm
shell&gt; rpm -ivh mysql-community-client-5.7.26-1.el7.x86_64.rpm
shell&gt; rpm -ivh mysql-community-server-5.7.26-1.el7.x86_64.rpm
复制代码</code></pre><p>还有一种简单的方式，可以自动处理各个包之间的依赖关系并自动下载缺少的依赖：</p><pre><code>shell&gt; yum install mysql-community-{server,client,common,libs}-*
复制代码</code></pre><p><em>注意：上面的<code>yum install</code>命令需要在tar解压之后的各个rpm包所在目录内执行，否则就变成yum方式安装了，需要配置MySQL的yum源并且速度很慢，还要当前机器支持外网访问</em>3、设置略三、tar.gz0、删除旧版本略1、下载下载地址：<a href="https://dev.mysql.com/downloads/mysql/" rel="nofollow noopener noreferrer">dev.mysql.com/downloads/m…</a>选择对应的版本： </p><figure class="kg-card kg-image-card"><img src="data:image/svg+xml;utf8,<?xml version=&quot;1.0&quot;?><svg xmlns=&quot;http://www.w3.org/2000/svg&quot; version=&quot;1.1&quot; width=&quot;1280&quot; height=&quot;420&quot;></svg>" class="kg-image"></figure><pre><code>shell&gt; wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
复制代码</code></pre><h3 id="2-mysql-libaio-">2、安装&amp;配置：依赖MySQL依赖libaio库，如果没有先安装一下：</h3><pre><code>shell&gt; yum install libaio
复制代码</code></pre><h5 id="-mysql-mysql-">创建mysql用户不需要登录的一个系统账号，启动MySQL服务时会使用该账号</h5><pre><code>shell&gt; groupadd mysql
shell&gt; useradd -r -g mysql -s /bin/false mysql
复制代码</code></pre><h5 id="--5">解压并创建链接</h5><pre><code>shell&gt; cd /usr/local
shell&gt; tar zxvf /path/to/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
shell&gt; ln -s mysql-5.7.26-linux-glibc2.12-x86_64/ mysql
复制代码</code></pre><h5 id="-mysql-files-secure_file_priv-">创建mysql-files目录这一步并不是必须的，可以设置secure_file_priv的值指向该目录（用于限制数据导入导出操作的目录）</h5><pre><code>shell&gt; cd mysql
shell&gt; mkdir mysql-files
shell&gt; chown mysql:mysql mysql-files
shell&gt; chmod 750 mysql-files
复制代码</code></pre><h5 id="--6">初始化</h5><pre><code>shell&gt; bin/mysqld --initialize --user=mysql
复制代码</code></pre><p>如果初始化时报错如下：</p><pre><code>error while loading shared libraries: libnuma.so.1: cannot open shared object file: No such file or directory
复制代码</code></pre><p>是因为libnuma没有安装（或者默认安装的是32位），我们这里需要64位的：</p><pre><code>shell&gt; yum install numactl.x86_64
复制代码</code></pre><p>执行完后重新初始化即可 初始化成功后返回结果中有一行包含初始密码，第一次登录时要用到它：</p><pre><code>A temporary password is generated for root@localhost: 8M0ary878s*U
复制代码</code></pre><h5 id="-ssl-">启用SSL（非必须）</h5><pre><code>shell&gt; bin/mysql_ssl_rsa_setup
复制代码</code></pre><h5 id="--7">启动</h5><pre><code>shell&gt; bin/mysqld_safe --user=mysql &amp;
复制代码</code></pre><p>查看进程可以看到一些默认参数，可以在配置文件中修改这些参数</p><pre><code>shell&gt; ps -ef | grep mysql
root     14604 12719  0 00:03 pts/0    00:00:00 /bin/sh bin/mysqld_safe --user=mysql
mysql    14674 14604  0 00:03 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=VM_2_24_centos.err --pid-file=VM_2_24_centos.pid
复制代码</code></pre><h5 id="-mysql-etc-profile-">设置环境变量避免每次执行mysql命令都要加上路径，在<code>/etc/profile</code>中添加：</h5><pre><code>export PATH=$PATH:/usr/local/mysql/bin
复制代码</code></pre><h5 id="--8">设置为服务</h5><pre><code>shell&gt; cp support-files/mysql.server /etc/init.d/mysqld
shell&gt; service mysqld start|stop|restart|status
复制代码</code></pre><h5 id="--9">开机启动</h5><pre><code>shell&gt; chkconfig --add mysqld
shell&gt; chkconfig --list mysqld
mysqld         	0:关	1:关	2:开	3:开	4:开	5:开	6:关</code></pre><p><br>作者：tianranll<br>链接：https://juejin.im/post/5d07cf13f265da1bd522cfb6<br>来源：掘金<br>著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。</p>]]></content:encoded></item><item><title><![CDATA[使用yum缓存源文件]]></title><description><![CDATA[<ol>
<li>使用 yum 缓存<br>
默认情况下，当前版本的 yum 在成功下载和安装软件包后，会把下载的文件删掉。这样可以减少 yum 占用的磁盘空间。你可以打开缓存，这样 yum 将在缓存目录保留下载到的文件。<br>
缓存带来很多好处：</li>
</ol>
<ul>
<li>yum 的性能可以提高</li>
<li>你可以离线运行 yum 操作，只使用缓存</li>
<li>你可以复制缓存中的软件包以备用<br>
默认情况下，yum 在 /var/cache/yum/ 目录保存临时文件，每个仓库都有自己的子目录。仓库目录中 packages/ 子目录包含了缓存的软件包。例如，目录 /var/cache/yum/development/packages/ 包含从 development 仓库下载的软件包。</li>
</ul>
<ol start="2">
<li>启用 yum 缓存<br>
要配置 yum 保留已下载的文件而不是删除，</li></ol>]]></description><link>http://xj10.xyz/shi-yong-yumhuan-cun-yuan-wen-jian/</link><guid isPermaLink="false">603319e09c23410001a3e122</guid><category><![CDATA[linux]]></category><category><![CDATA[centos]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Thu, 19 Mar 2020 14:38:25 GMT</pubDate><content:encoded><![CDATA[<ol>
<li>使用 yum 缓存<br>
默认情况下，当前版本的 yum 在成功下载和安装软件包后，会把下载的文件删掉。这样可以减少 yum 占用的磁盘空间。你可以打开缓存，这样 yum 将在缓存目录保留下载到的文件。<br>
缓存带来很多好处：</li>
</ol>
<ul>
<li>yum 的性能可以提高</li>
<li>你可以离线运行 yum 操作，只使用缓存</li>
<li>你可以复制缓存中的软件包以备用<br>
默认情况下，yum 在 /var/cache/yum/ 目录保存临时文件，每个仓库都有自己的子目录。仓库目录中 packages/ 子目录包含了缓存的软件包。例如，目录 /var/cache/yum/development/packages/ 包含从 development 仓库下载的软件包。</li>
</ul>
<ol start="2">
<li>启用 yum 缓存<br>
要配置 yum 保留已下载的文件而不是删除，设置 /etc/yum.conf 中的 keepcache 选项为 1：<br>
<code>keepcache=1</code><br>
打开缓存后，每个 yum 操作都可能从仓库下载软件包数据。要保证缓存包含了软件包数据，在启用缓存后运行一个操作，例如 list 或 search 来下载软件包数据而不影响系统。</li>
<li>在只使用缓存的模式下使用 yum<br>
要在没有网络的情况下执行 yum，只要启用了缓存，就可以用 -C 选项。这样 yum 就不会检查网络上的仓库，只使用缓存。在这个模式中，yum 只能安装已下载并缓存的软件包。<br>
由于网络安全的原因，服务器不允许上公网，有2种方案，解决这个问题<br>
1.搭建yum服务器<br>
2.使用yum下载缓存进行封装,然后使用缓存安装<br>
这里讲讲使用yum缓存封装</li>
</ol>
<ul>
<li>下载指定包及相关依赖<br>
<code>yum install --downloadonly packetName</code></li>
<li>查看下载的缓存文件,默认存/var/cache/yum<br>
<code>ll /var/cache/yum</code></li>
<li>yum使用缓存安装指定包<br>
<code>yum -C install packetName</code></li>
</ul>
]]></content:encoded></item><item><title><![CDATA[CentOS下查看CPU核数]]></title><description><![CDATA[<p></p><p>当我们 cat /proc/cpuinfo 时，具有相同core id的CPU是同一个core的超线程，具有相同physical id的CPU是同一个CPU封装的线程或核心。</p>
<ol>
<li>查看CPU型号</li>
</ol>
<pre><code>[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      4  Intel(R) Xeon(R) CPU E7-8860 v4 @ 2.20GHz
</code></pre>
<ol start="2">
<li>查看物理CPU个数</li>
</ol>
<pre><code>[root@localhost ~]# cat /proc/cpuinfo | grep &quot;physical id&quot; | sort | uniq|wc -l
2
</code></pre>
<ol start="3">
<li>查看逻辑CPU的个数</li>
</ol>
<pre><code>[root@</code></pre>]]></description><link>http://xj10.xyz/centosxia-cha-kan-cpuhe-shu/</link><guid isPermaLink="false">603319e09c23410001a3e121</guid><category><![CDATA[centos]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Thu, 19 Mar 2020 14:06:37 GMT</pubDate><content:encoded><![CDATA[<p></p><p>当我们 cat /proc/cpuinfo 时，具有相同core id的CPU是同一个core的超线程，具有相同physical id的CPU是同一个CPU封装的线程或核心。</p>
<ol>
<li>查看CPU型号</li>
</ol>
<pre><code>[root@localhost ~]# cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
      4  Intel(R) Xeon(R) CPU E7-8860 v4 @ 2.20GHz
</code></pre>
<ol start="2">
<li>查看物理CPU个数</li>
</ol>
<pre><code>[root@localhost ~]# cat /proc/cpuinfo | grep &quot;physical id&quot; | sort | uniq|wc -l
2
</code></pre>
<ol start="3">
<li>查看逻辑CPU的个数</li>
</ol>
<pre><code>[root@localhost ~]# cat /proc/cpuinfo | grep &quot;processor&quot; |wc -l
4
</code></pre>
<ol start="4">
<li>查看CPU是几核</li>
</ol>
<pre><code>[root@localhost ~]# cat /proc/cpuinfo | grep &quot;cores&quot;|uniq
cpu cores	: 2
</code></pre>
]]></content:encoded></item><item><title><![CDATA[查看centos系统版本]]></title><description><![CDATA[<h1 id="centos">查看centos系统版本命令</h1>
<pre><code>[oy@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[oy@localhost ~]$ cat /proc/version
Linux version 3.10.0-1062.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Wed Aug 7 18:08:</code></pre>]]></description><link>http://xj10.xyz/cha-kan-centosxi-tong-ban-ben/</link><guid isPermaLink="false">603319e09c23410001a3e120</guid><category><![CDATA[centos]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Thu, 19 Mar 2020 13:11:14 GMT</pubDate><content:encoded><![CDATA[<h1 id="centos">查看centos系统版本命令</h1>
<pre><code>[oy@localhost ~]$ cat /etc/redhat-release
CentOS Linux release 7.7.1908 (Core)
[oy@localhost ~]$ cat /proc/version
Linux version 3.10.0-1062.el7.x86_64 (mockbuild@kbuilder.bsys.centos.org) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) ) #1 SMP Wed Aug 7 18:08:02 UTC 2019
[oy@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[oy@localhost ~]$ uname -r
3.10.0-1062.el7.x86_64
</code></pre>
]]></content:encoded></item><item><title><![CDATA[CentOS安装docker]]></title><description><![CDATA[<blockquote>
<p>警告： 切勿在没有配置 Docker YUM 源的情况下直接使用 yum 命令安装<br>
Docker</p>
</blockquote>
<h1 id="yum">使用yum安装</h1>
<p>执行以下命令安装依赖包：</p>
<pre><code>$sudo yum install -y yum-utils device-mapper-persistent-data lvm2
</code></pre>
<p>鉴于国内网络问题， 强烈建议使用国内源， 官方源请在注释中查看。<br>
执行下面的命令添加 yum 软件源：</p>
<pre><code>$sudo yum-config-manager \
    --add-repo \
    https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo

# 官方源
# $ sudo yum-config-manager \
    # --add-repo \
    # https://download.docker.com/linux/centos/docker-ce.repo
</code></pre>
<h1 id="dockerce">安装 Docker</h1>]]></description><link>http://xj10.xyz/centos-anzhuang-docker/</link><guid isPermaLink="false">603319e09c23410001a3e11f</guid><category><![CDATA[docker]]></category><category><![CDATA[centos]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Mon, 22 Apr 2019 05:12:41 GMT</pubDate><content:encoded><![CDATA[<blockquote>
<p>警告： 切勿在没有配置 Docker YUM 源的情况下直接使用 yum 命令安装<br>
Docker</p>
</blockquote>
<h1 id="yum">使用yum安装</h1>
<p>执行以下命令安装依赖包：</p>
<pre><code>$sudo yum install -y yum-utils device-mapper-persistent-data lvm2
</code></pre>
<p>鉴于国内网络问题， 强烈建议使用国内源， 官方源请在注释中查看。<br>
执行下面的命令添加 yum 软件源：</p>
<pre><code>$sudo yum-config-manager \
    --add-repo \
    https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo

# 官方源
# $ sudo yum-config-manager \
    # --add-repo \
    # https://download.docker.com/linux/centos/docker-ce.repo
</code></pre>
<h1 id="dockerce">安装 Docker CE</h1>
<p>更新 yum 软件源缓存， 并安装 docker-ce 。</p>
<pre><code>$ sudo yum makecache fast
$ sudo yum install docker-ce
</code></pre>
<h1 id="dockerce">启动 Docker CE</h1>
<pre><code>$ sudo systemctl enable docker
$ sudo systemctl start docker
</code></pre>
<h1 id="docker">建立 docker 用户组</h1>
<p>默认情况下， <code>docker</code> 命令会使用 Unix socket 与 Docker 引擎通讯。 而只有<code>root</code> 用户和 <code>docker</code> 组的用户才可以访问 Docker 引擎的 Unix socket。 出于安全考虑， 一般 Linux 系统上不会直接使用 root 用户。 因此， 更好地做法是将需要使用 <code>docker</code> 的用户加入 <code>docker</code> 用户组。<br>
建立 <code>docker</code> 组：</p>
<pre><code>$ sudo groupadd docker
</code></pre>
<p>将当前用户加入 docker 组：</p>
<pre><code>$ sudo usermod -aG docker $USER
</code></pre>
<p>退出当前终端并重新登录， 进行如下测试。</p>
<h1 id="docker">测试 Docker 是否安装正确</h1>
<pre><code>$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the &quot;hello-world&quot; image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
</code></pre>
<p>若能正常输出以上信息， 则说明安装成功。</p>
]]></content:encoded></item><item><title><![CDATA[CentOS + Nginx 申请Let's Encrypt通配符HTTPS证书]]></title><description><![CDATA[<p>在CentOS 7.2系统中利用Certbot工具配置Let's Encrypt通配符证书，所域名下所有的子域名都能方便的使用 https证书，而且完全免费。值得关注的是，Let's encrypt通配符证书只是针对二级域名，并不能针对主域名，如*.example.com和example.com被认为是两个域名，如果和我一样使用的是主域名，在申请的时候需要注意都要申请。</p>
<h1 id="certbot">获取Certbot</h1>
<pre><code># 下载
wget https://dl.eff.org/certbot-auto
# 设为可执行权限
chmod u+x certbot-auto
</code></pre>
<h1 id="">申请证书</h1>
<h2 id="">执行以下命令</h2>
<pre><code>./certbot-auto certonly  -d &quot;*.example.com&quot; -d &quot;example.com&quot; --manual --preferred-challenges dns-01  --server https://acme-v02.</code></pre>]]></description><link>http://xj10.xyz/centos/</link><guid isPermaLink="false">603319e09c23410001a3e11e</guid><category><![CDATA[nginx]]></category><category><![CDATA[centos]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Thu, 21 Mar 2019 13:23:25 GMT</pubDate><content:encoded><![CDATA[<p>在CentOS 7.2系统中利用Certbot工具配置Let's Encrypt通配符证书，所域名下所有的子域名都能方便的使用 https证书，而且完全免费。值得关注的是，Let's encrypt通配符证书只是针对二级域名，并不能针对主域名，如*.example.com和example.com被认为是两个域名，如果和我一样使用的是主域名，在申请的时候需要注意都要申请。</p>
<h1 id="certbot">获取Certbot</h1>
<pre><code># 下载
wget https://dl.eff.org/certbot-auto
# 设为可执行权限
chmod u+x certbot-auto
</code></pre>
<h1 id="">申请证书</h1>
<h2 id="">执行以下命令</h2>
<pre><code>./certbot-auto certonly  -d &quot;*.example.com&quot; -d &quot;example.com&quot; --manual --preferred-challenges dns-01  --server https://acme-v02.api.letsencrypt.org/directory  
</code></pre>
<p>参数说明：</p>
<ul>
<li><code>-certonly</code> 表示安装模式，Certbot 有安装模式和验证模式两种类型的插件。</li>
<li><code>-manual</code> 表示手动安装插件，Certbot 有很多插件，不同的插件都可以申请证书，用户可以根据需要自行选择。</li>
<li><code>-d</code> 为哪些主机申请证书，如果是通配符，输入 *.example.com（替换为自己的域名）。</li>
<li><code>-preferred-challenges</code> 使用 DNS 方式校验域名所有权。</li>
<li><code>-server</code> Let’s Encrypt ACME v2 版本使用的服务器不同于 v1 版本，需要显示指定。<br>
<strong>注意</strong>将<code>example.com</code>替换为自己的域名</li>
</ul>
<h2 id="">执行过程中确认以下信息</h2>
<pre><code>Plugins selected: Authenticator manual, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): test@example.net

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Obtaining a new certificate
Performing the following challenges:
dns-01 challenge for example.com
dns-01 challenge for example.com

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NOTE: The IP of this machine will be publicly logged as having requested this
certificate. If you're running certbot in manual mode on a machine that is not
your server, please ensure you're okay with that.

Are you OK with your IP being logged?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y

</code></pre>
<h2 id="dnstxt">在域名 DNS 解析中添加 TXT记录</h2>
<pre><code>- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please deploy a DNS TXT record under the name
_acme-challenge.example.com with the following value:

c1tiuYabTeauuA3Byjc6Sdn7vbBPjwXZkdZDnry5wvg

Before continuing, verify the record is deployed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Press Enter to Continue
</code></pre>
<p>接下来需要到域名服务器商添加两条TXT记录，本人使用的是腾讯云，以下是解析记录</p>
<p><img src="http://xj10.xyz/content/images/2019/03/txt-----1.png" alt="txt-----1"><br>
添加以后会有最多10分钟的生效时间，这里先要确认解析已经生效，才能在配置Let's Encrypt的终端按回车。<br>
判断解析已经生效，可使用<code>dig _acme-challenge.example.com txt</code>，若出现DNS解析的记录值，则说明解析已经生效了。如下所示：</p>
<pre><code>[root@VM_0_15_centos ~]# dig _acme-challenge.example.com txt

; &lt;&lt;&gt;&gt; DiG 9.9.4-RedHat-9.9.4-50.el7_3.1 &lt;&lt;&gt;&gt; _acme-challenge.example.com txt
;; global options: +cmd
;; Got answer:
;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 48247
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;_acme-challenge.example.com.	IN	TXT

;; ANSWER SECTION:
_acme-challenge.xj10.xyz. 600	IN	TXT	&quot;c1tiuYabTeauuA3Byjc6Sdn7vbBPjwXZkdZDnry5wvg&quot;

;; Query time: 296 msec
;; SERVER: 183.60.83.19#53(183.60.83.19)
;; WHEN: Thu Mar 21 20:39:09 CST 2019
;; MSG SIZE  rcvd: 109

</code></pre>
<p>确认生效后回车后会让继续添加另一条TXT记录，生效后再次回车：</p>
<pre><code>Waiting for verification...
Cleaning up challenges

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/example.com/privkey.pem
   Your cert will expire on 2019-06-19. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot-auto
   again. To non-interactively renew *all* of your certificates, run
   &quot;certbot-auto renew&quot;
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

</code></pre>
<p>生成的文件在<code>/etc/letsencrypt/live/example.com/</code>目录中</p>
<h1 id="nginx">在Nginx中配置证书</h1>
<p>在nginx中进行如下配置：</p>
<pre><code>#http跳转至https
server {
        listen 80;
        server_name example.com;
        rewrite ^(.*)$  https://$host$1 permanent;
}
server {
        listen 443 http2 ssl;
        server_name example.com;
        ssl on;
        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
        ssl_trusted_certificate  /etc/letsencrypt/live/example.com/chain.pem;
        location / {
                proxy_pass http://127.0.0.1:8080/;
                proxy_set_header   Host             $host:$server_port;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_set_header   Remote_Addr    $remote_addr;
        }
}
</code></pre>
<h1 id="">证书更新</h1>
<p>Let's Encrypt 的免费证书默认有效期为 90 天，到期后如果要续期可以执行：<br>
<code>certbot-auto renew</code></p>
<p>可以定义crontab每晚自动执行</p>
<pre><code># 每月的 1,15号， 2点30 更新证书
30 2 1,15 * * /path/to/certbot-auto renew
# 每月的 1,15号， 3点30 重新加载配置
30 3 1,15 * * nginx -s reload
</code></pre>
<p></p><p></p>]]></content:encoded></item><item><title><![CDATA[Centos7重置root密码]]></title><description><![CDATA[<h2 id="1centos7e">1.启动Centos7系统，出现下面画面时按“e”键。</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_01.png" alt="centos7_reset_root_password_01"></p>
<h2 id="2rwsingleinitbinbashctrlx">2. 在下图位置添加“rw single init=/bin/bash”，然后安“Ctrl+X”引导系统。</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_02.png" alt="centos7_reset_root_password_02"></p>
<h2 id="3">3. 挂载根分区</h2>
<p><code>bash-4.2# mount -o remount, rw /</code></p>
<h2 id="4passwd">4. 键入“passwd”即可重置密码。</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_05-1.png" alt="centos7_reset_root_password_05-1"></p>
<h2 id="5execsbininitroot">5. 运行命令“exec /sbin/init”来正常启动系统，需要输入修改后的root密码</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_04-1.png" alt="centos7_reset_root_password_04-1"></p>]]></description><link>http://xj10.xyz/centos7_reset_root_password/</link><guid isPermaLink="false">603319e09c23410001a3e11d</guid><category><![CDATA[centos]]></category><category><![CDATA[linux]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Tue, 27 Nov 2018 16:02:28 GMT</pubDate><content:encoded><![CDATA[<h2 id="1centos7e">1.启动Centos7系统，出现下面画面时按“e”键。</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_01.png" alt="centos7_reset_root_password_01"></p>
<h2 id="2rwsingleinitbinbashctrlx">2. 在下图位置添加“rw single init=/bin/bash”，然后安“Ctrl+X”引导系统。</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_02.png" alt="centos7_reset_root_password_02"></p>
<h2 id="3">3. 挂载根分区</h2>
<p><code>bash-4.2# mount -o remount, rw /</code></p>
<h2 id="4passwd">4. 键入“passwd”即可重置密码。</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_05-1.png" alt="centos7_reset_root_password_05-1"></p>
<h2 id="5execsbininitroot">5. 运行命令“exec /sbin/init”来正常启动系统，需要输入修改后的root密码</h2>
<p><img src="http://xj10.xyz/content/images/2018/11/centos7_reset_root_password_04-1.png" alt="centos7_reset_root_password_04-1"></p>
]]></content:encoded></item><item><title><![CDATA[使用Tomcat+Redis实现集群部署中的Session共享]]></title><description><![CDATA[<p>使用Tomcat进行集群部署，需要解决集群中多个节点之间保持Session共享，大体上有两种方式：</p>
<ul>
<li>把所有Session数据放到一台服务器上或者数据库中，集群中的所有节点通过访问这台Session服务器来获取数据；</li>
<li>在集群中的所有节点间进行Session数据的同步拷贝，任何一个节点均保存了所有的Session数据。</li>
</ul>
<p>Tomcat集群Session同步方案有以下几种方式：</p>
<ol>
<li>使用tomcat自带的cluster方式，多个tomcat间自动实时复制session信息，配置起来很简单。但这个方案的效率比较低，在大并发下表现并不好。</li>
<li>利用nginx的基于访问ip的hash路由策略，保证访问的ip始终被路由到同一个tomcat上，这个配置更简单。但如果应用是某一个局域网大量用户同时登录，这样负载均衡就没什么作用了。</li>
<li>利用nginx插件实现tomcat集群和session同步，nginx-upstream-jvm-route-0.1.tar.gz，是一个Nginx的扩展模块，用来实现基于Cookie的Session Sticky的功能。</li>
<li>利用memcached实现（MSM工具）。memcached存储session，并把多个tomcat的session集中管理，前端在利用nginx负载均衡和动静态资源分离，在兼顾系统水平扩展的同时又能保证较高的性能。</li>
<li>利用redis实现。使用redis不仅仅可以将缓存的session持久化，还因为它支持的单个对象比较大，而且数据类型丰富，不只是缓存 session，还可以做其他用途，可以一举几得。</li>
<li>利用filter方法实现。这种方法比较推荐，因为它的服务器使用范围比较多，不仅限于tomcat ，而且实现的原理比较简单容易控制。</li>
</ol>
<p>本文使用Redis实现Tomcat集群的Session共享。</p>
<h2 id="">部署环境</h2>
<p>Tomcat7+jdk7</p>
<h2 id="jartomcatlib">将以下jar包复制到tomcat</h2>]]></description><link>http://xj10.xyz/shi-yong-tomcat-redisshi-xian/</link><guid isPermaLink="false">603319e09c23410001a3e11c</guid><category><![CDATA[redis]]></category><category><![CDATA[Tomcat]]></category><dc:creator><![CDATA[轶语林]]></dc:creator><pubDate>Mon, 26 Nov 2018 12:20:03 GMT</pubDate><content:encoded><![CDATA[<p>使用Tomcat进行集群部署，需要解决集群中多个节点之间保持Session共享，大体上有两种方式：</p>
<ul>
<li>把所有Session数据放到一台服务器上或者数据库中，集群中的所有节点通过访问这台Session服务器来获取数据；</li>
<li>在集群中的所有节点间进行Session数据的同步拷贝，任何一个节点均保存了所有的Session数据。</li>
</ul>
<p>Tomcat集群Session同步方案有以下几种方式：</p>
<ol>
<li>使用tomcat自带的cluster方式，多个tomcat间自动实时复制session信息，配置起来很简单。但这个方案的效率比较低，在大并发下表现并不好。</li>
<li>利用nginx的基于访问ip的hash路由策略，保证访问的ip始终被路由到同一个tomcat上，这个配置更简单。但如果应用是某一个局域网大量用户同时登录，这样负载均衡就没什么作用了。</li>
<li>利用nginx插件实现tomcat集群和session同步，nginx-upstream-jvm-route-0.1.tar.gz，是一个Nginx的扩展模块，用来实现基于Cookie的Session Sticky的功能。</li>
<li>利用memcached实现（MSM工具）。memcached存储session，并把多个tomcat的session集中管理，前端在利用nginx负载均衡和动静态资源分离，在兼顾系统水平扩展的同时又能保证较高的性能。</li>
<li>利用redis实现。使用redis不仅仅可以将缓存的session持久化，还因为它支持的单个对象比较大，而且数据类型丰富，不只是缓存 session，还可以做其他用途，可以一举几得。</li>
<li>利用filter方法实现。这种方法比较推荐，因为它的服务器使用范围比较多，不仅限于tomcat ，而且实现的原理比较简单容易控制。</li>
</ol>
<p>本文使用Redis实现Tomcat集群的Session共享。</p>
<h2 id="">部署环境</h2>
<p>Tomcat7+jdk7</p>
<h2 id="jartomcatlib">将以下jar包复制到tomcat lib目录下</h2>
<p>commons-pool2-2.4.2.jar<br>
jedis-2.9.0.jar<br>
tomcat-redis-session-manager-2.0.0.jar<br>
<a href="https://pan.baidu.com/s/10nBKXqcSvnC74NxGj_-uag">下载地址</a><code>https://pan.baidu.com/s/10nBKXqcSvnC74NxGj_-uag</code>  提取码: <code>n6rp</code></p>
<h2 id="contextxml">修改context.xml 增加配置</h2>
<pre><code>    &lt;Context&gt;

        &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
        &lt;Valve className=&quot;com.bluejeans.tomcat.redissessions.RedisSessionHandlerValve&quot;/&gt;
        &lt;Manager className=&quot;com.bluejeans.tomcat.redissessions.RedisSessionManager&quot;
            host=&quot;localhost&quot;
            port=&quot;6379&quot;
            password=&quot;123456&quot;
            database=&quot;0&quot;
            maxInactiveInterval=&quot;60&quot;
            /&gt;

    &lt;/Context&gt;
</code></pre>
<p>参数描述：<br>
host: redis数据库ip<br>
port: redis数据库端口<br>
password: redis数据库密码<br>
database:数据库下标(redis默认从0到15 16个分区)<br>
maxInactiveInterval:session过期时间 (测试无效)</p>
]]></content:encoded></item></channel></rss>