首页 🖥运维&安全

云平台简易版命令

IAAS搭建

1.修改网络配置
con/com
NM_CONtREOLLED=no
IPADDR=
NETMASK=
GATEWAY=
2.修改yum源
con:
mkdir /opt/centos7/
cd /etc/yum.repos.d/
rm -vf *
vi loca.repo
[centos7]
name=centos
baseurl=file:///opt/centos7/
gpgcheck=0
enbaled=1
[openstack]
name=Openstack Repository
baseurl=file:///opt/iaas-repo/
gpgcheck=0
enabled=1
com:
mkdir /opt/centos7/
cd /etc/yum.repos.d/
rm -vf *
vi loca.repo
[centos7]
name=centos
baseurl=ftp://controller.ip//opt/centos7/
gpgcheck=0
enbaled=1
[openstack]
name=Openstack Repository
baseurl=file://controller.ip//opt/iaas-repo/
gpgcheck=0
enabled=1

yum clean all
挂载光盘在mnt下
mount /Cetos7 /mnt
cp -r /mnt/* /opt/centos7
mount /xiandian-iaas /mnt/
cp -r /mnt/* /opt
3.安装ftp
con:
yum install vsftpd -y
vi /etc/vsftpd/vsftpd.conf
添加anon_root=/
service vsftpd restart
4.分区
com:
parted /dev/md126
mkpart cinder 开始大小    结束大小
mkpart swift  开始大小    结束大小
5.安装脚本文件
con/com
yum install iaas-xiandian
vi /etc/xiandian/admin-openrc.sh
6.安装pre脚本
con/com
iaas-pre-host.sh
7.安装mysql数据库
con:
iaas-install-mysql.sh
8.安装keystone认证服务
con:
iaas-install-keystone.sh
9.安装glance镜像服务
iaas-install-glance.sh
10.安装nova服务
con:
iaas-install-nova-controller.sh
com:
iaas-install-nova-compute.sh
11.安装neutron服务
con:
iaas-install-neutron-controller.sh
com:
iaas-install-neutron-compute.sh
con:
iaas-install-neutron-controller-gre.sh
com:
iaas-install-neutron-compute-gre.sh
12.安装dashboard
con:
iaas-install-dashboard.sh
13.安装cinder服务
con:
iaas-install-cinder-controller.sh
com:
iaas-install-cinder-compute.sh
14.安装swift服务
con:
iaas-install-swift-controller.sh
com:
iaas-install-swift-compute.sh
15.安装heat服务
con:
iaas-install-heat.sh
16.安装ceilometer服务
con:
iaas-install-ceilometer-controller.sh
com:
iaas-install-ceilometer-compute.sh
17.安装alarm
con:
iaas-install-alarm.sh

运维

nova flavor-list        //云主机列表
nova service-list        //服务列表
nova image-list        //镜像列表
nova list        //实例列表
nova show flavorid        //查看云主机实例
nova volume-list        //云硬盘列表
nova volume-create --display-name zhuhe size       //创建云硬盘
nova secgroup-create zhuhe "miaoshu"             //创建安全组
nova secgroup-rules-list name                    //查看安全组信息
glance image-create --name "centos7" --disk-format qcow2 --container-format bare --progress > 绝对路径
 //上传创建镜像
glance image-list        //镜像列表
glance image-show imageid    //查看镜像信息、
glance image-update --name=修改的名字     镜像id        //修改镜像    
glance image-delete 镜像id    //删除镜像
openstack user list        //查看用户列表
openstack project list        //查看项目列表
openstack role list        //查看角色列表
openstack service list        //查看服务列表
openstack endpoint list        //查看端口列表
openstack user show username         //查看用户信息
openstack role show rolename         //查看角色信息
openstack project show project         //查看项目信息
openstack endpoint show endpointid     // 查看端口信息
openstack user create --domain admin zhuhe --password 000000      //创建用户
openstack project create --domain admin zhuhe                    //创建项目
openstack role create zhuhe             //创建角色
openstack service create --type zhuhe --name zhuhe --description="openstack controller"      //创建服务
openstack role add zhuhe --user zhuhe --project zhuhe              //给某个角色赋予什么用户什么项目
show databases;           //查看数据库列表
create database db;         //创建数据库
use db;        //使用数据库
show tables;        //查看表列表
describe user;        //查看表结构
show grants for user;    //查看用户权限
select * from user;    //查看user表
select * from user where id=1;         //查看id=1的
delete from user where id=1;             //删除id=1的
update name='z' from user where id=1;     //修改id=1的名字
grant all(usage/select/delete/) privileges on user.* to 'user'@'localhost/%' identified by '000000';
//给某个用户赋予使用某个数据库的权限
heat stack-create zhuhe -f .yml --parameters "ImageID=centos7;NetID=int-net"            //创建栈
heat resource-show zhuhe    //查看栈资源列表
heat output-list        //查看栈输出列表
heat output-show zhuhe lieming         //查看栈输出值
heat event-list         //查看事件列表
heat event-show zhuhe        //查看栈事件详细信息
cinder absolute-limits        //查看当前用户资源信息
cinder volume-create --display-name zhuhe size           //创建云硬盘
cinder volume-show zhuhe    //查看云硬盘详细信息
cinder credentials        //查看当前用户认证信息
cinder snapshot-create --display-name zhuhe  云硬盘名    //创建快照
cinder snapshot-list        //查看快照列表
cinder type-create lvm        //创建云硬盘类型标识符
cinder extra-specs-list        //查看以创建的标识符
neutron ext-list        //查看资源列表
neutron router-list        //查看路由列表
neutron net-list        //查看网络列表
neutron subnet-list        //查看子网列表
neutron agent-list        //查看代理列表
neutron port-list        //查看端口列表
neutron net-show netid        //查看网络详细信息
    
ceilometer meter-list        //查看监控列表
ceilometer resource-list    //查看资源列表
ceilometer statistics -m network.incoming.bytes        //查看网络数据
ceilometer statistics -m instance                     //查看实例数据
ceilometer statistics -m disk.read.requests             //查看存储数据
ceilometer statistics -m memory                     //查看资源消耗列表
rabbitmqctl list_queues        //查看队列信息
rabbitmqctl stop_app        //停止应用
rabbitmqctl start_app        //启动应用
rabbitmqctl reset        //清空队列
rabbitmqctl add_user name 000000                  //新建用户
rabbitmqctl delete_user name        //删除用户
rabbitmqctl list_users            //用户列表    
rabbitmqctl change_password name newpassword      //修改用户密码

hadoop 
su hdfs
hadoop fs -ls /        //查看hadoop根目录
hadoop fs -chmod R 777 /    //修改文件权限
hadoop fs -mkdir /xiandian    //创建文件夹
hadoop fs -put /xx /xiandian    //上传文件
hadoop fs -cat /xx/xx        //查看文件
hadoop fs -get /xx        //下载文件
hadoop fs -rm /xx/xx        //删除文件
hadoop fs -touch /xx/xx        //创建文件
hadoop fs -count -q /        //查看目录下的数
hadoop jar  jarbao  canshu    运行jar包
hadoop dsfadmin  -safemode  enter    安全模式
hadoop dsfadmin  -safemode  get

su hive        //进入hive
hive
show tables;    //查看表
show tables 'ad*';    //查看以ad开头的表
set -v;        //查看所有变量
set s;        //查看某一变量
set s=a;        //设置某一变量
dfs -ls;        //查看hadoop的所有文件
source file;        //运行hive脚本
show functions;        //查看所有函数
describe function;     //查看函数具体内容
create table biaoming(id int,name string);             //创建表
create table biao() partitioned by(ds string);          //创建表并创建分区
show partitions name;                           //查看分区
alter table s add colume(id int);                    //给表增加一列 
alter table s rename to s1;                        //修改表名
drop table s;                                   //删除表
load data inpath 'hdfs://maser//x/x' overwrite into table s;           //给表添加数据
load data inpath 'hdfs://maser//x/x' overwrite into table s partition (ds=00);

create table abc
(id int,name string)
row format delimited 
fields terminated by '\t'
lines terminated by '\n'
stored as textfile; 

status              //查看状态
version              //查看版本
create 'biaoming','liezu1','liezu2'    //创建表名
list                      //查看表描述
describe 'biaoming';        //查看表结构
disable 'biaoming';        //停止表
drop 'biaoming';         //删除表
is_enabled/disabled 'biaoming';    //判断表是否e、d
put 'biaoming','id','mouliezu:moulie','22';    //添加
put 'biaoming','id','mouliezu:moulie','23';    //修改
get 'biaoming','id','';             //得到
scan 'biaoming';             //全表扫描
delete 'biaoming','id','liezu:lie';     //删除
deleteall 'biaoming','id';        //删除整行
count 'biao';             //查询表有几行
incr 'biao','id','liezu:lie';        //增加字段

Bigdata

1.修改主机名
m:
hostnamectl set-hostname master
s:
hostnamectl set-hostname slaver1
2.修改网络配置
m/s:
NM_CONREOLLED=no
IPADDR=
NETMASK=
GATEWAY=
3.修改yum源
m:
cd /etc/yum.repos.d/
rm -vf *
vi ambari.repo
[centos7]
name=centos
baseurl=ftp://controller.ip//opt/centos7/
gpgcheck=0
enbaled=1
[ambari]
name=ambari
baseurl=file:///opt/ambari/
gpgcheck=0
enabled=1

yum clean all
s:
cd /etc/yum.repos.d/
rm -vf *
vi ambari.repo
[centos7]
name=centos
baseurl=ftp://controller.ip//opt/centos7/
gpgcheck=0
enbaled=1
[ambari]
name=ambari
baseurl=ftp://master.ip//opt/ambari/
gpgcheck=0
enabled=1

yum clean all
挂载光盘在mnt下
mount /xiandian-bigdata /mnt
cp -r /mnt/* /opt/
4.安装ftp
m:
yum install vsftpd -y
vi /etc/vsftpd/vsftpd.conf
添加anon_root=/
service vsftpd restart
5.安装http
m:
yum install httpd -y
将/mnt下的HDP-*复制到/var/www/html
systemctl start httpd.service
systemctl enable http.service
systemctl statu http.service
6.安装ntp、ntpdate
m:
yum install ntp 
vi /etc/ntp.conf
添加
server 127.127.1.0
fudge  127.127.1.0    startum    10
s:
yum install ntpdate
ntpdate master
systemctl enable ntpdate
7.禁用htp
m/s:
echo never > /s/k/m/t/e
echo never > /s/k/m/t/d
cat /s/k/m/t/e
重启失效
8.安装JDK
m:
mkdir /usr/jdk64
cd /mnt
tar -zxvf jdk压缩包 -C /usr/jdk64
vi /etc/profile
添加
export JAVA_HOME=/usr/jdk64/jdk1.8.0_77
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
java -version
s:
mkdir /usr/jdk64
scp master.ip://mnt/jdk压缩包 .
tar -zxvf jdk压缩包 -C /usr/jdk64
vi /etc/profile
添加
export JAVA_HOME=/usr/jdk64/jdk1.8.0_77
export PATH=$JAVA_HOME/bin:$PATH
source /etc/profile
java -version
9.安装ambari
m:
yum install ambari-server
yum install mariadb mariadb-server mysql-connector-java
mysql_secure_installation
回车
bigdata
y   n   y  y
10.创建ambari数据库
mysql -uroot -pbigdata
create database ambari;
grant all privileges on ambari.* to 'ambari'@'localhost' identified by 'bigdata';
grant all privileges on ambari.* to 'ambari'@'%' identified by 'bigdata';
use ambari;
source /var/lib/ambari-server/resources/Ambari-DDL-Mysql-CREATE.sql
quit
10.配置ambari
m:
ambari-server setup
n 
3 
/usr/jdk64/jdk1.8.0_77
y
3
#
#
#
#
y
ambari-server start
11.安装ambari-agent
m/s:
yum install ambari-agent
vi /etc/ambari-agent/conf/ambari-agent.ini
[server]
localhost=master
ambari-agent restart 

PAAS

1.修改yum源
rm -rvf /etc/yum.repo.d/*
vi /etc/yum.repo.d/yum.repo
[centos]
name=centos
baseurl=ftp://172.24.2.10//opt/centos7/
gpgcheck=0
enabled=1
[paas]
name=paas
baseurl=ftp://172.24.2.20//opt/paas/docker/
gpgcheck=0
enable=1

yum clean all
2.修改防火墙规则
iptables -F
iptables -X
iptables -Z
/usr/sbin/iptables-save
3.修改内核转发
vi /etc/sysctl.conf
net.ipv4.ip_forward    =    1
net.ipv4.conf.default.rp    =    0
net.ipv4.conf.all.rp_filter    =    0
生效该文件
 /etc/sysctl.conf    -p
4.安装docker
yum install docker-io -y
修改docker配置文件
vi /etc/syscontry/docker
将两处地址修改为仓库节点的IP:5000
重启docker服务    service docker restart
设置开机自启动    chckong    docker on
5.在仓库节点的操作
上传镜像: docker load < registry_latest.tar    
查看上传的镜像:docker images
docker tag <ID> 10.0.0.8:5000/registry:latest
docker push  10.0.0.8:5000/registry:latest
以上操作可以由脚本完成:
install.sh

SDN

1.安装JAVA
tar -zxvf jdk..... -C /usr/local
2.安装maven
tar -zxvf apache-maven-3.0.4  -C /usr/local
3.修改变量
vi /etc/profile
export JAVA_HOME=/usr/local/jdk1.0.7_71/
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export MAVEN_HOME=/usr/local/apache-maven-3.0.4/
export PATH=${PATH}:{MAVEN_HOME}/bin
source /etc/profile
java -version
mvn -v
4.安装opendaylight
tar -zxvf OpenDayLight.tar.gz -C /opt
./bin/start
ssh -p 8101 karaf@localhost
password:karaf
feature:install  -openstack  odl-dlux-core
5.安装networking-odl
tar -zxvf networking-odl
cd networking-odl
python setup.py install
停止服务
service neutron-openvswitch-agent stop
chkconfig neutron-openvswitch-agent off
service neutron-server stop(所有节点)

service neutron-metadata-agent stop(所有节点)
service neutron-dhcp-agent stop(网络节点)
service neutron-l3-agent stop(网络节点)
6.删除neutron数据库
mysql -uroot -p000000
mysql> drop database neutron;
mysql> create database neutron;
mysql> grant all privileges on neutron.* to 'neutron'@'localhost' identified  by '000000';
mysql> grant all privileges on neutron.* to 'neutron'@'%' identified  by'000000';
mysql> exit
# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf  --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron

service openvswitch stop
rm -rfv /var/log/openvswitch/*
rm -rfv /etc/openvswitch/conf.db
service openvswitch start
ovs-vsctl show

vi /etc/neutron/plugins/ml2/ml2_conf.ini
....drivers=opendaylight
最下面添加
[ml2_odl]
password = admin
username = admin
url = http://172.24.2.10:9090/controller/nb/v2/neutron

修改local_ip
ovs-vsctl show

ovs-vsctl set Open_vSwitch <ID> other-config {'local_ip'='172.24.2.10'}(所有节点)
(备注:<ID>为ovs-vsctl show 查看得到)

ovs-vsctl list Open_vSwitch 

ovs-vsctl set-manage tcp:172.24.2.10:6640

ovs-vsctl show

ovs-vsctl add   br-ex 
ovs-vsctl set-port br-ex enp9s0

service neutron-server start
service neutron-metadata-agent start
service neutron-dhcp-agent start
service neutron-l3-agent start

curl  -u admin:admin http://172.24.2.10:9090/controller/nb/v2/neutron/networks


文章评论