$ yum -y install perl perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-IO-Socket-SSL perl-Digest-MD5

https://www.percona.com/downloads/percona-toolkit/LATEST/ 下载并安装:

# wget https://www.percona.com/downloads/percona-toolkit/3.1.0/binary/redhat/7/x86_64/percona-toolkit-3.1.0-
2.el7.x86_64.rpm

# rpm -ivh percona-toolkit-3.1.0-2.el7.x86_64.rpm


warning: percona-toolkit-3.1.0-2.el7.x86_64.rpm : Header V4 RSA/SHA256 Signature, key ID 8507efa5: NOKEY
error: Failed dependencies:
        perl(DBD::mysql) >= 1.0 is needed by percona-toolkit-3.5.5-1.el7.x86_64
        perl(IO::Socket::SSL) is needed by percona-toolkit-3.5.5-1.el7.x86_64
        perl(Digest::MD5) is needed by percona-toolkit-3.5.5-1.el7.x86_64

安装失败 的方案 增加 --force --nodeps 强制不检测依赖.

编写一个脚本 pt.sh

#!/bin/bash
table=$1
alter_conment=$2

cnn_host='127.0.0.1'
cnn_user='root'
cnn_pwd='密码'
cnn_db='kiddo'

echo "$table"
echo "$alter_conment"
/usr/bin/pt-online-schema-change --charset=utf8mb4 --no-version-check --user=${cnn_user} --password=${cnn_pwd} --host=${cnn_host} P=3306,D=${cnn_db},t=$table --alter "${alter_conment}" --execute --nocheck-unique-key-change --no-check-alter
chmod oug+x pt.sh

例子 :

./pt.sh rec_reading_record_v2_book "DROP PRIMARY KEY, ADD PRIMARY KEY (id, reading_record_id) PARTITION BY RANGE(reading_record_id) (PARTITION p0 VALUES LESS THAN (10000000), PARTITION p1 VALUES LESS THAN (20000000), PARTITION p2 VALUES LESS THAN (30000000))"

亲测 有效 可以尝试下.
账号需要有权限进行DDL 操作

阿里云 Centos6.5 yum install时会遇到类似如下404等错误:

$ yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel enchant-devel pam-devel  libc-client libc-client-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel  bzip2 bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel  libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel  xmlrpc-c xmlrpc-c-devel

Loaded plugins: security
http://mirrors.aliyun.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!')
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again

进入 /etc/yum.repos.d/目录

修改下面文件 CentOS-Base.repoepel.repo

CentOS-Base.repo文件中的以下网址

http://mirrors.aliyun.com/centos/
http://mirrors.aliyuncs.com/centos/
http://mirrors.cloud.aliyuncs.com/centos/

替换

http://mirrors.aliyun.com/centos-vault/centos/

epel.repo文件中的 enabled=1修改enabled=0
亲测有效

腾讯云做活动花了120买了台 1核2G的云服, 记录下装机全过程为以后准备;
安装软件配置 :

  • Nginx
  • Mysql
  • Redis
  • MongoDB
  • PHP7

    • swoole
    • yar
    • yac
    • yaf
    • redis
    • mongodb
  • PHP5

    • swoole
    • yar
    • yac
    • yaf
    • redis
    • mongodb
  • Python (默认自带python2.6)
  • NodeJs
  • Lua
  • Supervisor
  • Golang
  • Git
  • NetCat

准备工作:

查看 linux 版本

[root@centos software]# cat /etc/issue
CentOS release 6.8 (Final)
Kernel \r on an \m

安装依赖:

yum install -y gcc gcc-c++ autoconf libjpeg libjpeg-devel enchant-devel pam-devel  \
libc-client libc-client-devel libpng libpng-devel freetype freetype-devel libpng \
libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel  bzip2 \
bzip2-devel ncurses curl openssl-devel gdbm-devel db4-devel libXpm-devel \
 libX11-devel gd-devel gmp-devel readline-devel libxslt-devel expat-devel \
 xmlrpc-c xmlrpc-c-devel

