デフォルトでは、Cassandra のインストール時に認証は有効にされません。つまり、だれでも Cassandra にアクセスできます。Edge のインストール後、またはインストール プロセスの一環として認証を有効にできます。
ユーザーの追加、削除、変更には Cassandra の CREATE/ALTER/DROP USER
文を使用します。詳細については、 Cassandra SQL シェルコマンドをご覧ください。
インストール時に Cassandra 認証を有効にする
インストール時に Cassandra 認証を有効にできます。
インストール時に Cassandra 認証を有効にするには、すべての Cassandra ノードの構成ファイルに CASS_AUTH
プロパティを含めます。
CASS_AUTH=y # The default value is n.
Cassandra にアクセスする Edge コンポーネントは次のとおりです。
- 管理サーバー
- Message Processor
- ルーター
- Qpid サーバー
- Postgres サーバー
これらのコンポーネントをインストールするときに、構成ファイルでユーザー名とパスワードを設定する必要があります。
CASS_USERNAME=cassandra_username CASS_PASSWORD=cassandra_password
Cassandra インストール後に Cassandra の認証情報を変更できます。ただし、Management Server、Message Processor、Router、Qpid サーバー、Postgres サーバーをすでにインストールしている場合は、これらのコンポーネントも新しい認証情報を使用するよう更新する必要があります。
Cassandra のインストール後に Cassandra の認証情報を変更するには:
cqlsh
ツールとデフォルトの認証情報を使用していずれかの Cassandra にログインします。パスワードの変更は 1 つのノードだけで行い、その変更をリング内のすべての Cassandra ノードにブロードキャストします。/opt/apigee/apigee-cassandra/bin/cqlsh cassIP 9042 -u cassandra_username -p cassandra_password
ここで
- cassIP は Cassandra ノードの IP アドレスです。
- 9042 はデフォルトの Cassandra ポートです。
cqlsh>
プロンプトに対して次のコマンドを実行して、パスワードを更新します。ALTER USER cassandra_username/var> WITH PASSWORD 'new_cassandra_password';
- 次の例のように、
cqlsh
ツールを終了します。exit
- Management Server、Message Processor、Router、Qpid サーバー、Postgres サーバーをまだインストールしていない場合は、構成ファイルで次のプロパティを設定してそれらのコンポーネントをインストールします。
CASS_USERNAME=cassandra_username CASS_PASSWORD=new_cassandra_password
- Management Server、Message Processor、Router、Qpid サーバー、Postgres サーバーをすでにインストールしている場合は、Edge パスワードをリセットするの手順に従って、これらのコンポーネントで新しいパスワードが使用されるようにします。
インストール後に Cassandra 認証を有効にする
インストール後に認証を有効にするには、次の手順に従います。
- Cassandra に接続するすべての Edge コンポーネントを更新して、Cassandra のユーザー名とパスワードを反映させます。
- すべての Cassandra ノードで 認証を有効にし、いずれか 1 つのノードで Cassandra のユーザー名とパスワードを設定します。認証情報の変更は 1 つの Cassandra ノードだけで行い、その変更をリング内のすべての Cassandra ノードにブロードキャストします。
Cassandra に接続する Edge コンポーネントを更新する
Cassandra と通信するすべての Edge コンポーネントに新しい認証情報を設定する手順は次のとおりです。この手順は、Cassandra の認証情報を実際に更新する前に行う必要があります。
- Management Server ノードで、次のコマンドを実行します。
/opt/apigee/apigee-service/bin/apigee-service edge-management-server store_cassandra_credentials -u cassandra_username -p cassandra_password
必要に応じて、次のように新しいユーザー名とパスワードを含むファイルをコマンドに渡すこともできます。
apigee-service edge-management-server store_cassandra_credentials -f configFile
ここで、configFile には次の設定が含まれます。
CASS_USERNAME=cassandra_username # Default is cassandra CASS_PASSWORD='cassandra_password' # Default is cassandra; wrap in single quotes if it includes special chars
このコマンドは、自動的に Management Server を再起動します。
- 次の各サービスに対してステップ 1 を繰り返します。
- すべての Message Processor
- すべての Router
- すべての Qpid サーバー(edge-qpid-server)
- Postgres サーバー(edge-postgres-server)
各サービスに対してステップ 1 を繰り返すとき、上記のコマンドの
edge-management-server
の部分を適切なサービス名に置き換えます。たとえば、Router サービスに対してステップ 1 を行うときは、次のコマンドを使用します。/opt/apigee/apigee-service/bin/apigee-service edge-router store_cassandra_credentials -u cassandra -p cassandra
認証を有効にする
次の手順に従い、Cassandra 認証を有効にしてユーザー名とパスワードを設定します。
- 以下の設定を含むサイレント構成ファイルを作成します。
# Specify IP address or DNS name of cassandra node IP1=192.168.1.1 IP2=192.168.1.2 IP3=192.168.1.3 # Must resolve to IP address or DNS name of host HOSTIP=$(hostname -i) # Set to ‘y’ to enable Cassandra authentication. CASS_AUTH=y # Possible values are ‘y/n’ # Cassandra username. If it does not exist, this user would be created as a SUPERUSER CASS_USERNAME=cassandra_username # Default value is cassandra - don't use for production # Cassandra Password. If CASS_USERNAME does not exist, create SUPERUSER with this as password CASS_PASSWORD=cassandra_password # Default value is cassandra - don't use for production # Space-separated IP/DNS names of the Cassandra hosts CASS_HOSTS="$IP1:1,1 $IP2:1,1 $IP3:1,1" # Username of an existing C* user. Only needed if you have disabled or changed details of the default cassandra user(‘cassandra’) CASS_EXISTING_USERNAME=existing_cassandra_username # Password of an existing C* user. Only needed if you have disabled or change password of the default cassandra user(‘cassandra’) CASS_EXISTING_PASSWORD=existing_cassandra_password # Cassandra port CASS_PORT=9042 # The default port is 9042.
最初の Cassandra ノードにログインし、次のコマンドを実行します。
apigee-service apigee-cassandra enable_cassandra_authentication -f CONFIG
必要に応じて、次の例のようにプロパティをコマンド引数としてスクリプトに渡すこともできます。
CASS_AUTH=y HOSTIP=$(hostname -i) CASS_PORT=9042 CASS_EXISTING_USERNAME=existing_cassandra_username CASS_EXISTING_PASSWORD=existing_cassandra_password CASS_USERNAME=cassandra_username CASS_PASSWORD=cassandra_password CASS_HOSTS="192.168.1.1:1,1 192.168.1.2:1,1 192.168.1.3:1,1" apigee-service apigee-cassandra enable_cassandra_authentication
注:
- デフォルトの Cassandra 認証情報の場合、上記のコマンドを実行すると Cassandra 認証が有効になり、Cassandra が再起動します。
- デフォルト以外の認証情報の場合は、このコマンドにより、レプリケーション係数の変更、スーパーユーザーの作成、
system_auth keyspace
の修復も行われます。
- すべての Cassandra ノードでステップ 1 と 2 を繰り返します。