[SCM]源码管理 - perforce server的Linux的安装

 

perforce的Linux的安装

 

一 安装前配置

1) 机器配置

修改机器名

申请静态ip和dns上此ip到机器名的映射。

 

2) 用户配置

在root下创建用户组,用户和所在的home目录。

创建perforce group :

  /usr/sbin/groupadd perforceg

创建perforce user:

  mkdir /local

  mkdir /local/perforce

  /usr/sbin/useradd -m -d /local/perforce -g perforceg perforce

修改perforce user的密码:

  /usr/bin/passwd perforce  (输入123)

查看创建的用户perforce的信息:

id perforce
uid=504(perforce) gid=504(perforceg) groups=504(perforceg)

修改home目录的owner:

chown perforce:perforceg /local/perforce

 

3) perforce server 的目录

su - perforce

mkdir /local/perforce/p4root

mkdir /local/perforce/log

mkdir /local/perforce/journal

[通常地p4root,log,journal需要挂载到不同的物理硬盘,来避免灾难事故的影响]

 

4)设置用户的su和sudo为不需要密码

参考:设置su和sudo为不需要密码

 

二 下载和安装

0) 安装好后的文件和目录如下:

-bash-3.2$ pwd
/local/perforce
-bash-3.2$ ls -l
总计 3120
drwxr-xr-x 2 perforce perforceg    4096 2011-02-15 Desktop
drwxr-xr-x 2 perforce perforceg    4096 08-18 19:01 journal
drwxr-xr-x 2 perforce perforceg    4096 08-18 18:51 log
-rwxr-xr-x 1 perforce perforceg  777652 08-18 18:37 p4
-rwxr-xr-x 1 perforce perforceg 2381536 08-18 18:45 p4d
drwxr-xr-x 2 perforce perforceg    4096 08-19 13:02 p4root
-rwxr-xr-x 1 perforce perforceg     982 08-19 13:39 p4server001
-rw-r--r-- 1 perforce perforceg     366 08-19 13:28 p4server001.ini

 

1)安装

在perforce的download页面上找到P4D和p4的Linux下载文件。

chmod +x p4d

chmod +x p4

将p4d和p4拷贝到/local/perforce下

 

2)p4d的配置文件

/local/perforce/p4server001.ini
#  This will be configure file  for  p4 server ,
#  and it need be  $ USERHOME /$ P4SERVERNAME . ini
USER
= perforce
USERHOME
=/ local / perforce

P4USER
= perforce
P4PASSWD
= 123
P4SERVERNAME
= p4server001

p4
=$ USERHOME / p4
p4d
=$ USERHOME / p4d

P4PORT
= 10.148 . 151.98 : 1666
P4ROOT
=$ USERHOME / p4root
JOURNAL
=$ USERHOME / journal
LOG
=$ USERHOME / log / p4server001 . log

TRACKLEVEL
= 1
SERVERLEVEL
= 2

3) 启动脚本/local/perforce/p4server001,将p4server001拷贝到/etc/init.d下,命令为cp /local/perforce/p4server001 /etc/init.d/。

参考:http://www.xueai.org/2010/11/110.html

# ! / bin / bash
#
#  chkconfig: 1235   80   80
#  description: p4server001 daemon
#

PATH =/ sbin: / bin: / usr / bin: / usr / sbin

#  Source in the configs ...
.   / local / perforce / p4server001 . ini

SU
= " su $USER -c "
LOCKFILE
=$ USERHOME /$ P4SERVERNAME . lock

start ()  {
    STARTCMD
= " $p4d -d -v server=$SERVERLEVEL,track=$TRACKLEVEL -p $P4PORT -r $P4ROOT -L $LOG -J $JOURNAL "
    
$ SU  " $STARTCMD "   2 > & 1
    touch 
$ LOCKFILE
    
$ SU  " logger p4d starting "
    
echo   " p4d was started on "  `hostname -s`
}

stop
()  {
    STOPCMD
= " $p4 -p $P4PORT -u $P4USER admin stop "
    
echo   $ P4PASSWD |  $ p4 -p  $ P4PORT -u  $ P4USER login
    
$ SU  " $STOPCMD "   2 > & 1
    rm 
$ LOCKFILE
    
$ SU  " logger p4d stopping "
    
echo   " p4d was stopped on "  `hostname -s`
}

status
()  {
    
if  [ -f  $ LOCKFILE ] ;
        
then
            
echo  p4d status: running
        
else
            
echo  p4d status: stopped
    fi
}

case 
" $1 "  in

'
start ' )
        
start
        
;;

'stop'
)
        stop
        
;;

'status'
)
        status
        
;;
*
)
        
echo   " Usage: p4server001 { start | stop | status } "
        
;;

esac

 

4) 启动p4d

$su - perforce
-bash-3.2$ /etc/init.d/p4server001 start
Perforce Server starting...
p4d was started on machinie

 

也可以使用命令来启动:
/sbin/service p4server001 start


5) 查看

/etc/init.d/p4server001 status
p4d status: running
ps -ef | grep p4d
perforce 30898     1  0 14:04 ?        00:00:00 /local/perforce/p4d -d -v server=2,track=1 -p 10.148.151.98:1666 -r /local/perforce/p4root -L /local/perforce/log/p4server001.log -J /local/perforce/journal/journal

 

至此可以在远程的机器上使用p4v或p4来访问此p4server了。

 

三 优化

1) 配置为daemon,当机器重启后能自动运行

使用chkconfig,脚本前必须有如下的行:

#!/bin/bash
#
# chkconfig:1235 80 80
# description: p4server001 daemon
#
 

安装chkconfig,命令为yum install chkconfig

将上面的p4server001配置为daemon,命令为:

su -

/sbin/chkconfig --add p4server001

 

安装后查看:

/sbin/chkconfig --list | grep p4server001

p4server001     0:关闭  1:启用  2:启用  3:启用  4:关闭  5:启用  6:关闭

四 配置inetd 或xinetd, 使p4 server只有有request的时候才启动,需要使用p4d 的-i参数支持inetd,如果使用inetd或xinetd,则不需要前面的daemon的配置了,因为不需要p4d在机器启动的时候就启动。

参考:
http://kb.perforce.com/article/45/running-a-perforce-server-from-inetd-on-unix
http://hints.macworld.com/article.php?story=20041112174525470

 

在文件中/etc/services中增加:
p4server001 1666/tcp

 

#netview-aix-6   1666/udp   # netview-aix-6 
p4server001 1666/tcp # Perforce Server
#netview-aix-6 1666/tcp # netview-aix-6
 

 

然后创建/etc/xinetd.d/p4server001,且内容为:

service p4server001
{
  socket_type = stream
  wait = no
  user = perforce
  server = /local/perforce/p4d
  server_args = -i -L /local/perforce/log/p4server001.log -r /local/perforce/p4root -p 10.148.151.98:1888 -J /local/perforce/journal/journal
  disable = no

 

可以在远程的机器上登录10.148.151.98:1888,然后在server上查看进程ps -ef | grep p4d,如下:

perforce 11778 11776  0 19:20 ?        00:00:00 p4d -i -L /local/perforce/log/p4server001.log -r /local/perforce/p4root -p 10.148.151.98:1888 -J /local/perforce/journal/journal

 

 

注意: xinetd监听1666端口,然后当1666端口有请求时启动的p4d运行在1888端口。(这里不知道为啥想设置server运行在1666的时候老是起不来)

 

完!

转载于:https://www.cnblogs.com/itech/archive/2011/08/19/2146058.html

你可能感兴趣的:(操作系统,php,运维)