创建用户及用户组

$ groupadd www
$ useradd -g www www     #创建www用户到www用户组

Lua

官网地址: http://www.lua.org/download.html

$ wget http://www.lua.org/ftp/lua-5.3.4.tar.gz
$ tar zxf lua-5.3.4.tar.gz
[root@centos lua-5.3.4]# make  linux
[root@centos lua-5.3.4]# make install

测试 Ok

$ lua
Lua 5.3.4  Copyright (C) 1994-2017 Lua.org, PUC-Rio
>

安装 luajit http://luajit.org/download.html

$ wget https://github.com/openresty/lua-nginx-module/archive/v0.10.15.tar.gz
$ tar zxf  v0.10.15.tar.gz
$ cd lua-nginx-module-0.10.15
[root@centos lua-nginx-module-0.10.15]# make PREFIX=/usr/local/
[root@centos lua-nginx-module-0.10.15]# make install PREFIX=/usr/local/

Nginx

$ wget http://nginx.org/download/nginx-1.13.8.tar.gz
--2018-03-06 21:12:40--  http://nginx.org/download/nginx-1.13.8.tar.gz
Resolving nginx.org... 95.211.80.227, 206.251.255.63, 2001:1af8:4060:a004:21::e3, ...
Connecting to nginx.org|95.211.80.227|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 992237 (969K) [application/octet-stream]
Saving to: “nginx-1.13.8.tar.gz”

100%[=============================================================================================>] 992,237     64.9K/s   in 7.3s    

2018-03-06 21:12:48 (132 KB/s) - “nginx-1.13.8.tar.gz” saved [992237/992237]

$ tar zxf nginx-1.13.8.tar.gz
$ cd nginx-1.13.8
[root@centos nginx-1.13.8]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src

准备模块所需 :

