1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Azure】Perforceサーバー(p4d)とプロキシ(p4p)の構築手順まとめ

Last updated at Posted at 2025-10-29

1. はじめに

1-1 ご挨拶

初めまして、井村と申します。
Azure上のLinux仮想マシンにて、Perforceサーバー(p4d)とプロキシ(p4p)のインストールおよび、クライアントアプリからの接続検証を行いました。その手順をまとめた記事です。

参考リンクの皆様には感謝申し上げます。

1-2 Perforceとは

Perforce(正式名称:Helix Core)は、ソフトウェア開発におけるバージョン管理システム(VCS)の一つです。特に、大規模なコードベースやバイナリファイルの管理に強みを持ち、ゲーム開発や半導体設計などの分野で広く利用されています。

Perforceの主な特徴は以下の通りです:

  • 集中型のリポジトリ構造:Gitのような分散型とは異なり、中央サーバーで一元管理されます。
  • 高性能なファイル管理:数百万ファイルや巨大なバイナリでも高速に処理可能。
  • アクセス制御と監査機能:企業向けに細かい権限設定や操作履歴の追跡が可能。
  • プロキシ(p4p)やレプリケーション機能:地理的に分散した開発チームでも効率的に利用可能。

今回の記事では、Perforceの中核であるサーバー(p4d)と、リモートアクセスを高速化するプロキシ(p4p)の構築手順を紹介しています。

2. 構築

インフラのデプロイとパッケージのインストールはTerraformで行います。
ソースとデプロイ方法はGitHubにあります。

SystemConfiguration.png

2-1 p4-serverの設定

以下はp4-serverの設定手順です。

ubuntu
# 初期セットアップ
sudo /opt/perforce/sbin/configure-helix-p4d.sh

# サービス確認
systemctl status p4dctl

# p4d設定作業
# ログイン
export P4USER=super
export P4PORT=ssl:1666
p4 login

# 認証チケットの状態を確認
p4 login -s

# ライセンスの確認
p4 license -u

# サービスユーザーの作成(p4p用)
p4 user -f svc_proxy
# "Type: service"を追記する。

# サービスユーザーのパスワード(p4p用)
p4 -u svc_proxy passwd

# 一般ユーザーの作成(検証用)
p4 user -f testuser1

# グループの作成と設定(サービスユーザーのチケットを無期限にする)
p4 group service_users
# Timeout:43200 → Timeout:unlimited
# PasswordTimeout:unset → PasswordTimeout:unlimited
# Users:にsvc_proxyを追加する。

以下はp4-serverの設定手順実行ログ等です。

ubuntu
# 初期セットアップ
adminuser@vm-linux-dev-demo-p4d:~$ sudo /opt/perforce/sbin/configure-helix-p4d.sh

Summary of arguments passed:

Service-name        [(not specified)]
P4PORT              [(not specified)]
P4ROOT              [(not specified)]
Super-user          [(not specified)]
Super-user passwd   [(not specified)]
Unicode mode        [(not specified)]
Case-sensitive      [(not specified)]

For a list of other options, type Ctrl-C to exit, and then run:
$ sudo /opt/perforce/sbin/configure-helix-p4d.sh --help


You have entered interactive configuration for p4d. This script
will ask a series of questions, and use your answers to configure p4d
for first time use. Options passed in from the command line or
automatically discovered in the environment are presented as defaults.
You may press enter to accept them, or enter an alternative.

Please provide the following details about your desired P4 environment:


P4 Service name [master]: 
Service master not found. Creating...
P4 Server root (P4ROOT) [/opt/perforce/servers/master]: 
Create directory? (y/n) [y]: 
{P4} Server unicode-mode (y/n) [n]: 
P4 Server case-sensitive (y/n) [y]: 
P4 Server address (P4PORT) [ssl:1666]: 
P4 super-user login [super]: 
P4 super-user password: 
Re-enter password.
P4 super-user password: 

Configuring p4d service 'master' with the information you specified...

