服务器基本信息
轻量应用服务器(腾讯云):Ubuntu 18.04.1 LTS
https://console.cloud.tencent.com/lighthouse/instance
网络:
(公)x.x.x.x
(内)x.x.x.x
账号及密码:
root@x.x.x.x/xxxxxxxx
team@x.x.x.x/xxxxxxxx
用户管理
root@VM-4-13-ubuntu:~
team@VM-4-13-ubuntu:~$ sudo passwd root
root@VM-4-13-ubuntu:~
root@VM-4-13-ubuntu:~
team ALL=(ALL:ALL) ALL
root@VM-4-13-ubuntu:~
远程登录
(base) ? ~ telnet x.x.x.x 22
(base) ? ~ ssh team@x.x.x.x
? ~ ssh-keygen -C "xxxxxxx@163.com"
? .ssh cat id_rsa.pub >> authorized_keys
? .ssh chmod 600 authorized_keys
? ~ chmod 700 .ssh
? ~ sudo vi /etc/ssh/sshd_config
RSAAuthentication yes
PubkeyAuthentication yes
:wq!
PasswordAuthentication no
PermitRootLogin yes
? ~ ssh localhost
(base) ? ~ ssh -i .ssh/id_rsa team@x.x.x.x
? ~ sudo service sshd restart
安装 ohmyzsh
team@VM-4-13-ubuntu:~$ sudo apt install zsh
team@VM-4-13-ubuntu:~$ sudo apt install git
team@VM-4-13-ubuntu:~$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
安装并配置MySQL
root@VM-4-13-ubuntu:~
..............
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
........................
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
..............
root@VM-4-13-ubuntu:~
root@VM-4-13-ubuntu:~
......
update-alternatives: using /etc/mysql/mariadb.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
........
root@VM-4-13-ubuntu:~
root@VM-4-13-ubuntu:~
root@VM-4-13-ubuntu:~
alter user 'root'@'localhost' identified by 'xxxxxxxxx';
:wq!s
mysql> grant all privileges on *.* to 'root'@'*' identified by 'xxxxxxxxxxxx';
mysql> flush privileges;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'xxxxxxxxx';
mysql> CREATE USER 'team'@'%' IDENTIFIED WITH mysql_native_password BY 'xxxxxxx';
mysql> grant all privileges on *.* to 'team'@'*' identified by 'xxxxxxxx' with grant option;
[mysqld]
lower_case_table_names=1
? ~ mysqldump -uteam -pxxxxxxx dbxxxxx > workorders.sql
安装Docker
? ~ sudo apt update
? ~ sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
? ~ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
? ~ sudo apt-key fingerprint 0EBFCD88
? ~ sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
? ~ sudo apt update
? ~ sudo apt install docker-ce docker-ce-cli containerd.io
? ~ apt-cache madison docker-ce
? ~ sudo apt install docker-ce=5:18.09.9~3-0~ubuntu-xenial docker-ce-cli=5:18.09.9~3-0~ubuntu-xenial containerd.io
? ~ sudo usermod -aG docker team
? ~ newgrp docker
? ~ sudo tee /etc/docker/daemon.json <<-'EOF'
heredocd> {
"registry-mirrors": ["https://8th48jkz.mirror.aliyuncs.com"]
}
heredocd> EOF
{
"registry-mirrors": ["https://8th48jkz.mirror.aliyuncs.com"]
}
? ~ cat /etc/docker/daemon.json
{
"registry-mirrors": ["https://8th48jkz.mirror.aliyuncs.com"]
}
? ~ sudo systemctl daemon-reload
? ~ sudo systemctl restart docker.service
? ~ docker info
.......
Registry Mirrors:
https://8th48jkz.mirror.aliyuncs.com/
.......
? ~ docker pull mysql:5.7
? ~ docker pull nginx:1.10
? ~ docker pull redis:4.0
? ~ docker pull tomcat:8.0
? ~ docker run --name nginx-server -p 8081:80 -d nginx
? ~ docker run --name nginx -d -p 8081:80 \
-v /usr/docker/nginx/log:/var/log/nginx \
-v /usr/docker/nginx/html:/usr/share/nginx/html \
-v /usr/docker/nginx/conf.d:/etc/nginx/conf.d nginx:1.10
? ~ docker run --name nginx -d -p 8081:80 \
-v /usr/docker/nginx/log:/var/log/nginx \
-v /usr/docker/nginx/conf.d:/etc/nginx/conf.d nginx:1.10
? ~ docker run --name kylin3.0.1 -d -m 8G -p 7070:7070 -p 8088:8088 -p 50070:50070 -p 8032:8032 -p 8042:8042 -p 16010:16010 apachekylin/apache-kylin-standalone:3.0.1
(env3.7) ? ~ pip --no-cache-dir install tensorflow -i https://pypi.douban.com/simple/
配置容器:
? ~ sudo docker run -p 3306:3306 --name mysql -v /mydata/mysql/log:/var/log/mysql -v /mydata/mysql/data:/var/lib/mysql -v /mydata/mysql/conf:/etc/mysql -e MYSQL_ROOT_PASSWORD=root -d mysql:5.7
mysql> create user 'team' identified by 'xxxxxx';
mysql> grant all privileges on *.* to 'team'@'%' identified by 'xxxxxx';
? ~ sudo docker cp /home/team/projects/workorders.sql mysql:/
? ~ sudo docker run -p 6379:6379 --name redis -v /mydata/redis/data:/data -d redis:4.0 redis-server --appendonly yes
? ~ sudo docker run -p 80:80 --name nginx -v /mydata/nginx/html:/usr/share/nginx/html -v /mydata/nginx/logs:/var/logs/nginx -v /mydata/nginx/nginx:/etc/nginx -d nginx:1.10
? ~ sudo docker run -p 8080:8080 --name tomcat -v /mydata/tomcat/webapps:/usr/local/tomcat/webapps -v /mydata/tomcat/logs:/usr/local/tomcat/logs -d tomcat:8.0
? ~ sudo docker run -p 8080:8080 --name tomcat -d tomcat:8.5.54
? ~ sudo docker container cp tomcat:/usr/local/tomcat/conf /mydata/tomcat/conf
? ~ sudo docker run -p 8080:8080 --name tomcat -v /mydata/tomcat/webapps:/usr/local/tomcat/webapps -v /mydata/tomcat/logs:/usr/local/tomcat/logs -v /mydata/tomcat/conf:/usr/local/tomcat/conf -d tomcat:8.0
? ~ sudo docker run -p 8080:8080 --name tomcat -v /mydata/tomcat:/usr/local/tomcat -d tomcat:8.5.54
? tomcat docker build -f Dockerfile -t tomcat:new .
? ~ sudo docker run -it --rm zendesk/maxwell bin/maxwell --user='root' --password='xxxxxx' --host='x.x.x.x' --producer=stdout
安装Nginx
/usr/sbin/nginx:主程序
/etc/nginx:存放配置文件
/usr/share/nginx:存放静态文件
/var/log/nginx:存放日志
? ~ docker pull nginx
? ~ docker run --name nginx-demo -d -p 80:80 nginx:latest
? ~ docker exec -it nginx-demo /bin/bash
root@6b14f12532e1:/
root@6b14f12532e1:/
root@6b14f12532e1:/
? docker mkdir -p nginx/log nginx/conf nginx/html
? docker docker run --name nginx-demo -d -p 80:80 \
> -v /home/team/docker/nginx/log:/var/log/nginx\
> -v /home/team/docker/nginx/nginx:/etc/nginx\
> -v /home/team/docker/nginx/html:/usr/share/nginx/html nginx:latest
安装 Java
? tools ls -la jdk-8u291-linux-x64.tar.gz
? local sudo tar -xvf ~/tools/jdk-8u291-linux-x64.tar.gz
? local sudo ln -s jdk1.8.0_291 jdk1.8
? ~ vi .zshrc
export JAVA_HOME=/usr/local/jdk1.8
export PATH=$JAVA_HOME/bin:$PATH
:wq!
? ~ source .zshrc
搭建 Jenkins + GitHub
安装 Jenkins
? tools sudo vi /etc/apt/sources.list
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu xenial-security main restricted
deb http://mirrors.aliyun.com/ubuntu xenial-security universe
deb http://mirrors.aliyun.com/ubuntu xenial-security multiverse
:wq!
? tools sudo apt update
? tools wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
? tools echo deb http://pkg.jenkins.io/debian-stable binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list
? tools sudo apt update
? tools sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FCEF32E745F2C3D5
root@VM-4-13-ubuntu:~
? tools sudo apt install -y jenkins
参考文献
|