我在Docker中使用cassandra时遇到问题 我创建了一个像左
这样的Dockerfile----------------------Dockerfile----------------------------
FROM spotify/cassandra:base
COPY cassandra-schema.cql /tmp/
COPY cassandra-init.sh /usr/local/bin/
COPY cassandra-singlenode.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/cassandra-init.sh
RUN chmod +x /usr/local/bin/cassandra-singlenode.sh
#import schema
RUN /usr/local/bin/cassandra-init.sh
EXPOSE 9160
ENTRYPOINT ["/usr/local/bin/cassandra-singlenode.sh"]
如果我使用
docker run --name cassandradb cassandra
一切正常但如果我使用
docker run --name cassandradb -v /opt/argus/cassandra/data/:/var/lib/cassandra/data -v /opt/argus/cassandra/commitlog:/var/lib/cassandra/commitlog cassandra
cassandra开始但是/usr/local/bin/cassandra-init.sh没有导入我的scheam
有什么想法吗?
这些是我的文件内容
------------------cassandra-init.sh-----------------------
echo "===================================================="
echo "starting running cqlsh"
echo "===================================================="
cassandra &
while : ;do
# Get the status of this machine from the Cassandra nodetool
STATUS=`nodetool status | grep 'UN' | awk '{print $1}'`
echo $STATUS
# Once the status is Up and Normal, then we are ready
if [ $STATUS = "UN" ]; then
cqlsh -f /tmp/cassandra-schema.cql
break
fi
sleep 1;
done
----------------------------cassandra-singlenode.sh--------------------------------
echo "=============================================== Change configuration ====================================================="
IP=`hostname --ip-address`
SEEDS=`env | grep CASS[0-9]_PORT_9042_TCP_ADDR | sed 's/CASS[0-9]_PORT_9042_TCP_ADDR=//g' | sed -e :a -e N -e 's/\n/,/' -e ta`
if [ -z "$SEEDS" ]; then
SEEDS=$IP
fi
echo "Listening on: "$IP
echo "Found seeds: "$SEEDS
# Setup Cassandra
CONFIG=/etc/cassandra/
sed -i -e "s/^listen_address.*/listen_address: $IP/" $CONFIG/cassandra.yaml
sed -i -e "s/^rpc_address.*/rpc_address: 0.0.0.0/" $CONFIG/cassandra.yaml
sed -i -e "s/- seeds: \"127.0.0.1\"/- seeds: \"$SEEDS\"/" $CONFIG/cassandra.yaml
sed -i -e "s/# JVM_OPTS=\"$JVM_OPTS -Djava.rmi.server.hostname=<public name>\"/ JVM_OPTS=\"$JVM_OPTS -Djava.rmi.server.hostname=$IP\"/" $CONFIG/cassandra-env.sh
echo "=========================================================================================================================="
echo "starting running cassandra server"
echo "=========================================================================================================================="
cassandra &
while :
do
echo "Cassandra running, Press [CTRL+C] to stop.."
sleep 1
done