Started 'master' p4d service.
Started 1 services.
Establish trust relationship with SSL-enabled server...
The fingerprint of the server of your P4PORT setting
'ssl:1666' (127.0.0.1:1666) is not known.
That fingerprint is AB:AE:40:1F:67:DE:CA:FE:B6:62:EB:FF:A6:AE:22:C5:CB:EC:41:1F
Added trust for P4PORT 'ssl:1666' (127.0.0.1:1666)
Also adding trust to calling user 'adminuser'.
Creating super-user account...
User super not changed.
Initializing protections table...
Protections saved.
Setting security level to 4 (high)...
Counter security set.
Setting password...
Creating ticket for root user
Also creating ticket for calling user 'adminuser'.


::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::
::  P4 Server configuration has completed successfully.
::
::  Here is what has been done so far:
::
::  - Your p4d service settings have been written to 
::    the following p4dctl configuration file:
::      /etc/perforce/p4dctl.conf.d/master.conf
::  - The p4d service has been initialized with the P4ROOT:
::      /opt/perforce/servers/master/root
::  - The p4d service has been started with the P4PORT: ssl:1666
::  - The p4d service has been set to Security Level 3.
::  - The new P4 super-user 'super' has been created and the
::    password has been set to the one specified.
::
::  Here is what you can do now:
::
::  - You can manage it with the 'perforce' user, using the following:
::
::      sudo -u perforce p4dctl <cmd> 
::
::  - You can connect to it by setting the P4PORT and P4USER
::    environment variables and running 'p4 <cmd>'. For example, run:
::
::      export P4PORT=ssl:1666
::      export P4USER=super
::
::      p4 login
::
::    For help, run:
::
::      p4 help
::
::  - To connect to this p4d service from another machine, include
::    this machine's name or IP address in the P4PORT. For example:
::
::      export P4PORT=ssl:10.0.2.4:1666
::
::  - For help with creating P4 user accounts, populating the depot
::    with files, and making other customizations for your site, see
::    the P4 Server Administrator Guide:
::
::    https://www.perforce.com/perforce/doc.current/manuals/p4sag/index.html
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

# サービス確認
adminuser@vm-linux-dev-demo-p4d:~$ systemctl list-units --type=service | grep p4
  p4dctl.service                                        loaded active exited  P4 Server
adminuser@vm-linux-dev-demo-p4d:~$ 
adminuser@vm-linux-dev-demo-p4d:~$ systemctl status p4dctl
● p4dctl.service - P4 Server
     Loaded: loaded (/usr/lib/systemd/system/p4dctl.service; enabled; preset: enabled)
     Active: active (exited) since Wed 2025-10-29 04:47:36 UTC; 21min ago
    Process: 1974 ExecStart=/opt/perforce/sbin/p4dctl-init.sh start (code=exited, status=0/SUCCESS)
   Main PID: 1974 (code=exited, status=0/SUCCESS)
        CPU: 9ms

Oct 29 04:47:36 vm-linux-dev-demo-p4d systemd[1]: Started p4dctl.service - P4 Server.
Oct 29 04:47:36 vm-linux-dev-demo-p4d p4dctl[1980]: Started 0 services.
                                                    No services configured.

# p4d設定作業
adminuser@vm-linux-dev-demo-p4d:~$ export P4USER=super
adminuser@vm-linux-dev-demo-p4d:~$ export P4PORT=ssl:1666
adminuser@vm-linux-dev-demo-p4d:~$ p4 login
Enter password: 
User super logged in.
adminuser@vm-linux-dev-demo-p4d:~$ 

# 認証チケットの状態を確認
p4 login -s
User super ticket expires in 11 hours 59 minutes.

# ライセンス状態の確認
adminuser@vm-linux-dev-demo-p4d:~$ p4 license -u
... isLicensed no
... userCount 1
... userLimit unlimited
... userSoftLimit 5
... clientCount 0
... clientLimit unlimited
... clientSoftLimit 20
... fileCount 0
... fileLimit unlimited
... fileSoftLimit 1000
... repoCount 0
... repoLimit 3
... repoSoftLimit 3

