当前位置:首页 > IT技术 > 数据库 > 正文

docker 安装MySQL
2021-10-04 11:36:59

免密码配置

三台服务器同时做:
[root@localhost ~]# ssh-keygen -t rsa
一路回车
查看是否生成了秘钥:
[root@localhost ~]# ls /root/.ssh/

[root@localhost ~]# cd /root

[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub -p22 root@192.168.2.109
[root@localhost ~]# ssh-copy-id -i .ssh/id_rsa.pub -p22 root@192.168.2.110
测试:

[root@localhost ~]# ssh root@192.168.2.110

OK 可以免密登陆了

安装spark,集群配置

tar -zxvf spark-2.1.1-bin-hadoop2.7.tgz -C ../bigdata/
cd /home/bigdata/spark-2.1.1-bin-hadoop2.7

bin/spark-submit --class org.apache.spark.examples.SparkPi --master local[2] ./examples/jars/spark-examples_2.11-2.1.1.jar 10
集群配置:
mv slaves.template slaves
mv spark-env.sh.template spark-env.sh

vim slaves
添加
192.168.2.109
192.168.2.110
192.168.2.111

vim spark-env.sh
SPARK_MASTER_HOST=192.168.2.109
SPARK_MASTER_PORT=7077

启动:
/home/bigdata/spark-2.1.1-bin-hadoop2.7/sbin/start-all.sh

集群模式下运行:
[root@localhost spark-2.1.1-bin-hadoop2.7]# bin/spark-submit --class org.apache.spark.examples.SparkPi --master spark://192.168.2.109:7077 ./examples/jars/spark-examples_2.11-2.1.1.jar 10

kinbana 安装

下载路径:
https://www.elastic.co/cn/downloads/past-releases#kibana
注意选择适合自己 es的版本
解压:
[root@localhost soft]# tar -zxvf kibana-6.8.8-linux-x86_64.tar.gz -C ../bigdata/
修改配置:
server.port: 5601
server.host: "192.168.2.109"
elasticsearch.hosts: ["http://192.168.2.109:9200"]

启动:
nohup /home/bigdata/kibana-6.8.8-linux-x86_64/bin/kibana &

查看:
http://192.168.2.110:5601/app/kibana#/home?_g=()

centos7 安装elasticsearch

[root@localhost ~]# useradd --create-home --no-log-init --shell /bin/bash es
[root@localhost ~]# echo 'es:es2021!' | chpasswd
[root@localhost ~]# echo "root ALL=(ALL) ALL" >> /etc/sudoers
[root@localhost ~]# echo "es ALL=(ALL) ALL" >> /etc/sudoers
[root@localhost ~]# cd /home/soft/
[root@localhost soft]# ll
总用量 527580
-rw-r--r--. 1 root root 149927766 7月 22 15:55 elasticsearch-6.8.8.tar.gz
-rw-r--r--. 1 root root 189162738 10月 5 11:05 kibana-6.8.8-linux-x86_64.tar.gz
-rw-r--r--. 1 root root 201142612 9月 11 21:25 spark-2.1.1-bin-hadoop2.7.tgz
[root@localhost soft]# chmod 777 *
[root@localhost soft]# ll
总用量 527580
-rwxrwxrwx. 1 root root 149927766 7月 22 15:55 elasticsearch-6.8.8.tar.gz
-rwxrwxrwx. 1 root root 189162738 10月 5 11:05 kibana-6.8.8-linux-x86_64.tar.gz
-rwxrwxrwx. 1 root root 201142612 9月 11 21:25 spark-2.1.1-bin-hadoop2.7.tgz
[root@localhost soft]# tar -zxvf elasticsearch-6.8.8.tar.gz -C ../bigdata/

[root@localhost bigdata]# chown -R es:es /home/bigdata/elasticsearch-6.8.8/
[root@localhost bigdata]# cd elasticsearch-6.8.8/
[root@localhost elasticsearch-6.8.8]# echo "network.host: 0.0.0.0" >> /home/bigdata/elasticsearch-6.8.8/config/elasticsearch.yml
[root@localhost elasticsearch-6.8.8]# echo "vm.max_map_count=262144" >> /etc/sysctl.conf
[root@localhost elasticsearch-6.8.8]# echo "es soft nproc 11000" >> /etc/security/limits.conf
[root@localhost elasticsearch-6.8.8]# echo " es hard nproc 11000" >> /etc/security/limits.conf
[root@localhost elasticsearch-6.8.8]# echo " es soft nofile 655350" >> /etc/security/limits.conf
[root@localhost elasticsearch-6.8.8]# echo "es hard nofile 655350" >> /etc/security/limits.conf
[root@localhost elasticsearch-6.8.8]# /sbin/sysctl -p
vm.max_map_count = 262144
[root@localhost elasticsearch-6.8.8]# pwd
/home/bigdata/elasticsearch-6.8.8
[root@localhost elasticsearch-6.8.8]# echo "export ES_HOME=/home/bigdata/elasticsearch-6.8.8" >> /etc/profile
[root@localhost elasticsearch-6.8.8]# source /etc/profile
[root@localhost elasticsearch-6.8.8]# echo "export PATH=$PATH:$ES_HOME/bin" >> /etc/profile
[root@localhost elasticsearch-6.8.8]# source /etc/profile
[root@localhost elasticsearch-6.8.8]# su es
( 注意切换用户后生效 )
[es@localhost bigdata]$ /home/bigdata/elasticsearch-6.8.8/bin/elasticsearch -d

165 jps
166 history

3  jps
4  netstat -aptn |grep 9200
5  curl http://127.0.0.1:9200
6  curl http://192.168.2.109:9200

[root@localhost elasticsearch-6.8.8]# curl http://127.0.0.1:9200
{
"name" : "nuaI5m9",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "5pHVkVSbQJqX2x2ttmQnxg",
"version" : {
"number" : "6.8.8",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "2f4c224",
"build_date" : "2020-03-18T23:22:18.622755Z",
"build_snapshot" : false,
"lucene_version" : "7.7.2",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

使用 ulimit -Hn 查看当前值,果然是65535,

ulimit -Hn

docker 安装MySQL

docker pull mysql:5.7 # 拉取 mysql 5.7

docker run -p 3306:3306 --name mysql
-v /home/docker-v/mysql/conf:/etc/mysql
-v /home/docker-v/mysql/logs:/var/log/mysql
-v /home/docker-v/mysql/data:/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=123456
-d mysql:5.7

–name:容器名,此处命名为mysql
-e:配置信息,此处配置mysql的root用户的登陆密码
-p:端口映射,此处映射 主机3306端口 到 容器的3306端口
-d:后台运行容器,保证在退出终端后容器继续运行

docker run -p 3309:3306 --name mysql-gxhh5.7-3309
-v /home/docker-v/mysql5.7-3309/conf:/etc/mysql
-v /home/docker-v/mysql5.7-3309/logs:/var/log/mysql
-v /home/docker-v/mysql5.7-3309/data:/var/lib/mysql
-e MYSQL_ROOT_PASSWORD=gxhh.123
-d mysql:5.7

sudo docker exec -it mysql bash
mysql -uroot -p123456
mysql> grant all privileges on . to root@'%' identified by "password";

mysql> use mysql;
Database changed

mysql> select host,user from user;

mysql> grant all privileges on . to root@'%' identified by "123456";
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

本文摘自 :https://www.cnblogs.com/

开通会员,享受整站包年服务立即开通 >