Thursday, 7 November 2019

AWS CLI Command set

* pip Install : sudo easy_install pip

https://www.youtube.com/watch?v=M32O4Yv0ANc&list=PLxzKY3wu0_FJdJd3IKdiM4Om1hGo2Hsdt&index=9

https://github.com/ValaxyTech/DevOpsDemos/blob/master/Jenkins/Installation.MD

https://github.com/ValaxyTech/hello-world

https://github.com/miztiik/DevOps

https://github.com/miztiik/run-ansible-playbook-from-ssm

1. https://rndwiki.corp.hpicorp.net/confluence/display/FoothillsSW/Code+Signing
2. https://hp.sharepoint.com/teams/securesign/Shared%20Documents/Forms/AllItems.aspx?id=%2Fteams%2Fsecuresign%2FShared%20Documents%2FGuides

https://hpss.corp.hpicloud.net/

* Jenkins Install
https://github.com/miztiik/DevOps-Demos/tree/master/setup-jenkins

- login terminal
- sudo su -
- yum install java-1.8*
java -version
find /usr/lib/jvm/java-1.8* | head -n 3
* Do !!!  copy  /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64
vi .bash_profile
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64
PATH=$PATH:$JAVA_HOME:$HOME/bin

Jenkins Start / Stop
- sudo su -
- start : systemctl start jenkins
- stop : sstemctl stop jenkins
- setup jenkins to stgart at boot : systemctl enable jenkins

* Jenkins Slave
/home/jenkins-slave-01

* Jenkins : 708bb8129afd4c70ad06c308e544b4bf
http://13.125.238.9:8080/
admin / admin

* find / -name javac
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64

---- Maven
cd /opt
mkdir maven
cd maven

wget https://www-eu.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz

tar -xvzf apache-maven-3.6.1-bin.tar.gz

cd /root
vi .bash_profile

M2_HOME=/opt/maven/apache-maven-3.6.1
M2=$M2_HOME/bin


-- git
yum intall

# User specific environment and startup programs
JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-0.amzn2.x86_64
M2_HOME=/opt/maven/apache-maven-3.6.1
M2=$M2_HOME/bin

PATH=$PATH:$JAVA_HOME$M2_HOME:$M2:$HOME/bin


https://github.com/arsr319/maven-hello-world.git

---- Tomcat
/opt/apache-tomcat-8.5.40/bin
ln -s /opt/apache-tomcat-8.5.40/bin/startup.sh /usr/local/bin/tomcatup
ln -s /opt/apache-tomcat-8.5.40/bin/shutdown.sh /usr/local/bin/tomcatdown

tomcat start > tomcatup
tomcat stop  > tomcatdown

http://54.180.162.69:8080/

http://54.180.162.69:8080/manager/html









ansadmin / ansadmin

----- Ansible
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

useradd ansadmin
passwd ansadmin

Switch / Change user
]$ su ansadmin

----------SonarQube : http://13.125.159.237:9000/sonar/    - admin/admin
https://github.com/ValaxyTech/DevOpsDemos/blob/master/SonarQube/SonarQube_Installation.MD
sonarqubedb.czgb4olmfmiv.ap-northeast-2.rds.amazonaws.com
sonarqubedb
sonarqubedb

* Install mysql client
[ec2-user@ip-10..]$ sudo su -
[root@ip-10...]$ yum install mysql
[root@ip-10...]$ mysql -h sonarqubedb.czgb4olmfmiv.ap-northeast-2.rds.amazonaws.com -p 3306 -u sonarqubedb -p sonarqubedb

* Start
move to : /opt/sonar/bin/linux-x86-64
./sonar.sh status
./soner.sh start
./soner.sh stop

mysql -h sonarqubedb.czgb4olmfmiv.ap-northeast-2.rds.amazonaws.com:3306 -u sonarqubedb -p sonarqubedb

CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;

wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-3.2.0.1227-linux.zip

----- docker command
sudo yum install docker -y

sudo systemctl start docker
sudo docker run hello-world

docker image ls
docker ps -a
docker stop
docker start

doker images
docker image rm -f ubuntu
docker image rm -f 75835a67d134

docker container ls -a
docker container rm cc3f2ff51cab cd20b396a061
docker ps -a

adduser dockeradmin
passwd dockeradmin
usermod -aG docker dockeradmin
usermod -aG docker ansadmin
dockeradmin / dockeradmin


docker pull ubuntu
docker run -d --name ubuntu ubuntu:latest

docker tag ubuntu:latest kyhwang0/ubuntu_demo

docker login
docker push kyhwang0/ubuntu_demo

docker cp index.html 1afdc5ff7972:/tmp
docker exec -it 1afdc5ff7972 /bin/bash


