Archive for virtual server technology

Installation Directadmin encountered an error

Installation Directadmin encounter

*** Cannot find /usr/include/et/com_err.h. (yum install libcom_err-devel) ***
Installation didn’t pass, halting install.
Once requirements are met, run the following to continue the install:
cd /usr/local/directadmin/scripts
./install.sh
Common pre-install commands:

http://help.directadmin.com/item.php?id=354

==================
yum install libcom_err-devel
==================
Total 972 kB / s | 116 MB 02:02
Running rpm_check_debug
ERROR with rpm_check_debug vs depsolve:
keyutils-libs-devel is needed by krb5-devel-1.10.3-10.el6_4.1.i686
libselinux-devel is needed by krb5-devel-1.10.3-10.el6_4.1.i686
zlib-devel is needed by openssl-devel-1.0.0-27.el6_4.2.i686
** Found 7 pre-existing rpmdb problem(s), ‘yum check’ output follows:
e2fsprogs-devel-1.41.12-3.el6.i686 has missing requires of e2fsprogs-libs = (’0′, ’1.41.12′, '3.el6')
e2fsprogs-devel-1.41.12-3.el6.i686 has missing requires of libcom_err-devel
e2fsprogs-devel-1.41.12-3.el6.i686 has missing requires of pkgconfig(com_err)
krb5-devel-1.8.2-3.el6.i686 has missing requires of keyutils-libs-devel
krb5-devel-1.8.2-3.el6.i686 has missing requires of libcom_err-devel
krb5-devel-1.8.2-3.el6.i686 has missing requires of libselinux-devel
openssl-devel-1.0.0-4.el6.i686 has missing requires of zlib-devel

carried out

yum -y install zlib-devel
yum -y install e2fsprogs*

Can be solved

Comments

Linux build Swap partition file and automatically mount

purpose:Establish a 2G size of the swap partition,And automatically mount when the system boots。
System Environment:RedHat53

1. dd if=/dev/zero of=/swapfile bs=1k count=2048000
2. mkswap /swapfile
3. swapon /swapfile
4. Modify / etc / fstab to automatically mount at startup:
Add the following sentence in the / etc / fstab in:
/swapfile swap swap defaults 0 0
5. Get!

Comments

