Apache CloudStack . Apache Kafka |
Apache CloudStack (ACS) Apache Kafka.
, API, , , API.
ACS :
, ACS . . , , :
, , API. , , .
ACS AMPQ RabbitMQ Apache Kafka Apache Kafka, . Apache Kafka, ACS .
API . , , API (, REST ). :
. , , SMS . :
, , , , .
, , ( ), , , , API , , , .
. , Apache Kafka c , , , .
Apache Kafka "" . . , Kafka ACS .
Kafka Docker- spotify/kafka, (Apache Zookeeper Kafka) .
Docker ( CentOS 7) :
# yum install -y yum-utils device-mapper-persistent-data lvm2
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# yum makecache fast
# yum install docker-ce
Apache Kafka:
# docker run -d -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=10.0.0.66 --env ADVERTISED_PORT=9092 spotify/kafka
c660741b512a
, Kafka 10.0.0.66:9092, Apache Zookeeper 10.0.0.66:2181.
Kafka Zookeeper :
"cs" "test":
# docker exec -i -t c660741b512a bash -c "echo 'test' | /opt/kafka_2.11-0.10.1.0/bin/kafka-console-producer.sh --broker-list 10.0.0.66:9092 --topic cs"
[2017-07-23 08:48:11,222] WARN Error while fetching metadata with correlation id 0 : {cs=LEADER_NOT_AVAILABLE} (org.apache.kafka.clients.NetworkClient)
:
# docker exec -i -t c660741b512a /opt/kafka_2.11-0.10.1.0/bin/kafka-console-consumer.sh --bootstrap-server=10.0.0.66:9092 --topic cs --offset=earliest --partition=0
test
^CProcessed a total of 1 messages
, , Kafka .
ACS ( ). (/etc/cloudstack/management/kafka.producer.properties) Kafka, ACS :
bootstrap.servers=10.0.0.66:9092
acks=all
topic=cs
retries=1
Kafka bootstrap.servers .
java bean, Kafka:
# mkdir -p /etc/cloudstack/management/META-INF/cloudstack/core
bean-a (/etc/cloudstack/management/META-INF/cloudstack/core/spring-event-bus-context.xml) :
ACS:
# systemctl restart cloudstack-management
cs, JSON, ( ):
{
"Role":"e767a39b-6b93-11e7-81e3-06565200012c",
"Account":"54d5f55c-5311-48db-bbb8-c44c5175cb2a",
"eventDateTime":"2017-07-23 14:09:08 +0700",
"entityuuid":"54d5f55c-5311-48db-bbb8-c44c5175cb2a",
"description":"Successfully completed creating Account. Account Name: null, Domain Id:1",
"event":"ACCOUNT.CREATE",
"Domain":"8a90b067-6b93-11e7-81e3-06565200012c",
"user":"f484a624-6b93-11e7-81e3-06565200012c",
"account":"f4849ae2-6b93-11e7-81e3-06565200012c",
"entity":"com.cloud.user.Account","status":"Completed"
}
{
"Role":"e767a39b-6b93-11e7-81e3-06565200012c",
"Account":"54d5f55c-5311-48db-bbb8-c44c5175cb2a",
"eventDateTime":"2017-07-23 14:09:08 +0700",
"entityuuid":"4de64270-7bd7-4932-811a-c7ca7916cd2d",
"description":"Successfully completed creating User. Account Name: null, DomainId:1",
"event":"USER.CREATE",
"Domain":"8a90b067-6b93-11e7-81e3-06565200012c",
"user":"f484a624-6b93-11e7-81e3-06565200012c",
"account":"f4849ae2-6b93-11e7-81e3-06565200012c",
"entity":"com.cloud.user.User","status":"Completed"
}
{
"eventDateTime":"2017-07-23 14:14:13 +0700",
"entityuuid":"0f8ffffa-ae04-4d03-902a-d80ef0223b7b",
"description":"Successfully completed creating User. UserName: test2, FirstName :test2, LastName: test2",
"event":"USER.CREATE",
"Domain":"8a90b067-6b93-11e7-81e3-06565200012c",
"user":"f484a624-6b93-11e7-81e3-06565200012c",
"account":"f4849ae2-6b93-11e7-81e3-06565200012c",
"entity":"com.cloud.user.User","status":"Completed"
}
, . Kafka :
# docker exec -i -t c660741b512a \
/opt/kafka_2.11-0.10.1.0/bin/kafka-console-consumer.sh --bootstrap-server=10.0.0.66:9092 --topic cs --offset=earliest --partition=0
, , Apache Kafka. 15-20 .
"" :
/etc/cloudstack/management/kafka.producer.properties
., , , " ", , :
, .