--- Update /etc/ssh/sshd_config
...
...
# To disable tunneled clear text passwords, change to no here!
PasswordAuthentication yes
#PermitEmptyPasswords no
#PasswordAuthentication no

service sshd restart

* Jenkis integration
docker stop valaxy_demo;
docker rm -f valaxy_demo;
docker image rm -f valaxy_demo;
cd /opt/docker;
docker build -t valaxy_demo .

* Permission Error from Jenkins build > no permission for build owner
chown -R dockeradmin:dockeradmin /opt/docker



--- Nexus - http://13.124.67.13:8081/#browse/browse/components    (admin/admin123)
* nexus / nexus
sudo chown -R nexus:nexus /opt/nexus
sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
su - nexus
service nexus start

sudo service doker start
sudo service doker status

{
  "insecure-registries": ["13.124.67.13:8083"],
  "disable-legacy-registry":true
}

sudo service docker restart

sudo docker login -u admin -p admin123 http://13.124.67.13:8083

-- Jenkins + Ansible + Docker + Docker Hub
cd /opt/docker
docker login -u kyhwang0 -p kyhwang0
docker build -t $JOB_NAME:v1.$BUILD_ID .
docker tag $JOB_NAME:v1.$BUILD_ID kyhwang0/$JOB_NAME:v1.$BUILD_ID
docker tag $JOB_NAME:v1.$BUILD_ID kyhwang0/$JOB_NAME:latest
docker push kyhwang0/$JOB_NAME:v1.$BUILD_ID
docker push kyhwang0/$JOB_NAME:latest
docker rmi $JOB_NAME:v1.$BUILD_ID kyhwang0/$JOB_NAME:v1.$BUILD_ID
docker run -d --name web_demo -p 8090:8080 kyhwang0/ansible-docker-hub-2:latest



cd /opt/playbooks
ansible-playbook -i /opt/playbooks/hosts create_docker_container.yml

-------- Kubernates
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.14.2/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl

wget https://github.com/kubernetes/kops/releases/download/1.6.1/kops-linux-amd64
chmod +x kops-linux-amd64
sudo mv kops-linux-amd64 /usr/local/bin/kops

x-kicluster.k6s.ky.vpc

echo $KOPS_STATE_STORE
export KOPS_STATE_STORE=s3://x-kicluster.k6s.ky.vpc
echo $KOPS_STATE_STORE

kops create cluster --cloud=aws --zones=ap-northeast-2 --name=apnortheast2.k6s.ky.vpc --dns=ky.vpc --dns private