ifto[ Installation Tutorial

 

Direct omit the above steps

CentOS system:

yum install flex byacc libpcap ncurses ncurses-devel

wget ftp://fr2.rpmfind.net/linux/dag/redhat/el5/en/i386/dag/RPMS/iftop-0.17-1.el5.rf.i386.rpm

rpm -ivh iftop-0.17-1.el5.rf.i386.rpm

Comments

Three Free PHP Accelerator:APC、eAccelerator、XCache Comparison

I have been looking for articles on PHP acceleration,Chance to seeKill offThis article,Feeling good,For everyone to share,Again thank kill off。

one、PHP Accelerator Introduction

PHP is an accelerator in order to improve the efficiency of PHP,Thus from PHP opcode cache,PHP execution behind this would not resolve the converted,PHP opcode can invoke direct,On such speed is increased a lot。

Apache's request to use mod_php、In response to the flow of execution:

1、Apache receives a request。
2、Apache pass the request to the mod_php。
3、mod_php locate a disk file,And loaded into memory。
4、mod_php compile the source code tree becomes opcode。
5、mod_php execution opcode tree。

PHP is the fourth step of the corresponding accelerator,Its purpose is to prevent repeated every request to compile PHP PHP code,Because in high-traffic sites,Often not a lot of compiler execution speed fast? So there are a bottleneck that compiles PHP affects both the speed and load server load,In order to solve this problem,PHP accelerator was born。

two、PHP Accelerator Installation and Configuration

1、APC Installation and Configuration

APC stands for Alternative PHP Cache,The official translation is called "Optional PHP cache",It is an extension of PHP PECL,It seems to be using facebook,Here begin the installation (ubuntu environment):
$wget http://pecl.php.net/get/APC-3.0.19.tgz
$tar xvzf APC-3.0.19.tgz
$cd APC-3.0.19/APC-3.0.19
$/usr/local/php/bin/phpize
$./configure –enable-apc –enable-apc-mmap –with-php-config=/usr/local/php/bin/php-config
$make
$sudo make install

Here we configure APC,Because I changed the path of PECL extension,So I have to move under the compiled file:
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/apc.so /usr/local/php/lib/php/extensions/PECL

Then we edit the php.ini configuration file,Please add the following code to the php.ini to:
extension_dir = “/usr/local/php/lib/php/extensions/PECL”
extension = apc.so
; APC
apc.enabled = 1
apc.shm_segments = 1
apc.shm_size = 64
apc.optimization = 1
apc.num_files_hint = 0
apc.ttl = 0
apc.gc_ttl = 3600
apc.cache_by_default = on

This will restart apache in phpinfo()Information display。

2、Installation configuration eAccelerator

eAccelerator is actually the predecessor of truck-mmcache,Because the development truk-mmcache Zend people were given amnesty,Therefore, the development eAccelerator who inherited some of the characteristics truk-mmcache,EAccelerator accelerator design。Installation is as follows:
$wget http://jaist.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.5.tar.bz2
$tar -jxf eaccelerator-0.9.5.tar.bz2
$cd eaccelerator-0.9.5
$/usr/local/php/bin/phpize
$./configure –enable-eaccelerator=shared –with-php-config=/usr/local/php/bin/php-config
$make
$sudo make install
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so /usr/local/php/lib/php/extensions/PECL

The following code to your php.ini file
extension = eaccelerator.so
; eAccelerator
eaccelerator.shm_size = “16”
eaccelerator.cache_dir = “/tmp/eaccelerator”
eaccelerator.enable = “1”
eaccelerator.optimizer = “1”
eaccelerator.check_mtime = “1”
eaccelerator.debug = “0”
eaccelerator.filter = “”
eaccelerator.shm_max = “0”
eaccelerator.shm_ttl = “0”
eaccelerator.prune_period = “0”
eaccelerator.shm_only = “0”
eaccelerator.compress = “1”
eaccelerator.compress_level = “9”

Create cache directory,Restart apache

$sudo mkdir /tmp/eaccelerator
$sudo chmod 777 /tmp/eaccelerator
$sudo /usr/local/apache/apachectl restart

At phpinfo()Check whether the installation was successful.

3、Installation and Configuration XCache

XCache own people as something to be developed,I also do little rookie proud,And XCache in terms of speed and performance are doing well。Here quickly let us taste it now!

$wget http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz
$tar xvzf xcache-1.2.2.tar.gz
$cd xcache-1.2.2
$/usr/local/php/bin/phpize
$./configure –enable-xcache –enable-xcache-coverager –with-php-config=/usr/local/php/php-config
$make
$sudo make install
$sudo mv /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so /usr/local/php/lib/php/extensions/PECL

In php.ini add configuration information:

extension = xcache.so
; xcache
xcache.admin.user = “admin”
xcache.admin.pass = “(carried out) echo ’(Your password)’|md5sum(Resulting ciphertext)”
;
xcache.size = 24M
xcache.shm_scheme = “mmap”
xcache.count = 2
xcache.slots = 8k
xcache.ttl = 0
xcache.gc_interval = 0

xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8k
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = “/tmp/xcache”
xcache.coredump_directory = “”
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off
;
xcache.coverager = On
xcache.coveragedump_directory = “”

Create cache directory,Restart apache

$sudo mkdir /tmp/xcache
$sudo chmod 777 /tmp/xcache
$sudo /usr/local/apache/bin/apachectl restart

To view the phpinfo()Information now!

three、PHP Accelerator Test

1、test environment

hardware: AMD Athlon 64 X2 Dual Core Processor 4400+ @ 2.2GHz CPU, 2GB memory. 160GB SATA hard drive

software: Linux Ubuntu server Gutsy 7.10, Apache 2.2.4, MySQL 5.0.45 And PHP 5.2.3

Test instructions: ab -c5 -n3000 http://example.com/ (We are using Apache Benchmark (from) tool,5 concurrent connections,3000Request times)

2、Test Results

No accelerator:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 288.255212 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 10.41 [#/sec] (mean)
Time per request: 480.425 [ms] (mean)
Time per request: 96.085 [ms] (mean, across all concurrent requests)
Transfer rate: 226.23 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.5 0 19
Processing: 181 479 186.0 444 1822
Waiting: 166 461 184.7 427 1708
Total: 181 479 186.0 444 1822
Percentage of the requests served within a certain time (ms)
50% 444
66% 525
75% 577
80% 619
90% 732
95% 819
98% 946
99% 1012
100% 1822 (longest request)

APC 加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 98.530068 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 30.45 [#/sec] (mean)
Time per request: 164.217 [ms] (mean)
Time per request: 32.843 [ms] (mean, across all concurrent requests)
Transfer rate: 661.84 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 58 163 71.2 155 2452
Waiting: 53 158 69.6 150 2329
Total: 58 163 71.2 155 2452
Percentage of the requests served within a certain time (ms)
50% 155
66% 178
75% 193
80% 204
90% 235
95% 258
98% 285
99% 302
100% 2452 (longest request)

eAccelerator加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 95.983986 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 31.26 [#/sec] (mean)
Time per request: 159.973 [ms] (mean)
Time per request: 31.995 [ms] (mean, across all concurrent requests)
Transfer rate: 679.39 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.1 0 3
Processing: 57 159 91.3 148 3830
Waiting: 50 152 89.8 142 3704
Total: 57 159 91.3 148 3830
Percentage of the requests served within a certain time (ms)
50% 148
66% 174
75% 193
80% 205
90% 239
95% 263
98% 289
99% 309
100% 3830 (longest request)

XCache加速器:

Document Path: /
Document Length: 21757 bytes
Concurrency Level: 5
Time taken for tests: 99.76300 seconds
Complete requests: 3000
Failed requests: 0
Write errors: 0
Total transferred: 66777000 bytes
HTML transferred: 65271000 bytes
Requests per second: 30.28 [#/sec] (mean)
Time per request: 165.127 [ms] (mean)
Time per request: 33.025 [ms] (mean, across all concurrent requests)
Transfer rate: 658.19 [Kbytes/sec] received
Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.0 0 2
Processing: 59 164 83.4 155 3367
Waiting: 52 156 66.4 148 1802
Total: 59 164 83.4 155 3367
Percentage of the requests served within a certain time (ms)
50% 155
66% 178
75% 196
80% 206
90% 237
95% 263
98% 287
99% 305
100% 3367 (longest request)

3、Results Summary

Request Time(second)Single request time(millisecond)The maximum memory footprint(MB)The minimum memory footprint(MB)
None10.4196.082424
APC30.4532.842121
eAccelerator31.2631.992318
XCache30.2833.022919

four、PHP accelerator comparison summary

1、EAccelerator obtained by testing at request time and overall memory footprint area is best。

2、Test results using the ratio of the accelerator by accelerator-free request time about three times faster。

3、By observing the various official,XCache is the fastest updates,It also shows that most of the development。

These are the summary results,You might ask me in the end with the accelerator good? I can only tell you,First of all,Use must be better than no,Secondly, each of the accelerator some parameters can tune,So according to your system environment,then,Personally, I think you can study in detail under eAccelerator and XCache,Both still great potential,Finally, I get a map from the results of a more professional test site:

cache

Comments

How to view real-time under linux mysql current number of connections? ? Command is what?

mysqadmin -uroot -p processlist
Details can be seen in connection.

If you just want to see the number of connections.
Direct hit mysqladmin status
Threads is the number of connections

Comments

Server security plan

To ensure that my CentOS machines run as efficiently and securely as possible, I disable a number of services after each installation. The end result is a system that accepts ssh connections on TCP port 22, and on one or more service ports that are in use by the applications hosted on the platform. To get to this state, I go through and disable numerous services that come enabled by default. Here is the default list of services that are enabled after a CentOS 4.4 installation:

$ chkconfig –list | grep on

etc             0:off   1:off   2:off   3:on    4:on    5:on    6:off
messagebus      0:off   1:off   2:off   3:on    4:on    5:on    6:off
smartd          0:off   1:off   2:on    3:on    4:on    5:on    6:off
portmap         0:off   1:off   2:off   3:on    4:on    5:on    6:off
sendmail        0:off   1:off   2:on    3:on    4:on    5:on    6:off
netfs           0:off   1:off   2:off   3:on    4:on    5:on    6:off
cups            0:off   1:off   2:on    3:on    4:on    5:on    6:off
irqbalance      0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcgssd         0:off   1:off   2:off   3:on    4:on    5:on    6:off
xfs             0:off   1:off   2:on    3:on    4:on    5:on    6:off
isdn            0:off   1:off   2:on    3:on    4:on    5:on    6:off
autofs          0:off   1:off   2:off   3:on    4:on    5:on    6:off
gpm             0:off   1:off   2:on    3:on    4:on    5:on    6:off
apmd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
crond           0:off   1:off   2:on    3:on    4:on    5:on    6:off
acpid           0:off   1:off   2:off   3:on    4:on    5:on    6:off
microcode_ctl   0:off   1:off   2:on    3:on    4:on    5:on    6:off
pcmcia          0:off   1:off   2:on    3:on    4:on    5:on    6:off
cpuspeed        0:off   1:on    2:on    3:on    4:on    5:on    6:off
xinetd          0:off   1:off   2:off   3:on    4:on    5:on    6:off
rpcidmapd       0:off   1:off   2:off   3:on    4:on    5:on    6:off
readahead_early 0:off   1:off   2:off   3:off   4:off   5:on    6:off
readahead       0:off   1:off   2:off   3:off   4:off   5:on    6:off
sshd            0:off   1:off   2:on    3:on    4:on    5:on    6:off
anacron         0:off   1:off   2:on    3:on    4:on    5:on    6:off
network         0:off   1:off   2:on    3:on    4:on    5:on    6:off
kudzu           0:off   1:off   2:off   3:on    4:on    5:on    6:off
syslog          0:off   1:off   2:on    3:on    4:on    5:on    6:off
nfslock         0:off   1:off   2:off   3:on    4:on    5:on    6:off
rawdevices      0:off   1:off   2:off   3:on    4:on    5:on    6:off
mdmonitor       0:off   1:off   2:on    3:on    4:on    5:on    6:off
haldaemon       0:off   1:off   2:off   3:on    4:on    5:on    6:off

Several of these services are required, but several others serve no purpose in my environment, and use CPU and memory resources that would be better allocated to my applications. Since I don’t use RPC services, autofs or NFS, those are the first to get disabled:

$ /sbin/chkconfig –level 0123456 portmap off
$ /sbin/chkconfig –level 0123456 nfslock off
$ /sbin/chkconfig –level 0123456 netfs off
$ /sbin/chkconfig –level 0123456 rpcgssd off
$ /sbin/chkconfig –level 0123456 rpcidmapd off
$ /sbin/chkconfig –level 0123456 autofs off

I also don’t allow individual hosts to receive mail from the outside world, so sendmail gets nixed next:

$ /sbin/chkconfig –level 0123456 sendmail off

On server platforms, who needs printing?:

$ /sbin/chkconfig –level 0123456 cups off

Now we get to the font server, isdn capabilities, console mouse and pcmcia support. I don’t use these services on my servers, so they get disabled as well:

$ /sbin/chkconfig –level 0123456 xfs off
$ /sbin/chkconfig –level 0123456 isdn off
$ /sbin/chkconfig –level 0123456 gpm off
$ /sbin/chkconfig –level 0123456 pcmcia off

Once these services are disabled (and optionally stopped with the service command or a reboot), my netstat output looks nice and clean:

$ netstat –tcp –udp –listening

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State
tcp        0      0 *:ssh                       *:*                         LISTEN

This has served me well over the years, since it reduces boot time (less rc scripts to run), and frees up additional resources for my applications (while this isn’t substantial, every page of memory helps!).

Comments

CentOS 5 The OpenSSL and OpenSSH upgrade

CentOS 5 The OpenSSL and OpenSSH upgrade

2010-10-24 23:44

The OpenSSL and OpenSSH upgraded。CentOS 5.2 is brought OpenSSL 0.9.8b,OpenSSH is 4.0p1。Upgrade follows:

 

openssh latest version (http://www.openssh.com/portable.html)

 

wget http://www.openssl.org/source/openssl-0.9.8j.tar.gz

 

tar zxvf openssl-0.9.8j.tar.gz

 

cd openssl-0.9.8j

 

./config –prefix=/usr

 

make

 

make test

 

make install

 

wget http://openbsd.noc.jgm.gov.ar/pub/OpenBSD/OpenSSH/portable/openssh-5.2p1.tar.gz

 

tar zxvf openssh-5.2p1.tar.gz

 

cd openssh-5.2p1

 

./configure –prefix=/usr –with-pam –with-zlib –sysconfdir=/etc/ssh –with-ssl-dir=/usr –with-md5-passwords

 

make

 

make install

Comments

OpenVZ resource management -CPU share articles

 

Continued yesterday content,OpenVZ today describes how to control CPU resources that can be used VE。OpenVZ resource manager allows VE guarantee of CPU time can be used to implement QoS。in

 

Not set cpulimit,And the absence of other VE competitive CPU resources available,VE obtained outside the setting of minimum guaranteed value,You can also exceed this value,To take advantage of HW CPU resources。

 

one、You can set parameters
OpenVZ using specific arithmetic calculation rules CPU time,The unit of the setpoint is CPU time。This makes it possible to avoid a single CPU and multi-CPU load does not mean,Problems not make full use of resources。
You can set parameters:

Quote
ve0cpuunits:This parameter setting is global configuration file,CPU time defined minimum usable VPS 0,That is the least resources available to ensure that the value of HW。The recommended setting is HW gross CPU time of 5 to 10%;
cpuunits:VE available resources to ensure the minimum CPU time;
cpulimit:The percentage of CPU time must not exceed the VE。

As I mentioned at the beginning,cpuunits not a fixed value,As long as resources permit,In the case does not exceed the percentage of cpulimit,VE can have full access to CPU resources。

two、Setting CPU share
1、The total CPU time calculating HW
first step,Of course, we need to calculate the current VPS 0 (HW) how much CPU time can dominate。

Quote
# vzcpucheck
Current CPU utilization: 1000 #HW start and has been occupied by the CPU time of VE
Power of the node: 85105 #The total number of CPU time HW

2、HW可用CPU time

Quote
# grep ‘VE0CPUUNITS=1000’ /etc/vz/vz.conf
VE0CPUUNITS = 1000

This is the default value,Also did not mean to start before VE,The results obtained running vzcpucheck。

3、VE set of CPU time

# vzctl set 115 –cpuunits 2500 –cpulimit 5 –save

or

Quote
# vi /etc/vz/conf/115.conf
CPUUNITS =”2500″
CPULIMIT =”5″

it means:

Quote
1) CPU full load even in the HW,Or speak,the current CPU utilization等于the power of the Node的情况下,115 VE can get about 3% (2500/85105) of the CPU time resources;
2) But in the case of CPU idle,115 VE and can not get more than 5 percent of the CPU time resources;
3) Is speaking,Under normal circumstances,115 VE resources available CPU time between 3% to 5%;
4) If set cpulimit,So in the absence of other VE 115 VE competition,The lower resource and allow the situation,It can be more than 3%,But as long as no more than HW load on it。

Start VE,result:

Quote
# vzctl start 115
# vzcpucheck
Current CPU utilization: 3500
Power of the node: 85105

This setting is effective or dynamic:

Quote
# vzctl set 115 –cpuunits 4000 –cpulimit 5 –save
Setting CPU limit: 5
Setting CPU units: 4000
Configure meminfo: 49152
Saved parameters for VE 115
# vzcpucheck
Current CPU utilization: 5000
Power of the node: 85105

4、problem
From the above description may know,OpenVZ usually with a minimum guarantee value VE can make full use of system resources,This is one of the design principles。But the result will bring a problem,It is:

Quote
# vzctl set 112 –cpuunits 85000 –cpulimit 5 –save
# vzctl start 112
# vzcpucheck
Current CPU utilization: 105000
Power of the node: 85105
Warning: hardware node is overcommited

just in case,You set a minimum guarantee for all its VE gross CPU time resources available HW greater than the actual CPU time。Then,On issues of CPU overload may occur。When this happens in real,115 VE can not get 3% of the CPU time resources available to its original guarantee,This may cause the entire virtual system error。
of course,This will only happen 112 VE full use of CPU time in,HW case of overload。And in most cases,VE CPU-peak is not at the same time,Dynamically allocated on the OpenVZ,CPU time can get more fully utilized,and so,Only Warning,Instead of Error。But in order to avoid problems,Recommendations or make current CPU utilization equal to the power of the Node better。


Comments

Xen server mount new local hard disk

1、XenCenter console into the server
2、[root@szwj-xenvm01 ~]# fdisk -l to find new hard disk device number (such as:/dev / sdb)
3、[root@szwj-xenvm01 ~]# xe sr-create name-label=”The new hard disk device name” shared = false device-config-device = / dev / sdb type = lvm (/ dev / sdb device number of the new hard disk)

Comments

HyperVM Installation Notes (OpenVZ articles)

First talk about OpenVZ installation
cd /etc/yum.repos.d
wget http://download.openvz.org/openvz.repo
yum install ovzkernel

To complete the installation。Restart,Fromhttp://download.lxlabs.com/?software=hypervmChoose to download the required installation scripts

(Master's addresshttp://download.lxlabs.com/download/hypervm/production/hypervm-install-master.sh),On the server

运行sh ./hypervm-install-master.sh –-virtualization-type=openvz
The installation process will be done automatically,InstallingHyperVMAfter init 6 reboot,Then visit http browser://<server address>:8888Be able to operate virtual machines。

Comments

After whmcs restored to distortion

$mysql_charset=”utf8″;

Comments

Space into the database via SSH

Space Support SSH,It can be easily imported into the database via SSH

1. The database file format export to .sql,Do not compressed into .zip or .tar.gz file

2. .sql files uploaded to the server using FTP

3. Create a database,If the database does not exist

4. By SSH login server

5. In the SSH terminal,.sql file into the directory where

6. Run the following command:
# mysql -u username -p database_name < file.sql7. 然后,会提示输入数据库的密码,输入密码后就开始导入数据库的过程。在SSH中,使用命令行的方式,只能导入.sql文件

Comments

mysql master-slave synchronization principle

Replication thread

The Mysql Replication is an asynchronous replication process,From a Mysql instace(We call Master)Copied to another Mysql instance(We call it Slave)。Realization of the entire replication process between Master and Slave is done mainly by the three threads,Two threads(Sql threads and IO thread)In the end Slave,Another thread(IO thread)At the end of Master。

To achieve the MySQL Replication ,You must first open the Master end of the Binary Log(mysql-bin.xxxxxx)Features,Otherwise it is impossible to achieve。Various operations because the whole process is actually a copy Slave from the Master side to obtain the log and then himself completely in the implementation of the log in the order recorded。Open the MySQL Binary Log can be used in the process of starting MySQL Server "-log-bin" parameter options,Or my.cnf configuration file mysqld parameter set([mysqld]Section identifies the parameters after)Increase the "log-bin" Parameter。

The basic process is as follows MySQL replication:

  1. Slave IO above the thread connecting the Master,And requests the specified log file from the specified location(Or from the beginning of the log)After the contents of the log;

   2. After receiving the request from the Master of Slave IO thread,Log information is read by the specified log specify the location of the IO thread is responsible for copying the information after the request,Back to the Slave IO thread ends。Addition to the information contained in the log, in addition to the return information,This also includes the name of the information returned by the end of the Master Binary Log file and its location in the Binary Log in;

  3. Slave IO thread after receiving the information,The contents of the log of the received file are sequentially written to the Slave Relay Log end(mysql-relay-bin.xxxxxx)The very end,And records the file name and location of the read end of the Master bin-log to the master- info file,So that when the next time can be clearly read speed Master "I need a position from which bin-log log content beginning later,please send to me"

   4. Slave SQL thread detected Relay Log in newly added content after,Parses the contents of the Log file immediately becomes a real implementation of the Master side when those Query executable statement,And their implementation of these Query。such,Actually end in Master and Slave implementation of the same end Query,So the data is exactly the same at both ends。

Actually,In the old version,MySQL replication is not achieved at the end Slave to work together by the IO thread and the SQL thread two threads completed,But by a separate thread to do all the work。But MySQL's engineers soon discovered,Doing so there is a big risk and performance problems,Notably the following:

First of all,If you do this work independently, then by a single thread,Causes the end of the Master Copy,Binary Log Log,And parsing these logs,Then the execution of this process itself becomes a serial process,Performance will naturally be subject to greater restrictions,Replication of this architecture naturally relatively long delay。

Secondly,After this replication thread Slave side get up from Master Binary Log end,Then we need to resolve these,Restore the original end Query Master performed,Then in its own execution。During this process,Master end and is likely to have generated a lot of changes and generate a large amount of information Binary Log。If there is a fault can not be repaired at the end of this storage system Master stage,So at this stage all the changes arising will be lost forever,I can not get it back。This potential risk is particularly prominent in the Slave-side pressure is relatively large when,If the pressure is relatively large because the Slave,Log analysis and application of these logs time spent will naturally be longer,The data will also be lost more。

and so,In the latter part of the transformation,The new version of MySQL in order to minimize this risk,And improve the performance of replication,Copy the Slave-side instead of two threads to finish,That is, the aforementioned IO thread and the SQL thread。The first proposed improvement program is Yahoo!An engineer "Jeremy Zawodny"。Through this transformation,This will not only largely solve the performance problems,Shorten the delay time of asynchronous,While reducing the potential amount of data loss。

of course,Even replaced the two threads so now to collaborate after,Also there is still the possibility of Slave data latency and data loss is,After all, this replication is asynchronous。Whenever you change the data in a transaction not,These problems are there。

If you want to completely avoid these problems,We can only use the MySQL Cluster to solve。But the MySQL Cluster know when I wrote this part of,It is still a number of memory database solutions,That is, all the data including the index will need all Load into memory,This memory requirement is very large large,For the general popularity of applications can be implemented not too much。of course,Before that communicate with the MySQL CTO David when,MySQL is now achieve continuous improvement of its Cluster,One very large data do not allow a change is all the Load into memory,But merely an index of all Load into memory,I would like to believe that after the completion of the transformation will be more popular MySQL Cluster,Can be implemented will be greater。

Comments

mysql-yourself Mathematical Functions

All mathematical functions return NULL in case of an error。


Unary minus。Sign change parameters。
mysql> select – 2;

note,If this operator is used with a BIGINT,The return value is a BIGINT! This means you should avoid using the integer -,That may be the value of -2 ^ 63!
ABS(X)
Returns the absolute value of X。
mysql> select ABS(2);
-> 2
mysql> select ABS(-32);
-> 32

This function can be used to secure value BIGINT。

SIGN(X)
Returns the signs of the parameters,-1、0Or 1,Depending on whether X is negative、Zero or a positive number。
mysql> select SIGN(-32);
-> -1
mysql> select SIGN(0);
-> 0
mysql> select SIGN(234);
-> 1

MOD(N,M)
 
%
mold (Similarly% operators in C)。Returns the remainder being M divided by N。
mysql> select MOD(234, 10);
-> 4
mysql> select 253 % 7;
-> 1
mysql> select MOD(29,9);
-> 2

This function can be used safely BIGINT value。
FLOOR(X)
Returns the maximum integer value not greater than X,。

mysql> select FLOOR(1.23);
-> 1
mysql> select FLOOR(-1.23);
-> -2

Note that the return value is converted to a BIGINT!
CEILING(X)
Returns the smallest integer not less than X,。
mysql> select CEILING(1.23);
-> 2
mysql> select CEILING(-1.23);
-> -1

Note that the return value is converted to a BIGINT!

ROUND(X)
It returns an integer rounding parameter X。
mysql> select ROUND(-1.23);
-> -1
mysql> select ROUND(-1.58);
-> -2
mysql> select ROUND(1.58);
-> 2

Note that the return value is converted into a BIGINT!

ROUND(X,D)
Returns rounding the parameter X has a D decimals。If D is 0,The results will have no decimal point or fractional part。
mysql> select ROUND(1.298, 1);
-> 1.3
mysql> select ROUND(1.298, 0);
-> 1

Note that the return value is converted into a BIGINT!

EXP(X)
Return value e (natural logarithm of the bottom) of the power of X。
mysql> select EXP(2);
-> 7.389056
mysql> select EXP(-2);
-> 0.135335

LOG(X)
Returns the natural logarithm of X。
mysql> select LOG(2);
-> 0.693147
mysql> select LOG(-2);
-> NULL

If you want to count on any of the bottom B of a digital X,Use the formula LOG(X)/LOG(B)。

LOG10(X)
Returns the number X of the base 10。
mysql> select LOG10(2);
-> 0.301030
mysql> select LOG10(100);
-> 2.000000
mysql> select LOG10(-100);
-> NULL

POW(X,Y)
 
POWER(X,Y)
Y return power value X。
mysql> select POW(2,2);
-> 4.000000
mysql> select POW(2,-2);
-> 0.250000
SQRT(X)
Returns the non-negative square root of X。
mysql> select SQRT(4);
-> 2.000000
mysql> select SQRT(20);
-> 4.472136

PI()
PI return value (pi)。
mysql> select PI();
-> 3.141593

COS(X)
Returns the cosine of X, Where X is given in radians。
mysql> select COS(PI());
-> -1.000000

WITHOUT(X)
Returns the sine of X,Here X is given in radians。
mysql> select SIN(PI());
-> 0.000000

TAN(X)
Returns the tangent of X,Here X is given in radians。
mysql> select TAN(PI()+1);
-> 1.557408

ACOS(X)
X returns the inverse cosine,Ie it is a cosine X。If X is not in the range -1 to 1,,Return NULL。
mysql> select ACOS(1);
-> 0.000000
mysql> select ACOS(1.0001);
-> NULL
mysql> select ACOS(0);
-> 1.570796

ASIN(X)
X returns arcsine,I.e. the sine value which is X。L X is not in the range of -1 to 1 if the,Return NULL。
mysql> select ASIN(0.2);
-> 0.201358
mysql> select ASIN(‘foo’);
-> 0.000000

ATA(X)
X returns the arctangent,That which is tangent X。
mysql> select ATAN(2);
-> 1.107149
mysql> select ATAN(-2);
-> -1.107149
ATAN2(X,Y)
Back two variables X and Y arctangent。It is similar to calculation of Y / X arctangent,In addition to signs of both parameters are used to determine the quadrant of the result。
mysql> select ATAN(-2,2);
-> -0.785398
mysql> select ATAN(PI(),0);
-> 1.570796
COT(X)
Returns the cotangent of X。
mysql> select COT(12);
-> -1.57267341
mysql> select COT(0);
-> NULL

RAND()
 
RAND(N)
Back in the range 0 to 1.0 in the random floating point values。If N is a specified integer parameter,It is used as a seed value。
mysql> select RAND();
-> 0.5925
mysql> select RAND(20);
-> 0.1811
mysql> select RAND(20);
-> 0.1811
mysql> select RAND();
-> 0.2079
mysql> select RAND();
-> 0.7888

You can not use an ORDER BY clause RAND()Value using the column,Because ORDER BY would be repeated many times computed column。However, in the MySQL3.23,you can do: SELECT * FROM table_name ORDER BY RAND(),This is beneficial to get one from SELECT * FROM table1,table2 WHERE a=b AND c
LEAST(X,Y,…)
There are two or more parameters and,The minimum return(Minimum)Parameters。Parameters were compared using the following rules:
If the return value is used in a context INTEGER,Or all of the parameters are integer values,They compared as integers。
If the return value is used in a context REAL,Or all of the real-valued parameters,As they are more real numbers。
If any parameter is sensitive to the size of a string,Parameters are compared as case-sensitive string。
In other cases,Parameters are compared as a case insensitive string。
mysql> select LEAST(2,0);
-> 0
mysql> select LEAST(34.0,3.0,5.0,767.0);
-> 3.0
mysql> select LEAST(“B”,”A”,”C”);
-> “A”

In previous versions of MySQL 3.22.5,You can use MIN()Instead LEAST。

GREATEST(X,Y,…)
Returns the maximum(Maximum)Parameters。LEAST parameters using the same rules as to compare。
mysql> select GREATEST(2,0);
-> 2
mysql> select GREATEST(34.0,3.0,5.0,767.0);
-> 767.0
mysql> select GREATEST(“B”,”A”,”C”);
-> “C”

In the MySQL 3.22.5 previous version, You can use MAX()Instead of GREATEST.
DEGREES(X)
Return parameter X,Converted from radian angle。
mysql> select DEGREES(PI());
-> 180.000000
RADIANS(X)
Return parameter X,Is converted from degrees to radians。
mysql> select RADIANS(90);
-> 1.570796

TRUNCATE(X,D)
Returns X,Truncated to D decimals。If D is 0,The results will have no decimal point or fractional part。
mysql> select TRUNCATE(1.223,1);
-> 1.2
mysql> select TRUNCATE(1.999,1);
-> 1.9
mysql> select TRUNCATE(1.999,0);
-> 1

Comments

CentOS 5 The OpenSSL and OpenSSH upgrade

The OpenSSL and OpenSSH upgraded。CentOS 5.2 is brought OpenSSL 0.9.8b,OpenSSH is 4.0p1。Upgrade follows:

openssh latest version (http://www.openssh.com/portable.html)

wget http://www.openssl.org/source/openssl-0.9.8j.tar.gz

tar zxvf openssl-0.9.8j.tar.gz

cd openssl-0.9.8j

./config –prefix=/usr

make

make test

make install

wget http://openbsd.noc.jgm.gov.ar/pub/OpenBSD/OpenSSH/portable/openssh-5.2p1.tar.gz

tar zxvf openssh-5.2p1.tar.gz

cd openssh-5.2p1

./configure –prefix=/usr –with-pam –with-zlib –sysconfdir=/etc/ssh –with-ssl-dir=/usr –with-md5-passwords

make

make install

Comments

« Previous entries Next Page » Next Page »