CentOS处理 .rpmnew 和 .rpmsave 文件

日期: 08 月 07日, 2014
标签:

在升级软件包时,有时不同版本间的配置文件可能会不太兼容。RPM使用 .rpmnew.rpmsave 来处理这种情况。有时,新版本的配置文件会保存为 .rpmnew;有时,会把老版本的配置文件保存为 .rpmsave

处理 .rpmnew.rpmsave 文件的方法为:

  1. 比较新旧配置文件的不同
  2. 参照新的配置文件手动修改
  3. 删除旧的配置文件

下面举例说明具体步骤。

查找 .rpmnew.rpmsave 文件

root 权限执行下面的命令,查询系统中所有的 .rpmnew.rpmsave 文件:

for tmp in $(find /etc /var -name '*.rpm?*'); do echo $tmp; done

执行结果为:

/etc/php-fpm.d/www.conf.rpmnew
/etc/sysconfig/saslauthd.rpmsave
/var/lib/rpm/.rpm.lock

比较新旧配置文件

cd /etc/php-fpm.d/
diff -aur www.conf{,.rpmnew}

结果如下:

--- www.conf	2014-07-01 02:57:14.956961608 +0800
+++ www.conf.rpmnew	2014-07-16 17:14:47.000000000 +0800
@@ -9,7 +9,7 @@
 ;                            specific port;
 ;   '/path/to/unix/socket' - to listen on a unix socket.
 ; Note: This value is mandatory.
-listen = /var/run/php-fpm/php-fpm.sock
+listen = 127.0.0.1:9000
 
 ; Set listen(2) backlog. A value of '-1' means unlimited.
 ; Default Value: -1
@@ -21,24 +21,24 @@
 ; must be separated by a comma. If this value is left blank, connections will be
 ; accepted from any ip address.
 ; Default Value: any
-;listen.allowed_clients = 127.0.0.1
+listen.allowed_clients = 127.0.0.1
 
 ; Set permissions for unix socket, if one is used. In Linux, read/write
 ; permissions must be set in order to allow connections from a web server. Many
 ; BSD-derived systems allow connections regardless of permissions. 
 ; Default Values: user and group are set as the running user
-;                 mode is set to 0666
-listen.owner = nginx
-listen.group = nginx
-listen.mode = 0660
+;                 mode is set to 0660
+;listen.owner = nobody
+;listen.group = nobody
+;listen.mode = 0660
 
 ; Unix user/group of processes
 ; Note: The user is mandatory. If the group is not set, the default user's group
 ;       will be used.
 ; RPM: apache Choosed to be able to access some dir as httpd
-user = nginx
+user = apache
 ; RPM: Keep a group allowed to write in log dir.
-group = nginx
+group = apache
 
 ; Choose how the process manager will control the number of child processes.
 ; Possible Values:
@@ -67,22 +67,22 @@
 ; CGI.
 ; Note: Used when pm is set to either 'static' or 'dynamic'
 ; Note: This value is mandatory.
-pm.max_children = 64
+pm.max_children = 50
 
 ; The number of child processes created on startup.
 ; Note: Used only when pm is set to 'dynamic'
 ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2
-pm.start_servers = 8
+pm.start_servers = 5
 
 ; The desired minimum number of idle server processes.
 ; Note: Used only when pm is set to 'dynamic'
 ; Note: Mandatory when pm is set to 'dynamic'
-pm.min_spare_servers = 8
+pm.min_spare_servers = 5
 
 ; The desired maximum number of idle server processes.
 ; Note: Used only when pm is set to 'dynamic'
 ; Note: Mandatory when pm is set to 'dynamic'
-pm.max_spare_servers = 32
+pm.max_spare_servers = 35
  
 ; The number of requests each child process should execute before respawning.
 ; This can be useful to work around memory leaks in 3rd party libraries. For
@@ -222,5 +222,6 @@
 
 ; Set session path to a directory owned by process user
 php_value[session.save_handler] = files
-php_value[session.save_path] = /var/lib/php/session
+php_value[session.save_path]    = /var/lib/php/session
+php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache

处理

可以看出,大部分不同之处都是之前对 /etc/php-fpm.d/www.conf 做的修改,新的配置文件只是增加了php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache,那么把这一行添加到旧的配置文件中就行了

echo 'php_value[soap.wsdl_cache_dir]  = /var/lib/php/wsdlcache' >> www.conf
rm www.conf.pacnew
service php-fpm restart