下载ngx_devel_kit(NDK 模块 :https://github.com/simpl/ngx_devel_kit/tags

wget https://github.com/simplresty/ngx_devel_kit/archive/v0.3.1rc1.tar.gz
tar -xzvf v0.3.1rc1.tar.gz

下载最新的lua-nginx-module 模块 :https://github.com/openresty/lua-nginx-module/tags

wget https://github.com/openresty/lua-nginx-module/archive/v0.10.12rc2.tar.gz.gz
tar -xzvf v0.10.12rc2.tar.gz

下载最新的 redis2-nginx-module模块 : https://github.com/openresty/redis2-nginx-module/releases

wget https://github.com/openresty/redis2-nginx-module/archive/v0.15rc1.tar.gz
tar zxf v0.15rc1.tar.gz

下载 pcre 并编译: http://www.linuxfromscratch.org/blfs/view/svn/general/pcre.html

$ wget https://downloads.sourceforge.net/pcre/pcre-8.41.tar.bz2
$ tar jxf pcre-8.41.tar.bz2
$ cd pcre-8.41
$ ./configure --prefix=/usr/local/pcre --enable-utf8 --enable-unicode-properties
$ make && make install

开始加载的nginx 模块及编译参数

$ ./configure --prefix=/usr/local/nginx --user=www --group=www \
 --with-http_stub_status_module --with-http_ssl_module \
 --with-pcre=/usr/local/src/pcre-8.41 \
 --add-module=/usr/local/src/redis2-nginx-module-0.15rc1 \
 --add-module=/usr/local/src/ngx_devel_kit-0.3.1rc1 \
 --add-module=/usr/local/src/lua-nginx-module-0.10.12rc2

设置软链

$ ln -s /usr/local/nginx/sbin/nginx  /usr/bin/nginx
$ which nginx
$ /usr/bin/nginx

Redis


# https://redis.io/download
$ wget http://download.redis.io/releases/redis-4.0.8.tar.gz
$ tar xzf redis-4.0.8.tar.gz
$ cd redis-4.0.8
$ make
$ cd src
$ make install
$ cd ..
$ mkdir -p /usr/local/redis/bin
$ mkdir -p /usr/local/redis/ect
$ cp redis.conf /usr/local/redis/ect/
$ mv mkreleasdhdr.sh redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server redis-check-rdb redis-sentinel redis-trib.rb /usr/local/redis/bin

$ ln /usr/local/redis/bin/redis-server /usr/bin/redis-server
$ ln /usr/local/redis/bin/redis-cli /usr/bin/redis-cli
$ redis-server
    
    6443:C 18 Mar 22:57:20.008 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
    6443:C 18 Mar 22:57:20.008 # Redis version=4.0.8, bits=64, commit=00000000, modified=0, pid=6443, just started
    6443:C 18 Mar 22:57:20.008 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
    6443:M 18 Mar 22:57:20.009 # Not listening to IPv6: unsupproted
                    _._                                                  
               _.-``__ ''-._                                  
          _.-``    `.  `_.  ''-._           Redis 4.0.8 (00000000/0) 64 bit
      .-`` .-```.  ```\/    _.,_ ''-._              
    (    '      ,       .-`  | `,    )     Running in standalone mode
    |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
    |    `-._   `._    /     _.-'    |     PID: 6443
      `-._    `-._  `-./  _.-'    _.-'            
    |`-._`-._    `-.__.-'    _.-'_.-'|            
    |    `-._`-._        _.-'_.-'    |           http://redis.io
      `-._    `-._`-.__.-'_.-'    _.-'            
    |`-._`-._    `-.__.-'    _.-'_.-'|            
    |    `-._`-._        _.-'_.-'    |            
      `-._    `-._`-.__.-'_.-'    _.-'            
          `-._    `-.__.-'    _.-'                
              `-._        _.-'                    
                  `-.__.-'                                               
    
    6443:M 18 Mar 22:57:20.011 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
    6443:M 18 Mar 22:57:20.011 # Server initialized
    6443:M 18 Mar 22:57:20.011 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
    6443:M 18 Mar 22:57:20.011 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
    6443:M 18 Mar 22:57:20.011 * Ready to accept connections

Mysql

官方下载 社区开源免费版

下载网页 https://dev.mysql.com/downloads/file/?id=474703

云服下载太慢了, 本地下载在上传到服务器

下载rpm包

https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar

解压tar

$ tar xf mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
mysql-community-client-5.7.21-1.el6.x86_64.rpm 
mysql-community-embedded-5.7.21-1.el6.x86_64.rpm      
mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm
mysql-community-common-5.7.21-1.el6.x86_64.rpm  
mysql-community-embedded-devel-5.7.21-1.el6.x86_64.rpm 
mysql-community-server-5.7.21-1.el6.x86_64.rpm
mysql-community-devel-5.7.21-1.el6.x86_64.rpm   
mysql-community-libs-5.7.21-1.el6.x86_64.rpm            
mysql-community-test-5.7.21-1.el6.x86_64.rpm

按照以下顺序进行安装,因为它们之间存在依赖关系
common --> libs --> clients --> server

$ rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm

安装时抛错 --force --nodeps 完美解决 原因:这是由于yum安装了旧版本的GPG keys造成的

参考地址: https://www.cnblogs.com/royfans/p/7243641.html

$ rpm -ivh mysql-community-libs-compat-5.7.21-1.el6.x86_64.rpm --force --nodeps
$ rpm -ivh mysql-community-client-5.7.21-1.el6.x86_64.rpm --force --nodeps
$ rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm --force --nodeps
检查安装
$ which mysql
/usr/bin/mysql
$ mysql -V
mysql  Ver 14.14 Distrib 5.7.21, for Linux (x86_64) using  EditLine wrapper
启动mysql服务
$ /etc/init.d/mysqld start
Initializing MySQL database:  
                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

$  ps -aux |grep mysql
root     24518  0.0  0.0 106216  1568 pts/1    S    01:22   0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql
mysql    24712  2.4  9.0 1171424 173212 pts/1  Sl   01:22   0:00 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock
root     24755  0.0  0.0 103320   888 pts/1    S+   01:22   0:00 grep mysql

修改Mysql 密码

查看临时密码

$ grep password /var/log/mysqld.log
2018-03-19T17:22:19.429944Z 1 [Note] A temporary password is generated for root@localhost: hqhY9>D+YvYZ
$ mysql -h root -p 
set password = password("Mysql_123456");

创建mysql 用户数据目录

$ groupadd mysql
$ useradd -s /sbin/nologin -g mysql mysql

创建data目录和mysql-files目录,并修改权限

$ mkdir -p /usr/local/mysql/data
$ mkdir -p /usr/local/mysql/mysql-files
$ chown -R root:mysql /usr/local/mysql
$ chown -R mysql:mysql /usr/local/mysql/data
$ chown -R mysql:mysql /usr/local/mysql/mysql-files

Supervisor

(参考文献:http://blog.csdn.net/xyang81/article/details/51555473)

安装python包管理工具(easy_install)

easy_install是setuptools包里带的一个命令,使用easy_install实际上是在调用setuptools来完成安装模块的工作,所以安装setuptools即可。

$ wget --no-check-certificate https://bootstrap.pypa.io/ez_setup.py -O - | sudo python

安装supervisor

$ easy_install supervisor

运行echo_supervisord_conf程序生成supervisor的初始化配置文件详情查看:
http://supervisord.org/configuration.html

$  mkdir /etc/supervisor
$  echo_supervisord_conf > /etc/supervisor/supervisord.conf

启动Supervisor服务

$ supervisord -c /etc/supervisor/supervisord.conf

PHP

下载最新版本 http://php.net/get/php-7.2.3.tar.gz/from/this/mirror
下载5.6版本 http://cn2.php.net/get/php-5.6.34.tar.gz/from/this/mirror

$ tar zxf php-7.2.3.tar.gz
$ cd php-7.2.3
$ wget -c http://cn2.php.net/get/php-5.6.34.tar.gz/from/this/mirror -O php-5.tar.gz
--2018-03-22 00:27:43--  http://cn2.php.net/get/php-5.6.34.tar.gz/from/this/mirror
Resolving cn2.php.net... 123.125.23.168, 123.125.23.169, 123.125.23.172, ...
Connecting to cn2.php.net|123.125.23.168|:80... connected.
HTTP request sent, awaiting response... 302 Found
Location: http://cn2.php.net/distributions/php-5.6.34.tar.gz [following]
--2018-03-22 00:27:43--  http://cn2.php.net/distributions/php-5.6.34.tar.gz
Connecting to cn2.php.net|123.125.23.168|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19294951 (18M) [application/x-gzip]
Saving to: “php-5.tar.gz”

100%[=================================================>] 19,294,951  2.44M/s   in 6.8s    

2018-03-22 00:27:50 (2.71 MB/s) - “php-5.tar.gz” saved [19294951/19294951
$ tar zxf php-5.tar.gz

安装 libmcrypt

$ wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
$ tar xf libmcrypt-2.5.7.tar.gz
$ cd libmcrypt-2.5.7
$ ./configure
$ make && make install
异常:configure: WARNING: unrecognized options: --with-mcrypt php7.2 不支持以上三个选项,删掉即可

解决安装问题: libxml2 configure: error: xml2-config not found. Please check your libxml2 installation.

 $ wget ftp://xmlsoft.org/libxml2/libxml2-2.9.1.tar.gz
 $ tar zxf libxml2-2.9.1.tar.gz
 $ cd libxml2-2.9.1
 $ ./configure
 $ make && make install

创建目录

$ mkdir -p /usr/local/php7
$ mkdir -p /usr/local/php5

安装php7

$ ./configure  --prefix=/usr/local/php7/ --with-config-file-path=/usr/local/php7/etc \
 --with-config-file-scan-dir=/usr/local/php7/etc/conf.d --enable-fpm --with-fpm-user=www \
 --with-fpm-group=www --enable-soap --with-openssl --with-openssl-dir --with-pcre-regex \
 --with-zlib --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom \
 --enable-exif --with-pcre-dir --enable-ftp --with-gd --with-jpeg-dir --with-png-dir \
 --with-freetype-dir --with-gettext --with-gmp --with-mhash --enable-mbstring --with-libmbfl \
 --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-readline --enable-session \
 --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem \
 --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd \ 
 --with-mysqli --without-pear --enable-pcntl --enable-bcmath 
$ make && make install 

安装php5

$ ./configure  --prefix=/usr/local/php5/ --with-config-file-path=/usr/local/php5/etc \
 --with-config-file-scan-dir=/usr/local/php5/etc/conf.d --enable-fpm --with-fpm-user=www \
 --with-fpm-group=www --enable-soap --with-openssl --with-openssl-dir --with-mcrypt \
 --with-pcre-regex --with-zlib --with-iconv --with-bz2 --enable-calendar --with-curl \
 --with-cdb --enable-dom --enable-exif --with-pcre-dir --enable-ftp --with-gd --with-jpeg-dir \
 --with-png-dir --with-freetype-dir --with-gettext --with-gmp --with-mhash --enable-mbstring \
 --with-libmbfl --with-onig --enable-pdo --with-pdo-mysql --with-zlib-dir --with-readline \
 --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg \
 --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip \
 --enable-mysqlnd --with-mysqli --without-pear --enable-pcntl

安装php扩展

redis扩展

 $ wget http://pecl.php.net/get/redis-4.0.0.tgz
 $ tar xf redis-4.0.0.tgz

 $ cd redis-4.0.0
 $  /usr/local/php7/bin/phpize
 $ ./configure  --with-php-config=/usr/local/php7/bin/php-config
 $ make && make install
 $ make clean
 $ /usr/local/php5/bin/phpize
 $ ./configure  --with-php-config=/usr/local/php5/bin/php-config
 $ make && make install

mongodb扩展

$ tar xf mongodb-1.4.2.tgz
$ cd mongodb-1.4.2
$ /usr/local/php7/bin/phpize
$ ./configure  --with-php-config=/usr/local/php7/bin/php-config
$  make && make install
$  make clean 
$  ./configure  --with-php-config=/usr/local/php5/bin/php-config
$  make && make install

swoole 扩展

$ wget http://pecl.php.net/get/swoole-1.10.2.tgz
$ tar xf swoole-1.10.2.tgz
$ cd swoole-1.10.2
$ /usr/local/php7/bin/phpize
$ ./configure  --with-php-config=/usr/local/php7/bin/php-config
$  make && make install
$  make clean 
$  ./configure  --with-php-config=/usr/local/php5/bin/php-config
$  make && make install

Yac 扩展 (php7)

$ wget http://pecl.php.net/get/yac-2.0.2.tgz
$ tar xf yac-2.0.2.tgz
$ cd yac-2.0.2
$ /usr/local/php7/bin/phpize
$ ./configure  --with-php-config=/usr/local/php7/bin/php-config
$  make && make install

Yar 扩展 (php7)

$  wget http://pecl.php.net/get/yar-2.0.4.tgz
$ tar xf yar-2.0.4.tgz
$ cd yar-2.0.4
$ /usr/local/php7/bin/phpize
$ ./configure  --with-php-config=/usr/local/php7/bin/php-config
$  make && make install

Yaf扩展 (PHP7)

$ wget http://pecl.php.net/get/yaf-3.0.6.tgz
$ tar xf yaf-3.0.6.taz
$ cd yaf-3.0.6
$ /usr/local/php7/bin/phpize
$ ./configure  --with-php-config=/usr/local/php7/bin/php-config
$  make && make install

加载PHP配置

extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/mongodb.so
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/redis.so
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/swoole.so
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/yac.so
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/yaf.so
extension=/usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/yar.so

启用php-fpm

#优化php-fpm配置后 检测配置  dynamic 模式 使用socket方式连接

[root@centos sbin]# /usr/local/php7/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php7/etc/php-fpm.conf -t
[08-Apr-2018 15:54:10] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful

[root@centos sbin]# /usr/local/php7/sbin/php-fpm -c /usr/local/php7/etc/php.ini -y /usr/local/php7/etc/php-fpm.conf 
[root@centos sbin]# ps -ef |grep php-fpm

...... 启了50个进程

php-fpm 加入 service 服务

1)、设置php-fpm.conf,将;pid = run/php-fpm.pid前面分号去掉
2)、将解压后的php文件夹下的init.d.php-fpm拷贝到/etc/init.d/php-fpm
$ cp /usr/local/src/php7/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
3)、将解压后的php文件夹下的init.d.php-fpm拷贝到/etc/init.d/php-fpm
4)、修改 php-fpm 文件

$ php_fpm_BIN=@sbindir@/php-fpm
$ php_fpm_CONF=@sysconfdir@/php-fpm.conf
$ php_fpm_PID=@localstatedir@/run/php-fpm.pid

改成

$ php_fpm_BIN=/usr/local/php7/sbin/php-fpm
$ php_fpm_CONF=/usr/local/php7/etc/php-fpm.conf
$ php_fpm_PID=/usr/local/php7/var/run/php-fpm.pid

5)、执行

$ chmod +x /etc/init.d/php-fpm
$ chkconfig --add php-fpm
$ chkconfig php-fpm on
$ service php-fpm status
    php-fpm (pid 814) is running...

以后可以使用如下命令管理php-fpm

$ service php-fpm start
$ service php-fpm stop
$ service php-fpm restart
$ service php-fpm reload

安装Golang

参考地址:
Golang下载 : https://golangtc.com/download
下载太慢了 我用的迅雷 然后上传的文件

$ cd /usr/local/
$ wget https://golangtc.com/static/go/1.9.2/go1.9.2.linux-amd64.tar.gz
$ tar xf go1.9.2.linux-amd64.tar.gz
$ mkdir -p /usr/local/gopackage
$ sudo vim /etc/profile
export GOROOT=/usr/local/go
export GOPATH=/usr/local/gopackage
export PATH=$PATH:$GOROOT/bin:$GOPATH/bin

环境变量生效

$ source /etc/profile

安装成功

$ go version
go version go1.9.2 linux/amd64

安装NetCat

$ wget  https://sourceforge.net/projects/netcat/files/netcat/0.7.1/netcat-0.7.1.tar.gz
$ tar -zxvf netcat-0.7.1.tar.gz -C /usr/local
$ cd /usr/local
$ mv netcat-0.7.1 netcat
$ cd /usr/local/netcat
$ ./configure
$ make && make install    
$ vim /etc/profile
    export NETCAT_HOME=/usr/local/netcat
    export PATH=$PATH:$NETCAT_HOME/bin
$ source /etc/profile

安装Git

$ yum install -y curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel
$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.16.3.tar.gz

$ tar xf git-2.16.3.tar.gz

$ cd git-2.16.3
$ autoconf
$ ./configure
$ make
$ sudo make install

异常处理

usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale'
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [perl.mak] Error 2

make: *** [perl/perl.mak] Error 2

--------------下面是解决方法--------------------------------------------------------

$ yum install perl-ExtUtils-MakeMaker package

安装MongoDB

官网:https://www.mongodb.com/download-center

$ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.6.3.tgz
$ tar xf mongodb-linux-x86_64-rhel62-3.6.3.tgz
$  mv mongodb-linux-x86_64-rhel62-3.6.3 /usr/local/mongo
$ sudo vim /etc/profile 
    export MONGOROOT=/usr/local/mongo
    export PATH=$PATH:$MONGOROOT/bin
# 环境变量生效
$ source /etc/profile
$ which mongo
  /usr/local/mongo/bin/mongo

开启防火墙

$ iptables -A INPUT -p tcp -m tcp --dport 27017 -j ACCEPT

守护进程且不授权 --auth

$ mongod --dbpath=/usr/local/mongo/data --logpath=/usr/local/mongo/log/mongodb.log --fork

$ netstat -tunpl
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 127.0.0.1:27017             0.0.0.0:*                   LISTEN      32268/mongod        
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      27532/mysqld        
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      2064/nginx          
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      4971/sshd           
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      1215/master
$ mongo 
use leanote
    db.createUser({user:"libenfu01",pwd:"lbf2131.",roles: [ "readWrite", "dbAdmin" ]})
    Successfully added user: { "user" : "libenfu", "roles" : [ "readWrite", "dbAdmin" ] }

安装 Leanote (依赖go git)

参考文献: https://www.idaybreak.com/install-leanote-server.html

$ go get github.com/revel/cmd/revel
$ wget https://github.com/leanote/leanote-all/archive/master.zip
$ unzip leanote-all-master.zip
$ mv ./leanote-all-master/src /usr/local/gopackage

导入初始数据

$ mongorestore -h localhost -d leanote --dir /usr/local/gopackage/src/github.com/leanote/leanote/mongodb_backup/leanote_install_data


$ mongo
$ show dbs;
    admin    0.000GB
    config   0.000GB
    leanote  0.001GB
    local    0.000GB
$ use leanote
       switched to db leanote
$ show collections
    albums
    attachs
    blog_comments
    blog_likes
    blog_singles
    configs
    email_logs
    files
    find_pwds
    group_users
    groups
    has_share_notes
    leanote.ShareNotes
    leanote.has_share_notes
    note_content_histories
    note_contents
    note_images
    note_tags
    notebooks
    notes
    reports
    sessions
    share_notebooks
    share_notes
    suggestions
    tag_count
    tags
    themes
    tokens
    traffics
    user_blogs
    users
>

试运行 leanote

cd /usr/local/gopackage/src/github.com/leanote/leanote/bin

配置

vi app.conf
# 访问端口 可以自定义
http.port=8080
# 访问域名
site.url=http://
# 管理员用户名(默认用户名admin,密码abc123)
adminUsername=admin
# MongoDB 数据库配置
db.host=127.0.0.1
db.port=27017
db.dbname=leanote
db.username= #自定义数据库帐户
db.password= #自定义数据库帐户密码
mongodb://root:root123@localhost:27017/leanote
# app密钥 必须要自己修改 随便改成任意大小写字母加数字组合
app.secret=OIJiokioHoIOHUY072893bhJHui765GHjkgjJK8989GVghUIY788

安装 apache 组件 (ab, htpasswd)

yum install httpd-tools

Python3.6 安装

$ wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
$ tar zxf Python-3.6.5.tgz 
$ cd Python-3.6.5
$ ./configure --prefix=/usr/local/python36 
$ make && make install
$ ln -s /usr/local/python36/bin/python3.6 /usr/bin/python

Python安装常见问题(1):zipimport.ZipImportError: can't decompress data

Contos 7 Docker 推送到 Docker Hub

引言

Docker Hub 是一个广泛使用的 Docker 镜像仓库,它提供了公共和私有的镜像托管服务。在使用 Contos 7 操作系统上的 Docker 容器时,你可能希望将你的自定义镜像推送到 Docker Hub 上,以便与他人共享和使用。本文将介绍如何在 Contos 7 上配置 Docker,并将自定义的镜像推送到 Docker Hub。

步骤

1. 安装 Docker

首先,你需要在 Contos 7 操作系统上安装 Docker。执行以下命令来安装 Docker:

sudo yum install docker -y

2. 启动 Docker 服务

安装完成后,启动 Docker 服务:

sudo systemctl start docker

3. 创建 Docker Hub 账号

如果你还没有 Docker Hub 账号,请在 Docker Hub 网站(https://hub.docker.com/)上注册一个账号。

4. 登录 Docker Hub

通过以下命令使用你的 Docker Hub 账号登录到 Docker:

docker login

你将被提示输入你的 Docker Hub 用户名和密码。

5. 打标签和推送镜像

在推送镜像之前,你需要为你的镜像打上标签。首先,使用以下命令查找你想要推送的镜像的 ID:

docker images

然后,使用以下命令为镜像打标签:

docker tag <image-id> <docker-hub-username>/<repository-name>:<tag>

<image-id> 替换为你找到的镜像 ID,<docker-hub-username> 替换为你的 Docker Hub 用户名,<repository-name> 替换为你想要创建的仓库名称,<tag> 替换为你想要为镜像指定的标签。

最后,使用以下命令将镜像推送到 Docker Hub:

docker push <docker-hub-username>/<repository-name>:<tag>

6. 验证镜像是否推送成功

在推送完成后,你可以在 Docker Hub 网站上查看你的镜像。登录到 Docker Hub,导航到你的仓库,你应该能够看到刚刚推送的镜像。

结论

通过按照上述步骤,在 Contos 7 上配置 Docker,并将自定义的镜像推送到 Docker Hub,你可以方便地与他人共享和使用你的镜像。Docker Hub 提供了一个强大的平台,让你能够轻松地发布和管理你的镜像。现在你可以开始将你的自定义镜像推送到 Docker Hub,并与其他 Docker 用户共享你的作品了!

Contos 7 Docker 阿里镜像加速

引言

Docker 是一个流行的容器化平台,用于打包、部署和运行应用程序。在使用 Docker 进行镜像下载和推送时,有时可能会遇到下载速度慢的问题。为了解决这个问题,我们可以使用阿里云提供的镜像加速服务来提高 Docker 镜像的下载速度。本文将介绍如何在 Contos 7 操作系统上配置阿里镜像加速,以加快 Docker 镜像的下载。

步骤

1. 登录阿里云容器镜像服务

首先,登录阿里云容器镜像服务(https://cr.console.aliyun.com/)。如果没有阿里云账号,需要先注册一个账号。

2. 获取阿里镜像加速地址

在阿里云容器镜像服务页面,点击左侧导航栏中的「镜像加速器」,然后复制显示的镜像加速地址。这个地址将用于配置 Docker 的镜像加速器。

3. 配置 Docker 镜像加速器

在 Contos 7 操作系统上,打开终端并使用 root 权限编辑 /etc/docker/daemon.json 文件:

sudo vi /etc/docker/daemon.json

如果文件不存在,可以创建一个新文件。

在打开的文件中,添加以下内容:

{
  "registry-mirrors": ["<镜像加速地址>"]
}

<镜像加速地址> 替换为第二步中复制的阿里镜像加速地址。

保存并关闭文件。

4. 重启 Docker 服务

执行以下命令重启 Docker 服务,使配置生效:

sudo systemctl restart docker

5. 验证配置

执行以下命令验证 Docker 镜像加速器是否配置成功:

docker info

在输出的信息中,如果看到类似下面的内容,则表示配置成功:

Registry Mirrors:
  - <镜像加速地址>

结论

通过按照上述步骤,在 Contos 7 操作系统上配置阿里镜像加速,可以显著提高 Docker 镜像的下载速度。镜像加速服务通过在本地提供一个快速的镜像源,使得 Docker 镜像的下载变得更加快速和高效。这对于使用 Docker 进行开发和部署的用户来说是非常有用的。现在,您可以享受更快速的 Docker 镜像下载体验了!

karp

创建我自己的巨人