# サービスユーザーの作成(p4p用)
adminuser@vm-linux-dev-demo-p4d:~$ p4 user -f svc_proxy
# "Type:	service"を追記する。

# サービスユーザーのパスワード(p4p用)
adminuser@vm-linux-dev-demo-p4d:~$ p4 -u svc_proxy passwd
Enter new password: 
Re-enter new password: 
Password updated.

# 一般ユーザーの作成(検証用)
adminuser@vm-linux-dev-demo-p4d:~$ p4 user -f testuser1
# 修正なし

# グループの作成と設定(サービスユーザーのチケットを無期限にする)
adminuser@vm-linux-dev-demo-p4d:~$ p4 group service_users
# Timeout:43200 → Timeout:unlimited
# PasswordTimeout:unset → PasswordTimeout:unlimited
# Users:にsvc_proxyを追加する。

# 設定の確認
adminuser@vm-linux-dev-demo-p4d:~$ p4 group -o service_users
# A Perforce Group Specification.
#
#  Group:       The name of the group.
#  Description: A description for the group (optional).
#  MaxResults:  Limits the rows (unless 'unlimited' or 'unset') any one
#               operation can return to the client.
#               See 'p4 help maxresults'.
#  MaxScanRows: Limits the rows (unless 'unlimited' or 'unset') any one
#               operation can scan from any one database table.
#               See 'p4 help maxresults'.
#  MaxLockTime: Limits the time (in milliseconds, unless 'unlimited' or
#               'unset') any one operation can lock any database table when
#               scanning data. See 'p4 help maxresults'.
#  MaxOpenFiles:
#               Limits files (unless 'unlimited' or 'unset') any one
#               operation can open. See 'p4 help maxresults'.
#  MaxMemory:
#               Limits the amount of memory a command may consume.
#               Unit is megabytes.  See 'p4 help maxresults'.
#  Timeout:     A time (in seconds, unless 'unlimited' or 'unset')
#               which determines how long a 'p4 login'
#               session ticket remains valid (default is 12 hours).
#  IdleTimeout: A time (in seconds, unless 'unlimited' or 'unset')
#               which determines how long after the last command was run to
#               invalidate a 'p4 login' session (default is unset).
#               See 'p4 help group'.
#  PasswordTimeout:
#               A time (in seconds, unless 'unlimited' or 'unset')
#               which determines how long a 'p4 password'
#               password remains valid (default is unset).
#  LdapConfig:  The LDAP configuration to use when populating the group's
#               user list from an LDAP query. See 'p4 help ldap'.
#  LdapSearchQuery:
#               The LDAP query used to identify the members of the group.
#  LdapUserAttribute:
#               The LDAP attribute that represents the user's username.
#  LdapUserDNAttribute:
#               The LDAP attribute in the group object that contains the
#               DN of the user object.
#  Subgroups:   Other groups automatically included in this group.
#  Owners:      Users allowed to change this group without requiring super
#               access permission.
#  Users:       The users in the group.  One per line.

Group:service_users

Description:

MaxResults:unset

MaxScanRows:unset

MaxLockTime:unset

MaxOpenFiles:unset

MaxMemory:unset

Timeout:unlimited

IdleTimeout:unset

PasswordTimeout:unlimited

Subgroups:

Owners:

Users:
svc_proxy

# ユーザー作成の確認
adminuser@vm-linux-dev-demo-p4d:~$ p4 users
super <super@vm-linux-dev-demo-p4d> (super) accessed 2025/10/29
testuser1 <testuser1@vm-linux-dev-demo-p4d> (testuser1) accessed 2025/10/29

# ライセンス消費の確認
adminuser@vm-linux-dev-demo-p4d:~$ p4 license -u
... isLicensed no
... userCount 2
... userLimit unlimited
... userSoftLimit 5
... clientCount 0
... clientLimit unlimited
... clientSoftLimit 20
... fileCount 0
... fileLimit unlimited
... fileSoftLimit 1000
... repoCount 0
... repoLimit 3
... repoSoftLimit 3

