之所以要捣鼓这个，一方面是规划lua与redis交互后把redis与mysql的同步事务通过MQ发布出去。其他程序订阅该频道后去处理写入mysql的操作。另一方面，在实际情况中进程会遇到需要通过消息队列来处理各个环节间的延迟和阻塞带来的影响。MQ的集群可扩展性、跨语言开发也确实很吸引。在对比各个MQ平台后，对可靠性和成熟程度、各种语言的支持库和各种MQ协议的支持。最终选择rabbitMQ。Centos7 安装 rabbitmqyum安装法安装erlangwget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm yum localinstall erlang-19.0.4-1.el7.centos.x86_64.rpmwget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.9/rabbitmq-server-3.6.9-1.el7.noarch.rpm rpm --import https://www.rabbitmq.com/rabbitmq-release-signing-key.asc ###需要先导入key yum install rabbitmq-server-3.6.9-1.noarch.rpm启动rabbitmqsystemctl daemon-reload systemctl enable rabbitmq-server systemctl start rabbitmq-server.service若启动失败检测端口是否被占用4369 (epmd), 25672 (Erlang distribution)5672, 5671 (AMQP 0-9-1 without and with TLS)15672 (if management plugin is enabled)61613, 61614 (if STOMP is enabled)1883, 8883 (if MQTT is enabled)参考：http://www.rabbitmq.com/install-rpm.htmlRabbitMQ Server 配置复制一份完整的示例配置，只要把其中想要配置的部分注释去掉并根据自己的情况进行更改就可以了cp /usr/share/doc/rabbitmq-server-3.6.2/rabbitmq.config.example /etc/rabbitmq/rabbitmq.config vim /etc/rabbitmq/rabbitmq.config参考：http://www.rabbitmq.com/configure.html添加web管理插件rabbitmq-plugins enable rabbitmq_management配置主要在配置文件的rabbitmq_management部分进行添加，比如对web界面的端口和允许访问的IP进行限制{rabbitmq_management, [ {listener, [{port, 15671}, {ip, "127.0.0.1"} ] } ] },添加STOMP适配器rabbitmq-plugins enable rabbitmq_stomp配置方面可以修改,地址限制和端口还有默认用户等等{rabbitmq_stomp, [ {tcp_listeners, [{"127.0.0.1", 61613}] } ] },RabbitMQ 日志、用户、client日志目录 /var/log/rabbitmq默认virtual host与默认uservirtual host: /user:guestpasswd:guest默认用户只可在localhost上连至/且有全部权限添加用户命令rabbitmqctl add_user admin admin rabbitmqctl set_user_tags admin administratorSTOMP v1.2Stomp是一个简单的消息文本协议,它的设计核心理念就是简单与可用性，官方文档： http://stomp.github.io/stomp-specification-1.2.htmlrabbitmq安装了stomp适配器后支持该协议，下面先了解该协议的基本流程框架。先采用 centos 的netcat 进行调试yum install nc 1.CONNECT 建立连接当 Client 向 Server 发送一个CONNECT Frame，就向服务器发起了一个连接请求，此时服务器端返回一个CONNECTED Frame表示建立连接成功,还可以发起连接可以指定版本和登陆用户 CONNECT accept-version:1.2 login:guest passcode:guest host:/ ^@ #返回结果 ^@ CONNECTED server:RabbitMQ/3.6.2 session:session-lln_3mVKRWkDovu0CUQGxQ heart-beat:0,0 version:1.22.SEND 消息传递receipt 服务端收到返回receipt-idpersistent 是否持久化SEND destination:/topic/sync_mysql receipt:luaid1 app-id:luaresty delivery-mode:2 persistent:true content-type:json/application hello ^@ #返回结果 RECEIPT receipt-id:luaid1 3.DISCONNECT 断开连接receipt 服务端会返回同样的字符串进行确认DISCONNECT receipt:1004.SUBSCRIBE 订阅SUBSCRIBE id:python destination:/amq/queue/python_sync_mysql ack:client ^@5.ACK 确认当ack:client时，客户端收到服务端信息之后必须回复ACK帧。如果在收到客户端回复的ACK之前连接断开，服务端会认为这个消息没有被处理而改发给其他客户端。客户端回复的ACK会被当做累加的处理。这意味着对信息的确认操作不仅仅是确认了这单个的消息，还确认了这个订阅之前发送的所有消息（即接收到一个确认消息就会把之前的消息一起确认掉，批量操作）。如果客户端没有处理收到的消息，它应该回复一个NACK告诉服务端他没有处理该消息。ACK id:T_python@@session-RkbWBHO9WAlr_f1MoI58kw@@1 ^@6.UNSCUBSCRIBE 取消订阅UNSUBSCRIBE id:python ^@lua-resty-rabbitmqstomp环境部署好了，协议流程也了解了，可以使用lua的rabbitmq库来实验一下stomp协议。https://github.com/wingify/lua-resty-rabbitmqstomp分析其提供共的例子：local cjson = require "cjson" local rabbitmq = require "resty.rabbitmqstomp" --------CONNECT-------- local opts = { username = "guest", password = "guest", vhost = "/" } local mq, err = rabbitmq:new(opts) //输入用户名密码和虚拟主机名称创建一个对象 if not mq then return end mq:set_timeout(10000) local ok, err = mq:connect("127.0.0.1",61613) //建立连接 if not ok then return end --------CONNECT END-------- --------SEND-------- local msg = {key="value1", key2="value2"} local headers = {} headers["destination"] = "/exchange/test/binding" headers["receipt"] = "msg#1" headers["app-id"] = "luaresty" headers["persistent"] = "true" headers["content-type"] = "application/json" local ok, err = mq:send(cjson.encode(msg), headers) if not ok then return end ngx.log(ngx.INFO, "Published: " .. msg) --------SEND END-------- --------SUBSCRIBE-------- local headers = {} headers["destination"] = "/amq/queue/queuename" headers["persistent"] = "true" headers["id"] = "123" local ok, err = mq:subscribe(headers) if not ok then return end --------SUBSCRIBE END-------- --------RECEIVE-------- local data, err = mq:receive() if not data then return end ngx.log(ngx.INFO, "Consumed: " .. data) --------RECEIVE END-------- --------UNSUBSCRIBE-------- local headers = {} headers["persistent"] = "true" headers["id"] = "123" local ok, err = mq:unsubscribe(headers) --------UNSUBSCRIBE END-------- --------DISCONNECT-------- local ok, err = mq:set_keepalive(10000, 10000) if not ok then return end --------DISCONNECT END-------- 初步做了下二次封装，这里只是做了send的方法，订阅的目前lua还没用到local rabbitmq = require "resty.rabbitmqstomp" local _M = {} _M._VERSION = '0.01' local mt = { __index = _M } local msg_no = 1 function _M.new(self, opts) opts = opts or {} return setmetatable({ mq_host = opts.host or '127.0.0.1', mq_port = opts.port or 61613, mq_timeout = opts.timeout or 10000, mq_user = opts.username or 'guest', mq_password = opts.password or 'guest', mq_vhost = opts.vhost or "/"}, mt) end function _M.get_connect(self) local mq, err = rabbitmq:new({ username = self.mq_user, password = self.mq_password, vhost = self.mq_vhost }) if not mq then return false,err end mq:set_timeout(self.mq_timeout) local ok, err = mq:connect(self.mq_host,self.mq_port) if not ok then return false,err end return true,mq end function _M.send(self , destination, msg) local ret, client = self:get_connect() if not ret then return false,client end local send_receipt_id = "msgid"..msg_no local headers = {} headers["destination"] = destination headers["receipt"] = send_receipt_id headers["app-id"] = "luaresty" headers["persistent"] = "true" headers["content-type"] = "application/json" msg_no = msg_no + 1 local ok, err = client:send(msg, headers) if not ok then return false,err end local _,str_start = string.find(ok, "receipt%-id", 1) local str_end = string.find(ok, "\n\n", 1) if str_start == nil or str_end == nil then return false,"send receipt not receive" end local receipt_id = string.sub(ok, str_start + 2 ,str_end - 1) if receipt_id ~= send_receipt_id then return false,"receipt id not right" end local ok, err = client:set_keepalive(10000, 10000) return true,send_receipt_id end return _M
openresty 是一个基于 Nginx 与 Lua 的高性能 Web 平台，其内部集成了大量精良的 Lua 库、第三方模块以及大多数的依赖项。用于方便地搭建能够处理超高并发、扩展性极高的动态 Web 应用、Web 服务和动态网关。性能之高与具体内容就不贴了，官网介绍很详细了对我而言，我是觉得在nginx上加上这个lua的扩展来处理网关，路由和鉴权甚至加解密都是是非常合理的，这些工作在nginx就处理好，后端类似php程序等只管业务实现和界面展示，整个系统的架构也变得非常清晰。加上openresty 的性能还不是一般高的话就非常有可用性了。学习的第一步是搭建环境。以下教程是在centos上编译安装openresty，php，redis，mysql的全部过程编译前的准备工作//设置时区和NTP rm -rf /etc/localtime ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime yum install -y ntp ntpdate -u pool.ntp.org date //关闭selinux sed -i 's/^SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config //安装编译环境 cp /etc/yum.conf /etc/yum.conf.bak sed -i 's:exclude=.*:exclude=:g' /etc/yum.conf yum -y install wget flex patch bison unzip tar vim-minimal gettext gettext-devel unzip file screen yum -y install make cmake gcc gcc-c++ gcc-g77 yum -y install curl curl-devel libcurl libcurl-devel yum -y install kernel-devel gd gd-devel libtool-libs //一些依赖库 yum -y install libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel yum -y install libxml2 libxml2-devel libXpm-devel yum -y install glib2 glib2-devel yum -y install libevent libevent-devel yum -y install openssl openssl-devel net-tools yum -y install psmisc libc-client-devel yum -y install ca-certificates c-ares-devel libicu-devel yum -y install ncurses ncurses-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel yum -y install libxslt libxslt-devel bzip2 bzip2-devel yum -y install gmp-devel pspell-devel libcap diffutils yum -y install libtool autoconf zlib zlib-devel yum -y install readline-devel yum -y install pcre-devel还有几个需要编译安装的。这些依赖包很多都是为了添加一些扩展功能//上传安装libiconv-1.14.tar.gz 和相关补丁libiconv-glibc-2.16.patch tar xzvf libiconv-1.14.tar.gz cd libiconv-1.14 patch -p0 < ../patch/libiconv-glibc-2.16.patch ./configure --enable-static make && make install cd ../ //上传安装libmcrypt-2.5.8.tar.gz tar xzvf libmcrypt-2.5.8.tar.gz cd libmcrypt-2.5.8 ./configure make && make install /sbin/ldconfig cd libltdl/ ./configure --enable-ltdl-install make && make install ln -sf /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la ln -sf /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so ln -sf /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4 ln -sf /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8 ldconfig cd ../ cd ../ //上传安装mhash-0.9.9.9.tar.gz tar xzvf mhash-0.9.9.9.tar.gz cd mhash-0.9.9.9 ./configure make && make install ln -sf /usr/local/lib/libmhash.a /usr/lib/libmhash.a ln -sf /usr/local/lib/libmhash.la /usr/lib/libmhash.la ln -sf /usr/local/lib/libmhash.so /usr/lib/libmhash.so ln -sf /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2 ln -sf /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1 ldconfig cd ../ //上传安装mcrypt-2.6.8.tar.gz tar xzvf mcrypt-2.6.8.tar.gz cd mcrypt-2.6.8 ./configure make && make install cd ../ ---下面这几个centos7是不需要了 //上传安装autoconf-2.13.tar.gz tar xzvf autoconf-2.13.tar.gz cd autoconf-2.13 ./configure --prefix=/usr/local/autoconf-2.13 make && make install cd ../ //上传安装freetype-2.4.12.tar.gz tar xzvf freetype-2.4.12.tar.gz cd freetype-2.4.12 ./configure --prefix=/usr/local/freetype make && make install cat > /etc/ld.so.conf.d/freetype.conf<<EOF /usr/local/freetype/lib EOF ldconfig ln -sf /usr/local/freetype/include/freetype2 /usr/local/include ln -sf /usr/local/freetype/include/ft2build.h /usr/local/include //上传安装curl-7.42.1.tar.gz tar xzvf curl-7.42.1.tar.gz cd curl-7.42.1 ./configure --prefix=/usr/local/curl --enable-ares --without-nss --with-ssl make && make install ---上面这几个centos7是不需要了 安装这些依赖包后还需要做些设置ln -sf /usr/lib64/libpng.* /usr/lib/ ln -sf /usr/lib64/libjpeg.* /usr/lib/ ulimit -v unlimited echo "/lib" >> /etc/ld.so.conf echo "/usr/lib" >> /etc/ld.so.conf echo "/usr/lib64" >> /etc/ld.so.conf echo "/usr/local/lib" >> /etc/ld.so.conf ldconfig cat >>/etc/security/limits.conf<<eof * soft nproc 65535 * hard nproc 65535 * soft nofile 65535 * hard nofile 65535 eof echo "fs.file-max=65535" >> /etc/sysctl.conf接着就是安装配置openresty(版本1.9.7.4)groupadd www useradd -s /sbin/nologin -g www www tar xzvf openresty-1.9.7.4.tar.gz cd openresty-1.9.7.4 ./configure --with-luajit --user=www --group=www --with-http_stub_status_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-http_iconv_module //Centos6 需要 cd ../ tar xzvf pcre-8.36.tar.gz cd openresty-1.9.7.4 ./configure --with-luajit --user=www --group=www --with-http_stub_status_module --with-http_gzip_static_module --with-ipv6 --with-http_sub_module --with-http_iconv_module --with-pcre=../pcre-8.36 --with-pcre-jit //Centos6 需要 gmake gmake install cd ../ ln -sf /usr/local/openresty/nginx/sbin/nginx /usr/bin/nginx rm -f /usr/local/openresty/nginx/conf/nginx.conf cp conf/nginx.conf /usr/local/openresty/nginx/conf/nginx.conf cp conf/rewrite/dabr.conf /usr/local/openresty/nginx/conf/dabr.conf cp conf/rewrite/discuz.conf /usr/local/openresty/nginx/conf/discuz.conf cp conf/rewrite/sablog.conf /usr/local/openresty/nginx/conf/sablog.conf cp conf/rewrite/typecho.conf /usr/local/openresty/nginx/conf/typecho.conf cp conf/rewrite/typecho2.conf /usr/local/openresty/nginx/conf/typecho2.conf cp conf/rewrite/wordpress.conf /usr/local/openresty/nginx/conf/wordpress.conf cp conf/rewrite/discuzx.conf /usr/local/openresty/nginx/conf/discuzx.conf cp conf/rewrite/none.conf /usr/local/openresty/nginx/conf/none.conf cp conf/rewrite/wp2.conf /usr/local/openresty/nginx/conf/wp2.conf cp conf/rewrite/phpwind.conf /usr/local/openresty/nginx/conf/phpwind.conf cp conf/rewrite/shopex.conf /usr/local/openresty/nginx/conf/shopex.conf cp conf/rewrite/dedecms.conf /usr/local/openresty/nginx/conf/dedecms.conf cp conf/rewrite/drupal.conf /usr/local/openresty/nginx/conf/drupal.conf cp conf/rewrite/ecshop.conf /usr/local/openresty/nginx/conf/ecshop.conf cp conf/pathinfo.conf /usr/local/openresty/nginx/conf/pathinfo.conf cp conf/enable-php.conf /usr/local/openresty/nginx/conf/enable-php.conf cp conf/enable-php-pathinfo.conf /usr/local/openresty/nginx/conf/enable-php-pathinfo.conf cp conf/proxy-pass-php.conf /usr/local/openresty/nginx/conf/proxy-pass-php.conf cp conf/enable-ssl-example.conf /usr/local/openresty/nginx/conf/enable-ssl-example.conf mkdir -p /home/wwwroot/default chmod +w /home/wwwroot/default mkdir -p /home/wwwlogs chmod 777 /home/wwwlogs chown -R www:www /home/wwwroot/default mkdir /usr/local/openresty/nginx/conf/vhost cat >/home/wwwroot/default/.user.ini<<EOF open_basedir=/home/wwwroot/default:/tmp/:/proc/ EOF chmod 644 /home/wwwroot/default/.user.ini chattr +i /home/wwwroot/default/.user.ini cp conf/init.d/init.d.nginx /etc/init.d/nginx chmod +x /etc/init.d/nginx 安装配置php(版本7.0.4)tar xzvf php-7.0.4.tar.gz cd php-7.0.4 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-xsl make ZEND_EXTRA_LIBS='-liconv' make install ln -sf /usr/local/php/bin/php /usr/bin/php ln -sf /usr/local/php/bin/phpize /usr/bin/phpize ln -sf /usr/local/php/bin/pear /usr/bin/pear ln -sf /usr/local/php/bin/pecl /usr/bin/pecl ln -sf /usr/local/php/sbin/php-fpm /usr/bin/php-fpm mkdir -p /usr/local/php/etc cp php.ini-production /usr/local/php/etc/php.ini sed -i 's/post_max_size =.*/post_max_size = 50M/g' /usr/local/php/etc/php.ini sed -i 's/upload_max_filesize =.*/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini sed -i 's/;date.timezone =.*/date.timezone = PRC/g' /usr/local/php/etc/php.ini sed -i 's/short_open_tag =.*/short_open_tag = On/g' /usr/local/php/etc/php.ini sed -i 's/;cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini sed -i 's/max_execution_time =.*/max_execution_time = 300/g' /usr/local/php/etc/php.ini sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /usr/local/php/etc/php.ini pear config-set php_ini /usr/local/php/etc/php.ini pecl config-set php_ini /usr/local/php/etc/php.ini cat >>/usr/local/php/etc/php.ini<<EOF ;eaccelerator ;ionCube ;opcache [Zend ZendGuard Loader] ;php7 do not support zendguardloader @Sep.2015,after support you can uncomment the following line. ;zend_extension=/usr/local/zend/ZendGuardLoader.so ;zend_loader.enable=1 ;zend_loader.disable_licensing=0 ;zend_loader.obfuscation_level_support=3 ;zend_loader.license_path= ;xcache EOF mkdir -p /home/wwwroot/test chown -R www:www /home/wwwroot/test cp ../conf/ocp.php /home/wwwroot/test/ocp.php cat >/usr/local/php/etc/php-fpm.conf<<EOF [global] pid = /usr/local/php/var/run/php-fpm.pid error_log = /usr/local/php/var/log/php-fpm.log log_level = notice [www] listen = /tmp/php-cgi.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0666 user = www group = www pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 6 request_terminate_timeout = 100 request_slowlog_timeout = 0 slowlog = var/log/slow.log EOF cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm chmod +x /etc/init.d/php-fpm cat >/home/wwwroot/test/phpinfo.php<<eof <? phpinfo(); ?> eof tar zxf ../conf/p.tar.gz cp p.php /home/wwwroot/test/p.php cp ../conf/index.html /home/wwwroot/test/index.html cp ../conf/lnmp.gif /home/wwwroot/test/lnmp.gif tar zxf ../conf/phpMyAdmin-4.4.15.2-all-languages.tar.gz mv phpMyAdmin-4.4.15.2-all-languages /home/wwwroot/test/phpmyadmin cp ../conf/config.inc.php /home/wwwroot/test/phpmyadmin/config.inc.php mkdir /home/wwwroot/test/phpmyadmin/{upload,save} chmod 755 -R /home/wwwroot/test/phpmyadmin/ chown www:www -R /home/wwwroot/test/phpmyadmin/安装php的redis扩展unzip phpredis-php7.zip cd phpredis-php7 sed -i '/redis.so/d' /usr/local/php/etc/php.ini /usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make install sed -i '/the dl()/i\ extension = "redis.so"' /usr/local/php/etc/php.ini安装redis(版本3.0.7)tar xzvf redis-3.0.7.tar.gz cd redis-3.0.7 make PREFIX=/usr/local/redis install mkdir -p /usr/local/redis/etc/ cp redis.conf /usr/local/redis/etc/ sed -i 's/daemonize no/daemonize yes/g' /usr/local/redis/etc/redis.conf sed -i 's/^# bind 127.0.0.1/bind 127.0.0.1/g' /usr/local/redis/etc/redis.conf cp ../conf/init.d/init.d.redis /etc/init.d/redis chmod +x /etc/init.d/redis ln -s /usr/local/redis/bin/redis-cli /usr/local/bin/redis-cli ln -s /usr/local/redis/bin/redis-server /usr/local/bin/redis-server ln -s /usr/local/redis/bin/redis-benchmark /usr/local/bin/redis-benchmark ln -s /usr/local/redis/bin/redis-check-aof /usr/local/bin/redis-check-aof ln -s /usr/local/redis/bin/redis-check-dump /usr/local/bin/redis-check-dump ln -s /usr/local/redis/bin/redis-sentinel /usr/local/bin/redis-sentinel安装mysql(5.6.27)groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql screen -S mysql tar xzvf mysql-5.6.27.tar.gz cd mysql-5.6.27 patch -p1 < ../patch/mysql-openssl.patch cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 make && make install cat > /etc/my.cnf<<EOF [client] #password = your_password port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /usr/local/mysql/var skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M thread_cache_size = 8 query_cache_size = 8M tmp_table_size = 16M table_open_cache = 64 explicit_defaults_for_timestamp = true #skip-networking max_connections = 500 max_connect_errors = 100 open_files_limit = 65535 log-bin=mysql-bin binlog_format=mixed server-id = 1 expire_logs_days = 10 #loose-innodb-trx=0 #loose-innodb-locks=0 #loose-innodb-lock-waits=0 #loose-innodb-cmp=0 #loose-innodb-cmp-per-index=0 #loose-innodb-cmp-per-index-reset=0 #loose-innodb-cmp-reset=0 #loose-innodb-cmpmem=0 #loose-innodb-cmpmem-reset=0 #loose-innodb-buffer-page=0 #loose-innodb-buffer-page-lru=0 #loose-innodb-buffer-pool-stats=0 #loose-innodb-metrics=0 #loose-innodb-ft-default-stopword=0 #loose-innodb-ft-inserted=0 #loose-innodb-ft-deleted=0 #loose-innodb-ft-being-deleted=0 #loose-innodb-ft-config=0 #loose-innodb-ft-index-cache=0 #loose-innodb-ft-index-table=0 #loose-innodb-sys-tables=0 #loose-innodb-sys-tablestats=0 #loose-innodb-sys-indexes=0 #loose-innodb-sys-columns=0 #loose-innodb-sys-fields=0 #loose-innodb-sys-foreign=0 #loose-innodb-sys-foreign-cols=0 default_storage_engine = InnoDB #innodb_data_home_dir = /usr/local/mysql/var #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /usr/local/mysql/var #innodb_buffer_pool_size = 16M #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout EOF sed -i 's:^#innodb:innodb:g' /etc/my.cnf if [[ ${MemTotal} -gt 1024 && ${MemTotal} -lt 2048 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 32M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 128#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 768K#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 768K#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 8M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 16#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 16M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 32M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 128M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 32M#" /etc/my.cnf elif [[ ${MemTotal} -ge 2048 && ${MemTotal} -lt 4096 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 256#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 32M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 64M#" /etc/my.cnf elif [[ ${MemTotal} -ge 4096 && ${MemTotal} -lt 8192 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 128M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 512#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 2M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 2M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 32M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 64#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 64M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 512M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 128M#" /etc/my.cnf elif [[ ${MemTotal} -ge 8192 && ${MemTotal} -lt 16384 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 256M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 1024#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 4M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 4M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 64M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 128#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 128M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 128M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 1024M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 256M#" /etc/my.cnf elif [[ ${MemTotal} -ge 16384 && ${MemTotal} -lt 32768 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 512M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 2048#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 8M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 8M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 128M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 256#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 256M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 256M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 2048M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 512M#" /etc/my.cnf elif [[ ${MemTotal} -ge 32768 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 1024M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 4096#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 16M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 16M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 256M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 512#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 512M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 512M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 4096M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 1024M#" /etc/my.cnf fi mkdir -p /usr/local/mysql/var chown -R mysql:mysql /usr/local/mysql/var /usr/local/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql chgrp -R mysql /usr/local/mysql/. cp support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql cat > /etc/ld.so.conf.d/mysql.conf<<EOF /usr/local/mysql/lib /usr/local/lib EOF ldconfig ln -sf /usr/local/mysql/lib/mysql /usr/lib/mysql ln -sf /usr/local/mysql/include/mysql /usr/include/mysql ln -sf /usr/local/mysql/bin/mysql /usr/bin/mysql ln -sf /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump ln -sf /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk ln -sf /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe ln -sf /usr/local/mysql/bin/mysqlcheck /usr/bin/mysqlcheck 如果是安装5.7.9版本，按一下步骤groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql screen -S boost tar xzvf boost_1_59_0.tar.gz cd boost_1_59_0 ./bootstrap.sh ./b2 ./b2 install cd ../ tar xzvf mysql-5.7.9.tar.gz cd mysql-5.7.9 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8mb4 -DDEFAULT_COLLATION=utf8mb4_general_ci -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 make && make install cat > /etc/my.cnf<<EOF [client] #password = your_password port = 3306 socket = /tmp/mysql.sock [mysqld] port = 3306 socket = /tmp/mysql.sock datadir = /usr/local/mysql/var skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M thread_cache_size = 8 query_cache_size = 8M tmp_table_size = 16M table_open_cache = 64 explicit_defaults_for_timestamp = true #skip-networking max_connections = 500 max_connect_errors = 100 open_files_limit = 65535 log-bin=mysql-bin binlog_format=mixed server-id = 1 expire_logs_days = 10 #loose-innodb-trx=0 #loose-innodb-locks=0 #loose-innodb-lock-waits=0 #loose-innodb-cmp=0 #loose-innodb-cmp-per-index=0 #loose-innodb-cmp-per-index-reset=0 #loose-innodb-cmp-reset=0 #loose-innodb-cmpmem=0 #loose-innodb-cmpmem-reset=0 #loose-innodb-buffer-page=0 #loose-innodb-buffer-page-lru=0 #loose-innodb-buffer-pool-stats=0 #loose-innodb-metrics=0 #loose-innodb-ft-default-stopword=0 #loose-innodb-ft-inserted=0 #loose-innodb-ft-deleted=0 #loose-innodb-ft-being-deleted=0 #loose-innodb-ft-config=0 #loose-innodb-ft-index-cache=0 #loose-innodb-ft-index-table=0 #loose-innodb-sys-tables=0 #loose-innodb-sys-tablestats=0 #loose-innodb-sys-indexes=0 #loose-innodb-sys-columns=0 #loose-innodb-sys-fields=0 #loose-innodb-sys-foreign=0 #loose-innodb-sys-foreign-cols=0 default_storage_engine = InnoDB #innodb_data_home_dir = /usr/local/mysql/var #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /usr/local/mysql/var #innodb_buffer_pool_size = 16M #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer_size = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout EOF sed -i 's:^#innodb:innodb:g' /etc/my.cnf if [[ ${MemTotal} -gt 1024 && ${MemTotal} -lt 2048 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 32M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 128#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 768K#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 768K#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 8M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 16#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 16M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 32M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 128M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 32M#" /etc/my.cnf elif [[ ${MemTotal} -ge 2048 && ${MemTotal} -lt 4096 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 64M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 256#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 1M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 1M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 16M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 32#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 32M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 256M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 64M#" /etc/my.cnf elif [[ ${MemTotal} -ge 4096 && ${MemTotal} -lt 8192 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 128M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 512#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 2M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 2M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 32M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 64#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 64M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 64M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 512M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 128M#" /etc/my.cnf elif [[ ${MemTotal} -ge 8192 && ${MemTotal} -lt 16384 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 256M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 1024#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 4M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 4M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 64M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 128#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 128M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 128M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 1024M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 256M#" /etc/my.cnf elif [[ ${MemTotal} -ge 16384 && ${MemTotal} -lt 32768 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 512M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 2048#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 8M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 8M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 128M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 256#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 256M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 256M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 2048M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 512M#" /etc/my.cnf elif [[ ${MemTotal} -ge 32768 ]]; then sed -i "s#^key_buffer_size.*#key_buffer_size = 1024M#" /etc/my.cnf sed -i "s#^table_open_cache.*#table_open_cache = 4096#" /etc/my.cnf sed -i "s#^sort_buffer_size.*#sort_buffer_size = 16M#" /etc/my.cnf sed -i "s#^read_buffer_size.*#read_buffer_size = 16M#" /etc/my.cnf sed -i "s#^myisam_sort_buffer_size.*#myisam_sort_buffer_size = 256M#" /etc/my.cnf sed -i "s#^thread_cache_size.*#thread_cache_size = 512#" /etc/my.cnf sed -i "s#^query_cache_size.*#query_cache_size = 512M#" /etc/my.cnf sed -i "s#^tmp_table_size.*#tmp_table_size = 512M#" /etc/my.cnf sed -i "s#^innodb_buffer_pool_size.*#innodb_buffer_pool_size = 4096M#" /etc/my.cnf sed -i "s#^innodb_log_file_size.*#innodb_log_file_size = 1024M#" /etc/my.cnf fi mkdir -p /usr/local/mysql/var chown -R mysql:mysql /usr/local/mysql/var /usr/local/mysql/bin/mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql chgrp -R mysql /usr/local/mysql/. cp support-files/mysql.server /etc/init.d/mysql chmod 755 /etc/init.d/mysql cat > /etc/ld.so.conf.d/mysql.conf<<EOF /usr/local/mysql/lib /usr/local/lib EOF ldconfig ln -sf /usr/local/mysql/lib/mysql /usr/lib/mysql ln -sf /usr/local/mysql/include/mysql /usr/include/mysql ln -sf /usr/local/mysql/bin/mysql /usr/bin/mysql ln -sf /usr/local/mysql/bin/mysqldump /usr/bin/mysqldump ln -sf /usr/local/mysql/bin/myisamchk /usr/bin/myisamchk ln -sf /usr/local/mysql/bin/mysqld_safe /usr/bin/mysqld_safe ln -sf /usr/local/mysql/bin/mysqlcheck /usr/bin/mysqlcheck mysql安装后，设置远程登陆/usr/local/mysql/bin/mysqladmin -u root password "yourpassword" mysql -u root -p yourpassword DELETE FROM mysql.user WHERE User=''; DROP USER ''@'%'; DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1'); DROP DATABASE test; grant all privileges on *.* to 'root'@'%' identified by 'yourpassword' with grant option; flush privileges;开机自动启动，防火墙设置等chkconfig redis on chkconfig nginx on chkconfig php-fpm on chkconfig mysql on /sbin/iptables -I INPUT 1 -i lo -j ACCEPT /sbin/iptables -I INPUT 2 -m state --state ESTABLISHED,RELATED -j ACCEPT /sbin/iptables -I INPUT 3 -p tcp --dport 22 -j ACCEPT /sbin/iptables -I INPUT 4 -p tcp --dport 80 -j ACCEPT /sbin/iptables -I INPUT 5 -p tcp --dport 3306 -j DROP /sbin/iptables -I INPUT 6 -p icmp -m icmp --icmp-type 8 -j ACCEPT /sbin/iptables -A INPUT -p tcp --dport 6379 -j DROP service iptables save systemctl stop firewalld systemctl disable firewalld安装告一段落，安装包连接(包括依赖包、安装包和配置文件)：https://yunpan.cn/OcRYC8xdMAyVIe 访问密码 c406接下来就看教程和实践了，教程首推OpenResty最佳实践。
要在windows上做迅雷远程，可以很简单，就安装个迅雷客户端就好了。作为设备添加进去。那么一样可以通过手机迅雷或者在网页版远程下载去添加下载任务。但是，问题是这样是无法通过另一台电脑使用PC端客户端添加远程下载任务的。因为迅雷账号是无法多地登陆的。为了解决这个蛋疼的问题，我还是决定在虚拟机上安装Centos，再通过Xware运行迅雷远程。安装Hyper-V在windows server 2012 R2 添加角色和功能安装Centos准备好Centos的IOS，新建虚拟机，虚拟机类型选旧的类型就好，新的Centos7以上才支持。安装基本按默认，添加提个虚拟交换机和正常安装Centos基本一样，然后换下更新源mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo yum update挂载windows磁盘文件夹本来想通过nfs v4挂载windows下的NFS共享文件夹，结果还是失败，最终用回samba，也省得麻烦去搞NFS安装cifs工具并进行挂载yum install cifs-utils mount -t cifs //xx.xx.xx.xx/centos /mnt -o uid=1000,gid=1000,username=xxx,password=xxx,codepage=cp936,iocharset=utf8设置开机自动挂载 vim /etc/fstab//xx.xx.xx.xx/centos /mnt cifs uid=1000,gid=1000,username=xx,password=xxx,codepage=cp936,iocharset=utf8 0 2运行Xware解压Xware1.0.31_x86_32_glibc.zip,并运行就可以了。./portal运行后返回code，去绑定就可以了后续结果迅雷远程是运行起来了，但提交总是未知失败。百度了许久，好像挂载cifs都不能成功。只好弄回nfs，仔细查了下资料，server 2012 R2 自带的nfs服务是V3，而且缺少对utf8的支持。只好还是安装HaneWin，只能用administrator用户安装，安装后设置只用V3和添加UTF8支持并添加共享文件夹Centos上挂载NFSyum install nfs-utils mount -t nfs -o nolock 10.0.0.200:/NFS/ /nfs设置开机自动挂载，编辑/etc/fstab在末尾添加xx.xx.xx.xx:/nfs /nfs nfs auto,noatime,nolock,bg,nfsvers=3,intr,tcp,actimeo=1800 0 0设置开机自动启动xware，编辑/etc/rc.d/rc.local，添加/home/xware/portal
原本想把迅雷离线在路由上做，但我不希望直接插存储设备到路由，所以下载路径问题困扰了许久。既要在liunx下可以挂载，又希望下载后windows也可以共享出来。最终的尝试是用windows通过NFS或samba共享文件夹，linux下进行挂载，但都存在问题。路由下安装迅雷离线是非常简单的，在迅雷论坛下载对应版本的xware，比如newifi是Xware1.0.31_mipsel_32_uclibc.zip，而centos是Xware1.0.31_x86_32_glibc.zip下载后解压运行就文件夹中的profil就可以了。可能会有提示需要什么依赖库，看提示安装就好了。我可能之前已经有安装过cpp所以是可以正常运行的第一次运行会返回code，可以在迅雷远程进行绑定了。如果是在路由器上直接插存储设备，那完全没问题了，可是我是需要下载到windows server的磁盘上。 于是我在windows server安装了NFS服务端，在newifi上安装客户端和进行挂载opkg install nfs-utils kmod-fs-nfs kmod-fs-nfs-common mount -t nfs -o nolock XX:XX:XX:XX:/NFS/ /nfs这样是可以挂载，但问题是这样是NFS V3的，在linux下保存的编码是UTF-8,而windows下服务端没有这种编译可选。所以要么要安装第三方软件，不然就会两边各自保存的中文互相看到都是乱码的。听说NFS V4就可以解决这个问题。我有尝试用-t nfs4，但提示协议不支持，也搞不清楚是windows服务端不支持（听说2012R2的NFS服务端是支持NFSV4.1的）还是pandorabox不支持（但明明已经有mount.nfs4的命令）。反正一头雾水也就罢了。那我通samba就是了，既然潘多拉支持做samba服务端，那做客户端应该也没问题吧mount -t cifs -o username="用户名",password="密码" //主机地址/共享文件夹 /挂载点结果提示没有该device，而且默认源里也没有cifs的相关软件包安装。好吧我投降。就这样，折腾不下去了，而且其实Xware占用内存和CPU对于路由来说是比较高的，也就罢了。还是在windows 上做迅雷远程吧
这款叫Newifi的路由，貌似换了几个大老板。之前叫如意云，然后又和百度勾搭上，现在是联想旗下。不过貌似一直都是一家叫谛听科技的公司。不过这款newifi mini Y1就硬件配置来看性价比还是很无敌的联发科的 MT7620AMT7612E 2T2R千兆无线芯片，双频WIFI16M的ROM128M内存带一个USB2.0，两个LAN和一个WAN口京东降价79元入手。试用官方系统官方的系统几个版本都有很大差异，最低的版本很多应用都已经失效了，刷了2.1版本的试用了下。这个版本是最接近PandoraBox的，特别是高级设置模式，基本就是潘多拉了（其实官方系统也就是潘多拉改的）。3.0版本的刚更新不久，应用很多还不支持，界面好看了，但是貌似没有高级设置模式，只能通过SSH进行一些高级配置。官方系统的最大问题就是应用都要装到外接存储设备上。那也确实16M的rom能装几个luci的应用。所以都是插上U盘就自动在U盘分个120M的分区，挂载opt目录去放这些应用。二来，系统自带的应用我是不需要的。比如samba共享，视频监控等。而且很搞笑的是，安装其他应用要外接存储设备，那视频监控要插USB摄像头，这样就非要接个USB HUB才可以了。我希望这个路由就单单做路由好了，加个花生壳(内网)的客户端，顶多以后可能还需要用它来做打印机共享或者加个VPN功能。刚开始有考虑迅雷远程，折腾了两天，因为种种问题和考虑就改变想法了。毕竟我有一台windows在做NAS+HTPC了，其他很多功能还是不希望加重这个小路由的负担。刷机步骤我没有去刷不死uboot，始终觉得uboot还是不要乱动。uboot对性能也没什么影响，而且我也不是刷路由爱好者，我只是希望把路由按我的需求进行改造而已，基本就刷这么一两次。直接用官方自带的uboot就可以刷潘多拉了。上电前按紧复位键，再上电，等到电源灯长亮和USB，2.4G灯闪亮就可以放开复位键，这个时候路由进进入uboot了。电脑网线连接路由，电脑IP设置192.168.1.X，浏览器访问192.168.1.1，选择潘多拉的bin文件，我刷的是PandoraBox-ralink-mt7620-y1-squashfs-sysupgrade-r1024-20150608.bin。然后点击恢复，就开始刷机了。等待刷完，路由会重启。这时候电脑IP改为自动获取，再浏览器访问192.168.1.1就进入路由管理页面。初始密码admin。进入后台把不需要的服务停掉，比如samba，ftp。把该设置的设置，无线SSID名称，密码，上网设置等。弄好后就可以正常使用了。安装花生壳内网版潘多拉已经有DDNS的功能，但是现在很多时候（就像我贪便宜用长宽），我们pppoe获取到的并不是公网地址，而是上一级路由分配的地址。那传统的DDNS是无法使用的。花生壳内网版官方是没有发布支持openwrt的版本的。我是从官方提供给newifi的应用安装包xipk里面解压出ipk再解压出相关的可执行文件，并自己写了脚本来运行的。先要在软件包安装c++依赖库，可以直接在后台进行查找安装。也可以SSH进行安装opkg update opkg install libstdcpp把 oraynewph.zip 在linux下通过scp传到路由tmp目录下。或者其实也可以先不关潘多拉的ftp，通过ftp上传也可以。通过SSH连接路由。在根目录下创建opt/app目录，解压oraynewph.tar.gztar zxvf oraynewph.tar.gz把整个oraynewph文件夹移动到/opt/app。第一次运行和查看序列号sh ./oraynewph.sh start sh ./oraynewph.sh status然后就可以去官网（http://b.oray.com/ SN就刚才查看的序号，默认密码admin），登陆后设置新密码和绑定你自己的花生壳账号。设置好再查看状态已经是绑定状态了。添加开机自动启动进入oraynewph文件夹后，把oray2nat移动到/etc/init.d目录下，并给予777权限,再建立软连接到rc.dmv oray2nat /etc/init.d chmod 777 /etc/init.d/oray2nat ln -s /etc/init.d/oray2nat /etc/rc.d/S99oray2nat安装WOL远程唤醒可以通过后台查找软件包安装，也可以SSH进去安装opkg install etherwake安装好后，可以在SSH下输入命令进行唤醒，需要指定电脑所在局域网的接口：etherwake -i br-lan XX:XX:XX:XX:XX:XX定时重启直接在SSH下配置crontab就可以了,比如每天5点重启路由crontab -e 0 5 * * * /sbin/reboot crontab -lPS:重启方法有问题，会导致不断重启。原因：OPENWRT会在开机时检测/etc下最近修改过的一个文件的时间戳，并用这个时间戳来设定开机初始时间。如果reboot前刚好/etc下的文件发生过变化，开机后的时间设定就是reboot执行前的这个时间点这个时候系统还未通过ntp获得正确系统时间的话，就会造成不断重启循环发生。解决办法sleep 5touch /etc/bannerreboot可以把这个命令连起来执行，如：12 15 * * 2 sleep 5 && touch /etc/banner && reboot