Archive for Linux分享

HostMonster ssh 导入sql

HostMonster HostIt offers free SSH,By SSHImport / Export MySQL databaseIt is quite easy,Specific steps are as follows:

1. HostMonster host to export MySQL database

The following example shows how to export a MySQL database,Export data to be backed up often still necessary,Procedure In the following command line:

(1). mysqldump -u username -p database_name > FILE.sql
(2). Enter
(3). Prompt for password
(4). enter password,Enter.

Where username, database_name is the user name and password MySQL database、Password and database name。FILE.sql file is backed up on HostMonster host MySQL database,Now you can be downloaded to a local to save。

2. HostMonster host import MySQL database

MySQL database backup files to upload(For example, to export the above file FILE.sql)HostMonster to the server,Then execute the following command:

(1). mysql -u username -p database_name < FILE.sql
(2). Enter
(3). Prompt for password
(4). Enter the user name corresponding password,Enter.

Comments

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

 

Solution:

one、First look at the start of the case php-fpm:(In the end the problem is not caused by)

1
2
3
4
5
6
7
8
[root@localhost ~]# find / -name php-fpm #查看php-fpm
/www/wdlinux/init.d/php-fpm
/www/wdlinux/nginx_php-5.2.17/sbin/php-fpm
[root@localhost ~]# /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