# サービスユーザーの確認
adminuser@vm-linux-dev-demo-p4d:~$ p4 user -o svc_proxy
# A Perforce User Specification.
#
#  User:        The user's user name.
#  Type:        Either 'service', 'operator', or 'standard'.
#               Default: 'standard'. Read only.
#  Email:       The user's email address; for email review.
#  Update:      The date this specification was last modified.
#  Access:      The date this user was last active.  Read only.
#  FullName:    The user's real name.
#  JobView:     Selects jobs for inclusion during changelist creation.
#  Password:    If set, user must have matching $P4PASSWD on client.
#  AuthMethod:  'perforce' if using standard authentication or 'ldap' if
#               this user should use native LDAP authentication.  The '+2fa'
#               modifier can be added to the AuthMethod, requiring the user to
#               perform multi factor authentication in addition to password
#               authentication. For example: 'perforce+2fa'.
#  Reviews:     Listing of depot files to be reviewed by user.

User:svc_proxy

Type:service

Email:svc_proxy@vm-linux-dev-demo-p4d

Update:2025/10/29 05:18:35

Access:2025/10/29 05:18:35

FullName:svc_proxy

以上で、p4-serverの設定は完了です。

2-2 p4-proxyの設定

以下はp4-proxyの設定手順です。

ubuntu
# 変数宣言
P4USER=<サービスユーザー名>
P4TARGET="ssl:<address-of-parent-master-or-edge>:1666"
P4PNAME="p4proxy"
P4PCACHE=/opt/perforce/servers/p4proxy
P4PORT=<The port to open on the proxy that users will connect to>

# キャッシュディレクトリ作成
sudo mkdir -p $P4PCACHE
sudo chown perforce:perforce $P4PCACHE

# コンフィグファイル作成
sudo tee /etc/perforce/p4dctl.conf.d/p4p.conf > /dev/null << EOF
# Config File for p4proxy

p4p $P4PNAME
{
    Owner       =       perforce
    Execute     =       /usr/sbin/p4p
    Umask       =       077

    Environment
    {
        P4USER=$P4USER
        P4PORT=$P4PORT
        P4TARGET=$P4TARGET
        P4PCACHE=$P4PCACHE
        PATH=/bin:/usr/bin:/usr/local/bin
    }
}
EOF

# SSL接続のための信頼関係の確立
sudo runuser -l perforce -c "p4 -p $P4TARGET trust -y"

# 認証チケット取得
sudo runuser -l perforce -c "echo '<サービスユーザーのパスワード>' | p4 -u svc_proxy -p ssl:10.0.2.4:1666 login"

# 認証チケット確認
sudo runuser -l perforce -c "p4 -u svc_proxy -p ssl:10.0.2.4:1666 login -s"

# Proxyサービスの起動
sudo p4dctl start $P4PNAME

# Proxyサービスの状態確認コマンド
sudo p4dctl status $P4PNAME

# プロセス確認
ps aux | grep p4p

# ポート確認
sudo ss -tuln | grep 1999

# ログ確認
sudo tail -n 50 /opt/perforce/servers/p4proxy/log

# Proxyログのローテーション設定
sudo tee /etc/logrotate.d/p4proxy > /dev/null << 'EOF'
/opt/perforce/servers/p4proxy/log {
    size 10M
    rotate 7
    compress
    missingok
    notifempty
    create 0600 perforce perforce
}
EOF

# ローテーションのテスト(設定内容の確認(dry-run))
sudo logrotate -d /etc/logrotate.d/p4proxy

# 強制的にローテーションを実行(テスト)
sudo logrotate -f /etc/logrotate.d/p4proxy

# ログファイルの確認
sudo ls -l /opt/perforce/servers/p4proxy/

以下はp4-proxyの設定手順実行ログ等です。