* Bastion Host connetion
[ec2-user@ip-11-0-0-32 ~]$ ssh ec2-user@11.0.2.83
The authenticity of host '11.0.2.83 (11.0.2.83)' can't be established.
ECDSA key fingerprint is SHA256:XSCxR+EMEkSyNu9K84f0TaO2o/RQMkLewj1ZQNiKLzI.
ECDSA key fingerprint is MD5:99:ff:29:30:b0:16:a9:b6:36:ec:e4:fa:8b:70:03:47.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '11.0.2.83' (ECDSA) to the list of known hosts.

       __|  __|_  )
       _|  (     /   Amazon Linux 2 AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-2/
[ec2-user@ip-11-0-2-83 ~]$

Monday, 4 March 2019

python aws proxy boto3

You can install all of below library from pyCharm
1. open pyCharm
2. File > Settings > Appearance & Behavior > System Settings > HTTP Proxy
3. Select "Manual proxy configuration"
4. Host name : "web-proxy.sg.hpicorp.net" . Port number "8080"
5. Click Apply button
6. File > Settings > Project:py-scripting > Project Interpreter
7. Click "+" mark on the top of right
8. search "boto3", "awscli" .....
9. install all

- command line installation.
Open Window Command
https://www.youtube.com/watch?v=6dXZM9SAFzg
C:\>easy_install pip
C:\>pip instal python3 (or python2)
C:\>pip install boto3
C:\>pip install awscli

C:\>python
import boto3
import os
os.environ["HTTP_PROXY"] = "http://web-proxy.sg.hpicorp.net:8080"
os.environ["HTTPS_PROXY"] = "https://web-proxy.sg.hpicorp.net:8080"
s3 =boto3.resource('s3')
for bucket in s3.buckets.all():
print(bucket.name)

(Press "Enter" two times )

Wednesday, 22 November 2017

Hyper-V option for VMWare and Docker


- For VMWare > Off the Hyper-V
    . Run cmd with admin


bcdedit /set hypervisorlaunchtype off
and restrat PC 

- For Docker > On the Hyper-V
  
bcdedit /set hypervisorlaunchtype auto
and restrat PC 

Sunday, 12 November 2017

AWS Initial Setup


1. AWS CLI ( Command Line Interface )
  - Installation : http://docs.aws.amazon.com/ko_kr/cli/latest/userguide/installing.html
  - Configuration : http://docs.aws.amazon.com/ko_kr/cli/latest/userguide/cli-chap-getting-started.html

2. setup proxy if you need - hppt or https

  2.1.   setup proxy with window system (Permanent)
               https://docs.cloudfoundry.org/cf-cli/http-proxy.html
  2.2.   setup proxy with window system (Temporarily)
       C:\Users\hwangki>set HTTP_PROXY=http://web-proxy.sg.hpicorp.net:8080
       C:\Users\hwangki>set HTTPS_PROXY=http://web-proxy.sg.hpicorp.net:8080

3. AWS CLI test
C:\Users\hwangki>aws ec2 describe-availability-zones
{
    "AvailabilityZones": [
        {
            "State": "available",
            "ZoneName": "ap-southeast-2a",
            "Messages": [],
            "RegionName": "ap-southeast-2"
        },
        {
            "State": "available",
            "ZoneName": "ap-southeast-2b",
            "Messages": [],
            "RegionName": "ap-southeast-2"
        },
        {
            "State": "available",
            "ZoneName": "ap-southeast-2c",
            "Messages": [],
            "RegionName": "ap-southeast-2"
        }
    ]
}


Wednesday, 17 May 2017

[AWS] Web Connection under linux

http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Tutorials.WebServerDB.CreateWebServer.html

Install an Apache web server with PHP

Next you connect to your EC2 instance and install the web server.
To connect to your EC2 instance and install the Apache web server with PHP
  1. To connect to the EC2 instance that you created earlier, follow the steps in Connect to Your Instance.
  2. To get the latest bug fixes and security updates, update the software on your EC2 instance by using the following command:
    Note
    The -y option installs the updates without asking for confirmation. To examine updates before installing, omit this option.
    Copy
    [ec2-user ~]$ sudo yum update –y
  3. After the updates complete, install the Apache web server with the PHP software package using the yum install command, which installs multiple software packages and related dependencies at the same time:
    Copy
    [ec2-user ~]$ sudo yum install -y httpd24 php56 php56-mysqlnd
  4. Start the web server with the command shown following:
    Copy
    [ec2-user ~]$ sudo service httpd start
    You can test that your web server is properly installed and started by entering the public DNS name of your EC2 instance in the address bar of a web browser, for example: http://ec2-42-8-168-21.us-west-1.compute.amazonaws.com. If your web server is running, then you see the Apache test page. If you don't see the Apache test page, then verify that your inbound rules for the VPC security group that you created in Tutorial: Create an Amazon VPC for Use with an Amazon RDS DB Instance include a rule allowing HTTP (port 80) access for the IP address you use to connect to the web server.
    Note
    The Apache test page appears only when there is no content in the document root directory, /var/www/html. After you add content to the document root directory, your content appears at the public DNS address of your EC2 instance instead of the Apache test page.
  5. Configure the web server to start with each system boot using the chkconfig command:
    Copy
    [ec2-user ~]$ sudo chkconfig httpd on
To allow ec2-user to manage files in the default root directory for your Apache web server, you need to modify the ownership and permissions of the /var/www directory. In this tutorial, you add a group namedwww to your EC2 instance, and then you give that group ownership of the /var/www directory and add write permissions for the group. Any members of that group can then add, delete, and modify files for the web server.
To set file permissions for the Apache web server
  1. Add the www group to your EC2 instance with the following command:
    Copy
    [ec2-user ~]$ sudo groupadd www
  2. Add the ec2-user user to the www group:
    Copy
    [ec2-user ~]$ sudo usermod -a -G www ec2-user
  3. To refresh your permissions and include the new www group, log out:
    Copy
    [ec2-user ~]$ exit
  4. Log back in again and verify that the www group exists with the groups command:
    Copy
    [ec2-user ~]$ groups ec2-user wheel www
  5. Change the group ownership of the /var/www directory and its contents to the www group:
    Copy
    [ec2-user ~]$ sudo chown -R root:www /var/www
  6. Change the directory permissions of /var/www and its subdirectories to add group write permissions and set the group ID on subdirectories created in the future:
    Copy
    [ec2-user ~]$ sudo chmod 2775 /var/www [ec2-user ~]$ find /var/www -type d -exec sudo chmod 2775 {} +
  7. Recursively change the permissions for files in the /var/www directory and its subdirectories to add group write permissions:
    Copy
    [ec2-user ~]$ find /var/www -type f -exec sudo chmod 0664 {} +

Connect your Apache web server to your RDS DB instance

Next, you add content to your Apache web server that connects to your Amazon RDS DB instance.
To add content to the Apache web server that connects to your RDS DB instance
  1. While still connected to your EC2 instance, change the directory to /var/www and create a new subdirectory named inc:
    Copy
    [ec2-user ~]$ cd /var/www [ec2-user ~]$ mkdir inc [ec2-user ~]$ cd inc
  2. Create a new file in the inc directory named dbinfo.inc, and then edit the file by calling nano (or the editor of your choice).
    Copy
    [ec2-user ~]$ >dbinfo.inc [ec2-user ~]$ nano dbinfo.inc
  3. Add the following contents to the dbinfo.inc file, where endpoint is the endpoint of your RDS MySQL DB instance, without the port, and master password is the master password for your RDS MySQL DB instance.
    Note
    Placing the user name and password information in a folder that is not part of the document root for your web server reduces the possibility of your security information being exposed.
    Copy
    endpoint
'); define('DB_USERNAME', 'tutorial_user'); define('DB_PASSWORD', 'master password'); define('DB_DATABASE', 'sample'); ?>
  • Save and close the dbinfo.inc file.
  • Change the directory to /var/www/html:
    Copy
    [ec2-user ~]$ cd /var/www/html
  • Create a new file in the html directory named SamplePage.php, and then edit the file by calling nano (or the editor of your choice).
    Copy
    [ec2-user ~]$ >SamplePage.php [ec2-user ~]$ nano SamplePage.php
  • Add the following contents to the SamplePage.php file:
    Note
    Placing the user name and password information in a folder that is not part of the document root for your web server reduces the possibility of your security information being exposed.
    Copy

    Sample page

    Name Address
    "; echo "", "", ""; echo "
    ID Name Address
    ",$query_data[0], "",$query_data[1], "",$query_data[2], "
  • "; } ?> Error adding employee data."); } /* Check whether the table exists and, if not, create it. */ function VerifyEmployeesTable($connection, $dbName) { if(!TableExists("Employees", $connection, $dbName)) { $query = "CREATE TABLE `Employees` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(45) DEFAULT NULL, `Address` varchar(90) DEFAULT NULL, PRIMARY KEY (`ID`), UNIQUE KEY `ID_UNIQUE` (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1"; if(!mysqli_query($connection, $query)) echo("Error creating table.
    "); } } /* Check for the existence of a table. */ function TableExists($tableName, $connection, $dbName) { $t = mysqli_real_escape_string($connection, $tableName); $d = mysqli_real_escape_string($connection, $dbName); $checktable = mysqli_query($connection, "SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_NAME = '$t' AND TABLE_SCHEMA = '$d'"); if(mysqli_num_rows($checktable) > 0) return true; return false; } ?>
  • Save and close the SamplePage.php file.
  • Verify that your web server successfully connects to your RDS MySQL DB instance by opening a web browser and browsing to http://EC2 instance endpoint/SamplePage.php, for example:http://ec2-55-122-41-31.us-west-2.compute.amazonaws.com/SamplePage.php.
  • You can use SamplePage.php to add data to your RDS MySQL DB instance. The data that you add is then displayed on the page.
    To make sure your RDS MySQL DB instance is as secure as possible, verify that sources outside of the VPC cannot connect to your RDS MySQL DB instance.

    Monday, 28 October 2013

    Symbolic Link in Window

    C:\> mklink /D rmt_platformsvcs_view D:\ClearCase\kiy.hwang_view_PLATFORMSVCS

    Tuesday, 9 November 2010

    Patent

    1. P2006-0062654(Korea) / CG2006030941US1 (USA) /CG-200603-094-1-CN0 (China)
    Title : 디바이스 관리를 위한 웹페이지를 제공하는 웹서버 및 디바이스 관리를 위한 웹페이지 제공 방법
    Title: WEB SERVER AND METHOD TO PROVIDE WEB-PAGES TO MANAGE DEVICES
    Inventor(s): Ki-young HWANG :

    2. P2008-0070134(korea) / CG-200804-012-1-US0(USA) / CG-200804-012-1-CN0(China)
    title : 화상형성장치, 서비스 시스템 및 OSGi 기반 서비스 설치 방법
    Title: IMAGE FORMING APPARATUS, SERVICE SYSTEM AND METHOD OF INSTALLING OPEN SERVICES GATEWAY INITIATIVE (OSGi)-BASED SERVICE

    3. P2009-0131835(korea) / CG-200909-037-1-US0(USA)
    Title: 복수 개의 번들간에 서로 기능을 공유할 수 있는 프레임워크 기반으로 동작하는 화상형성장치 및 이러한 화상형성장치에 번들을 설치하는 방법
    Title : IMAGE FORMING APPARATUS OPERATING BASED ON FRAMEWORK CAPABLE OF SHARING FUNCTION AMONG A PLURALITY OF BUNDLES AND METHOD OF INSTALLING BUNDLE IN IMAGE FORMING APPARATUS