负载高,自动重启mysql,apache

#!/bin/sh
# crontab: */3 * * * * /root/loadavg_restart_apache.sh >> /var/log/restart_apache.log
sync
sync
echo 3 > /proc/sys/vm/drop_caches
TOP_SYS_LOAD_NUM=5
SYS_LOAD_NUM=`uptime | awk ‘{print $(NF-2)}’ | sed ‘s/,//’`
echo $(date +”%y-%m-%d”) `uptime`
if [ `echo “$TOP_SYS_LOAD_NUM < $SYS_LOAD_NUM”|bc` -eq 1 ]
then
sync
echo “#0#” $(date +”%y-%m-%d %H:%M:%S”) “pkill httpd” `ps -ef | grep httpd | wc -l`
echo “#0#” $(date +”%y-%m-%d %H:%M:%S”) “pkill mysql” `ps -ef | grep mysql | wc -l`
service httpd stop
service mysql stop
sleep 8
pkill httpd
pkill mysql

sleep 8
for i in 1 2 3
do
if [ `pgrep mysql | wc -l` -le 0 ]
then
/sbin/service mysql start

sleep 30
echo “#1#” $(date +”%y-%m-%d %H:%M:%S”) “start mysql” `ps -ef | grep mysql | wc -l`

fi

if [ `pgrep httpd | wc -l` -le 0 ]
then

service httpd start

      service wdapache start

sleep 30

echo “#1#” $(date +”%y-%m-%d %H:%M:%S”) “start httpd” `ps -ef | grep httpd | wc -l`
fi

done
else
if [ `pgrep mysql | wc -l` -le 0 ]
then
/sbin/service mysql start

sleep 30
echo “#2#” $(date +”%y-%m-%d %H:%M:%S”) “start mysql” `ps -ef | grep mysql | wc -l`

fi

if [ `pgrep httpd | wc -l` -le 0 ]
then

service httpd start

 

sleep 30

echo “#2#” $(date +”%y-%m-%d %H:%M:%S”) “start httpd” `ps -ef | grep httpd | wc -l`
fi

fi

将以上文件,保存在 /root/loadavg_restart_apa_my.sh

然后在

crontab -e

添加

*/3 * * * * /root/loadavg_restart_apa_my.sh >> /var/log/restart_apa_my.log

*/3 ***** 表示3分钟,/root/loadavg_restart_apa_my.sh 你可以自定义。

评论

directadmin恢复

Step 1

Run System Backup on the old server.

Admin Tools >> System Backup

 

We will be backuping home directories and mysql db’s manually so Uncheck and unselect the following options on System Backup

Add user home directories to directory list below

Backup httpd data

Backup MySQL Databases

Check and Select

Backup DNS data

Backup Directories and Files listed below

All directories/files listed in bottom section of the System Backup

now click on the Run System Backup Now icon . The backup will be stored mostly in /home/backup ( it will depend upon how you have set it in DA )

Step 2

rsync the system backup to the Newserver.

[email protected]:~# rsync -avurz -e ssh –delete /home/backup [email protected]_IP:/home/backup

Step 3

On the Newserver restore the system backups one by one manually.

For example, for restoring your /etc/virtual directory,

[email protected]:~# cd /etc
[email protected]:~# tar xvzfp /home/backup/<backup_date>/custom/etc/virtual.tar.gz

Please check here for the complete paths and files used on a DirectAdmin system.

( Do take extra care while restoring /etc/passwd /etc/shadow /etc/group etc.. )

Step 4

Synchronise the home directory

[email protected]:~# rsync -avurz -e ssh –delete /home [email protected]_IP:/home

Step 5

Backup and restore the mysql DB’s

On Oldserver

[email protected]:~# cat /usr/local/directadmin/conf/mysql.conf

Get the da_admin password from the above file

[email protected]:~# mysqldump -u da_admin -p  –all-databases > /root/all_databases.sql

[email protected]:~# scp /root/all_databases.sql [email protected]_IP:/root

On Newserver

[email protected]:~# cat /usr/local/directadmin/conf/mysql.conf

[email protected]:~# mysql -u da_admin -p < /root/all_databases.sql

Step 6

Use the ipswap script to change the Oldserver IP’s

[email protected]:~# cd /usr/local/direactadmin/scripts/

[email protected]:~# ./ipswap.sh Oldserver_IP  Newserver_IP

Step 7

Update the nameservers to the Newserver IP’s.

Step 8

To resolve all the queries correctly to the new server . You will have to setup the multi server dns clustering on the new server