ubuntu
# 変数宣言
adminuser@vm-linux-dev-demo-p4p:~$ P4USER=svc_prox
adminuser@vm-linux-dev-demo-p4p:~$ P4TARGET="ssl:10.0.2.4:1666" # the master server (or edge) that this will be a proxy for
adminuser@vm-linux-dev-demo-p4p:~$ P4PNAME="p4proxy" # The name for the proxy service in p4dctl
adminuser@vm-linux-dev-demo-p4p:~$ P4PCACHE=/opt/perforce/servers/p4proxy # local directory to store the cache
adminuser@vm-linux-dev-demo-p4p:~$ P4PORT=1999 # The port to open on the proxy that users will connect to

# Make our server directory
adminuser@vm-linux-dev-demo-p4p:~$ sudo mkdir -p $P4PCACHE
adminuser@vm-linux-dev-demo-p4p:~$ sudo chown perforce:perforce $P4PCACHE

# Make our config file for p4dctl
adminuser@vm-linux-dev-demo-p4p:~$ sudo tee /etc/perforce/p4dctl.conf.d/p4p.conf > /dev/null << EOF
# Config File for p4proxy

p4p $P4PNAME
{
    Owner       =       perforce
    Execute     =       /usr/sbin/p4p
    Umask       =       077

    Environment
    {
        P4USER=$P4USER
        P4PORT=$P4PORT
        P4TARGET=$P4TARGET
        P4PCACHE=$P4PCACHE
        PATH=/bin:/usr/bin:/usr/local/bin
    }
}
EOF

adminuser@vm-linux-dev-demo-p4p:~$ sudo cat /etc/perforce/p4dctl.conf.d/p4p.conf
# Config File for p4proxy

p4p p4proxy
{
    Owner       =       perforce
    Execute     =       /usr/sbin/p4p
    Umask       =       077

    Environment
    {
        P4USER=svc_proxy
        P4PORT=1999
        P4TARGET=ssl:10.0.2.4:1666
        P4PCACHE=/opt/perforce/servers/p4proxy
        PATH=/bin:/usr/bin:/usr/local/bin
    }
}

# Need to establish trust
adminuser@vm-linux-dev-demo-p4p:~$ sudo runuser -l perforce -c "p4 -p $P4TARGET trust -y"
The fingerprint of the server of your P4PORT setting
'ssl:10.0.2.4:1666' (10.0.2.4:1666) is not known.
That fingerprint is AB:AE:40:1F:67:DE:CA:FE:B6:62:EB:FF:A6:AE:22:C5:CB:EC:41:1F
Added trust for P4PORT 'ssl:10.0.2.4:1666' (10.0.2.4:1666)
adminuser@vm-linux-dev-demo-p4p:~$

# チケット取得
adminuser@vm-linux-dev-demo-p4p:~$ sudo runuser -l perforce -c "echo 'P@ssword@12345' | p4 -u svc_proxy -p ssl:10.0.2.4:1666 login"
Enter password:
User svc_proxy logged in.
adminuser@vm-linux-dev-demo-p4p:~$

# チケットの確認
adminuser@vm-linux-dev-demo-p4p:~$ sudo runuser -l perforce -c "p4 -u svc_proxy -p ssl:10.0.2.4:1666 login -s"
User svc_proxy ticket expires in 2288411 hours 26 minutes.
adminuser@vm-linux-dev-demo-p4p:~$

# Proxyサービスの起動
adminuser@vm-linux-dev-demo-p4p:~$ sudo p4dctl start p4proxy
Started 'p4proxy' p4p service.
Started 1 services.
adminuser@vm-linux-dev-demo-p4p:~$

# Proxyサービスの状態確認コマンド
adminuser@vm-linux-dev-demo-p4p:~$ sudo p4dctl status p4proxy
'p4proxy' p4p service is running.
adminuser@vm-linux-dev-demo-p4p:~$

# プロセス確認
adminuser@vm-linux-dev-demo-p4p:~$ ps aux | grep p4p
perforce    2745  0.0  0.1  45116  9460 ?        Ss   06:24   0:00 p4p [p4proxy/1999]
adminus+    2769  0.0  0.0   7076  2204 pts/0    S+   06:26   0:00 grep --color=auto p4p
adminuser@vm-linux-dev-demo-p4p:~$