two、Download mhash package:

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
[root@localhost ~]# ls #查看一下上传的包
mhash-0.9.9.9.tar.gz
[root@localhost ~]# tar xf mhash-0.9.9.9.tar.gz #解压mhash-0.9.9.9.tar.gz包
[root@localhost ~]# cd mhash-0.9.9.9 #进入到解压后生成的mhash-0.9.9.9目录中去
[root@localhost mhash-0.9.9.9]# ./configure #配置,检测安装环境
[root@localhost mhash-0.9.9.9]# make && make install #编译 && 安装
[root@localhost mhash-0.9.9.9]# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
[root@localhost mhash-0.9.9.9]# vim /etc/ld.so.conf.d/mhash.conf #新建的一个配置文件,往里写入:/usr/lib/
[root@localhost mhash-0.9.9.9]# cat /etc/ld.so.conf.d/mhash.conf #里面就只有:/usr/lib/
/usr/lib/
[root@localhost mhash-0.9.9.9]# ldconfig
[root@localhost 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

three、Download mcrypt package:

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
[root@localhost ~]# ls #查看一下上传的包
libmcrypt-2.5.8.tar.gz
[root@localhost ~]# tar xf libmcrypt-2.5.8.tar.gz #解压libmcrypt-2.5.8.tar.gz包
[root@localhost ~]# cd libmcrypt-2.5.8 #进入到解压后生成的libmcrypt-2.5.8目录中去
[root@localhost libmcrypt-2.5.8]# ./configure #配置,检测安装环境
[root@localhost libmcrypt-2.5.8]# make && make install #编译 && 安装
[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
[root@localhost libmcrypt-2.5.8]# ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
[root@localhost libmcrypt-2.5.8]# /www/wdlinux/init.d/php-fpm start #再次启动php-fpm,成功
Starting php_fpm don
[root@localhost libmcrypt-2.5.8]# reboot #重新开机

Comments

Gadget from v3.0.1 version began offering

Gadget from v3.0.1 version began offering

Modify / reset a user's password back
/www/wdlinux/wdcp/shell/wdcploginchp.sh
It applies to forget the admin user password operable

Modify / reset mysql root password
/www/wdlinux/wdcp/shell/mysqlrootchp.sh
It applies to forget the mysql root user password is operable

ftp user password check
/www/wdlinux/wdcp/shell/pureftpconfcheck.sh
Not apply to FTP user login or login 503 operable

Reset wdcp background logon restrictions
/www/wdlinux/wdcp/shell/wdcplogincip.sh
Suitable for operational error when setting the stage set IP / domain access restrictions after wdcp

Comments

WDCP panel background administrator login password forget how to reset

Mandatory Changes mysql root password,Useful if you forget your password mysql
sh /www/wdlinux/tools/mysql_root_chg.sh

ftp profile checks,FTP is useful when you can not connect or log in
sh /www/wdlinux/tools/pureftp_conf_check.sh

wdcp permission checks,Useful wdcp background is not normal or some functions can not be used
sh /www/wdlinux/tools/wdcp_perm_check.sh

Repair wdcp database can not connect,Such as login background prompts "can not connect mysql,Check to see if mysql is started and the user password is set correctly. "
sh /www/wdlinux/tools/mysql_wdcp_chg.sh

wdcp background login Forgotten password modification method
sh /www/wdlinux/tools/wdcp_login_chp.sh

wdcp background Restricting Login IP setting error fix
sh /www/wdlinux/tools/wdcp_login_cbip.sh

wdcp backstage limit the number of login error fix
sh /www/wdlinux/tools/wdcp_cdip.sh

Modification method and time synchronization time
sh /www/wdlinux/tools/wdcp_ntp.sh

Comments

Linux mount the ftp server

Linux mount the ftp server,You need to use a package called the fuse-curlftpfs。Under normal circumstances can not get this package through yum way,Therefore, you need to install 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
Then install the downloaded rpm package

rpm -ivh rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
Then you can install the fuse-curlftpfs the way through yum

yum install fuse-curlftpfs -y
Execute this command on Centos6,Requires might encounter: libcurl.so.3 error,Solution:Edit /etc/yum.repos.d/rpmforge.repo file,The [rpmforge-extras] Open item,It can then execute yum clean all。

Then you can mount the ftp

Written 1:curlftpfs ftp://username:Password @ftp address mount point -o codepage = utf8
Writing 2:curlftpfs ftp://ftp address mountpoint -o user =”username:password”
note:If you prompted to "fuse: failed to open /dev/fuse: Operation not permitted”,That you are using the Linux VPS OpenVZ technology,OpenVZ technology because of defective (all common hen chicks kernel) unusable curlftpfs command,Please use vmware or Xen technology。

Boot automatically mount

echo “curlftpfs # Username:Password @ftp address mount point fuse rw,allow_other,uid=0,gid=0 0 0” >> /etc/fstab

Comments

linux files download ftp several ways

one、The easiest way: wget
All files following command to download a specified directory on the ftp server
[html] view plain copy print?
wget ftp://IP:PORT/* –ftp-user=xxx –ftp-password=xxx -r
-r parameter represents a recursive downloads;
can use–directory-prefix = / mypath / designated storage path download;-nH option can not create the directory structure on the local server
Another option is confusing–delete-after,It is not to remove the downloaded file on the server,But to remove the machine;
The reason is wget wget instead wput,It can only download operation,On the ftp server does not support any write operation,For example, delete。
two、The method can delete files:lftp
Project requirements are specified file all the files on the ftp server download gripping inside,After downloading and delete,wget not meet the requirements,Then rewrite the script below。
mget command to download multiple files,-Delete files on the server after downloading E parameter indicates。
[python] view plain copy print?
#!/bin/bash
#ip designated ftp server
serverip=1.2.3.4
#ftp ftp server specified by the user
serveruser=root
#ftp user password specified ftp server
serverpass=123456
#Specifies the client to download a host of local file directory
localdir=./data
logfile=../log/ftp_download.log
#Specify the server host ftp directory
remotedir=./
#Host Name Specify the host server
host=test_host
#Switch to local download file directory
cd $localdir
#Enter the information to start the backup
echo “Starting FTP Download on ” $host
#Ftp server connection
/usr/bin/lftp << EOF open $serverip user $serveruser $serverpass #切换到server主机的ftp目录 echo "cd " $remotedir cd $remotedir #列出ftp服务器ftp目录中文件列表并存放到client中的$localdir中 ls . >> $logfile
#Ftp download ftp server directory of all files
mget -E *.txt
#Exit ftp server
bye
three、Other methods
System ftp command,And strong curl。
curl支持FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, TELNET and TFTP,Easy call in your program。Supports cookie、proxy、Password and certificate validation。Very powerful。

Comments

Badblocks Check whether the hard disk has bad sectors

Hard drive is relatively easy to broken equipment,It may appear bad sectors and other physical failure after a period of time。When the hard disk bad sectors,If not promptly replaced or conduct technical process,Disk bad sectors will be more and more,And would cause frequent crashes and data loss。The best approach is to replace the new disk。In the case of temporary,We should be part of the bad sectors sector shields,Do not touch them。

badblocks is to check whether a disk has bad sectors Tools,Can be read way to check,You can also check the way to write。

Here,I use

badblocks -v /dev/sda

Check for bad sectors,Test results without error

 

 

 

 

badblocks parameter options

-b blocksize
Block size specified disk,Bytes,The default value is "block 4K"(4K/block)
-c blocksize
Check the number of times each block,The default is 16
-f
Non-destructive read enforcement on an already mounted equipment write test operation
(We recommend that you umount equipment,Then to detect bad sectors。Only when the / etc / mtab mount the wrong device false positives when you can use this option)
-i file
Skip has been shown to bad sectors in the file file,Without detection (to avoid duplicate detection)
-or file
The detection result is output to the file file
-p number
Repeat search devices,Until a specified number of times through no bad blocks to find a new location,The default number is 0
-s
It shows progress check
-t pattern
By pressing the designated read mode is detected block。You can specify a decimal 0 to ULONG_MAX-1 positive value,Or random (stochastic)。
If you specify more than one mode,badblocks will use the first pattern detecting all blocks,Then use one mode to detect all of the blocks。
Read-only mode accepts only a mode,It can not accept random pattern。
-v
Display detailed information about the implementation
-w
Are the first written for each block,Then read information from it
[device]
Specifies the disk device to be checked。
[last-block]
The total number of blocks specified disk device。
[start-block]
Specifies the block from which you want to start checking

Comments

bash: scp: command not found lost connection问题解决

Intranet,Pass from one servermysqlofSourceWhen you install the package to another server,The following error occurred:

[root@localhost ~]# scp mysql-5.1.55.tar.gz root@192.168.3.22:.
[email protected]’s password:
bash: scp: command not found
lost connection
Tip scp command not found,But the discovery found that the command exists
[root@localhost ~]# whereis scp
scp: /usr/bin/scp /usr/share/man/man1/scp.1.gz
[root@localhost ~]# find / -name scp
/usr/bin/scp
Because there is no environment variable added to the reasons?
EVN 查看,We have joined the environment variables
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
And to bring the full path,When executed or reported the same error
[root@localhost ~]# /usr/bin/scp mysql-5.1.55.tar.gz [email protected]:.
[email protected]’s password:
bash: scp: command not found
lost connection
See scp relies package
[root@localhost ~]# rpm -qf /usr/bin/scp
openssh-clients-5.3p1-81.el6.i686
Suspect there will be other dependencies is not installed on,Reinstall it again
[root@localhost ~]# yum install openssh-clients*
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
* base: centos.ustc.edu.cn
* warm: mirrors.ustc.edu.cn
* extras: centos.ustc.edu.cn
* updates: centos.ustc.edu.cn
Setting up Install Process
package openssh-clients-5.3p1-81.el6.i686 already installed and latest version
Nothing to do
Tip has been installed,And already the newest version
When retesting,Still the same error。Nani,If the command does not exist or can not be found,Before scp command should knock them out is a problem ah,And should not be re-emergence of this problem after a successful command clincher。If you are not a local problem,That is not installed scp command server on the other end?
[root@com ~]# whereis scp
scp:
[root@com ~]#
Really so,So is the server side does not find scp command,Rather than the local
Dependencies installed scp
[root@com ~]# yum install openssh-clients*
After installing,Retransmission file
[root@localhost ~]# scp mysql-5.1.55.tar.gz [email protected]:.
[email protected]’s password:
mysql-5.1.55.tar.gz
This article

Comments

centos7 turn off the firewall

 

1. Disable Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl mask firewalld

2. Stop Firewalld Service.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl stop firewalld

3. Install iptables service related packages.

[root@rhel-centos7-tejas-barot-linux ~]# yum -y install iptables-services

4. Make sure service starts at boot:

[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable iptables

# If you do not want ip6tables, You can skip following command.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl enable ip6tables

5. Now, Finally Let’s start the iptables services.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl start iptables

# If you do not want ip6tables, You can skip following command.

[root@rhel-centos7-tejas-barot-linux ~]# systemctl start ip6tables

Firewalld Service is now disabled and stop, You can use iptables.

 

 

Close selinux

vi/etc/selinux/config

#SELINUX=enforcing
SELINUX=disabled

Comments

iftop

iftop what's the use?

iftop can be used in real-time traffic monitoring NIC (network segment can be specified)、Reverse lookup IP、Display port information, etc.,Details will be explained later in the parameter。

Installation iftop

Installation 1、Compile and install

If you can compile and install the iftop official website to download the latest source package。

Before installing the need to have installed the required basic compilation environment,For example, make、gcc、autoconf等。Installation iftop also need to install libpcap and libcurses。

On CentOS install the required dependencies:

yum install flex byacc libpcap ncurses ncurses-devel libpcap-devel

On Debian install the required dependencies:

apt-get install flex byacc libpcap0.8 libncurses5

Download iftop

wget http://www.ex-parrot.com/pdw/iftop/download/iftop-0.17.tar.gz

tar zxvf iftop-0.17.tar.gz

cd iftop-0.17

./configure

make && make install

Comments

NIC patch

http://ftp.colocall.net/pub/elrepo/elrepo/el6/x86_64/RPMS/

Comments

linux inode consume 100 percent solution

What is the inode?

Files stored on the hard disk,HDD minimum storage units called "sectors" (Sector)。Store 512 bytes per sector (equivalent 0.5KB)。
Operating system hard to read when,Not read a sector,Such efficiency is too low,But sequential read more sectors at once,That is a one-time read "block" (block)。This from a plurality of sectors "chunks",It is the smallest unit file access。Size "chunks",The most common is 4KB,That is a block consisting of eight consecutive sector。
Data files are stored in the "block" in the,Then it is clear,We must also find a place to store meta-information file,For example, the creator of the file、File creation date、File size, etc.。This storage area file meta information is called inode,Chinese translation for "inode"。
Each file has a corresponding inode,Which contains some information and documents relating to the。

How to view innode occupancy System

df -ih

How do I find that most catalog file

First cut to the root directory /

cd /

And then do

for i in /*; do echo $i; find $i | wc -l; done

or

for i in `ls -1A | grep -v "\.\./" | grep -v "\./"`; do echo "`find $i | sort -u | wc -l` $i"; done | sort -rn | head -10

This will in turn return/Most files under directory,Into this directory,And then execute the above command,In this way layers of depth is up to finalize the directory file

How do I delete all the files in that directory

Under normal circumstances,If there should be millions of files in this directory,If you directly rm -rf 目录名 If inefficient,You can use the following method

find 目录 -type f -name '*' -print0 | xargs -0 rm

Time may be relatively long,So you'd better open a screen to handle

You may be experiencing the following circumstances

/var / spool / postfix / maildrop below many files
in order to avoid,You can perform crontab -e
At the beginning of the most added MAILTO='"' Save,then server crond restart Restart crond

Comments

The method of Linux release the disk space occupied

1、Check with df find / root directory of free space 0

[root@/]#df -h

2、Check each directory found with du occupies very little space,About 3G space somehow lost。

[root@/]# du -m –max-depth=1 |sort -gr

3、Check with lsof after the discovery of reason,There files are deleted,And the process is still alive,Resulting phenomenon also takes up space

[root@/]# lsof |grep delete

According to numbers listed in the process lsof,After these processes kill,Space is released out

Comments

Linux how to modify the default port number of SSH?

In the installed linux,By default ssh is open,Vulnerable to hacker attacks,simple,Effective action is to modify one of the default port number
Such as the following,We modify my 22 2501
It is to modify / etc / ssh / sshd_config // note,Easy and ssh_config mixed
step one
[root@localhost ssh]# more sshd_config
# $OpenBSD: sshd_config,v 1.69 2004/05/23 23:59:53 dtucker Exp $
# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin
# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options change a
# default value.
#Port 22 //Comment out the first 22
port 2501 //Add a new port
#Protocol 2,1
Step Two
[root@localhost ~]# service sshd restart
Stopping sshd:[ OK ]
Starting sshd:[ OK ]
Step Three
Testing with SecureCRT

Comments

Linux Firewall Configuration,Open port 80、3306port

vi /etc/sysconfig/iptables

-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT (allow 80 port through the firewall)
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT (allow port 3306 through the firewall)
Special Note:Many users add these two rules to the last line of firewall configuration,Cause the firewall fails to start,Right should be added to the default port 22. This rule below
After adding a good firewall rules are as follows:

######################################
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
-A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT
-A INPUT -j REJECT –reject-with icmp-host-prohibited
-A FORWARD -j REJECT –reject-with icmp-host-prohibited
COMMIT
#####################################

/etc/init.d/iptables restart
#Finally, reboot the firewall configuration to take effect

Comments

« Previous Page« Previous entries « Previous Page · Next Page » Next entries »Next Page »