评论

密码保护:cpanel whm

这是一篇受密码保护的文章,您需要提供访问密码:

要查看留言请输入您的密码。

密码保护:SSH,Firefox和Putty实现 上网

这是一篇受密码保护的文章,您需要提供访问密码:

要查看留言请输入您的密码。

ovz

In a situation when a lot of disk space were freed on an in-ploop filesystem, use ploop balloon discard to optimize the ploop image size.

ploop balloon discard [–automount] [–to-free size] [–min-block min_size] [–defragDiskDescriptor.xml

Iteratively try to relocate and discard unused blocks from a ploop image, reducing its size.

Note that ploop device and its inner file system should be mounted. If not, one can use –automount option to automatically mount ploop for the duration of the operation.

Option –defrag can be used to run a filesystem defragmentation utility (currently e4defrag2 on ext4 only) before the main operation.

Option –to-free can be used to specify a maximum disk space to be freed. In other words, stop the process once freed space exceeded requested size. Default is 0, meaning to try to free as much space as possible.

Option –min-block can be used to specify a minimum size of an extent to free. The smallest possible extent is 1 cluster (currently 1 MB), one can specify higher value to speed up the whole discarding operation.

Note that the same functionality is available by means of vzctl compact command.

评论

whm cpanel php.ini

评论

密码保护:关于cpanel 编译php5.4

这是一篇受密码保护的文章,您需要提供访问密码:

要查看留言请输入您的密码。

HostMonster ssh 导入sql

HostMonster主机提供免费SSH,通过SSH导入/导出MySQL数据库还是比较方便的,具体步骤如下:

1. HostMonster主机导出MySQL数据库

下面的例子显示怎样导出一个MySQL数据库,经常将数据导出做个备份还是必要的,在命令行的操作步骤如下:

(1). mysqldump -u username -p database_name > FILE.sql
(2). 回车
(3). 提示输入密码
(4). 输入密码,回车.

其中username, password 和 database_name 就是MySQL数据库的用户名、密码 和 数据库名。文件FILE.sql就是HostMonster主机上MySQL数据库的备份,现在可以下载到本地来保存。

2. HostMonster主机导入MySQL数据库

上传MySQL数据库备份文件(比如上面导出的文件FILE.sql)到HostMonster服务器上,然后执行如下命令:

(1). mysql -u username -p database_name < FILE.sql
(2). 回车
(3). 提示输入密码
(4). 输入用户名对应的密码,回车.

评论

wdlinux 3.0 php 502

wget http://www.kscub.com/share/mhash-0.9.9.9.tar.gz
wget http://www.kscub.com/share/libmcrypt-2.5.8.tar.gz

 

解决方法:

一、先查看一下php-fpm的启动情况:(到底是不是这个问题造成的)

1
2
3
4
5
6
7
8
[[email protected] ~]# find / -name php-fpm       #查看php-fpm
/www/wdlinux/init.d/php-fpm
/www/wdlinux/nginx_php-5.2.17/sbin/php-fpm
[[email protected] ~]# /www/wdlinux/init.d/php-fpm start  #启动一下php-fpm 下面报错了(缺少包mhash)
Starting php_fpm /www/wdlinux/nginx_php-5.2.17/bin/php-cgi
error while loading shared libraries: 
libmhash.so.2: cannot open shared object file: No such file or directory failed

二、下载mhash包:

wget http://www.kscub.com/share/mhash-0.9.9.9.tar.gz

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
[[email protected] ~]# ls        #查看一下上传的包
mhash-0.9.9.9.tar.gz
[[email protected] ~]# tar xf mhash-0.9.9.9.tar.gz    #解压mhash-0.9.9.9.tar.gz包
[[email protected] ~]# cd mhash-0.9.9.9               #进入到解压后生成的mhash-0.9.9.9目录中去
[[email protected] mhash-0.9.9.9]# ./configure        #配置,检测安装环境
[[email protected] mhash-0.9.9.9]# make && make install         #编译 && 安装
[[email protected] mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
[[email protected] mhash-0.9.9.9]# vim /etc/ld.so.conf.d/mhash.conf #新建的一个配置文件,往里写入:/usr/lib/
[[email protected] mhash-0.9.9.9]# cat /etc/ld.so.conf.d/mhash.conf     #里面就只有:/usr/lib/
/usr/lib/
[[email protected] mhash-0.9.9.9]# ldconfig
[[email protected] mhash-0.9.9.9]# /www/wdlinux/init.d/php-fpm start  #再启动一下php-fpm,还是报缺少包
Starting php_fpm /www/wdlinux/nginx_php-5.2.17/bin/php-cgi
error while loading shared libraries: 
libmcrypt.so.4: cannot open shared object file: No such file or directory

三、下载mcrypt包:

wget http://www.kscub.com/share/libmcrypt-2.5.8.tar.gz

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[[email protected] ~]# ls                           #查看一下上传的包
libmcrypt-2.5.8.tar.gz
[[email protected] ~]# tar xf libmcrypt-2.5.8.tar.gz       #解压libmcrypt-2.5.8.tar.gz包
[[email protected] ~]# cd libmcrypt-2.5.8                  #进入到解压后生成的libmcrypt-2.5.8目录中去
[[email protected] libmcrypt-2.5.8]# ./configure           #配置,检测安装环境
[[email protected] libmcrypt-2.5.8]# make && make install  #编译 && 安装
[[email protected] libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[[email protected] libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
[[email protected] libmcrypt-2.5.8]# /www/wdlinux/init.d/php-fpm start  #再次启动php-fpm,成功
Starting php_fpm  don
[[email protected] libmcrypt-2.5.8]# reboot   #重新开机

评论

小工具从v3.0.1版本开始提供

小工具从v3.0.1版本开始提供

修改/重置后台用户的密码
/www/wdlinux/wdcp/shell/wdcploginchp.sh
适用于忘记了admin用户密码时可操作

修改/重置mysql的root用户密码
/www/wdlinux/wdcp/shell/mysqlrootchp.sh
适用于忘记了mysql的root用户密码时可操作

ftp用户密码检查
/www/wdlinux/wdcp/shell/pureftpconfcheck.sh
适用于FTP用户登录不了或是登录503时可操作

重置wdcp后台的登录限制
/www/wdlinux/wdcp/shell/wdcplogincip.sh
适用于在wdcp后台上设置IP/域名访问限制时设置错误时可操作

评论

WDCP面板忘记后台管理员登陆密码如何重置

强制修改mysql的root密码,在忘记mysql密码时有用
sh /www/wdlinux/tools/mysql_root_chg.sh

ftp配置文件检查,在FTP不能连接或登录时有用
sh /www/wdlinux/tools/pureftp_conf_check.sh

wdcp权限检查,在wdcp后台不正常或部分功能无法使用时有用
sh /www/wdlinux/tools/wdcp_perm_check.sh

wdcp数据库无法连接的修复,如登录后台提示”无法连接mysql,请检查mysql是否已启动及用户密码是否设置正确”
sh /www/wdlinux/tools/mysql_wdcp_chg.sh

wdcp后台登录密码忘记的修改方法
sh /www/wdlinux/tools/wdcp_login_chp.sh

wdcp后台限制登录IP设置错误的修复方法
sh /www/wdlinux/tools/wdcp_login_cbip.sh

wdcp后台限制登录错误次数的修复方法
sh /www/wdlinux/tools/wdcp_cdip.sh

修改时间和同步时间的方法
sh /www/wdlinux/tools/wdcp_ntp.sh

评论

cpanel关闭mysql strict mode的方法介绍

linux关闭mysql strict mode的方法非常简单,下面我来给大家总结了些常用的关闭mysql strict mode模式的例子,希望文章对各位同学会带来帮助。

首先用putty连接linux终端

vi /usr/my.cnf

 

方法1

在最后一行看到:

sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

更改为

sql-mode= NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

 

保存后service mysql restart

 

 

方法2

找到sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

在前面加#

 

保存后service mysql restart

 

评论

Linux挂载ftp服务器

Linux挂载ftp服务器,需要用到一个名为fuse-curlftpfs的包。正常情况下无法通过yum的方式获取此包,因此需要先安装DAG repository

Centos5 64位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
Centos5 32位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el5.rf.i386.rpm
Centos6 64位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
Centos6 32位 wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm
然后是安装下载的rpm包

rpm -ivh rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
然后就可以通过yum的方式安装fuse-curlftpfs了

yum install fuse-curlftpfs -y
在Centos6上执行此命令,可能会遇到 Requires: libcurl.so.3 的错误,解决方法:编辑 /etc/yum.repos.d/rpmforge.repo 文件,把 [rpmforge-extras] 项打开,再执行 yum clean all 即可。

接下来就可以挂载ftp了

写法1:curlftpfs ftp://用户名:密码@ftp地址 挂载点 -o codepage=utf8
写法2:curlftpfs ftp://ftp地址 挂载点 -o user=”用户名:密码”
注意:如果提示“fuse: failed to open /dev/fuse: Operation not permitted”,说明你是在使用OpenVZ技术的Linux VPS的,因为OpenVZ技术的缺陷性(所有小鸡共用母鸡的内核)导致无法使用curlftpfs命令,请在Xen或者vmware技术中使用。

开机自动挂载

echo “curlftpfs#用户名:密码@ftp地址 挂载点 fuse rw,allow_other,uid=0,gid=0 0 0” >> /etc/fstab

评论

linux中下载ftp文件的几个方法

一、最简单的方法: wget
下面的命令用来下载ftp服务器上指定目录的所有文件
[html] view plain copy print?
wget ftp://IP:PORT/* –ftp-user=xxx –ftp-password=xxx -r
-r 参数表示递归下载;
可以使用–directory-prefix=/mypath/ 指定下载后存储路径;-nH选项可以不在本地创建服务器上的目录结构
另一个令人迷惑的选项是–delete-after,它并不是用来删除服务器上的已下载文件,而是用来删除本机的;
wget之所以是wget而不是wput,它只能进行下载操作,不支持对ftp服务器上的任何写操作,比如删除。
二、可以删除文件的方法:lftp
项目需求是下载ftp服务器上的指定文件夹取内的所有文件,并于下载后删除,wget不能满足要求,于是改写出下面的脚本。
mget命令可以下载多个文件,-E参数表示下载后删除服务器上的文件。
[python] view plain copy print?
#!/bin/bash
#指定ftp服务器的ip
serverip=1.2.3.4
#指定ftp服务器的ftp用户
serveruser=root
#指定ftp服务器的ftp用户密码
serverpass=123456
#指定client主机本地下载文件存放的目录
localdir=./data
logfile=../log/ftp_download.log
#指定server主机的ftp目录
remotedir=./
#指定server主机的主机名
host=test_host
#切换到本地下载文件存放的目录
cd $localdir
#输入开始备份的信息
echo “Starting FTP Download on ” $host
#连接ftp服务器
/usr/bin/lftp << EOF open $serverip user $serveruser $serverpass #切换到server主机的ftp目录 echo "cd " $remotedir cd $remotedir #列出ftp服务器ftp目录中文件列表并存放到client中的$localdir中 ls . >> $logfile
#下载ftp服务器ftp目录中的所有文件
mget -E *.txt
#退出ftp服务器
bye
三、其他方法
系统中的ftp命令,和强大的curl。
curl支持FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET 和TFTP,方便在自己的程序中调用。同时支持cookie、代理、密码和证书验证。非常强大。

评论

Disable SSLv2 on cPanel and Apache Ports

On this post we are going to show how to quickly patch a common PCI Vulnerability Alert that says something like this:
“The remote service appears to encrypt traffic using SSL protocol version 2?.

In Apache common ports 80 and 443, you need to modify the SSLCipherSuite directive in the httpd.conf or ssl.conf file.
An example would be editing the following lines to something like:

在whm路径

WHM > Apache Configuration > Global Configuration area

1.
SSLProtocol -ALL +SSLv3 +TLSv1
2.
SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP

After you have done this, if you see you are still getting PCI Compliance vulnerability emails regarding to this issue its probably that cPanel is still allowing SSLv2 on their ports.

To quickly disable SSL version 2 on cPanel ports: 2082, 2083, 2086, 2087, 2095, 2096. You will need to do the following:

edit /var/cpanel/cpanel.config and change nativessl=1 to nativessl=0

This will make cPanel to use sTunnel.

edit /usr/local/cpanel/etc/stunnel/default/stunnel.conf

and add:

1.
options = NO_SSLv2

just below the “Authentication stuff” tab.

After you have done all this you will need to restart cPanel:

1.
/etc/init.d/cpanel restart

Done!

How to quickly check this?

SSH to your server and type the following commands

1.
[email protected] [~]# openssl s_client -ssl2 -connect localhost:2096
2.
[email protected] [~]# openssl s_client -ssl2 -connect localhost:2083
3.
[email protected] [~]# openssl s_client -ssl2 -connect localhost:2087
4.
[email protected] [~]# openssl s_client -ssl2 -connect localhost:2086

If everything is fine you should receive something like this,

1.
[email protected] [~]# openssl s_client -ssl2 -connect localhost:2096
2.
CONNECTED(00000003)
3.
write:errno=104

评论

« Previous entries 下一页 » 下一页 »