一道题的gms结果f是什么意思是f(0)=0,f '(0)=1. 为什么f '(0)不等于直接用0求导,等于0呢?

噢哦,这个页面找不到了
下载作业帮可以找到更多答案扫一扫,手机访问
您好,欢迎来到维库电子市场网
您所在的位置:&&&&&&&&不要什么地方都用0.1μF电容
版权与免责声明
凡本网注明“出处:维库电子市场网”的所有作品,版权均属于维库电子市场网,转载请必须注明维库电子市场网,http://www.dzsc.com,违反者本网将追究相关法律责任。
本网转载并注明自其它出处的作品,目的在于传递更多信息,并不代表本网赞同其观点或证实其内容的真实性,不承担此类作品侵权行为的直接责任及连带责任。其他媒体、网站或个人从本网转载时,必须保留本网注明的作品出处,并自负版权等法律责任。
如涉及作品内容、版权等问题,请在作品发表之日起一周内与本网联系,否则视为放弃相关权利。
相关技术资料
热门技术资料
最新技术资料qiouwanghao1
spark编程练习
申明:以下代码仅作学习参考使用,勿使用在商业用途。
UserMining
TweetMining
HashtagMining
InvertedIndex
import java.util.A
import java.util.L
import org.apache.spark.SparkC
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkC
public class Test {
& & public static void main(String[] args) {
& & & & // TODO Auto-generated method stub
& & & & SparkConf conf = new SparkConf().setAppName(&test&).setMaster(&spark://master:7077&); & & & &
& & & & @SuppressWarnings(&resource&)
& & & & JavaSparkContext sc = new JavaSparkContext(conf);
// & & &sc.addJar(&/home/sun/jars/myjar.jar&);
& & & & List&Integer& data = Arrays.asList(1, 2, 3, 4, 5);
& & & & JavaRDD&Integer& distData = sc.parallelize(data);
& & & & System.out.println(distData.count());
两个Utils方法
1.解析json的代码
import java.io.IOE
import com.fasterxml.jackson.databind.ObjectM
public class Parse {
& public static Tweet parseJsonToTweet(String jsonLine) {
& & ObjectMapper objectMapper = new ObjectMapper();
& & Tweet tweet =
& & & tweet = objectMapper.readValue(jsonLine, Tweet.class);
& & } catch (IOException e) {
& & & e.printStackTrace();
import java.io.S
public class Tweet implements Serializable {
& String userN
& public String getUserName() {
& & return userN
& public String getLang() {
& public long getId() {
& public String getUser() {}
& public String getText() {
& public String getPlace() {
& public String getCountry() {
& public void setId(long id) {
& & this.id =
& public void setUser(String user) {
& & this.user =
& public void setUserName(String userName) {
& & this.userName = userN
& public void setText(String text) {
& & this.text =
& public void setPlace(String place) {
& & this.place =
& public void setCountry(String country) {
& & this.country =
& public void setLang(String lang) {
& & this.lang =
& @Override
& public String toString(){
& & return getId() + &, & + getUser() + &, & + getText() + &, & + getPlace() + &, & + getCountry();
reduced-tweets.json
数据以及测试代码的获取请点击&。
WordCount代码块
import org.apache.spark.SparkC
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkC
import org.apache.spark.api.java.function.FlatMapF
import java.util.A
&* &step 1, the mapper:
&* &-我们为每一个单词添加属性 1.获取形如(word,1)的 JavaPairRDD&String, Integer&。单词作为key
&* &step 2, the reducer:
&* &-合并统计.
public class Wordcount {
& private static String pathToFile = &data/wordcount.txt&;
& public JavaRDD&String& loadData() {
& & SparkConf conf = new SparkConf()
& & & & .setAppName(&Wordcount&)
& & & & .set(&spark.driver.allowMultipleContexts&, &true&)
& & & & .setMaster(&local[*]&); // here local mode. And * means you will use as much as you have cores.
& & JavaSparkContext sc = new JavaSparkContext(conf);
& & JavaRDD&String& words = sc.textFile(pathToFile).flatMap(new FlatMapFunction&String, String&(){
& & & & public Iterable call(String line) throws Exception {
& & & & & & return Arrays.asList( line.split(& &)) ;
& &* &Now count how much each word appears!
& public JavaPairRDD&String, Integer& wordcount() {
& & JavaRDD&String& words = loadData();
& & // code here
& & JavaPairRDD&String, Integer& couples =
& & // code here
& & JavaPairRDD&String, Integer& result =
& &* &Now keep the word which appear strictly more than 4 times!
& public JavaPairRDD&String, Integer& filterOnWordcount() {
& & JavaPairRDD&String, Integer& wordcounts = wordcount();
& & // TODO write code here
& & JavaPairRDD&String, Integer& filtered =
UserMining代码块
import org.apache.spark.SparkC
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkC
import org.apache.spark.api.java.function.F
import utils.P
import utils.T
&* The Java Spark API documentation:
&* http://spark.apache.org/docs/latest/api/java/index.html
&* 我们使用包含了8198个tweet数据记录。数据格式如下:
&* {&id&:&430785&, &user&:&Srkian_nishu :)&, &text&:
&* &@always_nidhi @YouTube no i dnt understand bt i loved of this mve is rocking&
&* , &place&:&Orissa&, &country&:&India&}
&* 目标: & 找出user所有的tweet账户(一个user可能包含多个tweet账户,如Srkian_nishu的tweet账户有[430785,...])
public class UserMining {
& & private static String pathToFile = &data/reduced-tweets.json&;
& & public JavaRDD&Tweet& loadData() {
& & & & // Create spark configuration and spark context
& & & & SparkConf conf = new SparkConf().setAppName(&User mining&).set(&spark.driver.allowMultipleContexts&, &true&)
& & & & & & & & .setMaster(&local[*]&);
& & & & JavaSparkContext sc = new JavaSparkContext(conf);
& & & & // Load the data and parse it into a Tweet.
& & & & // Look at the Tweet Object in the TweetUtils class.
& & & & JavaRDD&Tweet& tweets = sc.textFile(pathToFile).map(new Function&String, Tweet&() {
& & & & & & public Tweet call(String line) throws Exception {
& & & & & & & & // TODO Auto-generated method stub
& & & & & & & & return Parse.parseJsonToTweet(line);
& & & & & & }
& & & & });
& & &* For each user return all his tweets
& & public JavaPairRDD&String, Iterable&Tweet&& tweetsByUser() {
& & & & JavaRDD&Tweet& tweets = loadData();
& & & & // TODO write code here
& & & & // Hint: the Spark API provides a groupBy method
& & & & JavaPairRDD&String, Iterable&Tweet&& tweetsByUser =
& & & & return tweetsByU
& & &* Compute the number of tweets by user
& & public JavaPairRDD&String, Integer& tweetByUserNumber() {
& & & & JavaRDD&Tweet& tweets = loadData();
& & & & // TODO write code here
& & & & // Hint: think about what you did in the wordcount example
& & & & JavaPairRDD&String, Integer& count =
TweetMining代码块
import org.apache.spark.SparkC
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkC
import org.apache.spark.api.java.function.FlatMapF
import org.apache.spark.api.java.function.F
import org.apache.spark.api.java.function.Function2;
import org.apache.spark.api.java.function.PairF
import scala.Tuple2;
import utils.P
import utils.T
import java.io.S
import java.util.HashS
import java.util.L
import java.util.S
&* The Java Spark API documentation:
&* http://spark.apache.org/docs/latest/api/java/index.html
&** 我们使用包含了8198个tweet数据记录。数据格式如下:
&* {&id&:&430785&, &user&:&Srkian_nishu :)&, &text&:
&* &@always_nidhi @YouTube no i dnt understand bt i loved of this mve is rocking&
&* , &place&:&Orissa&, &country&:&India&}
&* 目标: 1.找出所有被@的人
&* & & &2.计算每个人被@到的次数,找出前10个@次数最多的人
&* Use the TweetMiningTest to implement the code.
public class TweetMining implements Serializable {
& & private static String pathToFile = &data/reduced-tweets.json&;
& & &* Load the data from the json file and return an RDD of Tweet
& & public JavaRDD&Tweet& loadData() {
& & & & // create spark configuration and spark context
& & & & SparkConf conf = new SparkConf().setAppName(&Tweet mining&).setMaster(&spark://master:7077&);
& & & & conf.set(&spark.driver.allowMultipleContexts& ,&true&);
& & & & JavaSparkContext sc = new JavaSparkContext(conf);
& & & & sc.addJar(&/home/sun/jars/tutorial-all.jar&);
& & & & // load the data and create an RDD of Tweet
& & & & JavaRDD&Tweet& tweets = sc.textFile(&hdfs://master:9000/sparkdata/reduced-tweets.json&)
& & & & & & & & .map(new Function&String, Tweet&() {
& & & & & & & & & & public Tweet call(String line) throws Exception {
& & & & & & & & & & & & // TODO Auto-generated method stub
& & & & & & & & & & & & return Parse.parseJsonToTweet(line);
& & & & & & & & & & }
& & & & & & & & });
& & &* Find all the persons mentioned on tweets (case sensitive)
& & public JavaRDD&String& mentionOnTweet() {
& & & & JavaRDD&Tweet& tweets = loadData();
& & & & // You want to return an RDD with the mentions
& & & & // Hint: think about separating the word in the text field and then find
& & & & // the mentions
& & & & // TODO write code here
& & & & JavaRDD&String& mentions = tweets.flatMap(new FlatMapFunction&Tweet, String&() {
& & & & & & public Iterable&String& call(Tweet t) throws Exception {
& & & & & & & & String text = t.getText();
& & & & & & & & Set&String& set = new HashSet&String&();
& & & & & & & & String[] words = text.split(& &);
& & & & & & & & for (String word : words) {
& & & & & & & & & & if (word.startsWith(&@&)) {
& & & & & & & & & & & & set.add(word);
& & & & & & & & & & }
& & & & & & & & }
& & & & & & & &
& & & & & & }
& & & & });
& & &* Count how many times each person is mentioned
& & public JavaPairRDD&String, Integer& countMentions() {
& & & & JavaRDD&String& mentions = mentionOnTweet();
& & & & // Hint: think about what you did in the wordcount example
& & & & // TODO write code here
& & & & JavaPairRDD&String, Integer& mentionCount = mentions.mapToPair(new PairFunction&String, String, Integer&() {
& & & & & & public Tuple2&String, Integer& call(String t) throws Exception {
& & & & & & & & return new Tuple2&String, Integer&(t, 1);
& & & & & & }
& & & & }).reduceByKey(new Function2&Integer, Integer, Integer&() {
& & & & & & public Integer call(Integer v1, Integer v2) throws Exception {
& & & & & & & & // TODO Auto-generated method stub
& & & & & & & & return v1 + v2;
& & & & & & }
& & & & });
& & & & mentionCount.saveAsTextFile(&hdfs://master:9000/sparkdata/tweets-m4&);
& & & & return mentionC
& & &* Find the 10 most mentioned persons by descending order
& & public List&Tuple2&Integer, String&& top10mentions() {
& & & & JavaPairRDD&String, Integer& counts = countMentions();
& & & & // Hint: take a look at the sorting and take methods
& & & & // TODO write code here
& & & & List&Tuple2&Integer, String&& mostMentioned =
& & & & return mostM
& & public static void main(String[] args) {
& & & & Ex2TweetMining ex2TweetMining = new Ex2TweetMining();
& & & & JavaPairRDD&String, Integer& res = ex2TweetMining.countMentions();
& & & & System.out.println(res.take(1));
HashtagMining代码块
import org.apache.spark.SparkC
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkC
import org.apache.spark.api.java.function.F
import scala.Tuple2;
import utils.P
import utils.T
import java.util.L
&* &The Java Spark API documentation: http://spark.apache.org/docs/latest/api/java/index.html
&* 我们使用包含了8198个tweet数据记录。数据格式如下:
&* {&id&:&430785&, &user&:&Srkian_nishu :)&, &text&:
&* &@always_nidhi @YouTube no i dnt understand bt i loved of this mve is rocking&
&* , &place&:&Orissa&, &country&:&India&}
&* 目标: 1.找出所有所有被标记(”#“)到的人。
&* & & &2.找出每个被标记(“#”)的人被(”@“)到的次数,求出次数前十
public class HashtagMining {
& private static String pathToFile = &data/reduced-tweets.json&;
& &* &Load the data from the json file and return an RDD of Tweet
& public JavaRDD&Tweet& loadData() {
& & // create spark configuration and spark context
& & SparkConf conf = new SparkConf()
& & & & .setAppName(&Hashtag mining&)
& & & & .set(&spark.driver.allowMultipleContexts&, &true&)
& & & & .setMaster(&local[*]&);
& & JavaSparkContext sc = new JavaSparkContext(conf);
& & JavaRDD&Tweet& tweets = sc.textFile(pathToFile).map(new Function&String, Tweet&() {
& & & & public Tweet call(String line) throws Exception {
& & & & & & // TODO Auto-generated method stub
& & & & & & return Parse.parseJsonToTweet(line);
& &* &Find all the hashtags mentioned on tweets
& public JavaRDD&String& hashtagMentionedOnTweet() {
& & JavaRDD&Tweet& tweets = loadData();
& & // You want to return an RDD with the mentions
& & // Hint: think about separating the word in the text field and then find the mentions
& & // TODO write code here
& & JavaRDD&String& mentions =
& &* &Count how many times each hashtag is mentioned
& public JavaPairRDD&String,Integer& countMentions() {
& & JavaRDD&String& mentions = hashtagMentionedOnTweet();
& & // Hint: think about what you did in the wordcount example
& & // TODO write code here
& & JavaPairRDD&String, Integer& counts =
& &* &Find the 10 most popular Hashtags by descending order
& public List&Tuple2&Integer, String&& top10HashTags() {
& & JavaPairRDD&String, Integer& counts = countMentions();
& & // Hint: take a look at the sorting and take methods
& & // TODO write code here
& & List&Tuple2&Integer, String&& top10 =
& & return top10;
InvertedIndex代码块
import org.apache.spark.SparkC
import org.apache.spark.api.java.JavaPairRDD;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkC
import org.apache.spark.api.java.function.F
import utils.P
import utils.T
import java.util.M
&* 目标 : 建立标记的索引视图
&* 说明: &例如对于标记#spark,它出现在tweet1, tweet3, tweet39中。 建立的索引应该返回(#spark, List(tweet1,tweet3, tweet39))
public class InvertedIndex {
& private static String pathToFile = &data/reduced-tweets.json&;
& &* &Load the data from the json file and return an RDD of Tweet
& public JavaRDD&Tweet& loadData() {
& & // create spark configuration and spark context
& & SparkConf conf = new SparkConf()
& & & & .setAppName(&Inverted index&)
& & & & .set(&spark.driver.allowMultipleContexts&, &true&)
& & & & .setMaster(&local[*]&);
& & JavaSparkContext sc = new JavaSparkContext(conf);
& & JavaRDD&Tweet& tweets = sc.textFile(pathToFile).map(new Function&String, Tweet&() {
& & & & public Tweet call(String line) throws Exception {
& & & & & & // TODO Auto-generated method stub
& & & & & & return Parse.parseJsonToTweet(line);
& public Map&String, Iterable&Tweet&& invertedIndex() {
& & JavaRDD&Tweet& tweets = loadData();
& & // for each tweet, extract all the hashtag and then create couples (hashtag,tweet)
& & // Hint: see the flatMapToPair method
& & // TODO write code here
& & JavaPairRDD&String, Tweet& pairs =
& & // We want to group the tweets by hashtag
& & // TODO write code here
& & JavaPairRDD&String, Iterable&Tweet&& tweetsByHashtag =
& & // Then return the inverted index (= a map structure)
& & // TODO write code here
& & Map&String, Iterable&Tweet&& map =
log4j.rootLogger=INFO, stdout
#log4j.logger.org.springframework=INFO#log4j.logger.org.apache.activemq=INFO#log4j.logger.org.apache.activemq.spring=WARN#log4j.logger.org.apache.activemq.store.journal=INFO#log4j.logger.org.activeio.journal=INFO
log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.appender.stdout.layout=org.apache.log4j.PatternLayoutlog4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} | %-5.5p | %-16.16t | %-32.32c{1} | %-32.32C %4L | %m%n
nodepad++搭建各种开发环境
不需要安装任何插件,写好程序,直接按F5,在弹出框中输入相应命令并保存快捷方式
Node.js环境
代码块语法如下所示:cmd&/k&gcc&-o&&$(CURRENT_DIRECTORY)/$(NAME_PART)&.exe&&$(FULL_CURRENT_PATH)&&&&PAUSE&&&EXIT运行
代码块语法如下所示:cmd&/k&&&$(CURRENT_DIRECTORY)/$(NAME_PART)&.exe&&&PAUSE&&&EXITNode.js环境
代码块语法如下所示:cmd&/k&node&&$(FULL_CURRENT_PATH)&&&&PAUSE&&&EXITjava环境
编译和运行
代码块语法如下所示:cmd&/k&javac&&$(FULL_CURRENT_PATH)&&&&PAUSE&&&EXIT运行
代码块语法如下所示:cmd&/k&java&-classpath&&$(CURRENT_DIRECTORY);&&&$(NAME_PART)&&&&PAUSE&&&EXIT编译和运行
代码块语法如下所示:cmd&/k&javac&&$(FULL_CURRENT_PATH)&&&&&java&-classpath&&$(CURRENT_DIRECTORY);&&&$(NAME_PART)&&&&color&0a&&&PAUSE用到的宏
CURRENT_DIRECTORY:当前文件所在的目录
NAME_PART:文件名,不带后缀
FULL_CURRENT_PATH:当前的完整路径名,即包含文件名的完整路径
FILE_NAME : 表示当前文件的文件全名,不包括目录
& PAUSE:暂停当前进程,直到有信号发生,即等待键盘输入
& EXIT:退出控制台
C:&color /?&
设置默认的控制台前景和背景颜色。&
COLOR [attr]&
attr 指定控制台输出的颜色属性&
颜色属性由两个十六进制数字指定 – 第一个为背景,第二个则为&
前景。每个数字可以为以下任何值之一:&
0 = 黑色 8 = 灰色&
1 = 蓝色 9 = 淡蓝色&
2 = 绿色 A = 淡绿色&
3 = 湖蓝色 B = 淡浅绿色&
4 = 红色 C = 淡红色&
5 = 紫色 D = 淡紫色&
6 = 黄色 E = 淡黄色&
7 = 白色 F = 亮白色&
如果没有给定任何参数,该命令会将颜色还原到 CMD.EXE 启动时&
的颜色。这个值来自当前控制台窗口、/T 开关或&
DefaultColor 注册表值。&
如果用相同的前景和背景颜色来执行 COLOR 命令,COLOR 命令&
会将 ERRORLEVEL 设置为 1。&
例如: “COLOR fc” 在亮白色上产生亮红色&
不兼容的类变化错误。当正在执行的方法所依赖的类定义发生了不兼容的改变时,抛出该异常。一般在修改了应用中的某些类的声明定义而没有对整个应用重新编译而直接运行的情况下,容易引发该错误。
【报错信息】
[ERROR] Terminal i falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected&&&&at&jline.TerminalFactory.create(TerminalFactory.java:101) &&&&at&jline.TerminalFactory.get(TerminalFactory.java:158) &&&&at&jline.console.ConsoleReader.&init&(ConsoleReader.java:229) &&&&at&jline.console.ConsoleReader.&init&(ConsoleReader.java:221) &&&&at&jline.console.ConsoleReader.&init&(ConsoleReader.java:209) &&&&at&org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787) &&&&at&org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721) &&&&at&org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681) &&&&at&org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621) &&&&at&sun.reflect.NativeMethodAccessorImpl.invoke0(Native&Method) &&&&at&sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) &&&&at&sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) &&&&at&java.lang.reflect.Method.invoke(Method.java:606) &&&&at&org.apache.hadoop.util.RunJar.run(RunJar.java:221) &&&&at&org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Exception in thread “main” java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected&&&&at&jline.console.ConsoleReader.&init&(ConsoleReader.java:230) &&&&at&jline.console.ConsoleReader.&init&(ConsoleReader.java:221) &&&&at&jline.console.ConsoleReader.&init&(ConsoleReader.java:209) &&&&at&org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787) &&&&at&org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721) &&&&at&org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681) &&&&at&org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621) &&&&at&sun.reflect.NativeMethodAccessorImpl.invoke0(Native&Method) &&&&at&sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) &&&&at&sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) &&&&at&java.lang.reflect.Method.invoke(Method.java:606) &&&&at&org.apache.hadoop.util.RunJar.run(RunJar.java:221) &&&&at&org.apache.hadoop.util.RunJar.main(RunJar.java:136)
stack@op4:~$
【解决办法】
原因:YARN中的jline版本过低。
把${hive_home}/lib目录的jline包copy到${hadoop_home}/share/hadoop/yarn/lib目录下,启动hive。
解决:将hive-lib中的jline替换到yarn-lib目录中:
cp $ HIVE_HOME/lib/jline-2.12.jar $HADOOP_HOME/share/hadoop/yarn/lib/
rm -f $HADOOP_HOME/share/hadoop/yarn/lib/jline-0.9.94.jar
在window中打开功能里输入regedit,回车打开注册器。然后进入如下路径中HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\FipsAlgorithmPolicy将enable设置为0win7 64位下64位vs2015可以解决
海纳百川聚英才,上善若水促和平;
天道酬勤济阴阳,厚道载物孕乾坤。
道法自然安邦国,自强不息渡万难;
紫气东来屹四海,龙吟虎啸震九州。
安装脚本:
#! /bin/bash
HOSTS_IP=`ifconfig |grep inet| sed -n '1p'|awk '{print $2}'|awk -F ':' '{print $2}'`
echo &HOSTS_IP is:&$HOSTS_IP
MYSQL_PW=1111
echo &MYSQL_PW is :&$MYSQL_PW
#一、准备工作
#1. 配置ubuntu源仓库
cp /etc/apt/sources.list /etc/apt/sources.list.tmp
cat :& /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted && /etc/apt/sources.list
#echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main && /etc/apt/sources.list
#echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/folsom main && /etc/apt/sources.list
#apt-get install ubuntu-cloud-keyring
#apt-get update
#2. 安装ntp等服务(ntp非常重要,第一次安装失败与没有安装ntp服务有很大的关系,当时的想法是在一台机器上进行安装没必要进行时间同步。)
#apt-get install vlan bridge-utils ntp mysql-server python-mysqldb
#sed -i.orig 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
#sed -i '/\[client\]/a\default-character-set = utf8' /etc/mysql/my.cnf
#sed -i '/\[mysqld\]/a\init_connect = &SET NAMES utf8&' /etc/mysql/my.cnf&
#sed -i '/\[mysqld\]/a\skip-name-resolve' /etc/mysql/my.cnf
service mysql restart
#sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com server 127.127.1.0 fudge 127.127.1.0 stratum 10/g' /etc/ntp.conf
service ntp restart
#chang hosts file
#sed -i.orig 's/127.0.1.1/'$HOSTS_IP'/g' /etc/hosts
#add hostname to /etc/hostname
#echo `hostname` &&/etc/hostname
#3.创建数据库
mysql -u root -p$MYSQL_PW -e &&
mysql -u root -p$MYSQL_PW -e &cr&
mysql -u root -p$MYSQL_PW -e &cr&
mysql -u root -p$MYSQL_PW -e &crea&
#4. 配置数据库访问权限
mysql -u root -p$MYSQL_PW -e &grant all privileges on *.* to root@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on nova.* to nova@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on glance.* to glance@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on keystone.* to keystone@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on cinder.* to cinder@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &&
#二、安装和配置keystone
#1. 安装keystone相关软件包
apt-get install -y keystone python-keystone python-keystoneclient
#2. 配置相关文件
#sed -i 's/sqlite:\/\/\/\/var\/lib\/keystone\/keystone.db/mysql:\/\/keystone:'$MYSQL_PW'@'$HOSTS_IP':3306\/keystone/g' /etc/keystone/keystone.conf
#3. 同步数据库
keystone-manage db_sync
#(very important!!)
#4. 设置环境变量
#echo export SERVICE_TOKEN=ADMIN && /etc/profile
#echo export OS_TENANT_NAME=admin && /etc/profile
#echo export OS_USERNAME=admin && /etc/profile
#echo export OS_PASSWORD=$MYSQL_PW && /etc/profile
#echo export OS_AUTH_URL=http://$HOSTS_IP:/ && /etc/profile
#echo export SERVICE_ENDPOINT=http://$HOSTS_IP:3/ && /etc/profile
#echo export OS_NO_CACHE=1 && /etc/profile
#source /etc/profile
#5. 重启机子
#select * from user_tenant_
#6. 创建keystone中各种用户
keystone user-create --name admin --pass $MYSQL_PW --email
keystone user-create --name nova --pass $MYSQL_PW --email
keystone user-create --name glance --pass $MYSQL_PW --email
keystone user-create --name cinder --pass $MYSQL_PW --email
#7. 创建keystone中的role(admin和Member)
keystone role-create --name admin
keystone role-create --name Member
#8. 创建两个tenant(admin和service)
keystone tenant-create --name=service
keystone tenant-create --name=admin
#9. 创建各种service(每个service对应OpenStack中的相应组件的相关服务)
keystone service-create --name nova --type compute --description &OpenStack Compute Service&
keystone service-create --name glance --type image --description &OpenStack Image Service&
keystone service-create --name keystone --type identity --description &OpenStack Identity Service&
keystone service-create --name ec2 --type ec2 --description &EC2 Service&
keystone service-create --name cinder --type volume --description &Cinder Service&
#10.创建与service相对应的endpoint &glance 9292 &;nova 8774 ;volume 8778 ;keystone 5000
&keystone service-list&
#(查询出所有的service)
#+----------------------------------+----------+----------+----------------------------+
#| & & & & & & & &id & & & & & & & &| & name & | & type & | & & & &description & & & & |
#+----------------------------------+-----------+----------------------------+
#| eddb1985aa75dee06389b5 | &cinder &| &volume &| & & & Cinder Service & & & |
#| db0a92a895ea1c3ff661 | & ec2 & &| & ec2 & &| & & & &EC2 Service & & & & |
#| dcde085d9c254eac2f7581a | &glance &| &image & | &OpenStack Image Service & |
#| ae0db20bca8fd2f34bdf | keystone | identity | OpenStack Identity Service |
#| bdeecdea243d56ffdd050d3 | & nova & | compute &| OpenStack Compute Service &|
#+----------------------------------+-
keystone user-list
keystone role-list
keystone tenant-list
echo &--------------------------keyston service-list------------------------------------------------&
cinder_id=`keystone service-list |grep cinder|awk -F &|& '{ print $2}'`
echo &cinder_id:& $cinder_id
ec2_id=`keystone service-list |grep ec2|awk -F &|& '{ print $2}'`
echo &ec2_id:& $ec2_id
glance_id=`keystone service-list |grep glance|awk -F &|& '{ print $2}'`
echo &glance_id:& $glance_id
keystone_id=`keystone service-list |grep keystone|awk -F &|& '{ print $2}'`
echo &keystone_id:& $keystone_id
nova_id=`keystone service-list |grep nova|awk -F &|& '{ print $2}'`
echo &nova_id:& $nova_id
quantum_id=`keystone service-list |grep quantum|awk -F &|& '{ print $2}'`
echo &quantum_id:& $quantum_id
echo &--------------------------keyston user-list----------------------------------------------------&
user_cinder_id=`keystone user-list |grep cinder|awk -F &|& '{ print $2}'`
echo &user_cinder_id:& $user_cinder_id
user_glance_id=`keystone user-list |grep glance|awk -F &|& '{ print $2}'`
echo &user_glance_id:& $user_glance_id
user_admin_id=`keystone user-list |grep admin|awk -F &|& '{ print $2}'`
echo &user_admin_id:& $user_admin_id
user_nova_id=`keystone user-list |grep nova|awk -F &|& '{ print $2}'`
echo &user_nova_id:& $user_nova_id
user_quantum_id=`keystone user-list |grep quantum|awk -F &|& '{ print $2}'`
echo &user_quantum_id:& $user_quantum_id
echo &--------------------------keyston role-list------------------------------------------------&
role_KeystoneAdmin_id=`keystone role-list |grep KeystoneAdmin|awk -F &|& '{ print $2}'`
echo &role_KeystoneAdmin_id:& $role_KeystoneAdmin_id
role_KeystoneServiceAdmin_id=`keystone role-list |grep KeystoneServiceAdmin|awk -F &|& '{ print $2}'`
echo &role_KeystoneServiceAdmin_id:& $role_KeystoneServiceAdmin_id
role_Member_id=`keystone role-list |grep Member|awk -F &|& '{ print $2}'`
echo &role_Member_id:& $role_Member_id
role__member__id=`keystone role-list |grep _member_ |awk -F &|& '{ print $2}'`
echo &role__member__id:& $role__member__id
role_admin_id=`keystone role-list |grep admin|awk -F &|& '{ print $2}'`
echo &role_admin_id:& $role_admin_id
echo &--------------------------keyston tenant-list------------------------------------------------&
tenant_service_id=`keystone tenant-list |grep service |awk -F &|& '{ print $2}'`
echo &tenant_service_id:& $tenant_service_id
tenant_admin_id=`keystone tenant-list |grep admin|awk -F &|& '{ print $2}'`
echo &tenant_admin_id:& $tenant_admin_id
#For Nova-api
keystone endpoint-create --region myregion --service_id \
$nova_id --publicurl &http://$HOSTS_IP:8774/v2/%(tenant_id)s& \
--adminurl &http://$HOSTS_IP:8774/v2/%(tenant_id)s& --internalurl &http://$HOSTS_IP:8774/v2/%(tenant_id)s&
#For Glance
keystone endpoint-create --region myregion --service_id \
$glance_id --publicurl &http://$HOSTS_IP:9292/v2& \
--adminurl &http://$HOSTS_IP:9292/v2& --internalurl &http://$HOSTS_IP:9292/v2&&
#For keystone
keystone endpoint-create --region myregion --service_id \
$keystone_id --publicurl &http://$HOSTS_IP:& \
--adminurl &http://$HOSTS_IP:3& --internalurl &http://$HOSTS_IP:&
#For EC2_compatibility&
keystone endpoint-create --region myregion --service_id \
$ec2_id --publicurl &http://$HOSTS_IP:8773/services/Cloud& \
--adminurl &http://$HOSTS_IP:8773/services/Admin& --internalurl &http://$HOSTS_IP:8773/services/Cloud&
#For Cinder
keystone endpoint-create --region myregion --service_id \
$cinder_id --publicurl &http://$HOSTS_IP:8776/v1/%(tenant_id)s& \
--adminurl &http://$HOSTS_IP:8776/v1/%(tenant_id)s& --internalurl &http://$HOSTS_IP:8776/v1/%(tenant_id)s&
#10. 为各个用户加入对应的role(注意user_id, role_id以及tenant_id与前面的保持一致)
#//////////////User admin && role admin && tenant admin
keystone user-role-add --user_id $user_admin_id --role_id \
$role_admin_id --tenant_id $tenant_admin_id
#//////////////User nova && role admin && tenant service
keystone user-role-add --user_id $user_nova_id --role_id \
$role_admin_id --tenant_id $tenant_service_id
#//////////////User glance && role admin && tenant service
keystone user-role-add --user_id $user_glance_id --role_id \
$role_admin_id --tenant_id $tenant_service_id
#//////////////User admin && role Member && tenant admin
keystone user-role-add --user_id $user_admin_id --role_id \
$role_Member_id --tenant_id $tenant_admin_id
#//////////////User cinder && role admin && tenant service
keystone user-role-add --user_id $user_cinder_id --role_id \
$role_admin_id --tenant_id $tenant_service_id
apt-get install curl openssl
curl -d '{&auth&: {&tenantName&: &admin&, &passwordCredentials&:{&username&: &admin&, &password&: &'$MYSQL_PW'&}}}' -H &Content-type: application/json& http://$HOSTS_IP:35357 & &/v2.0/tokens | python -mjson.tool
#--------------------------------
#--------------------------------
#查看是否添加成功
#mysql -u root -p$MYSQL_PW & -e &&
mysql -u root -p$MYSQL_PW & -e &select * from user_tenant_&
#select * from user_tenant_
#+----------------------------------+----------------------------------+
#| user_id & & & & & & & & & & & & &| tenant_id & & & & & & & & & & & &|
#+----------------------------------+----------------------------------+
#| 4ad74eff83d24ed1b0da | 9e9cb9ef4f144ae8b734e1dc9746c60d |
#| d914b3fa3c021ed69fcc06a | ffaf57cfb40b41ea9e59 |
#| 6d159c79c4dc419d8ca12fbe086d6919 | ffaf57cfb40b41ea9e59 |
#| ec45e861a4e044bcbde5ff | ffaf57cfb40b41ea9e59 |
#+----------------------------------+----------------------------------+
#记住,千万不能有重复多余的;如果有,需要删除掉
#delete from endpoint(假设重复的) where service_id=&$MYSQL_PW1144(endpoint的id号)&
#三、安装和配置glance
#1. 安装glance相关组件
apt-get install -y glance glance-api python-glanceclient glance-common glance-registry python-glance
echo &-----------------------------begin conf /etc/glance/glance-api.conf------------------------------------&
#2.编辑/etc/glance/glance-api.conf文件
sed -i 's/auth_host = 127.0.0.1/auth_host = '$HOSTS_IP'/' /etc/glance/glance-api.conf
sed -i 's/%SERVICE_TENANT_NAME%/service/' /etc/glance/glance-api.conf
sed -i 's/%SERVICE_USER%/glance/' /etc/glance/glance-api.conf
sed -i 's/%SERVICE_PASSWORD%/'$MYSQL_PW'/' /etc/glance/glance-api.conf
sed -i.orig 's/sqlite:\/\/\/\/var\/lib\/glance\/glance.sqlite/mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-api.conf
sed -i.orig 's/sqlite_db = \/var\/lib\/glance\/glance.sqlite/sql_connection = mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-api.conf
echo flavor = keystone && /etc/glance/glance-api.conf
echo &-----------------------------finished conf /etc/glance/glance-api.conf------------------------------------&
#在glance-api.conf中找到:
#[keystone_authtoken]
#auth_host = $HOSTS_IP &&
#(改成自己的ip)
#auth_port = 35357
#auth_protocol = http
#admin_tenant_name = service
#admin_user = glance
#admin_password = $MYSQL_PW
#3.编辑/etc/glance/glance-api-paste.ini文件
#文件最后添加
echo &-----------------------------begin conf /etc/glance/glance-api-paste.ini------------------------------------&
echo auth_host = $HOSTS_IP &&&/etc/glance/glance-api-paste.ini
#(改成自己的ip)
echo auth_port = 35357 &&&/etc/glance/glance-api-paste.ini
echo auth_protocol = http &&&/etc/glance/glance-api-paste.ini
echo admin_tenant_name = service &&&/etc/glance/glance-api-paste.ini
echo admin_user = glance &&&/etc/glance/glance-api-paste.ini
echo admin_password = $MYSQL_PW &&&/etc/glance/glance-api-paste.ini
echo &-----------------------------finished conf /etc/glance/glance-api-paste.ini------------------------------------&
#4.编辑/etc/glance/glance-registry.conf文件
echo &-----------------------------begin conf /etc/glance/glance-registry.conf------------------------------------&
sed -i 's/auth_host = 127.0.0.1/auth_host = '$HOSTS_IP'/' /etc/glance/glance-registry.conf
sed -i 's/%SERVICE_TENANT_NAME%/service/' /etc/glance/glance-registry.conf
sed -i 's/%SERVICE_USER%/glance/' /etc/glance/glance-registry.conf
sed -i 's/%SERVICE_PASSWORD%/'$MYSQL_PW'/' /etc/glance/glance-registry.conf
sed -i.orig 's/sqlite:\/\/\/\/var\/lib\/glance\/glance.sqlite/mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-registry.conf
sed -i.orig 's/sqlite_db = \/var\/lib\/glance\/glance.sqlite/sql_connection = mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-registry.conf
echo flavor = keystone &&& /etc/glance/glance-registry.conf
echo &-----------------------------finished conf /etc/glance/glance-registry.conf------------------------------------&
#在glance-registry.conf中找到:
#[keystone_authtoken]
#auth_host = $HOSTS_IP &&
#(改成自己的ip)
#auth_port = 35357
#auth_protocol = http
#admin_tenant_name = service
#admin_user = glance
#admin_password = $MYSQL_PW
#3.编辑/etc/glance/glance-registry-paste.ini文件
#文件最后添加
echo &-----------------------------begin conf /etc/glance/glance-registry-paste.ini------------------------------------&
echo auth_host = $HOSTS_IP &&/etc/glance/glance-registry-paste.ini
echo auth_port = 35357 &&/etc/glance/glance-registry-paste.ini
echo auth_protocol = http &&/etc/glance/glance-registry-paste.ini
echo admin_tenant_name = service &&/etc/glance/glance-registry-paste.ini
echo admin_user = glance &&/etc/glance/glance-registry-paste.ini
echo admin_password = $MYSQL_PW &&/etc/glance/glance-registry-paste.ini
echo &-----------------------------finished conf /etc/glance/glance-registry-paste.ini------------------------------------&
#4. 同步数据库,重启服务
echo &-----------------------------begin conf glance-manage db_sync------------------------------------&
service glance-api stop
service glance-registry stop&
#(在同步之前先关闭相应服务)
glance-manage db_sync
service glance-api restart
service glance-registry restart
echo &-----------------------------finished conf glance-manage db_sync------------------------------------&
#5. 检查安装
glance index
#-----------------
#-----------------
#ID & & & & & & & & & & & & & & & & & Name & & & & & & & & & & & & & Disk Format & & & & &Container Format & & Size & & & & &
#------------------------------------ ------------------------------ -------------------- -------------------- --------------
# 表示安装正确
#四、安装和配置nova
#1. 安装相关组件包
apt-get install nova-api nova-cert nova-common nova-compute nova-compute-kvm nova-network nova-scheduler python-nova python-novaclient nova-consoleauth rabbitmq-server nova-novncproxy novnc python-novnc websockify nova-console &novnc &nova-doc
#2. 修改相应文件的权限
#chown -R nova:nova /etc/nova
#chmod 644 /etc/nova/nova.conf
echo &-----------------------------begin conf /etc/nova/nova.conf------------------------------------&
#2. 修改相应文件的权限
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
chown -R nova:nova /etc/nova
chmod 644 /etc/nova/nova.conf
#3. 配置/etc/nova/nova.conf文件----替换 改IP地址 &fixed_range=10.0.0.0/24 & & & & & & & & & & & & //////////修改网段cat
cat :& /etc/nova/nova.conf
echo &[DEFAULT] &&/etc/nova/nova.conf
echo &logdir=/var/log/nova &&&/etc/nova/nova.conf
echo state_path=/var/lib/nova &&&/etc/nova/nova.conf
echo lock_path=/run/lock/nova &&&/etc/nova/nova.conf
echo verbose=True &&&/etc/nova/nova.conf
echo &api_paste_config=/etc/nova/api-paste.ini &&&/etc/nova/nova.conf
echo &scheduler_driver=nova.scheduler.simple.SimpleScheduler &&&/etc/nova/nova.conf
echo s3_host=$HOSTS_IP & &&/etc/nova/nova.conf
echo ec2_host=$HOSTS_IP &&&/etc/nova/nova.conf
echo ec2_dmz_host=$HOSTS_IP &&&/etc/nova/nova.conf
echo rabbit_host=$HOSTS_IP &&&/etc/nova/nova.conf
echo metadata_host=$HOSTS_IP &&&/etc/nova/nova.conf
echo metadata_listen=0.0.0.0 &&&/etc/nova/nova.conf
echo nova_url=http://$HOSTS_IP:/ &&&/etc/nova/nova.conf
echo sql_connection=mysql://nova:$MYSQL_PW@$HOSTS_IP:3306/nova &&&/etc/nova/nova.conf
echo ec2_url=http://$HOSTS_IP:8773/services/Cloud &&&/etc/nova/nova.conf
echo root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf &&&/etc/nova/nova.conf
#echo [ Auth] &&/etc/nova/nova.conf
echo use_deprecated_auth=false &&&/etc/nova/nova.conf
echo auth_strategy=keystone &&&/etc/nova/nova.conf
echo keystone_ec2_url=http://$HOSTS_IP:/ec2tokens &&&/etc/nova/nova.conf
#echo [Imaging service] &&/etc/nova/nova.conf
echo glance_api_servers=$HOSTS_IP:9292 &&&/etc/nova/nova.conf
echo image_service=nova.image.glance.GlanceImageService &&&/etc/nova/nova.conf
#echo [Vnc configuration] &&/etc/nova/nova.conf
echo novnc_enabled=true &&&/etc/nova/nova.conf
echo novncproxy_base_url=http://$HOSTS_IP:6080/vnc_auto.html &&&/etc/nova/nova.conf
echo novncproxy_port=6080 &&&/etc/nova/nova.conf
echo vncserver_proxyclient_address=$HOSTS_IP &&&/etc/nova/nova.conf
echo vncserver_listen=$HOSTS_IP &&&/etc/nova/nova.conf
#echo #enabled_apis=metadata&&/etc/nova/nova.conf
#echo [ NETWORK] &&/etc/nova/nova.conf
echo libvirt_use_virtio_for_bridges=True &&&/etc/nova/nova.conf
echo network_manager=nova.network.manager.FlatDHCPManager &&&/etc/nova/nova.conf
echo dhcpbridge_flagfile=/etc/nova/nova.conf &&&/etc/nova/nova.conf
echo dhcpbridge=/usr/bin/nova-dhcpbridge &&&/etc/nova/nova.conf
echo public_interface=br100 &&&/etc/nova/nova.conf
echo flat_interface=eth0 &&&/etc/nova/nova.conf
echo flat_network_bridge=br100 &&&/etc/nova/nova.conf
echo fixed_range=10.0.0.0/24 &&&/etc/nova/nova.conf
echo flat_network_dhcp_start=10.0.0.2 &&&/etc/nova/nova.conf
echo network_size=256 &&&/etc/nova/nova.conf
echo force_dhcp_release=True &&&/etc/nova/nova.conf
echo flat_injected=false &&&/etc/nova/nova.conf
echo use_ipv6=false &&&/etc/nova/nova.conf
echo multi_host=True &&&/etc/nova/nova.conf
#echo [ Compute ] &&/etc/nova/nova.conf
echo compute_driver=libvirt.LibvirtDriver &&&/etc/nova/nova.conf
#echo [ Cinder ] &&/etc/nova/nova.conf
echo volume_api_class=nova.volume.cinder.API &&&/etc/nova/nova.conf
echo osapi_volume_listen_port=5900 &&/etc/nova/nova.conf
echo &-----------------------------finished conf /etc/nova/nova.conf------------------------------------&
#4. 修改/etc/nova//etc/nova/api-paste.ini
echo &-----------------------------begin conf /etc/nova/api-paste.ini------------------------------------&
sed -i 's/%SERVICE_TENANT_NAME%/service/' /etc/nova/api-paste.ini&
sed -i 's/%SERVICE_USER%/nova/' /etc/nova/api-paste.ini
sed -i 's/%SERVICE_PASSWORD%/'$MYSQL_PW'/' /etc/nova/api-paste.ini
#在/etc/nova/api-paste.ini中找到:
#[filter:authtoken]
#paste.filter_factory = keystone.middleware.auth_token:filter_factory
echo auth_host = $HOSTS_IP && /etc/nova/api-paste.ini &
#(改成自己的ip)
echo auth_port = 35357 && /etc/nova/api-paste.ini
echo auth_protocol = http && /etc/nova/api-paste.ini
echo admin_tenant_name = service && /etc/nova/api-paste.ini
echo admin_user = nova && /etc/nova/api-paste.ini
echo admin_password = $MYSQL_PW && /etc/nova/api-paste.ini
echo &----------------------------begin conf /etc/nova/nova-computer----------------------&
#sed -i 's/kvm/qemu/g' /etc/nova/nova-compute.conf
echo &----------------------------finished conf /etc/nova/nova-computer-------------------&
echo &-----------------------------finished conf /etc/nova/api-paste.ini------------------------------------&
#5. 同步数据库配置
echo &-----------------------------begin conf nova-manage db sync------------------------------------&
nova-manage db sync
echo &-----------------------------finished conf nova-manage db sync------------------------------------&
#7. 重启相关服务
sudo /etc/init.d/keyston restart
sudo /etc/init.d/glance-api restart
sudo /etc/init.d/glance-registry restart
keystone-manage db_sync
glance-manage db_sync
#cd /etc/init.d/;
#for i in $( ls /etc/init.d/nova-* );&
#do sudo service $&
sudo /etc/init.d/nova-api restart
sudo /etc/init.d/nova-cert restart
#sudo /etc/init.d/nova-compute restart
sudo /etc/init.d/nova-console restart
sudo /etc/init.d/nova-consoleauth restart
sudo /etc/init.d/nova-network restart
sudo /etc/init.d/nova-novncproxy restart
sudo /etc/init.d/nova-scheduler restart
sudo /etc/init.d/nova-compute restart
#6. 建立一个网络
echo &-----------------------------begin conf nova-manage network------------------------------------&
nova-manage network create private --multi_host=True --fixed_range_v4=10.0.0.0/24 --bridge=br100 --bridge_interface=eth0 --num_networks=1 --network_size=255&
echo &-----------------------------finished conf nova-manage network------------------------------------&
service open-iscsi restart
service novnc restart&
#(显示找不到服务,应该是被nova-novncproxy替代了)
service nova-novncproxy restart&
#8. 验证服务启动是否成功
echo &-----------------------------begin conf nova-manage service list------------------------------------&
nova-manage service list
echo &-----------------------------finished conf nova-manage service list------------------------------------&
#---------------
#-------------
#Binary & & & & & Host & & & & & & & & & & & & & & & & Zone & & & & & & Status & & State Updated_At
#nova-cert & & & &openstack & & & & & & & & & & & & & &nova & & & & & & enabled & &:-) &
#nova-console & & openstack & & & & & & & & & & & & & &nova & & & & & & enabled & &:-) &
#nova-compute & & openstack & & & & & & & & & & & & & &nova & & & & & & enabled & &:-) &
#nova-consoleauth openstack & & & & & & & & & & & & & &nova & & & & & & enabled & &:-) &
#nova-scheduler & openstack & & & & & & & & & & & & & &nova & & & & & & enabled & &:-) &
#nova-network & & openstack & & & & & & & & & & & & & &nova & & & & & & enabled & &:-) &
#-----------------------------
#六、cinder
#1. 安装包
apt-get install cinder-api cinder-scheduler cinder-volume &open-iscsi iscsitarget iscsitarget-dkms python-cinderclient linux-headers-`uname -r`
#2、配置并启动iSCSI服务:
service open-iscsi start
echo &-----------------------------begin conf /etc/cinder/api-paste.ini------------------------------------&
#编辑/etc/cinder/api-paste.ini
sed -i 's/%SERVICE_TENANT_NAME%/service/' /etc/cinder/api-paste.ini&
sed -i 's/%SERVICE_USER%/cinder/' /etc/cinder/api-paste.ini
sed -i 's/%SERVICE_PASSWORD%/$MYSQL_PW/' /etc/cinder/api-paste.ini
#在/etc/cinder/api-paste.ini找到:
#[filter:authtoken]
#paste.filter_factory = keystone.middleware.auth_token:filter_factory
echo service_protocol = http && /etc/cinder/api-paste.ini
echo service_host = $HOSTS_IP &&& /etc/cinder/api-paste.ini
# (改成自己的ip)
echo service_port = 5000 && /etc/cinder/api-paste.ini
echo auth_host = $HOSTS_IP &&& /etc/cinder/api-paste.ini
# (改成自己的ip)
echo auth_port = 35357 && /etc/cinder/api-paste.ini
echo auth_protocol = http && /etc/cinder/api-paste.ini
echo admin_tenant_name = service && /etc/cinder/api-paste.ini
echo admin_user = cinder && /etc/cinder/api-paste.ini
echo admin_password = $MYSQL_PW && /etc/cinder/api-paste.ini
echo &-----------------------------finished conf /etc/cinder/api-paste.ini------------------------------------&
#编辑/etc/cinder/cinder.conf文件,直接执行下面的命令
echo &-----------------------------begin conf /etc/cinder/cinder.conf------------------------------------&
echo sql_connection = mysql://cinder:$MYSQL_PW@$HOSTS_IP:3306/cinder && /etc/cinder/cinder.conf
echo &-----------------------------finished conf /etc/cinder/cinder.conf------------------------------------&
#同步数据库配置
echo &-----------------------------begin conf cinder-manage db sync------------------------------------&
cinder-manage db sync
echo &-----------------------------finished conf cinder-manage db sync------------------------------------&
service cinder-volume restart
service cinder-api restart
#七、horizon
apt-get install apache2 libapache2-mod-wsgi openstack-dashboard &memcached python-memcache
sed -i 'ServerName '$HOSTS_IP'' &&/etc/apache2/apache2.conf
service apache2 restart
service memcached restart
#cd /usr/lib/python2.7/dist-packages/
#/////// (新增加一个目录)
mkdir -p /usr/lib/python2.7/dist-packages/bin
cp /usr/bin/nova-dhcpbridge & /usr/lib/python2.7/dist-packages/bin/
#http://$HOSTS_IP/horizon
#先用qemu-img info 查看镜像格式
#如:qemu-img info cirros-0.3.0-x86_64-disk.img
#然后上传镜像
#glance add name=&为镜像命名& is_public=true container_format=ovf disk_format=镜像格式 & 镜像路径
#wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img -P &~/tools
wget https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img -P .
#source admin-openrc.sh
#glance add name=&cirros-0.3.0-x86_64& is_public=true container_format=ovf disk_format=qcow2 & ~/tools/cirros-0.3.0-x86_64-disk.img
glance add name=&cirros-0.3.0-x86_64& is_public=true container_format=ovf disk_format=qcow2 & cirros-0.3.0-x86_64-disk.img
glance image-list
#apt-get upgrade
#/etc/profile 改成本地ip&
#格式要对齐
#glance 启用端口
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
组件卸载脚本:
#! /bin/bash
MYSQL_PASSWD=${MYSQL_PASSWD:-&1111&}
mysql -uroot -p$MYSQL_PASSWD -e &DROP DATABASE IF EXISTS&
mysql -uroot -p$MYSQL_PASSWD -e &DROP DATABASE IF EXISTS&
mysql -uroot -p$MYSQL_PASSWD -e &DROP DATABASE IF EXISTS&
mysql -uroot -p$MYSQL_PASSWD -e &DROP DATABASE IF EXISTS&
#删除glance
apt-get remove -y glance glance-api glance-client glance-common glance-registry python-glance
apt-get remove -y nova-api nova-cert nova-common nova-compute nova-compute-kvm nova-doc nova-network nova-objectstore nova-scheduler &nova-volume python-nova python-novaclient &nova-consoleauth python-novnc novnc
删除dashboard
apt-get remove -y libapache2-mod-wsgi openstack-dashboard
#删除mysql数据库
apt-get remove -y mysql-server python-mysqldb
#删除keystone
apt-get remove -y keystone python-keystone python-keystoneclient
dpkg -l |grep keystone|awk '{print $2}'|xargs dpkg -P
dpkg -l |grep glance|awk '{print $2}'|xargs dpkg -P
dpkg -l |grep nova|awk '{print $2}'|xargs dpkg -P
dpkg -l |grep mysql|awk '{print $2}'|xargs dpkg -P
dpkg -l |grep libapache2-mod-wsgi|awk '{print $2}'|xargs dpkg -P
prev.sh(预执行脚本):
#! /bin/bash
HOSTS_IP=`ifconfig |grep inet| sed -n '1p'|awk '{print $2}'|awk -F ':' '{print $2}'`
echo &HOSTS_IP is:&$HOSTS_IP
MYSQL_PW=1111
echo &MYSQL_PW is :&$MYSQL_PW
#一、准备工作
#1. 配置ubuntu源仓库
cp /etc/apt/sources.list /etc/apt/sources.list.tmp
cat :& /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted && /etc/apt/sources.list
echo deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted && /etc/apt/sources.list
echo deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted && /etc/apt/sources.list
echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/folsom main && /etc/apt/sources.list
echo deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-proposed/folsom main && /etc/apt/sources.list
apt-get install ubuntu-cloud-keyring
apt-get update
#2. 安装ntp等服务(ntp非常重要,第一次安装失败与没有安装ntp服务有很大的关系,当时的想法是在一台机器上进行安装没必要进行时间同步。)
apt-get install vlan bridge-utils ntp mysql-server python-mysqldb
sed -i.orig 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
sed -i '/\[client\]/a\default-character-set = utf8' /etc/mysql/my.cnf
#sed -i '/\[mysqld\]/a\init_connect = &SET NAMES utf8&' /etc/mysql/my.cnf&
sed -i '/\[mysqld\]/a\skip-name-resolve' /etc/mysql/my.cnf
service mysql restart
sed -i 's/server ntp.ubuntu.com/server ntp.ubuntu.com server 127.127.1.0 fudge 127.127.1.0 stratum 10/g' /etc/ntp.conf
service ntp restart
#chang hosts file
sed -i.orig 's/127.0.1.1/'$HOSTS_IP'/g' /etc/hosts
#add hostname to /etc/hostname
#echo `hostname` &&/etc/hostname
#3.创建数据库
mysql -u root -p$MYSQL_PW -e &&
mysql -u root -p$MYSQL_PW -e &cr&
mysql -u root -p$MYSQL_PW -e &cr&
mysql -u root -p$MYSQL_PW -e &crea&
#4. 配置数据库访问权限
mysql -u root -p$MYSQL_PW -e &grant all privileges on *.* to root@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on nova.* to nova@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on glance.* to glance@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on keystone.* to keystone@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on cinder.* to cinder@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &&
#二、安装和配置keystone
#1. 安装keystone相关软件包
apt-get install -y keystone python-keystone python-keystoneclient
#2. 配置相关文件
sed -i 's/sqlite:\/\/\/\/var\/lib\/keystone\/keystone.db/mysql:\/\/keystone:'$MYSQL_PW'@'$HOSTS_IP':3306\/keystone/g' /etc/keystone/keystone.conf
#3. 同步数据库
keystone-manage db_sync
#(very important!!)
#4. 设置环境变量
echo export SERVICE_TOKEN=ADMIN && /etc/profile
echo export OS_TENANT_NAME=admin && /etc/profile
echo export OS_USERNAME=admin && /etc/profile
echo export OS_PASSWORD=$MYSQL_PW && /etc/profile
echo export OS_AUTH_URL=http://$HOSTS_IP:/ && /etc/profile
echo export SERVICE_ENDPOINT=http://$HOSTS_IP:3/ && /etc/profile
echo export OS_NO_CACHE=1 && /etc/profile
source /etc/profile
#5. 重启机子
------------------------------------------------------------------------------------------------------------------------------------------------------------------------&
conf.sh(配置脚本)
&#! /bin/bash
HOSTS_IP=`ifconfig |grep inet| sed -n '1p'|awk '{print $2}'|awk -F ':' '{print $2}'`
echo &HOSTS_IP is:&$HOSTS_IP
MYSQL_PW=1111
echo &MYSQL_PW is :&$MYSQL_PW
service mysql restart
service ntp restart
#3.创建数据库
mysql -u root -p$MYSQL_PW -e &&
mysql -u root -p$MYSQL_PW -e &cr&
mysql -u root -p$MYSQL_PW -e &cr&
mysql -u root -p$MYSQL_PW -e &crea&
#4. 配置数据库访问权限
mysql -u root -p$MYSQL_PW -e &grant all privileges on *.* to root@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on nova.* to nova@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on glance.* to glance@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on keystone.* to keystone@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &grant all privileges on cinder.* to cinder@'%' identified by '$MYSQL_PW';&
mysql -u root -p$MYSQL_PW -e &&
#select * from user_tenant_
#6. 创建keystone中各种用户
keystone user-create --name admin --pass $MYSQL_PW --email
keystone user-create --name nova --pass $MYSQL_PW --email
keystone user-create --name glance --pass $MYSQL_PW --email
keystone user-create --name cinder --pass $MYSQL_PW --email
#7. 创建keystone中的role(admin和Member)
keystone role-create --name admin
keystone role-create --name Member
#8. 创建两个tenant(admin和service)
keystone tenant-create --name=service
keystone tenant-create --name=admin
#9. 创建各种service(每个service对应OpenStack中的相应组件的相关服务)
keystone service-create --name nova --type compute --description &OpenStack Compute Service&
keystone service-create --name glance --type image --description &OpenStack Image Service&
keystone service-create --name keystone --type identity --description &OpenStack Identity Service&
keystone service-create --name ec2 --type ec2 --description &EC2 Service&
keystone service-create --name cinder --type volume --description &Cinder Service&
#10.创建与service相对应的endpoint &glance 9292 &;nova 8774 ;volume 8778 ;keystone 5000
&keystone service-list&
#(查询出所有的service)
#+----------------------------------+----------+----------+----------------------------+
#| & & & & & & & &id & & & & & & & &| & name & | & type & | & & & &description & & & & |
#+----------------------------------+-----------+----------------------------+
#| eddb1985aa75dee06389b5 | &cinder &| &volume &| & & & Cinder Service & & & |
#| db0a92a895ea1c3ff661 | & ec2 & &| & ec2 & &| & & & &EC2 Service & & & & |
#| dcde085d9c254eac2f7581a | &glance &| &image & | &OpenStack Image Service & |
#| ae0db20bca8fd2f34bdf | keystone | identity | OpenStack Identity Service |
#| bdeecdea243d56ffdd050d3 | & nova & | compute &| OpenStack Compute Service &|
#+----------------------------------+-
keystone user-list
keystone role-list
keystone tenant-list
echo &--------------------------keyston service-list------------------------------------------------&
cinder_id=`keystone service-list |grep cinder|awk -F &|& '{ print $2}'`
echo &cinder_id:& $cinder_id
ec2_id=`keystone service-list |grep ec2|awk -F &|& '{ print $2}'`
echo &ec2_id:& $ec2_id
glance_id=`keystone service-list |grep glance|awk -F &|& '{ print $2}'`
echo &glance_id:& $glance_id
keystone_id=`keystone service-list |grep keystone|awk -F &|& '{ print $2}'`
echo &keystone_id:& $keystone_id
nova_id=`keystone service-list |grep nova|awk -F &|& '{ print $2}'`
echo &nova_id:& $nova_id
quantum_id=`keystone service-list |grep quantum|awk -F &|& '{ print $2}'`
echo &quantum_id:& $quantum_id
echo &--------------------------keyston user-list----------------------------------------------------&
user_cinder_id=`keystone user-list |grep cinder|awk -F &|& '{ print $2}'`
echo &user_cinder_id:& $user_cinder_id
user_glance_id=`keystone user-list |grep glance|awk -F &|& '{ print $2}'`
echo &user_glance_id:& $user_glance_id
user_admin_id=`keystone user-list |grep admin|awk -F &|& '{ print $2}'`
echo &user_admin_id:& $user_admin_id
user_nova_id=`keystone user-list |grep nova|awk -F &|& '{ print $2}'`
echo &user_nova_id:& $user_nova_id
user_quantum_id=`keystone user-list |grep quantum|awk -F &|& '{ print $2}'`
echo &user_quantum_id:& $user_quantum_id
echo &--------------------------keyston role-list------------------------------------------------&
role_KeystoneAdmin_id=`keystone role-list |grep KeystoneAdmin|awk -F &|& '{ print $2}'`
echo &role_KeystoneAdmin_id:& $role_KeystoneAdmin_id
role_KeystoneServiceAdmin_id=`keystone role-list |grep KeystoneServiceAdmin|awk -F &|& '{ print $2}'`
echo &role_KeystoneServiceAdmin_id:& $role_KeystoneServiceAdmin_id
role_Member_id=`keystone role-list |grep Member|awk -F &|& '{ print $2}'`
echo &role_Member_id:& $role_Member_id
role__member__id=`keystone role-list |grep _member_ |awk -F &|& '{ print $2}'`
echo &role__member__id:& $role__member__id
role_admin_id=`keystone role-list |grep admin|awk -F &|& '{ print $2}'`
echo &role_admin_id:& $role_admin_id
echo &--------------------------keyston tenant-list------------------------------------------------&
tenant_service_id=`keystone tenant-list |grep service |awk -F &|& '{ print $2}'`
echo &tenant_service_id:& $tenant_service_id
tenant_admin_id=`keystone tenant-list |grep admin|awk -F &|& '{ print $2}'`
echo &tenant_admin_id:& $tenant_admin_id
#For Nova-api
keystone endpoint-create --region myregion --service_id \
$nova_id --publicurl &http://$HOSTS_IP:8774/v2/%(tenant_id)s& \
--adminurl &http://$HOSTS_IP:8774/v2/%(tenant_id)s& --internalurl &http://$HOSTS_IP:8774/v2/%(tenant_id)s&
#For Glance
keystone endpoint-create --region myregion --service_id \
$glance_id --publicurl &http://$HOSTS_IP:9292/v2& \
--adminurl &http://$HOSTS_IP:9292/v2& --internalurl &http://$HOSTS_IP:9292/v2&&
#For keystone
keystone endpoint-create --region myregion --service_id \
$keystone_id --publicurl &http://$HOSTS_IP:& \
--adminurl &http://$HOSTS_IP:3& --internalurl &http://$HOSTS_IP:&
#For EC2_compatibility&
keystone endpoint-create --region myregion --service_id \
$ec2_id --publicurl &http://$HOSTS_IP:8773/services/Cloud& \
--adminurl &http://$HOSTS_IP:8773/services/Admin& --internalurl &http://$HOSTS_IP:8773/services/Cloud&
#For Cinder
keystone endpoint-create --region myregion --service_id \
$cinder_id --publicurl &http://$HOSTS_IP:8776/v1/%(tenant_id)s& \
--adminurl &http://$HOSTS_IP:8776/v1/%(tenant_id)s& --internalurl &http://$HOSTS_IP:8776/v1/%(tenant_id)s&
#10. 为各个用户加入对应的role(注意user_id, role_id以及tenant_id与前面的保持一致)
#//////////////User admin && role admin && tenant admin
keystone user-role-add --user_id $user_admin_id --role_id \
$role_admin_id --tenant_id $tenant_admin_id
#//////////////User nova && role admin && tenant service
keystone user-role-add --user_id $user_nova_id --role_id \
$role_admin_id --tenant_id $tenant_service_id
#//////////////User glance && role admin && tenant service
keystone user-role-add --user_id $user_glance_id --role_id \
$role_admin_id --tenant_id $tenant_service_id
#//////////////User admin && role Member && tenant admin
keystone user-role-add --user_id $user_admin_id --role_id \
$role_Member_id --tenant_id $tenant_admin_id
#//////////////User cinder && role admin && tenant service
keystone user-role-add --user_id $user_cinder_id --role_id \
$role_admin_id --tenant_id $tenant_service_id
apt-get install curl openssl
curl -d '{&auth&: {&tenantName&: &admin&, &passwordCredentials&:{&username&: &admin&, &password&: &'$MYSQL_PW'&}}}' -H &Content-type: application/json& http://$HOSTS_IP:35357 & &/v2.0/tokens | python -mjson.tool
#--------------------------------
#--------------------------------
#查看是否添加成功
#mysql -u root -p$MYSQL_PW & -e &&
mysql -u root -p$MYSQL_PW & -e &select * from user_tenant_&
#select * from user_tenant_
#+----------------------------------+----------------------------------+
#| user_id & & & & & & & & & & & & &| tenant_id & & & & & & & & & & & &|
#+----------------------------------+----------------------------------+
#| 4ad74eff83d24ed1b0da | 9e9cb9ef4f144ae8b734e1dc9746c60d |
#| d914b3fa3c021ed69fcc06a | ffaf57cfb40b41ea9e59 |
#| 6d159c79c4dc419d8ca12fbe086d6919 | ffaf57cfb40b41ea9e59 |
#| ec45e861a4e044bcbde5ff | ffaf57cfb40b41ea9e59 |
#+----------------------------------+----------------------------------+
#记住,千万不能有重复多余的;如果有,需要删除掉
#delete from endpoint(假设重复的) where service_id=&$MYSQL_PW1144(endpoint的id号)&
#三、安装和配置glance
#1. 安装glance相关组件
apt-get install -y glance glance-api python-glanceclient glance-common glance-registry python-glance
echo &-----------------------------begin conf /etc/glance/glance-api.conf------------------------------------&
#2.编辑/etc/glance/glance-api.conf文件
sed -i 's/auth_host = 127.0.0.1/auth_host = '$HOSTS_IP'/' /etc/glance/glance-api.conf
sed -i 's/%SERVICE_TENANT_NAME%/service/' /etc/glance/glance-api.conf
sed -i 's/%SERVICE_USER%/glance/' /etc/glance/glance-api.conf
sed -i 's/%SERVICE_PASSWORD%/'$MYSQL_PW'/' /etc/glance/glance-api.conf
sed -i.orig 's/sqlite:\/\/\/\/var\/lib\/glance\/glance.sqlite/mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-api.conf
sed -i.orig 's/sqlite_db = \/var\/lib\/glance\/glance.sqlite/sql_connection = mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-api.conf
echo flavor = keystone && /etc/glance/glance-api.conf
echo &-----------------------------finished conf /etc/glance/glance-api.conf------------------------------------&
#在glance-api.conf中找到:
#[keystone_authtoken]
#auth_host = $HOSTS_IP &&
#(改成自己的ip)
#auth_port = 35357
#auth_protocol = http
#admin_tenant_name = service
#admin_user = glance
#admin_password = $MYSQL_PW
#3.编辑/etc/glance/glance-api-paste.ini文件
#文件最后添加
echo &-----------------------------begin conf /etc/glance/glance-api-paste.ini------------------------------------&
echo auth_host = $HOSTS_IP &&&/etc/glance/glance-api-paste.ini
#(改成自己的ip)
echo auth_port = 35357 &&&/etc/glance/glance-api-paste.ini
echo auth_protocol = http &&&/etc/glance/glance-api-paste.ini
echo admin_tenant_name = service &&&/etc/glance/glance-api-paste.ini
echo admin_user = glance &&&/etc/glance/glance-api-paste.ini
echo admin_password = $MYSQL_PW &&&/etc/glance/glance-api-paste.ini
echo &-----------------------------finished conf /etc/glance/glance-api-paste.ini------------------------------------&
#4.编辑/etc/glance/glance-registry.conf文件
echo &-----------------------------begin conf /etc/glance/glance-registry.conf------------------------------------&
sed -i 's/auth_host = 127.0.0.1/auth_host = '$HOSTS_IP'/' /etc/glance/glance-registry.conf
sed -i 's/%SERVICE_TENANT_NAME%/service/' /etc/glance/glance-registry.conf
sed -i 's/%SERVICE_USER%/glance/' /etc/glance/glance-registry.conf
sed -i 's/%SERVICE_PASSWORD%/'$MYSQL_PW'/' /etc/glance/glance-registry.conf
sed -i.orig 's/sqlite:\/\/\/\/var\/lib\/glance\/glance.sqlite/mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-registry.conf
sed -i.orig 's/sqlite_db = \/var\/lib\/glance\/glance.sqlite/sql_connection = mysql:\/\/glance:'$MYSQL_PW'@'$HOSTS_IP':3306\/glance/' /etc/glance/glance-registry.conf
echo flavor = keystone &&& /etc/glance/glance-registry.conf
echo &-----------------------------finished conf /etc/glance/glance-registry.conf------------------------------------&
#在glance-registry.conf中找到:
#[keystone_authtoken]
#auth_host = $HOSTS_IP &&
#(改成自己的ip)
#auth_port = 35357
#auth_protocol = http
#admin_tenant_name = service
#admin_user = glance
#admin_password = $MYSQL_PW
#3.编辑/etc/glance/glance-registry-paste.ini文件
#文件最后添加
echo &-----------------------------begin conf /etc/glance/glance-registry-paste.ini------------------------------------&
echo auth_host = $HOSTS_IP &&/etc/glance/glance-registry-paste.ini
echo auth_port = 35357 &&/etc/glance/glance-registry-paste.ini
echo auth_protocol = http &&/etc/glance/glance-registry-paste.ini
echo admin_tenant_name = service &&/etc/glance/glance-registry-paste.ini
echo admin_user = glance &&/etc/glance/glance-registry-paste.ini
echo admin_password = $MYSQL_PW &&/etc/glance/glance-registry-paste.ini
echo &-----------------------------finished conf /etc/glance/glance-registry-paste.ini------------------------------------&
#4. 同步数据库,重启服务
echo &-----------------------------begin conf glance-manage db_sync------------------------------------&
service glance-api stop
service glance-registry stop&
#(在同步之前先关闭相应服务)
glance-manage db_sync
service glance-api restart
service glance-registry restart
echo &-----------------------------finished conf glance-manage db_sync------------------------------------&
#5. 检查安装
glance index
#-----------------
#-----------------
#ID & & & & & & & & & & & & & & & & & Name & & & & & & & & & & & & & Disk Format & & & & &Container Format & & Size & & & & &
#------------------------------------ ------------------------------ -------------------- -------------------- --------------
# 表示安装正确
#四、安装和配置nova
#1. 安装相关组件包
apt-get install nova-api nova-cert nova-common nova-compute nova-compute-kvm nova-network nova-scheduler python-nova python-novaclient nova-consoleauth rabbitmq-server nova-novncproxy novnc python-novnc websockify nova-console &novnc &nova-doc
#2. 修改相应文件的权限
#chown -R nova:nova /etc/nova
#chmod 644 /etc/nova/nova.conf
echo &-----------------------------begin conf /etc/nova/nova.conf------------------------------------&
#2. 修改相应文件的权限
cp /etc/nova/nova.conf /etc/nova/nova.conf.bak
chown -R nova:nova /etc/nova
chmod 644 /etc/nova/nova.conf
#3. 配置/etc/nova/nova.conf文件----替换 改IP地址 &fixed_range=10.0.0.0/24 & & & & & & & & & & & & //////////修改网段cat
cat :& /etc/nova/nova.conf
echo &[DEFAULT] &&/etc/nova/nov}

我要回帖

更多关于 f组结果 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信