# ポート確認
adminuser@vm-linux-dev-demo-p4p:~$ sudo ss -tuln | grep 1999
tcp   LISTEN 0      128          0.0.0.0:1999      0.0.0.0:*
adminuser@vm-linux-dev-demo-p4p:~$

# ログ確認
adminuser@vm-linux-dev-demo-p4p:~$ sudo ls -l /opt/perforce/servers/p4proxy/log
-rw------- 1 perforce perforce 133 Oct 29 06:26 /opt/perforce/servers/p4proxy/log
adminuser@vm-linux-dev-demo-p4p:~$
adminuser@vm-linux-dev-demo-p4p:~$ sudo tail -n 50 /opt/perforce/servers/p4proxy/log
Perforce proxy info:
        2025/10/29 06:24:55 pid 2745 proxy starting
Perforce proxy info:
        2025/10/29 06:26:23 pid 2767 completed .031s
adminuser@vm-linux-dev-demo-p4p:~$

# ログローテーション設定
adminuser@vm-linux-dev-demo-p4p:~$ sudo tee /etc/logrotate.d/p4proxy > /dev/null << 'EOF'
/opt/perforce/servers/p4proxy/log {
    size 10M
    rotate 7
    compress
    missingok
    notifempty
    create 0600 perforce perforce
}
EOF
adminuser@vm-linux-dev-demo-p4p:~$

# ローテーションのテスト(設定内容の確認(dry-run))
adminuser@vm-linux-dev-demo-p4p:~$ sudo logrotate -d /etc/logrotate.d/p4proxy
warning: logrotate in debug mode does nothing except printing debug messages!  Consider using verbose mode (-v) instead if this is not what you want.

reading config file /etc/logrotate.d/p4proxy
Reading state from file: /var/lib/logrotate/status
state file /var/lib/logrotate/status does not exist
Allocating hash table for state file, size 64 entries

Handling 1 logs

rotating pattern: /opt/perforce/servers/p4proxy/log  10485760 bytes (7 rotations)
empty log files are not rotated, old logs are removed
considering log /opt/perforce/servers/p4proxy/log
Creating new state
  Now: 2025-10-29 06:46
  Last rotated at 2025-10-29 06:00
  log does not need rotating (log size is below the 'size' threshold)
adminuser@vm-linux-dev-demo-p4p:~$

# 強制的にローテーションを実行
adminuser@vm-linux-dev-demo-p4p:~$ sudo logrotate -f /etc/logrotate.d/p4proxy
adminuser@vm-linux-dev-demo-p4p:~$

# ログファイルの確認
adminuser@vm-linux-dev-demo-p4p:~$ sudo ls -l /opt/perforce/servers/p4proxy/
total 4
-rw------- 1 perforce perforce   0 Oct 29 06:48 log
-rw------- 1 perforce perforce 108 Oct 29 06:26 log.1.gz
adminuser@vm-linux-dev-demo-p4p:~$

以上で、p4-proxyの設定は完了です。

2-3 p4vの設定

Helix Core(Perforce)製品ダウンロードHelix Visual Client (P4V) Downloadsからクライアントアプリをダウンロードします。
ダウンロード後、p4vinst64.exeを管理者として実行します。

18.png

19.png

以下画面ではプロキシサーバーのパブリックIPアドレスおよび待ち受けポート、テスト用ユーザーを入力します。
※プロキシサーバーのパブリックIPアドレスはAzureコンソールから確認できます。

WS000017.JPG

インストール後下記画面で終了となります。

WS000013.JPG

3. 検証

クライアントアプリからプロキシサーバー経由でPerforceサーバーへアクセスします。
クライアントアプリを起動します。

以下の画面では[OK]をクリックします。

WS000018.JPG

以下画面では任意のパスワードを設定し、[OK]をクリックします。

WS000015.JPG

下記画面が表示されるとアクセス成功となります。

20.png

以上で検証は終了です。

4. 終わりに

本記事を最後まで読んで頂きましてありがとうございます。
Perforceには他にもさまざまな機能がありますので、実際にファイルを格納したり、他のサービスも試してみたいです。

5. 参考

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?